From: Roland Haeder Date: Tue, 25 Aug 2015 16:44:40 +0000 (+0200) Subject: Renamed classes/main/ to main/classes/ + added FuseFeature, an upcoming feature X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=751f9e6c51f00dba27757b72fc85490e51fd3797 Renamed classes/main/ to main/classes/ + added FuseFeature, an upcoming feature for mounting parts of your application as a file system in user space (FUSE). Signed-off-by: Roland Häder --- diff --git a/inc/classes/.htaccess b/inc/classes/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/.htaccess b/inc/classes/exceptions/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/actions/.htaccess b/inc/classes/exceptions/actions/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/actions/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/actions/class_InvalidActionException.php b/inc/classes/exceptions/actions/class_InvalidActionException.php deleted file mode 100644 index dcb79f50..00000000 --- a/inc/classes/exceptions/actions/class_InvalidActionException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidActionException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code) { - // Prepare the message - $message = sprintf('[%s:%d] Cannot resolve action %s (%s).', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/auth/.htaccess b/inc/classes/exceptions/auth/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/auth/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/auth/class_UserAuthorizationException.php b/inc/classes/exceptions/auth/class_UserAuthorizationException.php deleted file mode 100644 index dfb06e10..00000000 --- a/inc/classes/exceptions/auth/class_UserAuthorizationException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserAuthorizationException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $filterInstance An instance of the filter throwing this exception - * @param $code Error code - * @return void - */ - public function __construct (Filterable $filterInstance, $code) { - // Construct the message - $message = sprintf('[%s:%d] Authorization has failed. Error code %s', - $filterInstance->__toString(), - $this->getLine(), - $this->getHexCode($code) - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/base64/.htaccess b/inc/classes/exceptions/base64/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/base64/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/base64/class_Base64EncodingBadException.php b/inc/classes/exceptions/base64/class_Base64EncodingBadException.php deleted file mode 100644 index a0f2fb71..00000000 --- a/inc/classes/exceptions/base64/class_Base64EncodingBadException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Base64EncodingBadException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $message Error message - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Raw data %s contains invalid characters for BASE64-encoding.', - $messageArray[0]->__toString(), - $this->getLine(), - $messageArray[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/base64/class_Base64EncodingModuloException.php b/inc/classes/exceptions/base64/class_Base64EncodingModuloException.php deleted file mode 100644 index 39531410..00000000 --- a/inc/classes/exceptions/base64/class_Base64EncodingModuloException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Base64EncodingModuloException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Data length %s modulo 4 is not zero: data=%s', - $messageArray[0]->__toString(), - $this->getLine(), - strlen($messageArray[1]), - $messageArray[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/class_ b/inc/classes/exceptions/class_ deleted file mode 100644 index 156e7c9e..00000000 --- a/inc/classes/exceptions/class_ +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Exception extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $message Error message - * @param $code Error code - * @return void - */ - public function __construct ($message, $code) { - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/class_FrameworkException.php b/inc/classes/exceptions/class_FrameworkException.php deleted file mode 100644 index 8862e934..00000000 --- a/inc/classes/exceptions/class_FrameworkException.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class FrameworkException extends ReflectionException { - /** - * Array for the backtrace - */ - private $backTrace = array(); - - /** - * Extra data - */ - private $extraData = ''; - - /** - * The super constructor for all exceptions - * - * @param $message The non-optional message for the exception - * @param $code An optional code for better debugging - * @return void - */ - public function __construct ($message, $code = 0) { - // Make sure everything is assigned properly - parent::__construct($message, $code); - - // Extract backtrace - $this->saveBackTrace(); - - // Cast all data - $message = (string) $message; - $code = (int) $code; - - // In emergency exit? - if (defined('EMERGENCY_EXIT_CALLED')) { - // Output message - printf("[%s:] Message: %s, Backtrace:
%s
", - $this->__toString(), - $message, - $this->getPrintableBackTrace() - ); - - // End here - exit(); - } // END - if - - // Should we log exceptions? (bad implementation) - if (defined('LOG_EXCEPTIONS')) { - // Log the error - error_log(sprintf("[%s:] %s (%s)", - $this->__toString(), - $message, - $this->getHexCode() - )); - } // END - if - } - - /** - * Save the current backtrace - * - * @return void - */ - private final function saveBackTrace () { - // Get full backtrace - $this->backTrace = debug_backtrace(); - - // Remove this call - $dummy = array_shift($this->backTrace); - - // resort the array - ksort($this->backTrace); - } - - /** - * Get saved backtrace - * - * @return $backTrace The full backtrace in an array - */ - public final function getBackTrace () { - return $this->backTrace; - } - - /** - * Getter for printable backtrace - * - * @return $backTrace Backtrace for web pages - */ - public final function getPrintableBackTrace () { - // Get the backtrace - $dbgTrace = $this->getBackTrace(); - - // Taken from de.php.net user comments - $dbgMsg = "
\nDebug backtrace begin:
\n"; - foreach ($dbgTrace as $dbgIndex => $dbgInfo) { - // No info by default - $info = 'NULL'; - - // Are there arguments? - if ((isset($dbgInfo['args'])) && (is_array($dbgInfo['args'])) && (isset($dbgInfo['args'][0]))) { - //* DEBUG: */ echo $dbgIndex.":
".htmlentities(print_r($dbgInfo['args'], TRUE))."
"; - $info = ''; - foreach ($dbgInfo['args'] as $debug) { - // Add only non-array elements - if (!is_array($debug)) { - $info .= $debug . ', '; - } // END - if - } // END - foreach - - // Remove last chars (commata, space) - $info = substr($info, 0, -2); - } // END - if - - // Prepare argument infos - $info = '' . $info . ''; - - // File detection - $file = 'Unknown file'; - if (isset($dbgInfo['file'])) { - $file = basename($dbgInfo['file']); - } // END - if - - // Line detection - $line = 'Unknown line'; - if (isset($dbgInfo['line'])) { - $line = 'line ' . $dbgInfo['line']; - } // END - if - - // The message - $dbgMsg .= "\t at ".$dbgIndex." ".$file." (".$line.") -> ".$dbgInfo['function'].'('.$info.")
\n"; - } // END - if - - // Add end-message - $dbgMsg .= "Debug backtrace end
\n"; - - // Return full debug message - return $dbgMsg; - } - - /** - * Returns the name of the thrown exception - * - * @return $toString The name of the thrown exception - */ - public function __toString() { - return get_class($this); - } - - /** - * Getter for hex-decimal code - * - * @param $code Integer code to encode in hex - * @return $hexCode The exception code in hex-decimal format - */ - public final function getHexCode ($code = NULL) { - // Get the decimal code - if (is_null($code)) $code = $this->getCode(); - - // Format it to hex-decimal, 0x as prefix and 3 chars - $hexCode = sprintf("0x%03s", dechex($code)); - - // Return it - return $hexCode; - } - - /** - * Setter for extra data - * - * @param $extraData Extra data to store - * @return void - */ - protected final function setExtraData ($extraData) { - $this->extraData = $extraData; - } - - /** - * Getter for extra data - * - * @return $extraData Extra data to store - */ - public final function getExtraData () { - return $this->extraData; - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/compressor/.htaccess b/inc/classes/exceptions/compressor/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/compressor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php b/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php deleted file mode 100644 index d089c28d..00000000 --- a/inc/classes/exceptions/compressor/class_MismatchingCompressorsException.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MismatchingCompressorsException extends FrameworkException { - /** - * The constructor - * - * @param $array Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $array, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Der Kompressor %s zu den geladenen Daten aus %s und der aktuell verwendete Kompressor %s stimmen nicht überein!', - $array[0]->__toString(), - $this->getLine(), - strtoupper($array[1]), - sprintf('%s:%s', - basename(dirname($array[2])), - basename($array[2]) - ), - strtoupper($array[3]) - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/config/.htaccess b/inc/classes/exceptions/config/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/config/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/config/class_ConfigEntryIsEmptyException.php b/inc/classes/exceptions/config/class_ConfigEntryIsEmptyException.php deleted file mode 100644 index 862e0fbb..00000000 --- a/inc/classes/exceptions/config/class_ConfigEntryIsEmptyException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConfigEntryIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkConfiguration $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Empty configuration entry provided.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/config/class_ConfigValueTypeUnsupportedException.php b/inc/classes/exceptions/config/class_ConfigValueTypeUnsupportedException.php deleted file mode 100644 index b39fc811..00000000 --- a/inc/classes/exceptions/config/class_ConfigValueTypeUnsupportedException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConfigValueTypeUnsupportedException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $message Message data array - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Configuration key %s has unspported value type %s.', - $messageArray[0]->__toString(), - $this->getLine(), - $messageArray[1], - gettype($messageArray[2]) - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/config/class_NoConfigEntryException.php b/inc/classes/exceptions/config/class_NoConfigEntryException.php deleted file mode 100644 index d33d492d..00000000 --- a/inc/classes/exceptions/config/class_NoConfigEntryException.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Rename this class to NoFoundEntryException - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoConfigEntryException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array with exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Configuration entry %s not found.', - $classArray[0], - $this->getLine(), - $classArray[1] - ); - - // Set extra data - $this->setExtraData($classArray[1].':'.$this->getLine()); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/connection/.htaccess b/inc/classes/exceptions/connection/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/connection/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/connection/class_ConnectionAlreadyRegisteredException.php b/inc/classes/exceptions/connection/class_ConnectionAlreadyRegisteredException.php deleted file mode 100644 index 99b357c5..00000000 --- a/inc/classes/exceptions/connection/class_ConnectionAlreadyRegisteredException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConnectionAlreadyRegisteredException extends AbstractConnectionException { - /** - * A Constructor for this exception - * - * @param $messageData An array with all relevant data for the exception - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Connection with socket %s is already registered.', - $messageData[0]->__toString(), - $messageData[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/controller/.htaccess b/inc/classes/exceptions/controller/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/controller/class_DefaultControllerException.php b/inc/classes/exceptions/controller/class_DefaultControllerException.php deleted file mode 100644 index 922762c0..00000000 --- a/inc/classes/exceptions/controller/class_DefaultControllerException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DefaultControllerException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $resolverInstance An instance of a resolver class - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (ControllerResolver $resolverInstance, $code) { - // Prepare the message - $message = sprintf('[%s:%d] Cannot resolve default controller (%s). Maybe missing?', - $resolverInstance->__toString(), - $this->getLine(), - $resolverInstance->getClassName() - ); - - // Set extra data - $this->setExtraData($resolverInstance->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/controller/class_InvalidControllerException.php b/inc/classes/exceptions/controller/class_InvalidControllerException.php deleted file mode 100644 index e29b1f6d..00000000 --- a/inc/classes/exceptions/controller/class_InvalidControllerException.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidControllerException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code) { - // Prepare the message - $message = sprintf('[%s:%d] Cannot resolve controller %s (class name: %s).', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/criteria/.htaccess b/inc/classes/exceptions/criteria/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/criteria/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/crypto/.htaccess b/inc/classes/exceptions/crypto/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/crypto/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php b/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php deleted file mode 100644 index 9ecb93fa..00000000 --- a/inc/classes/exceptions/crypto/class_EncryptInvalidLengthException.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class 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()->getConfigEntry('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 deleted file mode 100644 index ded067f5..00000000 --- a/inc/classes/exceptions/crypto/class_EncryptMissingException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class EncryptMissingException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $message Error message - * @param $code Error code - * @return void - */ - public function __construct (Filterable $filterInstance, $code) { - // Construct message - $message = sprintf('[%s:%d] Encrypt string is missing.', - $filterInstance->__toString(), - $this->getLine() - ); - - // Set extra data - $this->setExtraData($filterInstance->__toString()); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/.htaccess b/inc/classes/exceptions/database/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/database/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/database/class_ b/inc/classes/exceptions/database/class_ deleted file mode 100644 index 4aa413e1..00000000 --- a/inc/classes/exceptions/database/class_ +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Exception extends DatabaseException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($message, $code) { - // Just call the parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/class_DatabaseException.php b/inc/classes/exceptions/database/class_DatabaseException.php deleted file mode 100644 index c7488588..00000000 --- a/inc/classes/exceptions/database/class_DatabaseException.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DatabaseException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($message, $code) { - // Just call the parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/general/.htaccess b/inc/classes/exceptions/database/general/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/database/general/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/database/general/class_SqlException.php b/inc/classes/exceptions/database/general/class_SqlException.php deleted file mode 100644 index 6991b0f7..00000000 --- a/inc/classes/exceptions/database/general/class_SqlException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SqlException extends DatabaseException { - /** - * The constructor - * - * @param $msgArray Message array - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Construct the message - $message = sprintf('[%s:%d] SQL error detected. Message from database: %s, code: %s.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $this->getHexCode($msgArray[2]) - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/local_file/.htaccess b/inc/classes/exceptions/database/local_file/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/database/local_file/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php b/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php deleted file mode 100644 index 742558ee..00000000 --- a/inc/classes/exceptions/database/local_file/class_SavePathIsEmptyException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SavePathIsEmptyException extends DatabaseException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Save path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php b/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php deleted file mode 100644 index c6d66bc2..00000000 --- a/inc/classes/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SavePathIsNoDirectoryException extends DatabaseException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($path, $code) { - // Add a message around the missing class - $message = sprintf('Save path %s is no directory.', $path); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php b/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php deleted file mode 100644 index c46affd4..00000000 --- a/inc/classes/exceptions/database/local_file/class_SavePathReadProtectedException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SavePathReadProtectedException extends DatabaseException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($path, $code) { - // Add a message around the missing class - $message = sprintf('Path %s is not readable. Please fix your file access rights.', $path); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php b/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php deleted file mode 100644 index 818e3357..00000000 --- a/inc/classes/exceptions/database/local_file/class_SavePathWriteProtectedException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SavePathWriteProtectedException extends DatabaseException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($path, $code) { - // Add a message around the missing class - $message = sprintf('Save path %s is write-protected. Please fix your file permissions.', $path); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/database/wrapper/.htaccess b/inc/classes/exceptions/database/wrapper/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/database/wrapper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/feature/.htaccess b/inc/classes/exceptions/feature/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/feature/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/feature/class_FeatureMethodNotCallableException.php b/inc/classes/exceptions/feature/class_FeatureMethodNotCallableException.php deleted file mode 100644 index 5a7224b7..00000000 --- a/inc/classes/exceptions/feature/class_FeatureMethodNotCallableException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FeatureMethodNotCallableException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Method %s cannot be called.', - $messageArray[0], - $this->getLine(), - $messageArray[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/.htaccess b/inc/classes/exceptions/file_directory/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/file_directory/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/file_directory/class_DirPointerNotOpenedException.php b/inc/classes/exceptions/file_directory/class_DirPointerNotOpenedException.php deleted file mode 100644 index 0c734c80..00000000 --- a/inc/classes/exceptions/file_directory/class_DirPointerNotOpenedException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DirPointerNotOpenedException extends FrameworkException { - /** - * The constructor - * - * @param $path Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($path, $code) { - // Add a message around the missing class - $message = sprintf('Für den Pfad %s konnte kein Pointer initialisiert werden.', $path); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_FileIoException.php b/inc/classes/exceptions/file_directory/class_FileIoException.php deleted file mode 100644 index 85744cbc..00000000 --- a/inc/classes/exceptions/file_directory/class_FileIoException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileIoException extends FrameworkException { - /** - * The constructor - * - * @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('A problem has been detected reading or writing to/from %s.', $fqfn); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_FileIsEmptyException.php b/inc/classes/exceptions/file_directory/class_FileIsEmptyException.php deleted file mode 100644 index 9e5e97c6..00000000 --- a/inc/classes/exceptions/file_directory/class_FileIsEmptyException.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $fqfn Ignored - * @param $code Code number for the exception - * @return void - */ - public function __construct ($fqfn, $code) { - // Call parent constructor - parent::__construct('No file name provided.', $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_FileNotFoundException.php b/inc/classes/exceptions/file_directory/class_FileNotFoundException.php deleted file mode 100644 index 3117bfaf..00000000 --- a/inc/classes/exceptions/file_directory/class_FileNotFoundException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileNotFoundException extends FrameworkException { - /** - * The constructor - * - * @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('File %s not found.', $fqfn); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_FileReadProtectedException.php b/inc/classes/exceptions/file_directory/class_FileReadProtectedException.php deleted file mode 100644 index b70a58ae..00000000 --- a/inc/classes/exceptions/file_directory/class_FileReadProtectedException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileReadProtectedException extends FrameworkException { - /** - * The constructor - * - * @param $fileName File which cannot be read from - * @param $code Code number for the exception - * @return void - */ - public function __construct ($fileName, $code) { - // Add a message around the missing class - $message = sprintf('File %s is read-protected. Please set read access rights (CHMOD).', $fileName); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_FileWriteProtectedException.php b/inc/classes/exceptions/file_directory/class_FileWriteProtectedException.php deleted file mode 100644 index 47ea7948..00000000 --- a/inc/classes/exceptions/file_directory/class_FileWriteProtectedException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileWriteProtectedException extends FrameworkException { - /** - * The constructor - * - * @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('File %s cannot be written. Please check file and/or directory permissions.', $fqfn); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_InvalidDataLengthException.php b/inc/classes/exceptions/file_directory/class_InvalidDataLengthException.php deleted file mode 100644 index fb240163..00000000 --- a/inc/classes/exceptions/file_directory/class_InvalidDataLengthException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidDataLengthException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Unexpected data length of %s bytes has been detected, %s bytes were expected.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[2] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_InvalidMD5ChecksumException.php b/inc/classes/exceptions/file_directory/class_InvalidMD5ChecksumException.php deleted file mode 100644 index fcc37efd..00000000 --- a/inc/classes/exceptions/file_directory/class_InvalidMD5ChecksumException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidMD5ChecksumException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] MD5 hashes %s and %s doesnt match.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[2] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_InvalidResourceException.php b/inc/classes/exceptions/file_directory/class_InvalidResourceException.php deleted file mode 100644 index fba3fd86..00000000 --- a/inc/classes/exceptions/file_directory/class_InvalidResourceException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidResourceException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Has an invalid resource.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_PathIsEmptyException.php b/inc/classes/exceptions/file_directory/class_PathIsEmptyException.php deleted file mode 100644 index a324f06e..00000000 --- a/inc/classes/exceptions/file_directory/class_PathIsEmptyException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PathIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Directory path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_PathIsNoDirectoryException.php b/inc/classes/exceptions/file_directory/class_PathIsNoDirectoryException.php deleted file mode 100644 index 94a3e1ad..00000000 --- a/inc/classes/exceptions/file_directory/class_PathIsNoDirectoryException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PathIsNoDirectoryException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($path, $code) { - // Add a message around the missing class - $message = sprintf('Der angegebene Pfad %s ist ungütig (kein Pfad).', $path); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_PathReadProtectedException.php b/inc/classes/exceptions/file_directory/class_PathReadProtectedException.php deleted file mode 100644 index 6d6268d4..00000000 --- a/inc/classes/exceptions/file_directory/class_PathReadProtectedException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PathReadProtectedException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($path, $code) { - // Add a message around the missing class - $message = sprintf('The path %s appears to be read-protected. Please fix your CHMOD rights.', $path); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/file_directory/class_PathWriteProtectedException.php b/inc/classes/exceptions/file_directory/class_PathWriteProtectedException.php deleted file mode 100644 index 67b8bf0e..00000000 --- a/inc/classes/exceptions/file_directory/class_PathWriteProtectedException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileWriteProtectedException extends FrameworkException { - /** - * The constructor - * - * @param $fqfn Full-qualified file name - * @param $code Code number for the exception - * @return void - */ - public function __construct ($fqfn, $code) { - // Add a message around the missing class - $message = sprintf('Path %s cannot be written to. Please check permissions.', dirname($fqfn)); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/filter/.htaccess b/inc/classes/exceptions/filter/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/filter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/filter/class_FilterChainException.php b/inc/classes/exceptions/filter/class_FilterChainException.php deleted file mode 100644 index ee14c2e9..00000000 --- a/inc/classes/exceptions/filter/class_FilterChainException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FilterChainException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $filterInstance Instance of a filter class - * @param $code Exception code for better debugging - * @return void - */ - public function __construct (Filterable $filterInstance, $code) { - // Construct the message - $message = sprintf('[%s:%d] Filter chain interruppted by fatal error in filter.', - $filterInstance->__toString(), - $this->getLine() - ); - - // Call the parent exception - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/filter/class_InvalidFilterChainException.php b/inc/classes/exceptions/filter/class_InvalidFilterChainException.php deleted file mode 100644 index 5ee49100..00000000 --- a/inc/classes/exceptions/filter/class_InvalidFilterChainException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidFilterChainException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $filterInstance Instance of a filter class - * @param $code Exception code for better debugging - * @return void - */ - public function __construct (array $filterArray, $code) { - // Construct the message - $message = sprintf('[%s:%d] Filter chain %s is not initialized.', - $filterArray[0]->__toString(), - $this->getLine(), - $filterArray[1] - ); - - // Call the parent exception - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/.htaccess b/inc/classes/exceptions/helper/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/helper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/helper/class_FormClosedException.php b/inc/classes/exceptions/helper/class_FormClosedException.php deleted file mode 100644 index 049e76da..00000000 --- a/inc/classes/exceptions/helper/class_FormClosedException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FormClosedException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Class throwing the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Could not add form element %s because form is closed.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_FormGroupClosedException.php b/inc/classes/exceptions/helper/class_FormGroupClosedException.php deleted file mode 100644 index 61fa90cd..00000000 --- a/inc/classes/exceptions/helper/class_FormGroupClosedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FormGroupClosedException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Class throwing the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Could not add sub group %s because no form group has been opened before.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_FormOpenedException.php b/inc/classes/exceptions/helper/class_FormOpenedException.php deleted file mode 100644 index a0986ab6..00000000 --- a/inc/classes/exceptions/helper/class_FormOpenedException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FormOpenedException extends FrameworkException { - /** - * The constructor - * - * @param $helperInstance Class throwing the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (BaseHelper $helperInstance, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Form is not yet closed. Close it with method %s::addFormTag() and add no parameters.', - $helperInstance->__toString(), - $this->getLine(), - $helperInstance->__toString() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php b/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php deleted file mode 100644 index 040cb55d..00000000 --- a/inc/classes/exceptions/helper/class_HelperGroupAlreadyCreatedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HelperGroupAlreadyCreatedException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Array containing exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Group %s already opened before.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php b/inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php deleted file mode 100644 index 7d8e1e93..00000000 --- a/inc/classes/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HelperNoPreviousOpenedSubGroupException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Array containing exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Sub group not opened before. Raw text follows: %s', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php b/inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php deleted file mode 100644 index b2e0ec1b..00000000 --- a/inc/classes/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HelperSubGroupAlreadyCreatedException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Array containing exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Sub group %s already opened before.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_InvalidFormNameException.php b/inc/classes/exceptions/helper/class_InvalidFormNameException.php deleted file mode 100644 index badede76..00000000 --- a/inc/classes/exceptions/helper/class_InvalidFormNameException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidFormNameException extends FrameworkException { - /** - * The constructor - * - * @param $helperInstance Class throwing the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (BaseHelper $helperInstance, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Form name not set.', - $helperInstance->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_NoGroupOpenedException.php b/inc/classes/exceptions/helper/class_NoGroupOpenedException.php deleted file mode 100644 index 39fcc2c4..00000000 --- a/inc/classes/exceptions/helper/class_NoGroupOpenedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoGroupOpenedException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Array containing exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Group not opened before. Raw text follows: %s', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/helper/class_UserInstanceMissingException.php b/inc/classes/exceptions/helper/class_UserInstanceMissingException.php deleted file mode 100644 index 4e5162a9..00000000 --- a/inc/classes/exceptions/helper/class_UserInstanceMissingException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserInstanceMissingException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array with class instance and registry key - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Registry key %s does not include a class with implemented interface Manageable(User|Guest).', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/language/.htaccess b/inc/classes/exceptions/language/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/language/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php b/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php deleted file mode 100644 index 68be0a4d..00000000 --- a/inc/classes/exceptions/language/class_InvalidLanguagePathStringException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidLanguagePathStringException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] %s is not a string with path.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php b/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php deleted file mode 100644 index e100a29f..00000000 --- a/inc/classes/exceptions/language/class_LanguagePathIsEmptyException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LanguagePathIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Language base path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php b/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php deleted file mode 100644 index dc37609a..00000000 --- a/inc/classes/exceptions/language/class_LanguagePathIsNoDirectoryException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LanguagePathIsNoDirectoryException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Language base path %s does not exist or is not a directory.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php b/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php deleted file mode 100644 index dbba52d1..00000000 --- a/inc/classes/exceptions/language/class_LanguagePathReadProtectedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LanguagePathReadProtectedException extends FrameworkException { - /** - * The constructor - * - * @param $class Array holding exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Base language path %s is read-protected. Please change access rights (CHMOD).', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/.htaccess b/inc/classes/exceptions/main/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/main/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/main/class_AssertionException.php b/inc/classes/exceptions/main/class_AssertionException.php deleted file mode 100644 index f7eb89aa..00000000 --- a/inc/classes/exceptions/main/class_AssertionException.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AssertionException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($message, $code) { - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_ClassMismatchException.php b/inc/classes/exceptions/main/class_ClassMismatchException.php deleted file mode 100644 index c347e0d0..00000000 --- a/inc/classes/exceptions/main/class_ClassMismatchException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ClassMismatchException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding the exception informations - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('The class %s does not match class %s.', - $classArray[0], - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php b/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php deleted file mode 100644 index dba31aa9..00000000 --- a/inc/classes/exceptions/main/class_DimNotFoundInArrayException.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DimNotFoundInArrayException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - if (is_object($class)) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Dimensions not found in array, array is invalid!', - $class->__toString(), - $this->getLine() - ); - } else { - // No class given - $message = sprintf('Please provide a class for %s', __CLASS__); - } - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_EmptyVariableException.php b/inc/classes/exceptions/main/class_EmptyVariableException.php deleted file mode 100644 index 2741d41d..00000000 --- a/inc/classes/exceptions/main/class_EmptyVariableException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class EmptyVariableException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Message array holding all needed data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Variable %s is not set.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_FatalErrorException.php b/inc/classes/exceptions/main/class_FatalErrorException.php deleted file mode 100644 index e0ca7594..00000000 --- a/inc/classes/exceptions/main/class_FatalErrorException.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FatalErrorException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($message, $code) { - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_IndexOutOfBoundsException.php b/inc/classes/exceptions/main/class_IndexOutOfBoundsException.php deleted file mode 100644 index 458e70f0..00000000 --- a/inc/classes/exceptions/main/class_IndexOutOfBoundsException.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class IndexOutOfBoundsException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($message, $code) { - // Add a message around the missing class - $message = sprintf('%s is out of bounds.', - $message - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_InvalidArrayCountException.php b/inc/classes/exceptions/main/class_InvalidArrayCountException.php deleted file mode 100644 index ee2c3880..00000000 --- a/inc/classes/exceptions/main/class_InvalidArrayCountException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidArrayCountException extends FrameworkException { - /** - * The constructor - * - * @param $array Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $array, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] %s has %d elements, expected arre %d.', - $array[0]->__toString(), - $this->getLine(), - $array[1], - $array[2], - $array[3] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_InvalidCommandException.php b/inc/classes/exceptions/main/class_InvalidCommandException.php deleted file mode 100644 index 64cbd6c1..00000000 --- a/inc/classes/exceptions/main/class_InvalidCommandException.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidCommandException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Invalid command %s (class %s) detected.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php b/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php deleted file mode 100644 index 82de3c73..00000000 --- a/inc/classes/exceptions/main/class_InvalidCommandInstanceException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidCommandInstanceException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Invalid command %s detected.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_InvalidInterfaceException.php b/inc/classes/exceptions/main/class_InvalidInterfaceException.php deleted file mode 100644 index bfb4cd03..00000000 --- a/inc/classes/exceptions/main/class_InvalidInterfaceException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidInterfaceException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array with exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Object does not implement expected interface %s.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_InvalidObjectException.php b/inc/classes/exceptions/main/class_InvalidObjectException.php deleted file mode 100644 index 09b917ae..00000000 --- a/inc/classes/exceptions/main/class_InvalidObjectException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidObjectException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Object is not allowed here.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_MissingArrayElementsException.php b/inc/classes/exceptions/main/class_MissingArrayElementsException.php deleted file mode 100644 index 22ab7be1..00000000 --- a/inc/classes/exceptions/main/class_MissingArrayElementsException.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MissingArrayElementsException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array with exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Extract all elements - $elements = ''; - if ((isset($classArray[2])) && (is_array($classArray[2]))) { - // Convert into strings - $elements = implode(', ', $classArray[2]); - } else { - // Invalid data - $elements = 'invalid_data'; - } - - // Add a message around the missing class - $message = sprintf('[%s:%d] Array %s() Does not have these elements: %s', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1], - $elements - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeparatorException.php b/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeparatorException.php deleted file mode 100644 index e3c5c9af..00000000 --- a/inc/classes/exceptions/main/class_MissingDecimalsThousandsSeparatorException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MissingDecimalsThousandsSeparatorException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct ($instance, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Decimal and thousand seperators are missing.', - $instance->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_MissingMethodException.php b/inc/classes/exceptions/main/class_MissingMethodException.php deleted file mode 100644 index 6ad4bb49..00000000 --- a/inc/classes/exceptions/main/class_MissingMethodException.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Try to rewrite user/guest login classes and mark this exception as deprecated - * @deprecated Please do no longer use this exception - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MissingMethodException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding the exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] This class has no method %s().', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_NoClassException.php b/inc/classes/exceptions/main/class_NoClassException.php deleted file mode 100644 index 212befcc..00000000 --- a/inc/classes/exceptions/main/class_NoClassException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoClassException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Class %s not found.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Set extra data - $this->setExtraData($msgArray[1]); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_NullPointerException.php b/inc/classes/exceptions/main/class_NullPointerException.php deleted file mode 100644 index 5b2665ca..00000000 --- a/inc/classes/exceptions/main/class_NullPointerException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NullPointerException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] An object instance is set to null.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php b/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php deleted file mode 100644 index f85ac4ed..00000000 --- a/inc/classes/exceptions/main/class_ResponseHeadersAlreadySentException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ResponseHeadersAlreadySentException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Headers are already sent.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_UnsupportedOperationException.php b/inc/classes/exceptions/main/class_UnsupportedOperationException.php deleted file mode 100644 index fd2465dc..00000000 --- a/inc/classes/exceptions/main/class_UnsupportedOperationException.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnsupportedOperationException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding the exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Init extra class name - $extraClassName = ''; - - // Do we have an extra instance? - if ((isset($classArray[2])) && ($classArray[2] instanceof FrameworkInterface)) { - // Get the class name - $extraClassName = $classArray[2]->__toString(); - } // END - if - - // Add a message around the missing class - $message = sprintf('[%s:%d] Method %s() is unsupported or should not be called. extraInstance=%s', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1], - $extraClassName - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/main/class_VariableIsNotSetException.php b/inc/classes/exceptions/main/class_VariableIsNotSetException.php deleted file mode 100644 index 2f2e3d60..00000000 --- a/inc/classes/exceptions/main/class_VariableIsNotSetException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class VariableIsNotSetException extends FrameworkException { - /** - * The constructor - * - * @param $array Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $array, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] While the application %s was initialized, a variable %s was not created.', - $array[0]->__toString(), - $this->getLine(), - $array[1], - $array[2] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/result/.htaccess b/inc/classes/exceptions/result/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/result/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php b/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php deleted file mode 100644 index 7695a8c3..00000000 --- a/inc/classes/exceptions/result/class_InvalidDatabaseResultException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidDatabaseResultException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $msgArray, $code) { - // Construct the message - $message = sprintf('[%s:%d] Database instance %s contains invalid entries.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1]->__toString() - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/result/class_ResultUpdateException.php b/inc/classes/exceptions/result/class_ResultUpdateException.php deleted file mode 100644 index 0a41b677..00000000 --- a/inc/classes/exceptions/result/class_ResultUpdateException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ResultUpdateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $resultInstance Instance of the failed result update - * @param $code Error code - * @return void - */ - public function __construct (UpdateableResult $resultInstance, $code) { - // Construct the message - $message = sprintf('[%s:%d] Update of result instance has nothing changed.', - $resultInstance->__toString(), - $this->getLine() - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/.htaccess b/inc/classes/exceptions/socket/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/socket/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/socket/class_AbstractSocketException.php b/inc/classes/exceptions/socket/class_AbstractSocketException.php deleted file mode 100644 index 4f61282e..00000000 --- a/inc/classes/exceptions/socket/class_AbstractSocketException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class AbstractSocketException extends FrameworkException { - // This abstract exception is currently kept empty -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_InvalidServerSocketException.php b/inc/classes/exceptions/socket/class_InvalidServerSocketException.php deleted file mode 100644 index fb50a52e..00000000 --- a/inc/classes/exceptions/socket/class_InvalidServerSocketException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidServerSocketException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Socket resource %s is not a server socket.', - $messageData[0]->__toString(), - $messageData[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_InvalidSocketException.php b/inc/classes/exceptions/socket/class_InvalidSocketException.php deleted file mode 100644 index 572394cb..00000000 --- a/inc/classes/exceptions/socket/class_InvalidSocketException.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidSocketException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Is it a resource? - if (is_resource($messageData[1])) { - // Get last error - $lastError = socket_last_error($messageData[1]); - - // Construct the message - $message = sprintf('[%s:] Invalid socket, type=%s, errno=%s, errstr=%s', - $messageData[0]->__toString(), - gettype($messageData[1]), - $lastError, - socket_strerror($lastError) - ); - } else { - // Construct the message - $message = sprintf('[%s:] Invalid socket, type=%s(%s), errno=%s, errstr=%s', - $messageData[0]->__toString(), - $messageData[1], - gettype($messageData[1]), - $messageData[2], - $messageData[3] - ); - } - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_NoSocketErrorDetectedException.php b/inc/classes/exceptions/socket/class_NoSocketErrorDetectedException.php deleted file mode 100644 index d9e6d0fa..00000000 --- a/inc/classes/exceptions/socket/class_NoSocketErrorDetectedException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoSocketErrorDetectedException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Socket %s has no error reported.', - $messageData[0]->__toString(), - $messageData[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_NoSocketRegisteredException.php b/inc/classes/exceptions/socket/class_NoSocketRegisteredException.php deleted file mode 100644 index 701a0ff3..00000000 --- a/inc/classes/exceptions/socket/class_NoSocketRegisteredException.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoSocketRegisteredException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $protocolInstance An instance of a HandleableProtocol class - * @param $code Error code - * @return void - */ - public function __construct (HandleableProtocol $protocolInstance, $code) { - // Construct the message - $message = sprintf('[%s:] Requested socket is not yet registered.', - $protocolInstance->__toString() - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_SocketAlreadyRegisteredException.php b/inc/classes/exceptions/socket/class_SocketAlreadyRegisteredException.php deleted file mode 100644 index 9445a889..00000000 --- a/inc/classes/exceptions/socket/class_SocketAlreadyRegisteredException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketAlreadyRegisteredException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageData An array with all relevant data for the exception - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Socket %s is already registered.', - $messageData[0]->__toString(), - $messageData[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_SocketConnectionException.php b/inc/classes/exceptions/socket/class_SocketConnectionException.php deleted file mode 100644 index dd9c8839..00000000 --- a/inc/classes/exceptions/socket/class_SocketConnectionException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketConnectionException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Could not make a connection, type=%s, errno=%s, errstr=%s', - $messageData[0]->__toString(), - gettype($messageData[1]), - $messageData[2], - $messageData[3] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_SocketCreationException.php b/inc/classes/exceptions/socket/class_SocketCreationException.php deleted file mode 100644 index 0ad42f94..00000000 --- a/inc/classes/exceptions/socket/class_SocketCreationException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketCreationException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Cannot create socket, type=%s, errno=%s, errstr=%s', - $messageData[0]->__toString(), - $messageData[1], - $messageData[2], - $messageData[3] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_SocketOptionException.php b/inc/classes/exceptions/socket/class_SocketOptionException.php deleted file mode 100644 index f863a833..00000000 --- a/inc/classes/exceptions/socket/class_SocketOptionException.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketOptionException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Changing option on socket failed, type=%s, errno=%s, errstr=%s', - $messageData[0]->__toString(), - gettype($messageData[1]), - $messageData[2], - $messageData[3] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_SocketShutdownException.php b/inc/classes/exceptions/socket/class_SocketShutdownException.php deleted file mode 100644 index 42ed51ff..00000000 --- a/inc/classes/exceptions/socket/class_SocketShutdownException.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketShutdownException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $helperInstance An instance of a ConnectionHelper class - * @param $code Error code - * @return void - */ - public function __construct (ConnectionHelper $helperInstance, $code) { - // Get socket resource - $socketResource = $helperInstance->getSocketResource(); - - // Construct the message - $message = sprintf('[%s:] Socket %s cannot be shutdown down. errNo=%s, errStr=%s', - $helperInstance->__toString(), - $socketResource, - socket_last_error($socketResource), - socket_strerror(socket_last_error($socketResource)) - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/socket/class_UnsupportedSocketErrorHandlerException.php b/inc/classes/exceptions/socket/class_UnsupportedSocketErrorHandlerException.php deleted file mode 100644 index 5072dbc3..00000000 --- a/inc/classes/exceptions/socket/class_UnsupportedSocketErrorHandlerException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnsupportedSocketErrorHandlerException extends AbstractSocketException { - /** - * A Constructor for this exception - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageData, $code) { - // Construct the message - $message = sprintf('[%s:] Socket error handler %s is not yet implemented, errorCode=%s, message=%s', - $messageData[0]->__toString(), - $messageData[1], - $messageData[2], - socket_strerror($messageData[2]) - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/stacker/.htaccess b/inc/classes/exceptions/stacker/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/stacker/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php b/inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php deleted file mode 100644 index dd0a38de..00000000 --- a/inc/classes/exceptions/stacker/class_AlreadyInitializedStackerException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AlreadyInitializedStackerException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Stacker %s already initialized, forceReInit=%d.', - $messageArray[0]->__toString(), - $this->getLine(), - $messageArray[1], - intval($messageArray[2]) - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/stacker/class_EmptyStackerException.php b/inc/classes/exceptions/stacker/class_EmptyStackerException.php deleted file mode 100644 index 7c0cd8f2..00000000 --- a/inc/classes/exceptions/stacker/class_EmptyStackerException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class EmptyStackerException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Stacker %s is empty.', - $messageArray[0]->__toString(), - $this->getLine(), - $messageArray[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/stacker/class_FullStackerException.php b/inc/classes/exceptions/stacker/class_FullStackerException.php deleted file mode 100644 index 2e04309b..00000000 --- a/inc/classes/exceptions/stacker/class_FullStackerException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FullStackerException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Stacker %s is full.', - $messageArray[0]->__toString(), - $this->getLine(), - $messageArray[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/stacker/class_NoStackerException.php b/inc/classes/exceptions/stacker/class_NoStackerException.php deleted file mode 100644 index 4ba59cd0..00000000 --- a/inc/classes/exceptions/stacker/class_NoStackerException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoStackerException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (array $messageArray, $code) { - // Construct message - $message = sprintf('[%s:%d] Stacker %s is not initialized.', - $messageArray[0]->__toString(), - $this->getLine(), - $messageArray[1] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/state/.htaccess b/inc/classes/exceptions/state/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/state/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/state/class_InvalidStateInstanceException.php b/inc/classes/exceptions/state/class_InvalidStateInstanceException.php deleted file mode 100644 index fc6883ab..00000000 --- a/inc/classes/exceptions/state/class_InvalidStateInstanceException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidStateInstanceException extends FrameworkException { - /** - * The constructor - * - * @param $message Message from the exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Invalid state %s of type %s detected.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - gettype($mgArray[2]) - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/state/class_UnexpectedStateException.php b/inc/classes/exceptions/state/class_UnexpectedStateException.php deleted file mode 100644 index 25114dd0..00000000 --- a/inc/classes/exceptions/state/class_UnexpectedStateException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnexpectedStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $messageArray Error message array - * @param $code Error code - * @return void - */ - public function __construct (Stateable $stateInstance, $code) { - // Construct the message - $message = sprintf('[%s:%d] Unexpected state detected.', - $stateInstance->__toString(), - $this->getLine() - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/state/class_UnresolveableStateException.php b/inc/classes/exceptions/state/class_UnresolveableStateException.php deleted file mode 100644 index f025e18c..00000000 --- a/inc/classes/exceptions/state/class_UnresolveableStateException.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnresolveableStateException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray An array with message parts - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code) { - // Prepare the message - $message = sprintf('[%s:%d] Cannot resolve state %s (class name: %s).', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getClassName() - ); - - // Set extra data - $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); - - // Call parent contructor with message - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/template/.htaccess b/inc/classes/exceptions/template/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/template/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/template/class_BasePathIsEmptyException.php b/inc/classes/exceptions/template/class_BasePathIsEmptyException.php deleted file mode 100644 index 51a5f842..00000000 --- a/inc/classes/exceptions/template/class_BasePathIsEmptyException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BasePathIsEmptyException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this exception - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Template path is empty.', - $class->__toString(), - $this->getLine() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php b/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php deleted file mode 100644 index 28677ea1..00000000 --- a/inc/classes/exceptions/template/class_BasePathIsNoDirectoryException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BasePathIsNoDirectoryException extends FrameworkException { - /** - * The constructor - * - * @param $classArray An array holding our informations - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Template base path %s does not exist.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/template/class_BasePathReadProtectedException.php b/inc/classes/exceptions/template/class_BasePathReadProtectedException.php deleted file mode 100644 index 440ccd01..00000000 --- a/inc/classes/exceptions/template/class_BasePathReadProtectedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BasePathReadProtectedException extends FrameworkException { - /** - * The constructor - * - * @param $classArray An array holding our informations - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Der Template-Basispfad %s ist lesegeschützt! Bitte Zugriffsrechte (CHMOD) ändern.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/template/class_InvalidBasePathStringException.php b/inc/classes/exceptions/template/class_InvalidBasePathStringException.php deleted file mode 100644 index 10b0dc04..00000000 --- a/inc/classes/exceptions/template/class_InvalidBasePathStringException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidBasePathStringException extends FrameworkException { - /** - * The constructor - * - * @param $classArray Array holding exception data - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $classArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] %s is not a string with a base path.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/template/class_NoVariableException.php b/inc/classes/exceptions/template/class_NoVariableException.php deleted file mode 100644 index 52b22615..00000000 --- a/inc/classes/exceptions/template/class_NoVariableException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NoVariableException extends FrameworkException { - /** - * The constructor - * - * @param $messageArray Data for the message - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $messageArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Variable %s is not set, cannot modify(?) its value to %s.', - $messageArray[0]->__toString(), - $this->getLine(), - $messageArray[1], - $messageArray[2] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php b/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php deleted file mode 100644 index 66b77128..00000000 --- a/inc/classes/exceptions/template/class_UnexpectedTemplateTypeException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnexpectedTemplateTypeException extends FrameworkException { - /** - * The constructor - * - * @param $msgArray An array holding our informations - * @param $code Code number for the exception - * @return void - */ - public function __construct (array $msgArray, $code) { - // Add a message around the missing class - $message = sprintf('[%s:%d] Der Template-Typ %s entspricht nicht dem erwartetem Template-Typ %s.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[2] - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php b/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php deleted file mode 100644 index e0042073..00000000 --- a/inc/classes/exceptions/template/class_UnsupportedTemplateEngineException.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnsupportedTemplateEngineException extends FrameworkException { - /** - * The constructor - * - * @param $class Class throwing this class - * @param $code Code number for the exception - * @return void - */ - public function __construct (FrameworkInterface $class, $code) { - // Add a message around the missing class - $message = sprintf('Template-Engine %s not (yet) supported.', - $class->__toString() - ); - - // Call parent constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/user/.htaccess b/inc/classes/exceptions/user/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/user/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php b/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php deleted file mode 100644 index 647ab230..00000000 --- a/inc/classes/exceptions/user/class_AccountPasswordMismatchException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AccountPasswordMismatchException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $filterInstance A filterable class instance - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (Filterable $filterInstance, $code) { - // Create the message - $message = sprintf('[%s:%d] Supplied account password did not match with stored.', - $filterInstance->__toString(), - $this->getLine() - ); - - // Make sure everything is assigned properly - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/user/class_UnexpectedGuestAccountException.php b/inc/classes/exceptions/user/class_UnexpectedGuestAccountException.php deleted file mode 100644 index 9100f1dd..00000000 --- a/inc/classes/exceptions/user/class_UnexpectedGuestAccountException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UnexpectedGuestAccountException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray The non-optional message for the exception - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code = 0) { - // Create the message - $message = sprintf('[%s:%d] User %s is a guest account.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Make sure everything is assigned properly - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/user/class_UserEmailMissingException.php b/inc/classes/exceptions/user/class_UserEmailMissingException.php deleted file mode 100644 index 37a01393..00000000 --- a/inc/classes/exceptions/user/class_UserEmailMissingException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserEmailMissingException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray The non-optional message for the exception - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code = 0) { - // Create the message - $message = sprintf('[%s:%d] User email %s was not found.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Make sure everything is assigned properly - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/user/class_UserNoGuestException.php b/inc/classes/exceptions/user/class_UserNoGuestException.php deleted file mode 100644 index 515431a7..00000000 --- a/inc/classes/exceptions/user/class_UserNoGuestException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserNoGuestException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray The non-optional message for the exception - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code = 0) { - // Create the message - $message = sprintf('[%s:%d] User %s is not a guest account: %s', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1], - $msgArray[0]->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) - ); - - // Make sure everything is assigned properly - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php b/inc/classes/exceptions/user/class_UserPasswordMismatchException.php deleted file mode 100644 index 2a422390..00000000 --- a/inc/classes/exceptions/user/class_UserPasswordMismatchException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserPasswordMismatchException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray The non-optional message for the exception - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code = 0) { - // Create the message - $message = sprintf('[%s:%d] Supplied password for user %s did not match with stored password.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1]->getUserName() - ); - - // Make sure everything is assigned properly - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/user/class_UsernameMissingException.php b/inc/classes/exceptions/user/class_UsernameMissingException.php deleted file mode 100644 index 2ea69048..00000000 --- a/inc/classes/exceptions/user/class_UsernameMissingException.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UsernameMissingException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $msgArray The non-optional message for the exception - * @param $code An optional code for better debugging - * @return void - */ - public function __construct (array $msgArray, $code = 0) { - // Create the message - $message = sprintf('[%s:%d] Username %s was not found.', - $msgArray[0]->__toString(), - $this->getLine(), - $msgArray[1] - ); - - // Make sure everything is assigned properly - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/xml/.htaccess b/inc/classes/exceptions/xml/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/exceptions/xml/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php b/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php deleted file mode 100644 index 6e8f81e9..00000000 --- a/inc/classes/exceptions/xml/class_InvalidXmlNodeException.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class InvalidXmlNodeException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $classArray Array holding the exception data - * @param $code Error code - * @return void - */ - public function __construct (array $classArray, $code) { - // Extract attributes - $attributes = 'None'; - if ((is_array($classArray[2])) && (count($classArray[2]) > 0)) { - $attributes = implode(', ', $classArray[2]); - } // END - if - - // Construct our message - $message = sprintf('[%s:%d] Invalid XML node found: %s, attributes: %s.', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1], - $attributes - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php b/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php deleted file mode 100644 index 92fe138f..00000000 --- a/inc/classes/exceptions/xml/class_XmlNodeMismatchException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlNodeMismatchException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $classArray Array holding the exception data - * @param $code Error code - * @return void - */ - public function __construct (array $classArray, $code) { - // Construct our message - $message = sprintf('[%s:%d] XML nodes mismatch. Given: %s, Expected: %s', - $classArray[0]->__toString(), - $this->getLine(), - $classArray[1], - $classArray[2] - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/exceptions/xml/class_XmlParserException.php b/inc/classes/exceptions/xml/class_XmlParserException.php deleted file mode 100644 index b5532695..00000000 --- a/inc/classes/exceptions/xml/class_XmlParserException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlParserException extends FrameworkException { - /** - * The super constructor for all exceptions - * - * @param $classArray Array holding the exception data - * @param $code Error code - * @return void - */ - public function __construct (array $classArray, $code) { - // Construct our message - $message = sprintf('[%s:%d] XML Error: %s at line %d.', - $classArray[0]->__toString(), - $this->getLine(), - xml_error_string(xml_get_error_code($classArray[1])), - xml_get_current_line_number($classArray[1]) - ); - - // Call parent exception constructor - parent::__construct($message, $code); - } -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/.htaccess b/inc/classes/interfaces/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/actions/.htaccess b/inc/classes/interfaces/actions/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/actions/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/actions/class_PerformableAction.php b/inc/classes/interfaces/actions/class_PerformableAction.php deleted file mode 100644 index 2a6f506f..00000000 --- a/inc/classes/interfaces/actions/class_PerformableAction.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface PerformableAction extends FrameworkInterface { - /** - * Executes the command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - function execute (Requestable $requestInstance, Responseable $responseInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/actions/commands/.htaccess b/inc/classes/interfaces/actions/commands/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/actions/commands/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/actions/commands/class_Commandable.php b/inc/classes/interfaces/actions/commands/class_Commandable.php deleted file mode 100644 index 1d9138d2..00000000 --- a/inc/classes/interfaces/actions/commands/class_Commandable.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Commandable extends PerformableAction { - /** - * 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 - */ - function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/application/.htaccess b/inc/classes/interfaces/application/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/application/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/application/class_ManageableApplication.php b/inc/classes/interfaces/application/class_ManageableApplication.php deleted file mode 100644 index 65b98650..00000000 --- a/inc/classes/interfaces/application/class_ManageableApplication.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ManageableApplication extends FrameworkInterface { - /** - * Launches the application - * - * @return void - */ - function entryPoint (); - - /** - * Handle the indexed array of fatal messages and puts them out in an - * acceptable fasion - * - * @param $messageList An array of fatal messages - * @return void - */ - function handleFatalMessages (array $messageList); - - /** - * Builds the master template's name - * - * @return $masterTemplateName Name of the master template - */ - function buildMasterTemplateName(); - - /** - * Assigns extra application-depending data - * - * @param $templateInstance An instance of a CompileableTemplate - * @return void - * @todo Nothing to add? - */ - function assignExtraTemplateData (CompileableTemplate $templateInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/auth/.htaccess b/inc/classes/interfaces/auth/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/auth/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/auth/class_Authorizeable.php b/inc/classes/interfaces/auth/class_Authorizeable.php deleted file mode 100644 index f10eaac5..00000000 --- a/inc/classes/interfaces/auth/class_Authorizeable.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Authorizeable extends FrameworkInterface { - /** - * Destroy the authorization data - * - * @return void - */ - function destroyAuthData(); - - /** - * Updates the authorization data and/or sets additional tracking data - * - * @return void - */ - function updateAuthData (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/block/.htaccess b/inc/classes/interfaces/block/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/block/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/block/calculatable/.htaccess b/inc/classes/interfaces/block/calculatable/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/block/calculatable/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/block/calculatable/class_CalculatableBlock.php b/inc/classes/interfaces/block/calculatable/class_CalculatableBlock.php deleted file mode 100644 index 289f0790..00000000 --- a/inc/classes/interfaces/block/calculatable/class_CalculatableBlock.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface CalculatableBlock extends Block { - /** - * Calculates minimum length for one entry/block - * - * @return $length Minimum length for one entry/block - */ - function calculateMinimumBlockLength (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/block/class_Block.php b/inc/classes/interfaces/block/class_Block.php deleted file mode 100644 index 12c99f0f..00000000 --- a/inc/classes/interfaces/block/class_Block.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface Block extends FrameworkInterface { - /** - * Reads the file header - * - * @return void - */ - function readFileHeader (); - - /** - * Flushes the file header - * - * @return void - */ - function flushFileHeader (); - - /** - * Determines whether the EOF has been reached - * - * @return $isEndOfFileReached Whether the EOF has been reached - */ - function isEndOfFileReached (); - - /** - * Getter for file name - * - * @return $fileName The current file name - */ - function getFileName (); - - /** - * Initializes counter for valid entries, arrays for damaged entries and - * an array for gap seek positions. If you call this method on your own, - * please re-analyze the file structure. So you are better to call - * analyzeFile() instead of this method. - * - * @return void - */ - function initCountersGapsArray (); - - /** - * Getter for header size - * - * @return $totalEntries Size of file header - */ - function getHeaderSize (); - - /** - * Setter for header size - * - * @param $headerSize Size of file header - * @return void - */ - function setHeaderSize ($headerSize); - - /** - * Getter for header array - * - * @return $totalEntries Size of file header - */ - function getHeader (); - - /** - * Setter for header - * - * @param $header Array for a file header - * @return void - */ - function setHeader (array $header); - - /** - * Updates seekPosition attribute from file to avoid to much access on file. - * - * @return void - */ - function updateSeekPosition (); - - /** - * Getter for total entries - * - * @return $totalEntries Total entries in this file - */ - function getCounter (); - - /** - * "Getter" for file size - * - * @return $fileSize Size of currently loaded file - */ - function getFileSize (); - - /** - * Writes given value to the file and returns a hash and gap position for it - * - * @param $groupId Group identifier - * @param $value Value to be added to the stack - * @return $data Hash and gap position - */ - function writeValueToFile ($groupId, $rawData); - - /** - * Writes given raw data to the file and returns a gap position and length - * - * @param $groupId Group identifier - * @param $hash Hash from encoded value - * @param $encoded Encoded value to be written to the file - * @return $data Gap position and length of the raw data - */ - function writeDataToFreeGap ($groupId, $hash, $encoded); - - /** - * Writes data at given position - * - * @param $seekPosition Seek position - * @param $data Data to be written - * @param $flushHeader Whether to flush the header (default: flush) - * @return void - */ - function writeData ($seekPosition, $data, $flushHeader = TRUE); - - /** - * Searches for next suitable gap the given length of data can fit in - * including padding bytes. - * - * @param $length Length of raw data - * @return $seekPosition Found next gap's seek position - */ - function searchNextGap ($length); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/cache/.htaccess b/inc/classes/interfaces/cache/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/cache/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/cache/class_Cacheable.php b/inc/classes/interfaces/cache/class_Cacheable.php deleted file mode 100644 index ae1d03ed..00000000 --- a/inc/classes/interfaces/cache/class_Cacheable.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Cacheable extends FrameworkInterface { - /** - * Does the specified offset exist in cache? - * - * @param $offset The offset we are looking for - * @param $arrayElement If type is array, then this element must be found - * @param $minimumCount If array element is found then this count must at least match - * @return $exists Whether the offset exists - */ - function offsetExists($offset, $arrayElement = NULL, $minimumCount = 0); - - /** - * Setter for cache offset - * - * @param $offset The offset we shall set - * @param $data Data to store in cache - * @return void - */ - function offsetSet($offset, $data); - - /** - * Getter for cache offset or "null" if not found - * - * @param $offset The offset we shall set - * @return $data Data to store in cache - */ - function offsetGet($offset); - - /** - * Purges the given cache entry - * - * @param $offset The offset we shall set - * @return void - */ - function purgeOffset($offset); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/captcha/.htaccess b/inc/classes/interfaces/captcha/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/captcha/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/captcha/class_SolveableCaptcha.php b/inc/classes/interfaces/captcha/class_SolveableCaptcha.php deleted file mode 100644 index 9916e590..00000000 --- a/inc/classes/interfaces/captcha/class_SolveableCaptcha.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface SolveableCaptcha extends FrameworkInterface { - /** - * Initiates the CAPTCHA - * - * @return void - */ - function initiateCaptcha (); - - /** - * Render the CAPTCHA code - * - * @return void - */ - function renderCode (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/class_ b/inc/classes/interfaces/class_ deleted file mode 100644 index b3a5c087..00000000 --- a/inc/classes/interfaces/class_ +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface ??? extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/class_FrameworkInterface.php b/inc/classes/interfaces/class_FrameworkInterface.php deleted file mode 100644 index 724e57d7..00000000 --- a/inc/classes/interfaces/class_FrameworkInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Find a better name for this interface - * - * 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 . - */ -interface FrameworkInterface { - /** - * Getter for field name - * - * @param $fieldName Field name which we shall get - * @return $fieldValue Field value from the user - * @throws NullPointerException If the result instance is null - */ - function getField ($fieldName); - - /** - * Checks if given field is set - * - * @param $fieldName Field name to check - * @return $isSet Whether the given field name is set - * @throws NullPointerException If the result instance is null - */ - function isFieldSet ($fieldName); - - /** - * Checks whether an object equals this object. You should overwrite this - * method to implement own equality checks - * - * @param $objectInstance An instance of a FrameworkInterface object - * @return $equals Whether both objects equals - */ - function equals (FrameworkInterface $objectInstance); - - /** - * Generates a code for hashes from this class - * - * @return $hashCode The hash code respresenting this class - */ - function hashCode (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/client/.htaccess b/inc/classes/interfaces/client/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/client/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/client/class_Client.php b/inc/classes/interfaces/client/class_Client.php deleted file mode 100644 index de441385..00000000 --- a/inc/classes/interfaces/client/class_Client.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface Client extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/compressor/.htaccess b/inc/classes/interfaces/compressor/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/compressor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/compressor/class_Compressor.php b/inc/classes/interfaces/compressor/class_Compressor.php deleted file mode 100644 index b80a6c8d..00000000 --- a/inc/classes/interfaces/compressor/class_Compressor.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Compressor extends FrameworkInterface { - /** - * A compression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object - */ - function compressStream ($streamData); - - /** - * A decompression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object - */ - function decompressStream ($streamData); - - /** - * Getter for the file extension of this compressor - * - * @return $string The compressor's file extension - */ - function getCompressorExtension (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/controller/.htaccess b/inc/classes/interfaces/controller/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/controller/class_Controller.php b/inc/classes/interfaces/controller/class_Controller.php deleted file mode 100644 index c4debd47..00000000 --- a/inc/classes/interfaces/controller/class_Controller.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Controller extends FrameworkInterface { - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - function handleRequest (Requestable $requestInstance, Responseable $responseInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/criteria/.htaccess b/inc/classes/interfaces/criteria/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/criteria/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/criteria/class_Criteria.php b/inc/classes/interfaces/criteria/class_Criteria.php deleted file mode 100644 index 9609302f..00000000 --- a/inc/classes/interfaces/criteria/class_Criteria.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Criteria extends FrameworkInterface { - /** - * Setter for wrapper class name - * - * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name - * @return void - */ - function setWrapperConfigEntry ($wrapperConfigEntry); - - /** - * Getter for wrapper class name - * - * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name - */ - function getWrapperConfigEntry (); - - /** - * Checks whether given key is set - * - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @param $criteriaKey Criteria key - * @return $isSet Whether key is set - */ - function isKeySet ($criteriaType, $criteriaKey); - - /** - * Checks whether given key is set for 'choice' type - * - * @param $criteriaKey Criteria key - * @return $isSet Whether key is set - */ - function isChoiceKeySet ($criteriaKey); - - /** - * Checks whether given key is set for 'exclude' type - * - * @param $criteriaKey Criteria key - * @return $isSet Whether key is set - */ - function isExcludeKeySet ($criteriaKey); - - /** - * Getter for criteria array - * - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $criteria - */ - function getCriteriaArray ($criteriaType = 'default'); - - /** - * Getter for criteria array 'choice' type - * - * @return $criteria - */ - function getCriteriaChoiceArray (); - - /** - * Getter for criteria array 'exclude' type - * - * @return $criteria - */ - function getCriteriaExcludeArray (); - - /** - * Unsets a criteria key from all criteria types - * - * @param $criteriaKey Criteria key to unset - * @return void - */ - function unsetCriteria ($criteriaKey); - - /** - * Add criteria, this method converts dashes to underscores because dashes - * are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return void - */ - function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default'); - - /** - * Sets criteria, this method converts dashes to underscores because dashes - * are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return void - */ - function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default'); - - /** - * Add "choice" criteria, this method converts dashes to underscores because - * dashes are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @return void - */ - function addChoiceCriteria ($criteriaKey, $criteriaValue); - - /** - * Add "exclude" criteria, this method converts dashes to underscores because - * dashes are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @return void - */ - function addExcludeCriteria ($criteriaKey, $criteriaValue); - - /** - * Add configured criteria - * - * @param $criteriaKey Criteria key - * @param $configEntry Configuration entry - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return void - */ - function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default'); - - /** - * Get criteria element or FALSE if not found - * - * @param $criteriaKey The requested criteria key - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $value Whether the value of the critera or FALSE - */ - function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default'); - - /** - * Get criteria element or FALSE if not found for 'choice' type - * - * @param $criteriaKey The requested criteria key - * @return $value Whether the value of the critera or FALSE - */ - function getCriteriaChoiceElemnent ($criteriaKey); - - /** - * Get criteria element or FALSE if not found for 'exclude' type - * - * @param $criteriaKey The requested criteria key - * @return $value Whether the value of the critera or FALSE - */ - function getCriteriaExcludeElemnent ($criteriaKey); - - /** - * Checks whether given array entry matches - * - * @param $entryArray Array with the entries to find - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $matches Whether the entry matches or not - */ - function ifEntryMatches (array $entryArray, $criteriaType = 'default'); - - /** - * Checks whether given array 'choice' entry matches - * - * @param $entryArray Array with the entries to find - * @return $matches Whether the entry matches or not - */ - function ifChoiceMatches (array $entryArray); - - /** - * Checks whether given array 'exclude' entry matches - * - * @param $entryArray Array with the entries to find - * @return $matches Whether the entry matches or not - */ - function ifExcludeMatches (array $entryArray); - - /** - * "Getter" for a cache key - * - * @param $onlyKeys Only use these keys for a cache key - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $cacheKey The key suitable for the cache system - */ - function getCacheKey ($onlyKeys = array(), $criteriaType = 'default'); - - /** - * "Getter" for a cache key ('choice' type) - * - * @param $onlyKeys Only use these keys for a cache key - * @return $cacheKey The key suitable for the cache system - */ - function getCacheKeyChoice ($onlyKeys = array()); - - /** - * "Getter" for a cache key ('exclude' type) - * - * @param $onlyKeys Only use these keys for a cache key - * @return $cacheKey The key suitable for the cache system - */ - function getCacheKeyExclude ($onlyKeys = array()); - - /** - * Count the criteria, e.g. useful to find out if a database query has no - * limitation (search criteria). - * - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $count Count of all criteria entries - */ - function count ($criteriaType = 'default'); - - /** - * Count 'choice' criteria, e.g. useful to find out if a database query - * has no limitation (search criteria). - * - * @return $count Count of all criteria entries - */ - function countChoice (); - - /** - * Count 'exclude' criteria, e.g. useful to find out if a database query - * has no limitation (search criteria). - * - * @return $count Count of all criteria entries - */ - function countExclude (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/criteria/extended/.htaccess b/inc/classes/interfaces/criteria/extended/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/criteria/extended/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/criteria/extended/class_AddableCriteria.php b/inc/classes/interfaces/criteria/extended/class_AddableCriteria.php deleted file mode 100644 index e1254b23..00000000 --- a/inc/classes/interfaces/criteria/extended/class_AddableCriteria.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface AddableCriteria extends FrameworkInterface { - /** - * Adds registration elements to a given dataset instance - * - * @param $criteriaInstance An instance of a StoreableCriteria class - * @param $requestInstance An instance of a Requestable class - * @return void - */ - function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php b/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php deleted file mode 100644 index e0920c86..00000000 --- a/inc/classes/interfaces/criteria/extended/class_LocalSearchCriteria.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface LocalSearchCriteria extends Criteria { - /** - * Setter for limit - * - * @param $limit Search limit - * @return void - * @todo Find a nice casting here. (int) allows until and including 32766. - */ - function setLimit ($limit); - - /** - * "Setter" for limit from a configuration entry - * - * @param $configEntry The configuration entry which hold a number as limit - * @return void - */ - function setConfiguredLimit ($configEntry); - - /** - * Getter for limit - * - * @return $limit Search limit - */ - function getLimit (); - - /** - * Setter for skip - * - * @param $skip Search skip - * @return void - * @todo Find a nice casting here. (int) allows until and including 32766. - */ - function setSkip ($skip); - - /** - * Getter for skip - * - * @return $skip Search skip - */ - function getSkip (); - - /** - * Checks whether the given key/value pair is matching with 'default' and one of 'choice' and - * never with in 'exclude'. - * - * @param $key Key element to check - * @param $value Value to check - * @param $separator Separator for "exploding" $value (default: ',') - * @return $isMatching Whether the key/value is matching or excluded - */ - function isCriteriaMatching ($key, $value, $separator = ','); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php b/inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php deleted file mode 100644 index 5b627e93..00000000 --- a/inc/classes/interfaces/criteria/extended/class_LocalUpdateCriteria.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface LocalUpdateCriteria extends Criteria { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php b/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php deleted file mode 100644 index faa6c89e..00000000 --- a/inc/classes/interfaces/criteria/extended/class_StoreableCriteria.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface StoreableCriteria extends Criteria { - /** - * Setter for table name - * - * @param $tableName Name of the table to set - * @return void - */ - function setTableName ($tableName); - - /** - * Getter for table name - * - * @return $tableName Name of the table to set - */ - function getTableName (); - - /** - * Setter for unique key - * - * @param $uniqueKey Column to use as unique key - * @return void - */ - function setUniqueKey ($uniqueKey); - - /** - * Getter for unique key - * - * @return $uniqueKey Column to use as unique key - */ - function getUniqueKey (); - - /** - * Getter for unique key value - * - * @return $uniqueValue Value of the unique key - */ - function getUniqueValue (); - - /** - * Getter for primary key or unique key if not set - * - * @return $primaryKey Primary key or unique key if not set - */ - function getPrimaryKey (); - - /** - * Setter for primary key - * - * @param $primaryKey Primary key to set - * @return void - */ - function setPrimaryKey ($primaryKey); - - /** - * Setter for primary key array - * - * @param $primaryKeys Primary key array to set - * @return void - */ - function setPrimaryKeyCombined (array $primaryKeys); - - /** - * Getter for primary keys - * - * @return $primaryKeys Primary key array - */ - function getPrimaryKeys (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/crypto/.htaccess b/inc/classes/interfaces/crypto/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/crypto/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/crypto/class_Cryptable.php b/inc/classes/interfaces/crypto/class_Cryptable.php deleted file mode 100644 index 5f30f5a8..00000000 --- a/inc/classes/interfaces/crypto/class_Cryptable.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Cryptable extends FrameworkInterface { - /** - * Hashes a string with salt and returns the hash. If an old previous hash - * is supplied the method will use the first X chars of that hash for hashing - * the password. This is useful if you want to check if password is identical - * for authorization purposes. - * - * @param $str Unhashed string - * @param $oldHash A hash from previous hashed string - * @param $withFixed Whether to include a fixed salt (not recommended in p2p applications) - * @return $hashed The hashed and salted string - */ - function hashString ($str, $oldHash = '', $withFixed = TRUE); - - /** - * Encrypt the string with fixed salt - * - * @param $str The unencrypted string - * @param $key Optional key, if none provided, a random key will be generated - * @return $encrypted Encrypted string - */ - function encryptString ($str, $key = NULL); - - /** - * Decrypt the string with fixed salt - * - * @param $encrypted Encrypted string - * @return $str The unencrypted string - */ - function decryptString ($encrypted); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/database/.htaccess b/inc/classes/interfaces/database/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/database/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/database/backend/.htaccess b/inc/classes/interfaces/database/backend/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/database/backend/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/database/backend/class_DatabaseBackend.php b/inc/classes/interfaces/database/backend/class_DatabaseBackend.php deleted file mode 100644 index e040e8cb..00000000 --- a/inc/classes/interfaces/database/backend/class_DatabaseBackend.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface DatabaseBackend extends FrameworkDatabase { - /** - * Getter for last read file - * - * @return $lastFile The last read file's name with full path - */ - function getLastFile (); - - /** - * Getter for last read file's content as an array - * - * @return $lastContent The array with elements 'header' and 'data'. - */ - function getLastContents (); - - /** - * Getter for file extension - * - * @return $fileExtension The array with elements 'header' and 'data'. - */ - function getFileExtension (); - - /** - * Getter for index key - * - * @return $indexKey Index key - */ - function getIndexKey (); - - /** - * Makes sure that the database connection is alive - * - * @return void - * @todo Do some checks on the database directory and files here - */ - function connectToDatabase (); - - /** - * Starts a SELECT query on the database by given return type, table name - * and search criteria - * - * @param $tableName Name of the database table - * @param $searchInstance Local search criteria class - * @return $resultData Result data of the query - * @throws UnsupportedCriteriaException If the criteria is unsupported - * @throws SqlException If an 'SQL error' occurs - */ - function querySelect ($tableName, LocalSearchCriteria $searchInstance); - - /** - * "Inserts" a data set instance into a local file database folder - * - * @param $dataSetInstance A storeable data set - * @return void - * @throws SqlException If an SQL error occurs - */ - function queryInsertDataSet (StoreableCriteria $dataSetInstance); - - /** - * "Updates" a data set instance with a database layer - * - * @param $dataSetInstance A storeable data set - * @return void - * @throws SqlException If an SQL error occurs - */ - function queryUpdateDataSet (StoreableCriteria $dataSetInstance); - - /** - * Getter for primary key of specified table or if not found null will be - * returned. This must be database-specific. - * - * @param $tableName Name of the table we need the primary key from - * @return $primaryKey Primary key column of the given table - */ - function getPrimaryKeyOfTable ($tableName); - - /** - * Removes non-data from given array. - * - * @param $data An array with possible non-data that needs to be removed. - * @return $data A cleaned up array with only data. - * @todo Add more generic non-data for removal - */ - function removeNonPublicDataFromArray (array $data); - - /** - * Counts total rows of given table - * - * @param $tableName Table name - * @return $count Total rows of given table - */ - function countTotalRows($tableName); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/database/class_DatabaseWrapper.php b/inc/classes/interfaces/database/class_DatabaseWrapper.php deleted file mode 100644 index 03962256..00000000 --- a/inc/classes/interfaces/database/class_DatabaseWrapper.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface DatabaseWrapper extends FrameworkInterface { - /** - * Getter for index key - * - * @return $indexKey Index key - */ - function getIndexKey(); - - /** - * Getter for last exception - * - * @return $lastException Last exception or NULL if none occured - */ - function getLastException(); - - /** - * Do a "select" query on the current table with the given search criteria and - * store it in cache for later usage - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $resultInstance An instance of a database result class - */ - function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = array()); - - /** - * Count the numbers of rows we shall receive - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $numRows Numbers of rows of database entries - */ - function doSelectCountByCriteria(Criteria $criteriaInstance, $onlyKeys = array()); - - /** - * Getter for primary key used in wrapped table - * - * @return $primaryKey Primary key used in wrapped table - */ - function getPrimaryKeyValue(); - - /** - * Counts total rows of this table - * - * @return $count Total rows of this table - */ - function countTotalRows(); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/database/class_FrameworkDatabase.php b/inc/classes/interfaces/database/class_FrameworkDatabase.php deleted file mode 100644 index 8b7c72c4..00000000 --- a/inc/classes/interfaces/database/class_FrameworkDatabase.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface FrameworkDatabase extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/database/class_Updateable.php b/inc/classes/interfaces/database/class_Updateable.php deleted file mode 100644 index 1887b357..00000000 --- a/inc/classes/interfaces/database/class_Updateable.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Updateable extends FrameworkInterface { - /** - * Updates a given field with new value - * - * @param $fieldName Field to update - * @param $fieldValue New value to store - * @return void - */ - function updateDatabaseField ($fieldName, $fieldValue); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/database/frontend/.htaccess b/inc/classes/interfaces/database/frontend/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/database/frontend/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/database/middleware/.htaccess b/inc/classes/interfaces/database/middleware/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/database/middleware/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php b/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php deleted file mode 100644 index 86acb923..00000000 --- a/inc/classes/interfaces/database/middleware/class_DatabaseConnector.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface DatabaseConnector extends FrameworkDatabase { - /** - * Get an instance of this class (Singleton) - * - * @return $selfInstance An instance of this class - */ - static function getSelfInstance (); - - /** - * Setter for database connection - * - * @param $login Login to database - * @param $pass Password (plain) - * @param $dbase Database to choose - * @param $host Hostname to use - * @return void - */ - function setConnectionData ($login, $pass, $dbase, $host='localhost'); - - /** - * Getter for connection data - * - * @return $connectData Connection data stored with this clas - */ - function getConnectionData (); - - /** - * Setter for the real database layer - * @param $dbLayer An instance of the real database layer - * @return void - */ - function setDatabaseLayer (DatabaseBackend $dbLayer); - - /** - * Getter for index key - * - * @return $indexKey Index key - */ - function getIndexKey (); - - /** - * Runs a 'select' statement on the database layer with given table name - * and criteria. If this doesn't fail the result will be returned - * - * @param $tableName Name of the 'table' we shall query - * @param $criteriaInstance An instance of a Criteria class - * @return $result The result as an array - */ - function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance); - - /** - * Getter for last exception - * - * @return $exceptionInstance Last thrown exception - */ - function getLastException (); - - /** - * 'Inserts' a data set instance into a local file database folder - * - * @param $dataSetInstance A storeable data set - * @return void - */ - function queryInsertDataSet (StoreableCriteria $dataSetInstance); - - /** - * 'Updates' a data set instance with a database layer - * - * @param $dataSetInstance A storeable data set - * @return void - */ - function queryUpdateDataSet (StoreableCriteria $dataSetInstance); - - /** - * Getter for primary key column of specified table name - * - * @param $tableName Name of table we need the primary key column from - * @return $primaryKey Primary key column of requested table - */ - function getPrimaryKeyOfTable ($tableName); - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - function removeNonPublicDataFromArray (array $data); - - /** - * Counts total rows of given table - * - * @param $tableName Table name - * @return $count Total rows of given table - */ - function countTotalRows($tableName); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/database/wrapper/.htaccess b/inc/classes/interfaces/database/wrapper/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/database/wrapper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/database/wrapper/class_BookablePointsWrapper.php b/inc/classes/interfaces/database/wrapper/class_BookablePointsWrapper.php deleted file mode 100644 index eaeb13e8..00000000 --- a/inc/classes/interfaces/database/wrapper/class_BookablePointsWrapper.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface BookablePointsWrapper extends DatabaseWrapper { - /** - * Inserts the given points for the given user in the database - * - * @param $pointsInstance An instance of a user class - * @return void - */ - function insertUserPoints (BookablePoints $pointsInstance); - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a Updateable database result - * @return void - */ - function doUpdateByResult (UpdateableResult $resultInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/database/wrapper/class_ManageableAccountWrapper.php b/inc/classes/interfaces/database/wrapper/class_ManageableAccountWrapper.php deleted file mode 100644 index ec9126dd..00000000 --- a/inc/classes/interfaces/database/wrapper/class_ManageableAccountWrapper.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ManageableAccountWrapper extends DatabaseWrapper { - /** - * Handles inserting the registration data from a registration instance into the database - * - * @param $registrationInstance An instance of a registration class - * @return void - */ - function insertRegistrationObject (UserRegister $registrationInstance); - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a Updateable database result - * @return void - */ - function doUpdateByResult (UpdateableResult $resultInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/debug/.htaccess b/inc/classes/interfaces/debug/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/debug/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/debug/class_Debugger.php b/inc/classes/interfaces/debug/class_Debugger.php deleted file mode 100644 index a8925403..00000000 --- a/inc/classes/interfaces/debug/class_Debugger.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Debugger extends FrameworkInterface { - /** - * Outputs the given data - * - * @param $output Debug text for output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - function outputStream ($output, $stripTags = FALSE); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/discovery/.htaccess b/inc/classes/interfaces/discovery/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/discovery/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/discovery/class_Discoverable.php b/inc/classes/interfaces/discovery/class_Discoverable.php deleted file mode 100644 index d9a13ffc..00000000 --- a/inc/classes/interfaces/discovery/class_Discoverable.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Discoverable extends FrameworkInterface { - /** - * Discovers the request - * - * @param $requestInstance An instance of a Requestable class - * @return void - */ - function discover (Requestable $requestInstance); - - /** - * Adds the database result in a human-readable format to the helper class - * - * @param $helperInstance An instance of a helper class - * @return void - */ - function addResultsToHelper (HelpableTemplate $helperInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/feature/.htaccess b/inc/classes/interfaces/feature/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/feature/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/feature/class_Feature.php b/inc/classes/interfaces/feature/class_Feature.php deleted file mode 100644 index 9fa497fe..00000000 --- a/inc/classes/interfaces/feature/class_Feature.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface Feature extends FrameworkInterface { - /** - * Checks whether this feature can be made available to other classes. - * - * @return $isAvailable Whether this feature is available - */ - function isFeatureAvailable (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/filter/.htaccess b/inc/classes/interfaces/filter/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/filter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/filter/class_Filterable.php b/inc/classes/interfaces/filter/class_Filterable.php deleted file mode 100644 index 9d9e3a4a..00000000 --- a/inc/classes/interfaces/filter/class_Filterable.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Filterable extends FrameworkInterface { - /** - * 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 - */ - function execute (Requestable $requestInstance, Responseable $responseInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/handler/.htaccess b/inc/classes/interfaces/handler/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/handler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/handler/class_Handleable.php b/inc/classes/interfaces/handler/class_Handleable.php deleted file mode 100644 index cc2539cf..00000000 --- a/inc/classes/interfaces/handler/class_Handleable.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Handleable extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/handler/class_HandleableDataSet.php b/inc/classes/interfaces/handler/class_HandleableDataSet.php deleted file mode 100644 index 26e12f91..00000000 --- a/inc/classes/interfaces/handler/class_HandleableDataSet.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface HandleableDataSet extends Handleable { - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - */ - function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/handler/protocol/.htaccess b/inc/classes/interfaces/handler/protocol/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/handler/protocol/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/handler/protocol/class_HandleableProtocol.php b/inc/classes/interfaces/handler/protocol/class_HandleableProtocol.php deleted file mode 100644 index a4918ab6..00000000 --- a/inc/classes/interfaces/handler/protocol/class_HandleableProtocol.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface HandleableProtocol extends Handleable { - /** - * Getter for port number to satify HandleableProtocol - * - * @return $port The port number - */ - function getPort (); - - /** - * Getter for protocol name - * - * @return $protocol Name of used protocol - */ - function getProtocolName (); - - /** - * Validates given 'recipient' if it is a valid UNL. This means that the UNL - * can be parsed by the protocol handler. - * - * @param $packageData Valid raw package data - * @return $isValid Whether the UNL can be validated - */ - function isValidUniversalNodeLocatorByPackageData (array $packageData); - - /** - * If the found UNL (address) matches own external or internal address - * - * @param $unl UNL to test - * @return $ifMatches Whether the found UNL matches own addresss - */ - function isOwnAddress ($unl); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/handler/task/.htaccess b/inc/classes/interfaces/handler/task/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/handler/task/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/handler/task/class_HandleableTask.php b/inc/classes/interfaces/handler/task/class_HandleableTask.php deleted file mode 100644 index 67969ac9..00000000 --- a/inc/classes/interfaces/handler/task/class_HandleableTask.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo HandleableDataSet looks strange here - * - * 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 . - */ -interface HandleableTask extends HandleableDataSet { - /** - * Searches a task by given instance - * - * @param $taskInstanc An instanceof a Taskable class - * @return $taskName Name of the task as used while registration - */ - function searchTask (Taskable $taskInstance); - - /** - * Registers a task with a task handler. - * - * @param $taskName A task name to register the task on - * @param $taskInstance The instance we should register as a task - * @return void - */ - function registerTask ($taskName, Visitable $taskInstance); - - /** - * Checks whether tasks are left including idle task - * - * @return $tasksLeft Whether there are tasks left to handle - */ - function hasTasksLeft (); - - /** - * Handles all tasks by checking if they should startup or if it is their - * turn to run. You should use this method in a while() loop in conjuntion - * with hasTasksLeft() so you can e.g. shutdown by adding a ShutdownTask - * which will attempt to remove all tasks from the task handler. - * - * @return void - */ - function handleTasks (); - - /** - * Shuts down all tasks and the task handler itself. This method should be - * called from a corresponding filter class. - * - * @return void - */ - function doShutdown (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/helper/.htaccess b/inc/classes/interfaces/helper/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/helper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/helper/class_Helper.php b/inc/classes/interfaces/helper/class_Helper.php deleted file mode 100644 index 427f3813..00000000 --- a/inc/classes/interfaces/helper/class_Helper.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Helper extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/helper/login/.htaccess b/inc/classes/interfaces/helper/login/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/helper/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/helper/login/class_HelpableLogin.php b/inc/classes/interfaces/helper/login/class_HelpableLogin.php deleted file mode 100644 index 90a1717e..00000000 --- a/inc/classes/interfaces/helper/login/class_HelpableLogin.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface HelpableLogin extends Helper { - /** - * Execute the login request by given response instance. This instance can - * be used for sending cookies or at least the session id out. - * - * @param $responseInstance An instance of a Responseable class - * @return void - */ - function executeLogin (Responseable $responseInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/helper/template/.htaccess b/inc/classes/interfaces/helper/template/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/helper/template/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/helper/template/class_HelpableTemplate.php b/inc/classes/interfaces/helper/template/class_HelpableTemplate.php deleted file mode 100644 index 54462567..00000000 --- a/inc/classes/interfaces/helper/template/class_HelpableTemplate.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface HelpableTemplate extends Helper { - /** - * Flush the content out,e g. to a template variable - * - * @return void - */ - function flushContent (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/index/.htaccess b/inc/classes/interfaces/index/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/index/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/index/class_Indexable b/inc/classes/interfaces/index/class_Indexable deleted file mode 100644 index d3dfbc13..00000000 --- a/inc/classes/interfaces/index/class_Indexable +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface Indexable??? extends Indexable { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/index/class_Indexable.php b/inc/classes/interfaces/index/class_Indexable.php deleted file mode 100644 index 079d0368..00000000 --- a/inc/classes/interfaces/index/class_Indexable.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface Indexable extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/index/stack/.htaccess b/inc/classes/interfaces/index/stack/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/index/stack/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/index/stack/class_IndexableStack.php b/inc/classes/interfaces/index/stack/class_IndexableStack.php deleted file mode 100644 index 64b88056..00000000 --- a/inc/classes/interfaces/index/stack/class_IndexableStack.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface IndexableStack extends Indexable, CalculatableBlock { - /** - * Adds given hash to an index file - * - * @param $stackName Name of stack to add hash - * @param $data Hash and gap position to be added to the index - * @return void - */ - function addHashToIndex ($stackName, array $data); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/.htaccess b/inc/classes/interfaces/io/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/class_FilePointer.php b/inc/classes/interfaces/io/class_FilePointer.php deleted file mode 100644 index 20a3c375..00000000 --- a/inc/classes/interfaces/io/class_FilePointer.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface FilePointer extends FrameworkInterface { - /** - * Getter for the file pointer - * - * @return $filePointer The file pointer which shall be a valid file resource - */ - function getPointer (); - - /** - * Getter for file name - * - * @return $fileName The current file name - */ - function getFileName (); - - /** - * Determines whether the EOF has been reached - * - * @return $isEndOfFileReached Whether the EOF has been reached - */ - function isEndOfFileReached (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/class_Streamable.php b/inc/classes/interfaces/io/class_Streamable.php deleted file mode 100644 index 2c143932..00000000 --- a/inc/classes/interfaces/io/class_Streamable.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Streamable extends FrameworkInterface { - /** - * Determines seek position - * - * @return $seekPosition Current seek position - */ - function determineSeekPosition (); - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - */ - function seek ($offset, $whence = SEEK_SET); - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - function size (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/class_StreamableInput.php b/inc/classes/interfaces/io/class_StreamableInput.php deleted file mode 100644 index 5b36bb9b..00000000 --- a/inc/classes/interfaces/io/class_StreamableInput.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface StreamableInput extends Streamable { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/class_StreamableOutput.php b/inc/classes/interfaces/io/class_StreamableOutput.php deleted file mode 100644 index 2798e50c..00000000 --- a/inc/classes/interfaces/io/class_StreamableOutput.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface StreamableOutput extends Streamable { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/directory/.htaccess b/inc/classes/interfaces/io/directory/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/directory/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/directory/class_FrameworkDirectory.php b/inc/classes/interfaces/io/directory/class_FrameworkDirectory.php deleted file mode 100644 index bc06c093..00000000 --- a/inc/classes/interfaces/io/directory/class_FrameworkDirectory.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface FrameworkDirectory extends FrameworkInterface { - /** - * Read raw lines of data from a directory pointer and return the data - * - * @return $currentEntry Current entry from encapsulated iterator - */ - function readRawDirectory (); - - /** - * Read lines from the current directory pointer except some parts - * - * @param $except Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored - * @return string Directory and/or file names read from the current directory pointer - */ - function readDirectoryExcept (array $except = array()); - - /** - * Close a directory source and set it's instance to null and the path name - * to empty - * - * @return void - */ - function closeDirectory (); - - /** - * Getter for the directory pointer - * - * @return $iteratorInstance The directory pointer which shall be a valid directory resource - */ - function getDirectoryIteratorInstance (); - - /** - * Getter for path name - * - * @return $pathName The current path name - */ - function getPathName (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/file/.htaccess b/inc/classes/interfaces/io/file/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/file/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/file/class_FileInputStreamer.php b/inc/classes/interfaces/io/file/class_FileInputStreamer.php deleted file mode 100644 index 34bb1217..00000000 --- a/inc/classes/interfaces/io/file/class_FileInputStreamer.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface FileInputStreamer extends StreamableInput { - /** - * Reads from a local or remote file - * - * @param $fqfn The file's FQFN we shall load - * @return $array An array containing all read lines - * @throws InvalidArrayCountException If an array has not the expected size - * @throws InvalidMD5ChecksumException If two MD5 hashes did not match - */ - function loadFileContents ($fqfn); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/file/class_FileOutputStreamer.php b/inc/classes/interfaces/io/file/class_FileOutputStreamer.php deleted file mode 100644 index ee9f2a25..00000000 --- a/inc/classes/interfaces/io/file/class_FileOutputStreamer.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface FileOutputStreamer extends StreamableOutput { - /** - * Saves streamed (that are mostly serialized objects) data to files or - * external servers. - * - * @param $fileName The local file's name including full path - * @param $dataArray Array containing the compressor's extension and streamed data - * @return void - */ - function saveFile ($fileName, array $dataArray); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/file/csv/.htaccess b/inc/classes/interfaces/io/file/csv/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/file/csv/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/file/csv/class_CsvInputStreamer.php b/inc/classes/interfaces/io/file/csv/class_CsvInputStreamer.php deleted file mode 100644 index 558dd725..00000000 --- a/inc/classes/interfaces/io/file/csv/class_CsvInputStreamer.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface CsvInputStreamer extends FileInputStreamer { - /** - * Reads a line from CSV file and returns it as an indexed array - * - * @param $columnSeparator Character to use separting columns - * @return $lineArray An index array with the read line - */ - function readCsvFileLine ($columnSeparator); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/file/handler/.htaccess b/inc/classes/interfaces/io/file/handler/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/file/handler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/file/handler/class_IoHandler.php b/inc/classes/interfaces/io/file/handler/class_IoHandler.php deleted file mode 100644 index 6348cc9a..00000000 --- a/inc/classes/interfaces/io/file/handler/class_IoHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface IoHandler extends FileInputStreamer, FileOutputStreamer { - /** - * Setter for the *real* file input instance - * - * @param $inputStream The *real* file-input class - * @return void - */ - function setInputStream (FileInputStreamer $inputStream); - - /** - * Getter for the *real* file input instance - * - * @return $inputStream The *real* file-input class - */ - function getInputStream (); - - /** - * Setter for the *real* file output instance - * - * @param $outputStream The *real* file-output class - * @return void - */ - function setOutputStream (FileOutputStreamer $outputStream); - - /** - * Getter for the *real* file output instance - * - * @return $outputStream The *real* file-output class - */ - function getOutputStream (); - - /** - * Saves a file with data by using the current output stream - * - * @param $fileName Name of the file - * @param $dataStream File data stream - * @param $objectInstance An instance of a FrameworkInterface class (default: NULL) - * @return void - */ - function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/output/.htaccess b/inc/classes/interfaces/io/output/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/output/class_OutputStreamer.php b/inc/classes/interfaces/io/output/class_OutputStreamer.php deleted file mode 100644 index 1d2f89c5..00000000 --- a/inc/classes/interfaces/io/output/class_OutputStreamer.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface OutputStreamer extends StreamableOutput { - /** - * Output the code - * - * @param $outStream Stream to output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - function output ($outStream = FALSE, $stripTags = FALSE); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/pointer/.htaccess b/inc/classes/interfaces/io/pointer/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/pointer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/pointer/class_InputPointer.php b/inc/classes/interfaces/io/pointer/class_InputPointer.php deleted file mode 100644 index a4567af0..00000000 --- a/inc/classes/interfaces/io/pointer/class_InputPointer.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface InputPointer extends StreamableInput, FilePointer { - /** - * Read data a file pointer - * - * @return $data Read data from file - */ - function readFromFile (); - - /** - * Reads a line, maximum 4096 Bytes from current file pointer - * - * @return $data Read data from file - */ - function readLine (); - - /** - * Reads given amount of bytes from file. - * - * @param $bytes Amount of bytes to read or whole line (only text files) - * @return $data Data read from file - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - */ - function read ($bytes = NULL); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/pointer/class_OutputPointer.php b/inc/classes/interfaces/io/pointer/class_OutputPointer.php deleted file mode 100644 index 4ac2fe94..00000000 --- a/inc/classes/interfaces/io/pointer/class_OutputPointer.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface OutputPointer extends StreamableOutput, FilePointer { - /** - * Write data to a file pointer - * - * @param $dataStream The data stream we shall write to the file - * @return mixed Number of writes bytes or FALSE on error - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - * an invalid file resource - */ - function writeToFile ($dataStream); - - /** - * Writes at given position by seeking to it. - * - * @param $seekPosition Seek position in file - * @param $data Data to be written - * @return mixed Number of writes bytes or FALSE on error - */ - function writeAtPosition ($seedPosition, $data); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/io/pointer/io/.htaccess b/inc/classes/interfaces/io/pointer/io/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/io/pointer/io/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php b/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php deleted file mode 100644 index 8d4500b2..00000000 --- a/inc/classes/interfaces/io/pointer/io/class_InputOutputPointer.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface InputOutputPointer extends InputPointer, OutputPointer { - /** - * Rewinds to the beginning of the file - * - * @return $status Status of this operation - */ - function rewind (); - - /** - * Advances to next "block" of bytes - * - * @return void - */ - function next (); - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - */ - function valid (); - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - */ - function key (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/iterator/.htaccess b/inc/classes/interfaces/iterator/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/iterator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php b/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php deleted file mode 100644 index 26ed97dd..00000000 --- a/inc/classes/interfaces/iterator/class_SeekableWritableFileIterator.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @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 . - */ -interface SeekableWritableFileIterator extends SeekableIterator { - /** - * Seeks to given position - * - * @param $seekPosition Seek position in file - * @return $status Status of this operation - */ - function seek ($seekPosition); - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - function size (); - - /** - * Reads given amount of bytes from file. - * - * @param $bytes Amount of bytes to read - * @return $data Data read from file - */ - function read ($bytes); - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - */ - function analyzeFile (); - - /** - * Checks whether the file header is initialized - * - * @return $isInitialized Whether the file header is initialized - */ - function isFileHeaderInitialized (); - - /** - * Creates the assigned file - * - * @return void - */ - function createFileHeader (); - - /** - * Pre-allocates file (if enabled) with some space for later faster write access. - * - * @param $type Type of the file - * @return void - */ - function preAllocateFile ($type); - - /** - * Initializes counter for valid entries, arrays for damaged entries and - * an array for gap seek positions. If you call this method on your own, - * please re-analyze the file structure. So you are better to call - * analyzeFile() instead of this method. - * - * @return void - */ - function initCountersGapsArray (); - - /** - * Getter for header size - * - * @return $totalEntries Size of file header - */ - function getHeaderSize (); - - /** - * Setter for header size - * - * @param $headerSize Size of file header - * @return void - */ - function setHeaderSize ($headerSize); - - /** - * Getter for header array - * - * @return $totalEntries Size of file header - */ - function getHeader (); - - /** - * Setter for header - * - * @param $header Array for a file header - * @return void - */ - function setHeader (array $header); - - /** - * Updates seekPosition attribute from file to avoid to much access on file. - * - * @return void - */ - function updateSeekPosition (); - - /** - * Getter for total entries - * - * @return $totalEntries Total entries in this file - */ - function getCounter (); - - /** - * "Getter" for file size - * - * @return $fileSize Size of currently loaded file - */ - function getFileSize (); - - /** - * Writes data at given position - * - * @param $seekPosition Seek position - * @param $data Data to be written - * @param $flushHeader Whether to flush the header (default: flush) - * @return void - */ - function writeData ($seekPosition, $data, $flushHeader = TRUE); - - /** - * Getter for seek position - * - * @return $seekPosition Current seek position (stored here in object) - */ - function getSeekPosition (); - - /** - * Writes given value to the file and returns a hash and gap position for it - * - * @param $groupId Group identifier - * @param $value Value to be added to the stack - * @return $data Hash and gap position - */ - function writeValueToFile ($groupId, $value); - - /** - * Writes given raw data to the file and returns a gap position and length - * - * @param $groupId Group identifier - * @param $hash Hash from encoded value - * @param $encoded Encoded value to be written to the file - * @return $data Gap position and length of the raw data - */ - function writeDataToFreeGap ($groupId, $hash, $encoded); - - /** - * Searches for next suitable gap the given length of data can fit in - * including padding bytes. - * - * @param $length Length of raw data - * @return $seekPosition Found next gap's seek position - */ - function searchNextGap ($length); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/language/.htaccess b/inc/classes/interfaces/language/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/language/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/language/class_ManageableLanguage.php b/inc/classes/interfaces/language/class_ManageableLanguage.php deleted file mode 100644 index ceffb104..00000000 --- a/inc/classes/interfaces/language/class_ManageableLanguage.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ManageableLanguage extends FrameworkInterface { - /** - * Initialize the array-object for all later language strings - * - * @return void - */ - function initLanguageStrings(); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/lists/.htaccess b/inc/classes/interfaces/lists/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/lists/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/lists/class_Listable.php b/inc/classes/interfaces/lists/class_Listable.php deleted file mode 100644 index f3a60f92..00000000 --- a/inc/classes/interfaces/lists/class_Listable.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Listable extends FrameworkInterface, IteratorAggregate { - /** - * Checks whether the given group is set - * - * @param $groupName Group to check if found in list - * @return $isset Whether the group is valid - */ - function isGroupSet ($groupName); - - /** - * Adds the given group or if already added issues a ListGroupAlreadyAddedException - * - * @param $groupName Group to add - * @return void - * @throws ListGroupAlreadyAddedException If the given group is already added - */ - function addGroup ($groupName); - - /** - * Adds the given instance to list group and sub group - * - * @param $groupName Group to add instance to - * @param $subGroup Sub group to add instance to - * @param $visitableInstance An instance of Visitable - * @return void - * @throws NoListGroupException If the given group is not found - */ - function addInstance ($groupName, $subGroup, Visitable $visitableInstance); - - /** - * Adds the given entry to list group - * - * @param $groupName Group to add instance to - * @param $entry An entry of any type - * @return void - * @throws NoListGroupException If the given group is not found - */ - function addEntry ($groupName, $entry); - - /** - * Updates the given entry by hash with given array - * - * @param $hash Hash for this entry - * @param $entryArray Array with entry we should update - * @return void - * @throws InvalidListHashException If the solved hash index is invalid - */ - function updateCurrentEntryByHash ($hash, array $entryArray); - - /** - * "Getter" for an iterator instance of this list - * - * @return $iteratorInstance An instance of a Iterator class - */ - function getListIterator (); - - /** - * Clears this list (mostly by clearing all groups together) - * - * @return void - */ - function clearList (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/login/.htaccess b/inc/classes/interfaces/login/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/login/class_LoginableUser.php b/inc/classes/interfaces/login/class_LoginableUser.php deleted file mode 100644 index d1c26b32..00000000 --- a/inc/classes/interfaces/login/class_LoginableUser.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface LoginableUser extends FrameworkInterface { - /** - * Logins the user with the given request containing the credential. The - * result of the login can be thrown by exception or, if prefered stored - * in a boolean attribute which is then readable by a matching getter. - * - * @param $requestInstance An instance of a Requestable class - * @param $responseInstance An instance of a Responseable class - * @return void - */ - function doLogin (Requestable $requestInstance, Responseable $responseInstance); - - /** - * Check if the implementation is correct. Only the request instance is - * needed as no redirect is done here. - * - * @param $requestInstance An instance of a Requestable class - * @return - */ - function testLogin (Requestable $requestInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/mailer/.htaccess b/inc/classes/interfaces/mailer/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/mailer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/mailer/class_DeliverableMail.php b/inc/classes/interfaces/mailer/class_DeliverableMail.php deleted file mode 100644 index 2e03b4ea..00000000 --- a/inc/classes/interfaces/mailer/class_DeliverableMail.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface DeliverableMail extends FrameworkInterface { - /** - * Adds a user class to the recipient list for current template - * - * @param $userInstance An instance of a user class - * @return void - */ - function addRecipientByUserInstance (ManageableMember $userInstance); - - /** - * Use subject line provided by the (XML) template otherwise a subject line must be set - * - * @return void - */ - function useSubjectFromTemplate (); - - /** - * Deliver email to the recipient(s) - * - * @return void - */ - function deliverEmail (); - - /** - * Send notification to the admin - * - * @return void - */ - function sendAdminNotification (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/menu/.htaccess b/inc/classes/interfaces/menu/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/menu/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/menu/class_RenderableMenu.php b/inc/classes/interfaces/menu/class_RenderableMenu.php deleted file mode 100644 index 8b0281c2..00000000 --- a/inc/classes/interfaces/menu/class_RenderableMenu.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface RenderableMenu extends FrameworkInterface { - /** - * Renders the menu by loading the base template and a menu-specific - * template. - * - * @return void - */ - function renderMenu (); - - /** - * Transfers the rendered menu to a given template engine by assigning - * the rendered content with a template variable. - * - * @2param $templateInstance An instance of a CompileableTemplate class - * @return void - */ - function transferContentToTemplateEngine (CompileableTemplate $templateInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/parser/.htaccess b/inc/classes/interfaces/parser/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/parser/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/parser/class_Parseable.php b/inc/classes/interfaces/parser/class_Parseable.php deleted file mode 100644 index c3bcb3ea..00000000 --- a/inc/classes/interfaces/parser/class_Parseable.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Parseable extends FrameworkInterface { - /** - * Parses the given XML content - * - * @param $content Valid XML content - * @return void - * @throws XmlParserException If an XML error was found - */ - function parseXmlContent ($content); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/points/.htaccess b/inc/classes/interfaces/points/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/points/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/points/class_BookablePoints.php b/inc/classes/interfaces/points/class_BookablePoints.php deleted file mode 100644 index eba95cdf..00000000 --- a/inc/classes/interfaces/points/class_BookablePoints.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface BookablePoints extends AddableCriteria { - /** - * Checks whether the user has the required amount of points left for the specified action - * - * @param $action The action or configuration entry plus prefix the user wants to perform - * @return $hasRequired Whether the user has the required points - */ - function ifUserHasRequiredPoints ($action); - - /** - * "Books" the given points amount on the current user's account - * - * @param $amount Amount of points we shall book - * @return void - */ - function bookPointsDirectly ($amount); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/reader/.htaccess b/inc/classes/interfaces/reader/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/reader/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/reader/class_ReadableNews.php b/inc/classes/interfaces/reader/class_ReadableNews.php deleted file mode 100644 index 44af0ee0..00000000 --- a/inc/classes/interfaces/reader/class_ReadableNews.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ReadableNews extends FrameworkInterface { - /** - * Initializes the news reader class. This is very reader-dependent - * - * @return void - */ - function initializeReader(); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/registration/.htaccess b/inc/classes/interfaces/registration/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/registration/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/registration/class_UserRegister.php b/inc/classes/interfaces/registration/class_UserRegister.php deleted file mode 100644 index ad4bf56a..00000000 --- a/inc/classes/interfaces/registration/class_UserRegister.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface UserRegister extends AddableCriteria { - /** - * Encrypt given request key or throws an exception if key was not found in - * request. - * - * @param $requestKey Key in request class - * @return void - */ - function encryptPassword ($requestKey); - - /** - * Perform things like informing assigned affilates about new registration - * before registration - * - * @return void - */ - function doPreRegistration (); - - /** - * Registers the new user account by insterting the request data into the - * database and paying some start credits or throw exceptions if this fails - * - * @return void - */ - function registerNewUser (); - - /** - * Perform things like notifying partner websites after registration is done - * - * @return void - */ - function doPostRegistration (); - - /** - * Do the action which is required after all registration steps are done. - * This can be a simple redirect to another webpage or displaying a message - * to the user. Or this can be a login step into the newly created account. - * - * @return void - */ - function doPostAction (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/registry/.htaccess b/inc/classes/interfaces/registry/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/registry/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/registry/class_Register.php b/inc/classes/interfaces/registry/class_Register.php deleted file mode 100644 index 222e7c10..00000000 --- a/inc/classes/interfaces/registry/class_Register.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Register extends FrameworkInterface { - /** - * Checks whether an instance key was found - * - * @param $instanceKey The key holding an instance in registry - * @return $exists Whether the key exists in registry - */ - function instanceExists ($instanceKey); - - /** - * Adds/overwrites a new instance to the registry at the given key - * - * @param $instanceKey The key to identify the instance - * @param $objectInstance An instance we shall store - * @return void - */ - function addInstance ($instanceKey, Registerable $objectInstance); - - /** - * Gets a registered instance or null if not found - * - * @param $instanceKey The key to identify the instance - * @return $objectInstance An instance we shall store - */ - function getInstance ($instanceKey); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/registry/class_Registerable.php b/inc/classes/interfaces/registry/class_Registerable.php deleted file mode 100644 index 213a562a..00000000 --- a/inc/classes/interfaces/registry/class_Registerable.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Registerable extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/registry/socket/.htaccess b/inc/classes/interfaces/registry/socket/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/registry/socket/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/registry/socket/class_RegisterableSocket.php b/inc/classes/interfaces/registry/socket/class_RegisterableSocket.php deleted file mode 100644 index efe266a8..00000000 --- a/inc/classes/interfaces/registry/socket/class_RegisterableSocket.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface RegisterableSocket extends Registerable { - /** - * Checks whether given socket resource is registered. If $socketResource is - * FALSE only the instance will be checked. - * - * @param $infoInstance An instance of a ShareableInfo class - * @param $socketResource A valid socket resource - * @return $isRegistered Whether the given socket resource is registered - */ - function isSocketRegistered (ShareableInfo $infoInstance, $socketResource); - - /** - * Registeres given socket for listener or throws an exception if it is already registered - * - * @param $infoInstance An instance of a ShareableInfo class - * @param $socketResource A valid socket resource - * @return void - * @throws SocketAlreadyRegisteredException If the given socket is already registered - */ - function registerSocket (ShareableInfo $infoInstance, $socketResource); - - /** - * Getter for given listener's socket resource - * - * @param $listenerInstance An instance of a Listenable class - * @return $socketResource A valid socket resource - * @throws NoSocketRegisteredException If the requested socket is not registered - */ - function getRegisteredSocketResource (Listenable $listenerInstance); - - /** - * "Getter" for info instance from given package data - * - * @param $packageData Raw package data - * @return $infoInstance An instance of a ShareableInfo class - */ - function getInfoInstanceFromPackageData (array $packageData); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/request/.htaccess b/inc/classes/interfaces/request/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/request/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/request/class_Requestable.php b/inc/classes/interfaces/request/class_Requestable.php deleted file mode 100644 index 5a9ef492..00000000 --- a/inc/classes/interfaces/request/class_Requestable.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Requestable extends FrameworkInterface { - /** - * Prepares the request data for usage - * - * @return void - */ - function prepareRequestData (); - - /** - * Checks whether a request element is set - * - * @param $element Name of the request element we want to check - * @return $isSet Whether the request element is set - * @throws MissingArrayElementsException Thrown if a request element is not set - */ - function isRequestElementSet ($element); - - /** - * Getter for request element or 'null' if element was not found - * - * @param $element Name of the request element we want to check - * @return $value Value of the found request element or 'null' if the - * element was not found - */ - function getRequestElement ($element); - - /** - * Wrapper method for array_key() function for the request data array - * - * @return $array An array containing all array keys to return - */ - function getParameterNames (); - - /** - * Getter for a header element or 'null' if header was not found - * - * @param $headerName Name of the header - * @return $headerValue Value of the header or 'null' if not found - */ - function getHeaderElement ($headerName); - - /** - * Sets whether the request was valid (default: TRUE) - * - * @param $isValid Whether the request is valid - * @return void - */ - function requestIsValid ($isValid = TRUE); - - /** - * Reads a cookie and returns it's value or null if not found - * - * @param $cookieName Name of cookie we shall read - * @return $cookieValue Value of cookie or null if not found - */ - function readCookie ($cookieName); - - /** - * Checks if the request method is GET. - * - * @return $isGet Whether the request method is GET - */ - function isGetRequestMethod (); - - /** - * Checks if the request method is HEAD. - * - * @return $isHead Whether the request method is HEAD - */ - function isHeadRequestMethod (); - - /** - * Checks if the request method is POST. - * - * @return $isPost Whether the request method is POST - */ - function isPostRequestMethod (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/resolver/.htaccess b/inc/classes/interfaces/resolver/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/resolver/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/resolver/actions/.htaccess b/inc/classes/interfaces/resolver/actions/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/resolver/actions/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/resolver/actions/class_ActionResolver.php b/inc/classes/interfaces/resolver/actions/class_ActionResolver.php deleted file mode 100644 index bdf99179..00000000 --- a/inc/classes/interfaces/resolver/actions/class_ActionResolver.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ActionResolver extends Resolver { - /** - * Returns an action instance for the current action - * - * @return $actionInstance An instance of the resolved action - */ - function resolveAction (); - - /** - * Returns an action instance for a given request class - * - * @param $requestInstance An instance of a request class - * @return $actionInstance An instance of the resolved action - */ - function resolveActionByRequest (Requestable $requestInstance); - - /** - * Checks whether the given action is valid - * - * @param $actionName The default action we shall execute - * @return $isValid Whether the given action is valid - * @throws EmptyVariableException Thrown if given action is not set - */ - function isActionValid ($actionName); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/resolver/class_Resolver.php b/inc/classes/interfaces/resolver/class_Resolver.php deleted file mode 100644 index 9620fb2f..00000000 --- a/inc/classes/interfaces/resolver/class_Resolver.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Resolver extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/resolver/commands/.htaccess b/inc/classes/interfaces/resolver/commands/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/resolver/commands/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/resolver/commands/class_CommandResolver.php b/inc/classes/interfaces/resolver/commands/class_CommandResolver.php deleted file mode 100644 index 16349bd6..00000000 --- a/inc/classes/interfaces/resolver/commands/class_CommandResolver.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface CommandResolver extends Resolver { - /** - * Returns an command instance for a given request class - * - * @param $requestInstance An instance of a request class - * @return $commandInstance An instance of the resolved command - */ - function resolveCommandByRequest (Requestable $requestInstance); - - /** - * Checks whether the given command is valid - * - * @param $commandName The default command we shall execute - * @return $isValid Whether the given command is valid - * @throws EmptyVariableException Thrown if given command is not set - */ - function isCommandValid ($commandName); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/resolver/controller/.htaccess b/inc/classes/interfaces/resolver/controller/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/resolver/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/resolver/controller/class_ControllerResolver.php b/inc/classes/interfaces/resolver/controller/class_ControllerResolver.php deleted file mode 100644 index 11a0dbb5..00000000 --- a/inc/classes/interfaces/resolver/controller/class_ControllerResolver.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ControllerResolver extends Resolver { - /** - * Resolves the default controller of the given command - * - * @return $controllerInstance A controller instance for the default command - */ - function resolveController (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/resolver/state/.htaccess b/inc/classes/interfaces/resolver/state/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/resolver/state/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/resolver/state/class_StateResolver.php b/inc/classes/interfaces/resolver/state/class_StateResolver.php deleted file mode 100644 index dc220cf6..00000000 --- a/inc/classes/interfaces/resolver/state/class_StateResolver.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface StateResolver extends Resolver { - /** - * Returns an state instance for a given package raw data and socket resource - * - * @param $helperInstance An instance of a ConnectionHelper class - * @param $packageData Raw package data - * @param $socketResource A valid socket resource - * @return $stateInstance An instance of the resolved state - */ - static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource); - - /** - * Checks whether the given state is valid - * - * @param $stateName The default state we shall execute - * @return $isValid Whether the given state is valid - * @throws EmptyVariableException Thrown if given state is not set - */ - function isStateValid ($stateName); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/response/.htaccess b/inc/classes/interfaces/response/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/response/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/response/class_Responseable.php b/inc/classes/interfaces/response/class_Responseable.php deleted file mode 100644 index 976503d0..00000000 --- a/inc/classes/interfaces/response/class_Responseable.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Responseable extends FrameworkInterface { - /** - * Setter for status - * - * @param $status New response status - * @return void - */ - function setResponseStatus ($status); - - /** - * Adds a header to the response. This method "wraps" the direct header() - * function call and so it can be done "generic". E.g. if a local - * application like my hub does not support redirects, this method can be - * kept empty or it can be done something else which would not be possible - * with a direct header() call. - * - * @param $name Name of header element - * @param $value Value of header element - * @return void - */ - function addHeader ($name, $value); - - /** - * "Writes" data to the response body - * - * @param $output Output we shall sent in the HTTP response - * @return void - */ - function writeToBody ($output); - - /** - * Flushs the cached HTTP response to the outer world - * - * @param $force Whether we shall force the output or abort if headers are - * already sent with an exception - * @return void - * @throws ResponseHeadersAlreadySentException Thrown if headers are - * already sent - */ - function flushBuffer ($force = FALSE); - - /** - * Adds a fatal message id to the response. The added messages can then be - * processed and outputed to the world - * - * @param $messageId The message id we shall add - * @return void - */ - function addFatalMessage ($messageId); - - /** - * Adds a cookie to the response - * - * @param $cookieName Cookie's name - * @param $cookieValue Value to store in the cookie - * @param $encrypted Do some extra encryption on the value - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - */ - function addCookie ($cookieName, $cookieValue, $encrypted = FALSE); - - /** - * Redirect to a configured URL. The URL can be absolute or relative. In - * case of relative URL it will be extended automatically with the - * 'base_url' from configuration. - * - * @param $configEntry The configuration entry which holds our URL - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - */ - function redirectToConfiguredUrl ($configEntry); - - /** - * Expires the given cookie if it is set - * - * @param $cookieName Cookie to expire - * @return void - */ - function expireCookie ($cookieName); - - /** - * Refreshs a given cookie. This will make the cookie live longer - * - * @param $cookieName Cookie to refresh - * @return void - */ - function refreshCookie ($cookieName); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/result/.htaccess b/inc/classes/interfaces/result/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/result/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/result/class_SearchableResult.php b/inc/classes/interfaces/result/class_SearchableResult.php deleted file mode 100644 index 8e18e48f..00000000 --- a/inc/classes/interfaces/result/class_SearchableResult.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface SearchableResult extends FrameworkInterface { - /** - * Searches for an entry in the data result and returns it - * - * @param $criteriaInstance The criteria to look inside the data set - * @return $result Found result entry - */ - function searchEntry (LocalSearchCriteria $criteriaInstance); - - /** - * Solver for result index value with call-back method - * - * @param $databaseColumn Database column where the index might be found - * @para $callBack Call-back object for setting the index - * @return void - */ - function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/result/class_UpdateableResult.php b/inc/classes/interfaces/result/class_UpdateableResult.php deleted file mode 100644 index 5f774ad8..00000000 --- a/inc/classes/interfaces/result/class_UpdateableResult.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface UpdateableResult extends AddableCriteria { - /** - * Adds an update request to the database result for writing it to the - * database layer - * - * @param $criteriaInstance An instance of a updateable criteria - * @return void - * @throws ResultUpdateException If no result was updated - */ - function add2UpdateQueue (LocalUpdateCriteria $criteriaInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/stacker/.htaccess b/inc/classes/interfaces/stacker/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/stacker/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/stacker/class_Stackable.php b/inc/classes/interfaces/stacker/class_Stackable.php deleted file mode 100644 index 22376985..00000000 --- a/inc/classes/interfaces/stacker/class_Stackable.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Stackable extends FrameworkInterface { - /** - * Pushs a value on a named stacker - * - * @param $stackerName Name of the stacker - * @param $value Value to push on it - * @return void - * @throws StackerFullException If the stacker is full - */ - function pushNamed ($stackerName, $value); - - /** - * 'Pops' a value from a named stacker and returns it's value - * - * @param $stackerName Name of the stacker - * @return $value Value of the current stack entry - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - function popNamed ($stackerName); - - /** - * Get value from named stacker but don't "pop" it - * - * @param $stackerName Name of the stacker - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - function getNamed ($stackerName); - - /** - * Checks whether the given stack is initialized (set in array $stackers) - * - * @param $stackerName Name of the stack - * @return $isInitialized Whether the stack is initialized - */ - function isStackInitialized ($stackerName); - - /** - * Checks whether the given stack is empty - * - * @param $stackerName Name of the stack - * @return $isEmpty Whether the stack is empty - * @throws NoStackerException If given stack is missing - */ - function isStackEmpty ($stackerName); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/stacker/file/.htaccess b/inc/classes/interfaces/stacker/file/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/stacker/file/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/stacker/file/class_StackableFile.php b/inc/classes/interfaces/stacker/file/class_StackableFile.php deleted file mode 100644 index daaf885e..00000000 --- a/inc/classes/interfaces/stacker/file/class_StackableFile.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface StackableFile extends Stackable { - /** - * Seeks to given position - * - * @param $seekPosition Seek position in file - * @return $status Status of this operation - */ - function seek ($seekPosition); - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - function size (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/state/.htaccess b/inc/classes/interfaces/state/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/state/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/state/class_Stateable.php b/inc/classes/interfaces/state/class_Stateable.php deleted file mode 100644 index 7ecfa0b9..00000000 --- a/inc/classes/interfaces/state/class_Stateable.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Stateable extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/streams/.htaccess b/inc/classes/interfaces/streams/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/streams/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/streams/class_Stream.php b/inc/classes/interfaces/streams/class_Stream.php deleted file mode 100644 index 3cb93f4c..00000000 --- a/inc/classes/interfaces/streams/class_Stream.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Stream extends FrameworkInterface { - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - */ - function streamData ($data); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/streams/crypto/.htaccess b/inc/classes/interfaces/streams/crypto/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/streams/crypto/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/streams/crypto/class_EncryptableStream.php b/inc/classes/interfaces/streams/crypto/class_EncryptableStream.php deleted file mode 100644 index 59287d5d..00000000 --- a/inc/classes/interfaces/streams/crypto/class_EncryptableStream.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface EncryptableStream extends Stream { - /** - * Encrypt the string with fixed salt - * - * @param $str The unencrypted string - * @param $key Optional key, if none provided, a random key will be generated - * @return $encrypted Encrypted string - */ - function encryptStream ($str, $key = NULL); - - /** - * Decrypt the string with fixed salt - * - * @param $encrypted Encrypted string - * @return $str The unencrypted string - */ - function decryptStream ($encrypted); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/streams/input/.htaccess b/inc/classes/interfaces/streams/input/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/streams/input/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/streams/input/class_InputStream.php b/inc/classes/interfaces/streams/input/class_InputStream.php deleted file mode 100644 index 44b16f03..00000000 --- a/inc/classes/interfaces/streams/input/class_InputStream.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface InputStream extends Stream { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/streams/output/.htaccess b/inc/classes/interfaces/streams/output/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/streams/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/streams/output/class_OutputStream.php b/inc/classes/interfaces/streams/output/class_OutputStream.php deleted file mode 100644 index 4802a8d4..00000000 --- a/inc/classes/interfaces/streams/output/class_OutputStream.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface OutputStream extends Stream { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/tasks/.htaccess b/inc/classes/interfaces/tasks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/tasks/class_Taskable.php b/inc/classes/interfaces/tasks/class_Taskable.php deleted file mode 100644 index b1915b92..00000000 --- a/inc/classes/interfaces/tasks/class_Taskable.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Taskable extends FrameworkInterface { - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - function accept (Visitor $visitorInstance); - - /** - * Executes the task - * - * @return void - */ - function executeTask (); - - /** - * Shuts down the task - * - * @return void - */ - function doShutdown (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/template/.htaccess b/inc/classes/interfaces/template/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/template/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/template/class_CompileableTemplate.php b/inc/classes/interfaces/template/class_CompileableTemplate.php deleted file mode 100644 index d1265687..00000000 --- a/inc/classes/interfaces/template/class_CompileableTemplate.php +++ /dev/null @@ -1,285 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface CompileableTemplate extends FrameworkInterface { - /** - * Assign variables for templates - * - * @param $variableName The "variable" we want to assign - * @param $value The value we want to store in the variable - * @return void - */ - function assignVariable ($variableName, $value); - - /** - * Load a specified HTML template into the engine - * - * @param $template The web template we shall load which is located in - * "html" by default - * @return void - */ - function loadHtmlTemplate ($template); - - /** - * Load a specified code template into the engine for later compilation - * with other code/web/email templates. - * - * @param $template The code template we shall load which is - * located in "html" by default - * @return void - */ - function loadCodeTemplate ($template); - - /** - * Load a specified email template into the engine for later compilation - * with other code/web/email templates. - * - * @param $template The email template we shall load which is - * located in "html" by default - * @return void - */ - function loadEmailTemplate ($template); - - /** - * Compile all variables by inserting their respective values - * - * @return void - */ - function compileVariables (); - - - /** - * Compile all required code/web/email-templates into the current one - * - * @return void - */ - function compileTemplate (); - - /** - * Adds a variable to current group - * - * @param $variableName Variable to set - * @param $value Value to store in variable - * @return void - */ - function addGroupVariable ($variableName, $value); - - /** - * Removes a given variable - * - * @param $variableName The variable we are looking for - * @param $variableGroup Name of variable group (default: 'general') - * @return void - */ - function removeVariable ($variableName, $variableGroup = 'general'); - - /** - * Assign a given congfiguration variable with a value - * - * @param $variableName The configuration variable we want to assign - * @return void - */ - function assignConfigVariable ($variableName); - - /** - * Compiles configuration place-holders in all variables. This 'walks' - * through the variable stack 'general'. It interprets all values from that - * variables as configuration entries after compiling them. - * - * @return void - */ - function compileConfigInVariables (); - - /** - * Assigns the last loaded raw template content with a given variable - * - * @param $templateName Name of the template we want to assign - * @param $variableName Name of the variable we want to assign - * @return void - */ - function assignTemplateWithVariable ($templateName, $variableName); - - /** - * Transfers the content of this template engine to a given response instance - * - * @param $responseInstance An instance of a response class - * @return void - */ - function transferToResponse (Responseable $responseInstance); - - /** - * Assigns all the application data with template variables - * - * @param $applicationInstance A manageable application instance - * @return void - */ - function assignApplicationData (ManageableApplication $applicationInstance); - - /** - * "Compiles" a variable by replacing {?var?} with it's content - * - * @param $rawCode Raw code to compile - * @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: FALSE) - * @return $rawCode Compile code with inserted variable value - */ - function compileRawCode ($rawCode, $setMatchAsCode = FALSE); - - /** - * Renames a variable in code and in stack - * - * @param $oldName Old name of variable - * @param $newName New name of variable - * @return void - */ - function renameVariable ($oldName, $newName); - - /** - * Renders the given XML content - * - * @param $content Valid XML content or if not set the current loaded raw content - * @return void - * @throws XmlParserException If an XML error was found - */ - function renderXmlContent ($content = NULL); - - /** - * Enables or disables language support - * - * @param $languageSupport New language support setting - * @return void - */ - function enableLanguageSupport ($languageSupport = TRUE); - - /** - * Checks whether language support is enabled - * - * @return $languageSupport Whether language support is enabled or disabled - */ - function isLanguageSupportEnabled (); - - /** - * Enables or disables XML compacting - * - * @param $xmlCompacting New XML compacting setting - * @return void - */ - function enableXmlCompacting ($xmlCompacting = TRUE); - - /** - * Checks whether XML compacting is enabled - * - * @return $xmlCompacting Whether XML compacting is enabled or disabled - */ - function isXmlCompactingEnabled (); - - /** - * Removes all comments, tabs and new-line charcters to compact the content - * - * @param $uncompactedContent The uncompacted content - * @return $compactedContent The compacted content - */ - function compactContent ($uncompactedContent); - - /** - * Getter for given variable group - * - * @param $variableGroup Variable group to check - * @return $varStack Found variable group - */ - function getVarStack ($variableGroup); - - /** - * Settter for variable group - * - * @param $groupName Name of variable group - * @param $add Whether add this group - * @return void - */ - function setVariableGroup ($groupName, $add = TRUE); - - /** - * Getter for template type - * - * @return $templateType The current template's type - */ - function getTemplateType (); - - /** - * Getter for base path - * - * @return $templateBasePath The relative base path for all templates - */ - function getTemplateBasePath (); - - /** - * Getter for generic base path - * - * @return $templateBasePath The relative base path for all templates - */ - function getGenericBasePath (); - - /** - * Getter for template extension - * - * @return $templateExtension The file extension for all uncompiled - * templates - */ - function getRawTemplateExtension (); - - /** - * Getter for code-template extension - * - * @return $codeExtension The file extension for all code- - * templates - */ - function getCodeTemplateExtension (); - - /** - * Getter for raw template data - * - * @return $rawTemplateData The raw data from the template - */ - function getRawTemplateData (); - - /** - * Assigns a lot variables into the stack of currently loaded template. - * This method should only be used in very rare circumstances, e.g. when - * you have to copy a whole set of variables into the template engine. - * Before you use this method, please make sure you have considered all - * other possiblities. - * - * @param $variables An array with variables to be assigned - * @return void - */ - function assignMultipleVariables (array $variables); - - /** - * Getter for variable group array - * - * @return $variableGroups All variable groups - */ - function getVariableGroups (); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/template/view/class_ViewHelper.php b/inc/classes/interfaces/template/view/class_ViewHelper.php deleted file mode 100644 index 51f51044..00000000 --- a/inc/classes/interfaces/template/view/class_ViewHelper.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ViewHelper extends FrameworkInterface { - /** - * The execute method for executing the view helper - * - * @param $args Arguments to send to the view helper - * @return mixed Unknown return arguments, or void - */ - function execute (array $args = NULL); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/user/.htaccess b/inc/classes/interfaces/user/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/user/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/user/class_ManageableAccount.php b/inc/classes/interfaces/user/class_ManageableAccount.php deleted file mode 100644 index 6f015147..00000000 --- a/inc/classes/interfaces/user/class_ManageableAccount.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ManageableAccount extends FrameworkInterface { - /** - * Determines whether the username exists or not - * - * @return $exists Whether the username exists - */ - function ifUsernameExists (); - - /** - * Determines whether the email exists or not - * - * @return $exists Whether the email exists - */ - function ifEmailAddressExists (); - - /** - * Checks if supplied password hash in request matches with stored in - * database. - * - * @param $requestInstance A requestable class instance - * @return $matches Whether the supplied password hash matches - */ - function ifPasswordHashMatches (Requestable $requestInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/user/extended/.htaccess b/inc/classes/interfaces/user/extended/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/user/extended/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/user/extended/class_ManageableGuest.php b/inc/classes/interfaces/user/extended/class_ManageableGuest.php deleted file mode 100644 index be24383c..00000000 --- a/inc/classes/interfaces/user/extended/class_ManageableGuest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ManageableGuest extends ManageableAccount { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/user/extended/class_ManageableMember.php b/inc/classes/interfaces/user/extended/class_ManageableMember.php deleted file mode 100644 index 98106f06..00000000 --- a/inc/classes/interfaces/user/extended/class_ManageableMember.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ManageableMember extends ManageableAccount { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/visitor/.htaccess b/inc/classes/interfaces/visitor/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/visitor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/visitor/class_Visitable.php b/inc/classes/interfaces/visitor/class_Visitable.php deleted file mode 100644 index 149b671e..00000000 --- a/inc/classes/interfaces/visitor/class_Visitable.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Visitable extends FrameworkInterface { - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - function accept (Visitor $visitorInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/visitor/class_Visitor.php b/inc/classes/interfaces/visitor/class_Visitor.php deleted file mode 100644 index 96e9ceef..00000000 --- a/inc/classes/interfaces/visitor/class_Visitor.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface Visitor extends FrameworkInterface { -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/visitor/decorator/.htaccess b/inc/classes/interfaces/visitor/decorator/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/visitor/decorator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/visitor/decorator/class_DecoratorVisitor.php b/inc/classes/interfaces/visitor/decorator/class_DecoratorVisitor.php deleted file mode 100644 index 0e08e479..00000000 --- a/inc/classes/interfaces/visitor/decorator/class_DecoratorVisitor.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface DecoratorVisitor extends Visitor { - /** - * Visits the given decorator instance - * - * @param $decoratorInstance A decorator instance - * @return void - */ - function visitDecorator (BaseDecorator $decoratorInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/visitor/listener/.htaccess b/inc/classes/interfaces/visitor/listener/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/visitor/listener/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/visitor/listener/class_ListenerVisitor.php b/inc/classes/interfaces/visitor/listener/class_ListenerVisitor.php deleted file mode 100644 index 57403719..00000000 --- a/inc/classes/interfaces/visitor/listener/class_ListenerVisitor.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface ListenerVisitor extends Visitor { - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - function visitListener (Listenable $listenerInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/visitor/pool/.htaccess b/inc/classes/interfaces/visitor/pool/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/visitor/pool/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/visitor/pool/class_PoolVisitor.php b/inc/classes/interfaces/visitor/pool/class_PoolVisitor.php deleted file mode 100644 index 9deaec35..00000000 --- a/inc/classes/interfaces/visitor/pool/class_PoolVisitor.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface PoolVisitor extends Visitor { - /** - * Visits the given pool instance - * - * @param $poolInstance A Poolable instance - * @return void - */ - function visitPool (Poolable $poolInstance); -} - -// [EOF] -?> diff --git a/inc/classes/interfaces/visitor/tasks/.htaccess b/inc/classes/interfaces/visitor/tasks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/interfaces/visitor/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/interfaces/visitor/tasks/class_TaskVisitor.php b/inc/classes/interfaces/visitor/tasks/class_TaskVisitor.php deleted file mode 100644 index b729a42f..00000000 --- a/inc/classes/interfaces/visitor/tasks/class_TaskVisitor.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface TaskVisitor extends Visitor { - /** - * Visits the given task instance - * - * @param $taskInstance A Taskable instance - * @return void - */ - function visitTask (Taskable $taskInstance); -} - -// [EOF] -?> diff --git a/inc/classes/main/.htaccess b/inc/classes/main/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/actions/.htaccess b/inc/classes/main/actions/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/actions/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/actions/class_ b/inc/classes/main/actions/class_ deleted file mode 100644 index c654e18b..00000000 --- a/inc/classes/main/actions/class_ +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Action extends BaseAction implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this action - * - * @return $actionInstance An instance of this action class - */ - public final static function create???Action () { - // Get a new instance - $actionInstance = new ???Action(); - - // Return the instance - return $actionInstance; - } - - /** - * Executes the command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub("You have to implement me."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/actions/class_BaseAction.php b/inc/classes/main/actions/class_BaseAction.php deleted file mode 100644 index 59d76686..00000000 --- a/inc/classes/main/actions/class_BaseAction.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseAction extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/actions/html/.htaccess b/inc/classes/main/actions/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/actions/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/actions/html/class_HtmlLoginProfileAction.php b/inc/classes/main/actions/html/class_HtmlLoginProfileAction.php deleted file mode 100644 index 55ff8cee..00000000 --- a/inc/classes/main/actions/html/class_HtmlLoginProfileAction.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLoginProfileAction extends BaseAction implements Commandable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this action - * - * @param $resolverInstance An instance of an action resolver - * @return $actionInstance An instance of this action class - */ - public static final function createHtmlLoginProfileAction (ActionResolver $resolverInstance) { - // Get a new instance - $actionInstance = new HtmlLoginProfileAction(); - - // Set the resolver instance - $actionInstance->setResolverInstance($resolverInstance); - - // Return the instance - return $actionInstance; - } - - /** - * Executes the command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Dummy method - } - - /** - * 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) { - // Add user status filter here - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/actions/post_registration/.htaccess b/inc/classes/main/actions/post_registration/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/actions/post_registration/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php b/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php deleted file mode 100644 index 2ee90844..00000000 --- a/inc/classes/main/actions/post_registration/class_LoginAfterRegistrationAction.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LoginAfterRegistrationAction extends BaseAction implements PerformableAction { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this action - * - * @return $actionInstance An instance of this action class - */ - public static final function createLoginAfterRegistrationAction () { - // Get a new instance - $actionInstance = new LoginAfterRegistrationAction(); - - // Return the instance - return $actionInstance; - } - - /** - * Executes the command with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a login class from factory - $loginInstance = LoginFactory::createLoginObjectByRequest($requestInstance); - - // Login the user by the request instance - $loginInstance->doLogin($requestInstance, $responseInstance); - - // Was the login fine? Then redirect here - if ($loginInstance->ifLoginWasSuccessfull()) { - // Try to redirect here - try { - // Redirect... - $responseInstance->redirectToConfiguredUrl('app_login'); - - // Stop here - exit(); - } catch (FrameworkException $e) { - // Something went wrong here! - $responseInstance->addFatalMessage($e->getMessage()); - } - } else { - // Attach error message to the response - $responseInstance->addFatalMessage('failed_login_after_registration'); - } - } -} - -// [EOF] -?> diff --git a/inc/classes/main/application/.htaccess b/inc/classes/main/application/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/application/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/application/class_BaseApplication.php b/inc/classes/main/application/class_BaseApplication.php deleted file mode 100644 index 7f14fe24..00000000 --- a/inc/classes/main/application/class_BaseApplication.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseApplication extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Get registry instance - $registryInstance = Registry::getRegistry(); - - // Add this instance - $registryInstance->addInstance('application', $this); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/auth/.htaccess b/inc/classes/main/auth/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/auth/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/auth/class_CookieAuth.php b/inc/classes/main/auth/class_CookieAuth.php deleted file mode 100644 index 1e195271..00000000 --- a/inc/classes/main/auth/class_CookieAuth.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class by the given response instance - * - * @param $responseInstance An instance of a Responseable class - * @return $loginInstance An instance of this login class - */ - public static final function createCookieAuth (Responseable $responseInstance) { - // Get a new instance - $loginInstance = new CookieAuth(); - - // Set the response instance - $loginInstance->setResponseInstance($responseInstance); - - // Return the prepared instance - return $loginInstance; - } - - /** - * "Setter" for username auth data - * - * @param $userName The username from request we shall set - * @return void - */ - public function setUserAuth ($userName) { - $this->getResponseInstance()->addCookie('username', $userName); - } - - /** - * "Setter" for password hash auth data - * - * @param $passHash The hashed password from request we shall set - * @return void - */ - public function setPasswordAuth ($passHash) { - $this->getResponseInstance()->addCookie('u_hash', $passHash); - } - - /** - * Getter for user auth cookie - * - * @return $userName Username to get from cookie - */ - public function getUserAuth () { - // Get the username from cookie - $userName = $this->getRequestInstance()->readCookie('username'); - - // Return the username - return $userName; - } - - /** - * Getter for password hash auth cookie - * - * @return $passHash Password hash to get from cookie - */ - public function getPasswordAuth () { - // Get the username from cookie - $passHash = $this->getRequestInstance()->readCookie('u_hash'); - - // Return the username - return $passHash; - } - - /** - * Destroy the authorization data - * - * @return void - */ - public function destroyAuthData () { - // Expire both cookies - $this->getResponseInstance()->expireCookie('username'); - $this->getResponseInstance()->expireCookie('u_hash'); - } - - /** - * Updates the authorization data and/or sets additional tracking data - * - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public function updateAuthData () { - $this->getResponseInstance()->refreshCookie('username'); - $this->getResponseInstance()->refreshCookie('u_hash'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/cache/.htaccess b/inc/classes/main/cache/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/cache/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/cache/class_MemoryCache.php b/inc/classes/main/cache/class_MemoryCache.php deleted file mode 100644 index 9b827ba9..00000000 --- a/inc/classes/main/cache/class_MemoryCache.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MemoryCache extends BaseFrameworkSystem implements Cacheable { - /** - * The "memory cache" is simply a wrapped object array - */ - private $dataCache = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $cacheInstance An instance of this cache class - */ - public static final function createMemoryCache () { - // Get a new instance - $cacheInstance = new MemoryCache(); - - // Initialize the cache - $cacheInstance->initCache(); - - // Return the prepared instance - return $cacheInstance; - } - - /** - * Initialize this cache by creating an object array - * - * @return void - */ - protected function initCache () { - // Now create the "data cache" - $this->dataCache = new FrameworkArrayObject('FakedDataCache'); - } - - /** - * Does the specified offset exist in cache? - * - * @param $offset The offset we are looking for - * @param $arrayElement If type is array, then this element must be found - * @param $minimumCount If array element is found then this count must at least match - * @return $exists Whether the offset exists - */ - public function offsetExists ($offset, $arrayElement = NULL, $minimumCount = 0) { - // Is it there? - $exists = $this->dataCache->offsetExists($offset); - - // So look for array element? - if (($exists === TRUE) && (!is_null($arrayElement))) { - // Get it - $array = $this->offsetGet($offset); - - // Is it an array and element is found? - if ((is_array($array)) && (isset($array[$arrayElement]))) { - // Is an array and element is found, so check count - $exists = (count($array[$arrayElement]) >= $minimumCount); - } else { - // Not found - $exists = FALSE; - } - } // END - if - - // Return status - return $exists; - } - - /** - * Setter for cache offset - * - * @param $offset The offset we shall set - * @param $data Data to store in cache - * @return void - */ - public function offsetSet ($offset, $data) { - $this->dataCache->offsetSet($offset, $data); - } - - /** - * Getter for cache offset or "null" if not found - * - * @param $offset The offset we shall set - * @return $data Data to store in cache - */ - public function offsetGet ($offset) { - // Default is offset not found - $data = NULL; - - // Is the offset there? - if ($this->offsetExists($offset)) { - // Then get the data from it - $data = $this->dataCache->offsetGet($offset); - } // END - if - - // Return data - return $data; - } - - /** - * Purges the given cache entry - * - * @param $offset The offset we shall set - * @return void - */ - public function purgeOffset ($offset) { - // Is the offset there? - if ($this->offsetExists($offset)) { - // Purge only existing keys - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CACHE: Unsetting cache ' . $offset); - $this->dataCache->offsetUnset($offset); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/class_ b/inc/classes/main/class_ deleted file mode 100644 index 48f2751a..00000000 --- a/inc/classes/main/class_ +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???!!! extends Base!!! implements CompileableTemplate { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this !!! class and prepares it for usage - * - * @param $appInstance A manageable application - * @return $///Instance An instance of this !!! class - */ - public final static function create???!!! (ManageableApplication $appInstance) { - // Get a new instance - $///Instance = new ???!!!(); - - // Return the prepared instance - return $///Instance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/class_Base b/inc/classes/main/class_Base deleted file mode 100644 index fce73ca5..00000000 --- a/inc/classes/main/class_Base +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Base??? extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php deleted file mode 100644 index 7bee5eca..00000000 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ /dev/null @@ -1,3380 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseFrameworkSystem extends stdClass implements FrameworkInterface { - /** - * Length of output from hash() - */ - private static $hashLength = NULL; - - /** - * The real class name - */ - private $realClass = 'BaseFrameworkSystem'; - - /** - * Instance of a request class - */ - private $requestInstance = NULL; - - /** - * Instance of a response class - */ - private $responseInstance = NULL; - - /** - * Search criteria instance - */ - private $searchInstance = NULL; - - /** - * Update criteria instance - */ - private $updateInstance = NULL; - - /** - * The file I/O instance for the template loader - */ - private $fileIoInstance = NULL; - - /** - * Resolver instance - */ - private $resolverInstance = NULL; - - /** - * Template engine instance - */ - private $templateInstance = NULL; - - /** - * Database result instance - */ - private $resultInstance = NULL; - - /** - * Instance for user class - */ - private $userInstance = NULL; - - /** - * A controller instance - */ - private $controllerInstance = NULL; - - /** - * Instance of a RNG - */ - private $rngInstance = NULL; - - /** - * Instance of a crypto helper - */ - private $cryptoInstance = NULL; - - /** - * Instance of an Iterator class - */ - private $iteratorInstance = NULL; - - /** - * Instance of the list - */ - private $listInstance = NULL; - - /** - * Instance of a menu - */ - private $menuInstance = NULL; - - /** - * Instance of the image - */ - private $imageInstance = NULL; - - /** - * Instance of the stacker - */ - private $stackInstance = NULL; - - /** - * A Compressor instance - */ - private $compressorInstance = NULL; - - /** - * A Parseable instance - */ - private $parserInstance = NULL; - - /** - * A HandleableProtocol instance - */ - private $protocolInstance = NULL; - - /** - * A database wrapper instance - */ - private $databaseInstance = NULL; - - /** - * A helper instance for the form - */ - private $helperInstance = NULL; - - /** - * An instance of a Source class - */ - private $sourceInstance = NULL; - - /** - * An instance of a UrlSource class - */ - private $urlSourceInstance = NULL; - - /** - * An instance of a InputStream class - */ - private $inputStreamInstance = NULL; - - /** - * An instance of a OutputStream class - */ - private $outputStreamInstance = NULL; - - /** - * Networkable handler instance - */ - private $handlerInstance = NULL; - - /** - * Visitor handler instance - */ - private $visitorInstance = NULL; - - /** - * DHT instance - */ - private $dhtInstance = NULL; - - /** - * An instance of a database wrapper class - */ - private $wrapperInstance = NULL; - - /** - * An instance of a file I/O pointer class (not handler) - */ - private $pointerInstance = NULL; - - /** - * An instance of an Indexable class - */ - private $indexInstance = NULL; - - /** - * An instance of a Block class - */ - private $blockInstance = NULL; - - /** - * A Minable instance - */ - private $minableInstance = NULL; - - /** - * A FrameworkDirectory instance - */ - private $directoryInstance = NULL; - - /** - * Listener instance - */ - private $listenerInstance = NULL; - - /** - * An instance of a communicator - */ - private $communicatorInstance = NULL; - - /** - * The concrete output instance - */ - private $outputInstance = NULL; - - /** - * State instance - */ - private $stateInstance = NULL; - - /** - * Thousands separator - */ - private $thousands = '.'; // German - - /** - * Decimal separator - */ - private $decimals = ','; // German - - /** - * Socket resource - */ - private $socketResource = FALSE; - - /** - * Regular expression to use for validation - */ - private $regularExpression = ''; - - /** - * Package data - */ - private $packageData = array(); - - /** - * Generic array - */ - private $genericArray = array(); - - /** - * Command name - */ - private $commandName = ''; - - /** - * Controller name - */ - private $controllerName = ''; - - /** - * Name of used protocol - */ - private $protocolName = 'invalid'; - - /** - * Array with bitmasks and such for pack/unpack methods to support both - * 32-bit and 64-bit systems - */ - private $packingData = array( - 32 => array( - 'step' => 3, - 'left' => 0xffff0000, - 'right' => 0x0000ffff, - 'factor' => 16, - 'format' => 'II', - ), - 64 => array( - 'step' => 7, - 'left' => 0xffffffff00000000, - 'right' => 0x00000000ffffffff, - 'factor' => 32, - 'format' => 'NN' - ) - ); - - /** - * Simple 64-bit check, thanks to "Salman A" from stackoverflow.com: - * - * The integer size is 4 bytes on 32-bit and 8 bytes on a 64-bit system. - */ - private $archArrayElement = FALSE; - - /*********************** - * Exception codes.... * - ***********************/ - - // @todo Try to clean these constants up - const EXCEPTION_IS_NULL_POINTER = 0x001; - const EXCEPTION_IS_NO_OBJECT = 0x002; - const EXCEPTION_IS_NO_ARRAY = 0x003; - const EXCEPTION_MISSING_METHOD = 0x004; - const EXCEPTION_CLASSES_NOT_MATCHING = 0x005; - const EXCEPTION_INDEX_OUT_OF_BOUNDS = 0x006; - const EXCEPTION_DIMENSION_ARRAY_INVALID = 0x007; - const EXCEPTION_ITEM_NOT_TRADEABLE = 0x008; - const EXCEPTION_ITEM_NOT_IN_PRICE_LIST = 0x009; - const EXCEPTION_GENDER_IS_WRONG = 0x00a; - const EXCEPTION_BIRTH_DATE_IS_INVALID = 0x00b; - const EXCEPTION_EMPTY_STRUCTURES_ARRAY = 0x00c; - const EXCEPTION_HAS_ALREADY_PERSONELL_LIST = 0x00d; - const EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES = 0x00e; - const EXCEPTION_TOTAL_PRICE_NOT_CALCULATED = 0x00f; - const EXCEPTION_HARBOR_HAS_NO_SHIPYARDS = 0x010; - const EXCEPTION_CONTRACT_PARTNER_INVALID = 0x011; - const EXCEPTION_CONTRACT_PARTNER_MISMATCH = 0x012; - const EXCEPTION_CONTRACT_ALREADY_SIGNED = 0x013; - const EXCEPTION_UNEXPECTED_EMPTY_STRING = 0x014; - const EXCEPTION_PATH_NOT_FOUND = 0x015; - const EXCEPTION_INVALID_PATH_NAME = 0x016; - const EXCEPTION_READ_PROTECED_PATH = 0x017; - const EXCEPTION_WRITE_PROTECED_PATH = 0x018; - const EXCEPTION_DIR_POINTER_INVALID = 0x019; - const EXCEPTION_FILE_POINTER_INVALID = 0x01a; - const EXCEPTION_INVALID_RESOURCE = 0x01b; - const EXCEPTION_UNEXPECTED_OBJECT = 0x01c; - const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d; - const EXCEPTION_GETTER_IS_MISSING = 0x01e; - const EXCEPTION_ARRAY_EXPECTED = 0x01f; - const EXCEPTION_ARRAY_HAS_INVALID_COUNT = 0x020; - const EXCEPTION_ID_IS_INVALID_FORMAT = 0x021; - const EXCEPTION_MD5_CHECKSUMS_MISMATCH = 0x022; - const EXCEPTION_UNEXPECTED_STRING_SIZE = 0x023; - const EXCEPTION_SIMULATOR_ID_INVALID = 0x024; - const EXCEPTION_MISMATCHING_COMPRESSORS = 0x025; - const EXCEPTION_CONTAINER_ITEM_IS_NULL = 0x026; - const EXCEPTION_ITEM_IS_NO_ARRAY = 0x027; - const EXCEPTION_CONTAINER_MAYBE_DAMAGED = 0x028; - const EXCEPTION_INVALID_STRING = 0x029; - const EXCEPTION_VARIABLE_NOT_SET = 0x02a; - const EXCEPTION_ATTRIBUTES_ARE_MISSING = 0x02b; - const EXCEPTION_ARRAY_ELEMENTS_MISSING = 0x02c; - const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED = 0x02d; - const EXCEPTION_UNSPPORTED_OPERATION = 0x02e; - const EXCEPTION_FACTORY_REQUIRE_PARAMETER = 0x02f; - const EXCEPTION_MISSING_ELEMENT = 0x030; - const EXCEPTION_HEADERS_ALREADY_SENT = 0x031; - const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x032; - const EXCEPTION_CLASS_NOT_FOUND = 0x033; - const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x034; - const EXCEPTION_FATAL_ERROR = 0x035; - const EXCEPTION_FILE_NOT_FOUND = 0x036; - const EXCEPTION_ASSERTION_FAILED = 0x037; - const EXCEPTION_FILE_NOT_REACHABLE = 0x038; - const EXCEPTION_FILE_CANNOT_BE_READ = 0x039; - const EXCEPTION_FILE_CANNOT_BE_WRITTEN = 0x03a; - const EXCEPTION_PATH_CANNOT_BE_WRITTEN = 0x03b; - const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03c; - const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03d; - - /** - * Hexadecimal->Decimal translation array - */ - private static $hexdec = array( - '0' => 0, - '1' => 1, - '2' => 2, - '3' => 3, - '4' => 4, - '5' => 5, - '6' => 6, - '7' => 7, - '8' => 8, - '9' => 9, - 'a' => 10, - 'b' => 11, - 'c' => 12, - 'd' => 13, - 'e' => 14, - 'f' => 15 - ); - - /** - * Decimal->hexadecimal translation array - */ - private static $dechex = array( - 0 => '0', - 1 => '1', - 2 => '2', - 3 => '3', - 4 => '4', - 5 => '5', - 6 => '6', - 7 => '7', - 8 => '8', - 9 => '9', - 10 => 'a', - 11 => 'b', - 12 => 'c', - 13 => 'd', - 14 => 'e', - 15 => 'f' - ); - - /** - * Startup time in miliseconds - */ - private static $startupTime = 0; - - /** - * Protected super constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Set real class - $this->setRealClass($className); - - // Set configuration instance if no registry ... - if (!$this instanceof Register) { - // ... because registries doesn't need to be configured - $this->setConfigInstance(FrameworkConfiguration::getSelfInstance()); - } // END - if - - // Is the startup time set? (0 cannot be TRUE anymore) - if (self::$startupTime == 0) { - // Then set it - self::$startupTime = microtime(TRUE); - } // END - if - - // Set array element - $this->archArrayElement = (PHP_INT_SIZE === 8 ? 64 : 32); - } - - /** - * Destructor for all classes. You should not call this method on your own. - * - * @return void - */ - public function __destruct () { - // Flush any updated entries to the database - $this->flushPendingUpdates(); - - // Is this object already destroyed? - if ($this->__toString() != 'DestructedObject') { - // Destroy all informations about this class but keep some text about it alive - $this->setRealClass('DestructedObject'); - } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { - // Already destructed object - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] The object %s is already destroyed.', - __CLASS__, - $this->__toString() - )); - } else { - // Do not call this twice - trigger_error(__METHOD__ . ': Called twice.'); - exit; - } - } - - /** - * The __call() method where all non-implemented methods end up - * - * @param $methodName Name of the missing method - * @args $args Arguments passed to the method - * @return void - */ - public final function __call ($methodName, $args) { - return self::__callStatic($methodName, $args); - } - - /** - * The __callStatic() method where all non-implemented static methods end up - * - * @param $methodName Name of the missing method - * @args $args Arguments passed to the method - * @return void - */ - public static final function __callStatic ($methodName, $args) { - // Init argument string - $argsString = ''; - - // Is it NULL, empty or an array? - if (is_null($args)) { - // No arguments - $argsString = 'NULL'; - } elseif (empty($args)) { - // Empty arguments - $argsString = '(empty)'; - } elseif (is_array($args)) { - // Some arguments are there - foreach ($args as $arg) { - // Add the value itself if not array. This prevents 'array to string conversion' message - if (is_array($arg)) { - $argsString .= 'Array'; - } else { - $argsString .= $arg; - } - - // Add data about the argument - $argsString .= ' (' . gettype($arg); - - if (is_string($arg)) { - // Add length for strings - $argsString .= ', ' . strlen($arg); - } elseif (is_array($arg)) { - // .. or size if array - $argsString .= ', ' . count($arg); - } elseif ($arg === TRUE) { - // ... is boolean 'TRUE' - $argsString .= ', TRUE'; - } elseif ($arg === FALSE) { - // ... is boolean 'FALSE' - $argsString .= ', FALSE'; - } - - // Closing bracket - $argsString .= '), '; - } // END - foreach - - // Remove last comma - if (substr($argsString, -2, 1) == ',') { - $argsString = substr($argsString, 0, -2); - } // END - if - } else { - // Invalid arguments! - $argsString = '!INVALID:' . gettype($args) . '!'; - } - - // Output stub message - // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s', - $methodName, - $argsString - )); - - // Return nothing - return NULL; - } - - /** - * Getter for $realClass - * - * @return $realClass The name of the real class (not BaseFrameworkSystem) - */ - public function __toString () { - return $this->realClass; - } - - /** - * Magic method to catch setting of missing but set class fields/attributes - * - * @param $name Name of the field/attribute - * @param $value Value to store - * @return void - */ - public final function __set ($name, $value) { - $this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s', - $name, - gettype($value), - print_r($value, TRUE) - )); - } - - /** - * Magic method to catch getting of missing fields/attributes - * - * @param $name Name of the field/attribute - * @return void - */ - public final function __get ($name) { - $this->debugBackTrace(sprintf('Tried to get a missing field. name=%s', - $name - )); - } - - /** - * Magic method to catch unsetting of missing fields/attributes - * - * @param $name Name of the field/attribute - * @return void - */ - public final function __unset ($name) { - $this->debugBackTrace(sprintf('Tried to unset a missing field. name=%s', - $name - )); - } - - /** - * Magic method to catch object serialization - * - * @return $unsupported Unsupported method - * @throws UnsupportedOperationException Objects of this framework cannot be serialized - */ - public final function __sleep () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Magic method to catch object deserialization - * - * @return $unsupported Unsupported method - * @throws UnsupportedOperationException Objects of this framework cannot be serialized - */ - public final function __wakeup () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Magic method to catch calls when an object instance is called - * - * @return $unsupported Unsupported method - * @throws UnsupportedOperationException Objects of this framework cannot be serialized - */ - public final function __invoke () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Setter for the real class name - * - * @param $realClass Class name (string) - * @return void - */ - public final function setRealClass ($realClass) { - // Set real class - $this->realClass = (string) $realClass; - } - - /** - * Setter for database result instance - * - * @param $resultInstance An instance of a database result class - * @return void - * @todo SearchableResult and UpdateableResult shall have a super interface to use here - */ - protected final function setResultInstance (SearchableResult $resultInstance) { - $this->resultInstance = $resultInstance; - } - - /** - * Getter for database result instance - * - * @return $resultInstance An instance of a database result class - */ - public final function getResultInstance () { - return $this->resultInstance; - } - - /** - * Setter for template engine instances - * - * @param $templateInstance An instance of a template engine class - * @return void - */ - protected final function setTemplateInstance (CompileableTemplate $templateInstance) { - $this->templateInstance = $templateInstance; - } - - /** - * Getter for template engine instances - * - * @return $templateInstance An instance of a template engine class - */ - protected final function getTemplateInstance () { - return $this->templateInstance; - } - - /** - * Setter for search instance - * - * @param $searchInstance Searchable criteria instance - * @return void - */ - public final function setSearchInstance (LocalSearchCriteria $searchInstance) { - $this->searchInstance = $searchInstance; - } - - /** - * Getter for search instance - * - * @return $searchInstance Searchable criteria instance - */ - public final function getSearchInstance () { - return $this->searchInstance; - } - - /** - * Setter for update instance - * - * @param $updateInstance Searchable criteria instance - * @return void - */ - public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) { - $this->updateInstance = $updateInstance; - } - - /** - * Getter for update instance - * - * @return $updateInstance Updateable criteria instance - */ - public final function getUpdateInstance () { - return $this->updateInstance; - } - - /** - * Setter for resolver instance - * - * @param $resolverInstance Instance of a command resolver class - * @return void - */ - public final function setResolverInstance (Resolver $resolverInstance) { - $this->resolverInstance = $resolverInstance; - } - - /** - * Getter for resolver instance - * - * @return $resolverInstance Instance of a command resolver class - */ - public final function getResolverInstance () { - return $this->resolverInstance; - } - - /** - * Setter for language instance - * - * @param $configInstance The configuration instance which shall - * be FrameworkConfiguration - * @return void - */ - public final function setConfigInstance (FrameworkConfiguration $configInstance) { - Registry::getRegistry()->addInstance('config', $configInstance); - } - - /** - * Getter for configuration instance - * - * @return $configInstance Configuration instance - */ - public final function getConfigInstance () { - $configInstance = Registry::getRegistry()->getInstance('config'); - return $configInstance; - } - - /** - * Setter for debug instance - * - * @param $debugInstance The instance for debug output class - * @return void - */ - public final function setDebugInstance (DebugMiddleware $debugInstance) { - Registry::getRegistry()->addInstance('debug', $debugInstance); - } - - /** - * Getter for debug instance - * - * @return $debugInstance Instance to class DebugConsoleOutput or DebugWebOutput - */ - public final function getDebugInstance () { - // Get debug instance - $debugInstance = Registry::getRegistry()->getInstance('debug'); - - // Return it - return $debugInstance; - } - - /** - * Setter for web output instance - * - * @param $webInstance The instance for web output class - * @return void - */ - public final function setWebOutputInstance (OutputStreamer $webInstance) { - Registry::getRegistry()->addInstance('web_output', $webInstance); - } - - /** - * Getter for web output instance - * - * @return $webOutputInstance - Instance to class WebOutput - */ - public final function getWebOutputInstance () { - $webOutputInstance = Registry::getRegistry()->getInstance('web_output'); - return $webOutputInstance; - } - - /** - * Setter for database instance - * - * @param $databaseInstance The instance for the database connection (forced DatabaseConnection) - * @return void - */ - public final function setDatabaseInstance (DatabaseConnection $databaseInstance) { - Registry::getRegistry()->addInstance('db_instance', $databaseInstance); - } - - /** - * Getter for database layer - * - * @return $databaseInstance The database layer instance - */ - public final function getDatabaseInstance () { - // Get instance - $databaseInstance = Registry::getRegistry()->getInstance('db_instance'); - - // Return instance - return $databaseInstance; - } - - /** - * Setter for compressor channel - * - * @param $compressorInstance An instance of CompressorChannel - * @return void - */ - public final function setCompressorChannel (CompressorChannel $compressorInstance) { - Registry::getRegistry()->addInstance('compressor', $compressorInstance); - } - - /** - * Getter for compressor channel - * - * @return $compressorInstance The compressor channel - */ - public final function getCompressorChannel () { - $compressorInstance = Registry::getRegistry()->getInstance('compressor'); - return $compressorInstance; - } - - /** - * Protected getter for a manageable application helper class - * - * @return $applicationInstance An instance of a manageable application helper class - */ - protected final function getApplicationInstance () { - $applicationInstance = Registry::getRegistry()->getInstance('application'); - return $applicationInstance; - } - - /** - * Setter for a manageable application helper class - * - * @param $applicationInstance An instance of a manageable application helper class - * @return void - */ - public final function setApplicationInstance (ManageableApplication $applicationInstance) { - Registry::getRegistry()->addInstance('application', $applicationInstance); - } - - /** - * Setter for request instance - * - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public final function setRequestInstance (Requestable $requestInstance) { - $this->requestInstance = $requestInstance; - } - - /** - * Getter for request instance - * - * @return $requestInstance An instance of a Requestable class - */ - public final function getRequestInstance () { - return $this->requestInstance; - } - - /** - * Setter for response instance - * - * @param $responseInstance An instance of a Responseable class - * @return void - */ - public final function setResponseInstance (Responseable $responseInstance) { - $this->responseInstance = $responseInstance; - } - - /** - * Getter for response instance - * - * @return $responseInstance An instance of a Responseable class - */ - public final function getResponseInstance () { - return $this->responseInstance; - } - - /** - * Private getter for language instance - * - * @return $langInstance An instance to the language sub-system - */ - protected final function getLanguageInstance () { - $langInstance = Registry::getRegistry()->getInstance('language'); - return $langInstance; - } - - /** - * Setter for language instance - * - * @param $langInstance An instance to the language sub-system - * @return void - * @see LanguageSystem - */ - public final function setLanguageInstance (ManageableLanguage $langInstance) { - Registry::getRegistry()->addInstance('language', $langInstance); - } - - /** - * Private getter for file IO instance - * - * @return $fileIoInstance An instance to the file I/O sub-system - */ - protected final function getFileIoInstance () { - return $this->fileIoInstance; - } - - /** - * Setter for file I/O instance - * - * @param $fileIoInstance An instance to the file I/O sub-system - * @return void - */ - public final function setFileIoInstance (IoHandler $fileIoInstance) { - $this->fileIoInstance = $fileIoInstance; - } - - /** - * Protected setter for user instance - * - * @param $userInstance An instance of a user class - * @return void - */ - protected final function setUserInstance (ManageableAccount $userInstance) { - $this->userInstance = $userInstance; - } - - /** - * Getter for user instance - * - * @return $userInstance An instance of a user class - */ - public final function getUserInstance () { - return $this->userInstance; - } - - /** - * Setter for controller instance (this surely breaks a bit the MVC patterm) - * - * @param $controllerInstance An instance of the controller - * @return void - */ - public final function setControllerInstance (Controller $controllerInstance) { - $this->controllerInstance = $controllerInstance; - } - - /** - * Getter for controller instance (this surely breaks a bit the MVC patterm) - * - * @return $controllerInstance An instance of the controller - */ - public final function getControllerInstance () { - return $this->controllerInstance; - } - - /** - * Setter for RNG instance - * - * @param $rngInstance An instance of a random number generator (RNG) - * @return void - */ - protected final function setRngInstance (RandomNumberGenerator $rngInstance) { - $this->rngInstance = $rngInstance; - } - - /** - * Getter for RNG instance - * - * @return $rngInstance An instance of a random number generator (RNG) - */ - public final function getRngInstance () { - return $this->rngInstance; - } - - /** - * Setter for Cryptable instance - * - * @param $cryptoInstance An instance of a Cryptable class - * @return void - */ - protected final function setCryptoInstance (Cryptable $cryptoInstance) { - $this->cryptoInstance = $cryptoInstance; - } - - /** - * Getter for Cryptable instance - * - * @return $cryptoInstance An instance of a Cryptable class - */ - public final function getCryptoInstance () { - return $this->cryptoInstance; - } - - /** - * Setter for the list instance - * - * @param $listInstance A list of Listable - * @return void - */ - protected final function setListInstance (Listable $listInstance) { - $this->listInstance = $listInstance; - } - - /** - * Getter for the list instance - * - * @return $listInstance A list of Listable - */ - protected final function getListInstance () { - return $this->listInstance; - } - - /** - * Setter for the menu instance - * - * @param $menuInstance A RenderableMenu instance - * @return void - */ - protected final function setMenuInstance (RenderableMenu $menuInstance) { - $this->menuInstance = $menuInstance; - } - - /** - * Getter for the menu instance - * - * @return $menuInstance A RenderableMenu instance - */ - protected final function getMenuInstance () { - return $this->menuInstance; - } - - /** - * Setter for image instance - * - * @param $imageInstance An instance of an image - * @return void - */ - public final function setImageInstance (BaseImage $imageInstance) { - $this->imageInstance = $imageInstance; - } - - /** - * Getter for image instance - * - * @return $imageInstance An instance of an image - */ - public final function getImageInstance () { - return $this->imageInstance; - } - - /** - * Setter for stacker instance - * - * @param $stackInstance An instance of an stacker - * @return void - */ - public final function setStackInstance (Stackable $stackInstance) { - $this->stackInstance = $stackInstance; - } - - /** - * Getter for stacker instance - * - * @return $stackInstance An instance of an stacker - */ - public final function getStackInstance () { - return $this->stackInstance; - } - - /** - * Setter for compressor instance - * - * @param $compressorInstance An instance of an compressor - * @return void - */ - public final function setCompressorInstance (Compressor $compressorInstance) { - $this->compressorInstance = $compressorInstance; - } - - /** - * Getter for compressor instance - * - * @return $compressorInstance An instance of an compressor - */ - public final function getCompressorInstance () { - return $this->compressorInstance; - } - - /** - * Setter for Parseable instance - * - * @param $parserInstance An instance of an Parseable - * @return void - */ - public final function setParserInstance (Parseable $parserInstance) { - $this->parserInstance = $parserInstance; - } - - /** - * Getter for Parseable instance - * - * @return $parserInstance An instance of an Parseable - */ - public final function getParserInstance () { - return $this->parserInstance; - } - - /** - * Setter for HandleableProtocol instance - * - * @param $protocolInstance An instance of an HandleableProtocol - * @return void - */ - public final function setProtocolInstance (HandleableProtocol $protocolInstance) { - $this->protocolInstance = $protocolInstance; - } - - /** - * Getter for HandleableProtocol instance - * - * @return $protocolInstance An instance of an HandleableProtocol - */ - public final function getProtocolInstance () { - return $this->protocolInstance; - } - - /** - * Setter for DatabaseWrapper instance - * - * @param $wrapperInstance An instance of an DatabaseWrapper - * @return void - */ - public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) { - $this->wrapperInstance = $wrapperInstance; - } - - /** - * Getter for DatabaseWrapper instance - * - * @return $wrapperInstance An instance of an DatabaseWrapper - */ - public final function getWrapperInstance () { - return $this->wrapperInstance; - } - - /** - * Setter for socket resource - * - * @param $socketResource A valid socket resource - * @return void - */ - public final function setSocketResource ($socketResource) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource); - $this->socketResource = $socketResource; - } - - /** - * Getter for socket resource - * - * @return $socketResource A valid socket resource - */ - public final function getSocketResource () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource); - return $this->socketResource; - } - - /** - * Setter for regular expression - * - * @param $regularExpression A valid regular expression - * @return void - */ - public final function setRegularExpression ($regularExpression) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); - $this->regularExpression = $regularExpression; - } - - /** - * Getter for regular expression - * - * @return $regularExpression A valid regular expression - */ - public final function getRegularExpression () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); - return $this->regularExpression; - } - - /** - * Setter for helper instance - * - * @param $helperInstance An instance of a helper class - * @return void - */ - protected final function setHelperInstance (Helper $helperInstance) { - $this->helperInstance = $helperInstance; - } - - /** - * Getter for helper instance - * - * @return $helperInstance An instance of a helper class - */ - public final function getHelperInstance () { - return $this->helperInstance; - } - - /** - * Setter for a Source instance - * - * @param $sourceInstance An instance of a Source class - * @return void - */ - protected final function setSourceInstance (Source $sourceInstance) { - $this->sourceInstance = $sourceInstance; - } - - /** - * Getter for a Source instance - * - * @return $sourceInstance An instance of a Source class - */ - protected final function getSourceInstance () { - return $this->sourceInstance; - } - - /** - * Setter for a UrlSource instance - * - * @param $sourceInstance An instance of a UrlSource class - * @return void - */ - protected final function setUrlSourceInstance (UrlSource $urlSourceInstance) { - $this->urlSourceInstance = $urlSourceInstance; - } - - /** - * Getter for a UrlSource instance - * - * @return $urlSourceInstance An instance of a UrlSource class - */ - protected final function getUrlSourceInstance () { - return $this->urlSourceInstance; - } - - /** - * Getter for a InputStream instance - * - * @param $inputStreamInstance The InputStream instance - */ - protected final function getInputStreamInstance () { - return $this->inputStreamInstance; - } - - /** - * Setter for a InputStream instance - * - * @param $inputStreamInstance The InputStream instance - * @return void - */ - protected final function setInputStreamInstance (InputStream $inputStreamInstance) { - $this->inputStreamInstance = $inputStreamInstance; - } - - /** - * Getter for a OutputStream instance - * - * @param $outputStreamInstance The OutputStream instance - */ - protected final function getOutputStreamInstance () { - return $this->outputStreamInstance; - } - - /** - * Setter for a OutputStream instance - * - * @param $outputStreamInstance The OutputStream instance - * @return void - */ - protected final function setOutputStreamInstance (OutputStream $outputStreamInstance) { - $this->outputStreamInstance = $outputStreamInstance; - } - - /** - * Setter for handler instance - * - * @param $handlerInstance An instance of a Handleable class - * @return void - */ - protected final function setHandlerInstance (Handleable $handlerInstance) { - $this->handlerInstance = $handlerInstance; - } - - /** - * Getter for handler instance - * - * @return $handlerInstance A Networkable instance - */ - protected final function getHandlerInstance () { - return $this->handlerInstance; - } - - /** - * Setter for visitor instance - * - * @param $visitorInstance A Visitor instance - * @return void - */ - protected final function setVisitorInstance (Visitor $visitorInstance) { - $this->visitorInstance = $visitorInstance; - } - - /** - * Getter for visitor instance - * - * @return $visitorInstance A Visitor instance - */ - protected final function getVisitorInstance () { - return $this->visitorInstance; - } - - /** - * Setter for DHT instance - * - * @param $dhtInstance A Distributable instance - * @return void - */ - protected final function setDhtInstance (Distributable $dhtInstance) { - $this->dhtInstance = $dhtInstance; - } - - /** - * Getter for DHT instance - * - * @return $dhtInstance A Distributable instance - */ - protected final function getDhtInstance () { - return $this->dhtInstance; - } - - /** - * Setter for raw package Data - * - * @param $packageData Raw package Data - * @return void - */ - public final function setPackageData (array $packageData) { - $this->packageData = $packageData; - } - - /** - * Getter for raw package Data - * - * @return $packageData Raw package Data - */ - public function getPackageData () { - return $this->packageData; - } - - - /** - * Setter for Iterator instance - * - * @param $iteratorInstance An instance of an Iterator - * @return void - */ - protected final function setIteratorInstance (Iterator $iteratorInstance) { - $this->iteratorInstance = $iteratorInstance; - } - - /** - * Getter for Iterator instance - * - * @return $iteratorInstance An instance of an Iterator - */ - public final function getIteratorInstance () { - return $this->iteratorInstance; - } - - /** - * Setter for FilePointer instance - * - * @param $pointerInstance An instance of an FilePointer class - * @return void - */ - protected final function setPointerInstance (FilePointer $pointerInstance) { - $this->pointerInstance = $pointerInstance; - } - - /** - * Getter for FilePointer instance - * - * @return $pointerInstance An instance of an FilePointer class - */ - public final function getPointerInstance () { - return $this->pointerInstance; - } - - /** - * Unsets pointer instance which triggers a call of __destruct() if the - * instance is still there. This is surely not fatal on already "closed" - * file pointer instances. - * - * I don't want to mess around with above setter by giving it a default - * value NULL as setter should always explicitly only set (existing) object - * instances and NULL is NULL. - * - * @return void - */ - protected final function unsetPointerInstance () { - // Simply it to NULL - $this->pointerInstance = NULL; - } - - /** - * Setter for Indexable instance - * - * @param $indexInstance An instance of an Indexable class - * @return void - */ - protected final function setIndexInstance (Indexable $indexInstance) { - $this->indexInstance = $indexInstance; - } - - /** - * Getter for Indexable instance - * - * @return $indexInstance An instance of an Indexable class - */ - public final function getIndexInstance () { - return $this->indexInstance; - } - - /** - * Setter for Block instance - * - * @param $blockInstance An instance of an Block class - * @return void - */ - protected final function setBlockInstance (Block $blockInstance) { - $this->blockInstance = $blockInstance; - } - - /** - * Getter for Block instance - * - * @return $blockInstance An instance of an Block class - */ - public final function getBlockInstance () { - return $this->blockInstance; - } - - /** - * Setter for Minable instance - * - * @param $minableInstance A Minable instance - * @return void - */ - protected final function setMinableInstance (Minable $minableInstance) { - $this->minableInstance = $minableInstance; - } - - /** - * Getter for minable instance - * - * @return $minableInstance A Minable instance - */ - protected final function getMinableInstance () { - return $this->minableInstance; - } - - /** - * Setter for FrameworkDirectory instance - * - * @param $directoryInstance A FrameworkDirectoryPointer instance - * @return void - */ - protected final function setDirectoryInstance (FrameworkDirectory $directoryInstance) { - $this->directoryInstance = $directoryInstance; - } - - /** - * Getter for FrameworkDirectory instance - * - * @return $directoryInstance A FrameworkDirectory instance - */ - protected final function getDirectoryInstance () { - return $this->directoryInstance; - } - - /** - * Setter for listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - protected final function setListenerInstance (Listenable $listenerInstance) { - $this->listenerInstance = $listenerInstance; - } - - /** - * Getter for listener instance - * - * @return $listenerInstance A Listenable instance - */ - protected final function getListenerInstance () { - return $this->listenerInstance; - } - - /** - * Getter for communicator instance - * - * @return $communicatorInstance An instance of a Communicator class - */ - public final function getCommunicatorInstance () { - return $this->communicatorInstance; - } - - /** - * Setter for communicator instance - * - * @param $communicatorInstance An instance of a Communicator class - * @return void - */ - protected final function setCommunicatorInstance (Communicator $communicatorInstance) { - $this->communicatorInstance = $communicatorInstance; - } - - /** - * Setter for state instance - * - * @param $stateInstance A Stateable instance - * @return void - */ - public final function setStateInstance (Stateable $stateInstance) { - $this->stateInstance = $stateInstance; - } - - /** - * Getter for state instance - * - * @return $stateInstance A Stateable instance - */ - public final function getStateInstance () { - return $this->stateInstance; - } - - /** - * Setter for output instance - * - * @param $outputInstance The debug output instance - * @return void - */ - public final function setOutputInstance (OutputStreamer $outputInstance) { - $this->outputInstance = $outputInstance; - } - - /** - * Getter for output instance - * - * @return $outputInstance The debug output instance - */ - public final function getOutputInstance () { - return $this->outputInstance; - } - - /** - * Setter for command name - * - * @param $commandName Last validated command name - * @return void - */ - protected final function setCommandName ($commandName) { - $this->commandName = $commandName; - } - - /** - * Getter for command name - * - * @return $commandName Last validated command name - */ - protected final function getCommandName () { - return $this->commandName; - } - - /** - * Setter for controller name - * - * @param $controllerName Last validated controller name - * @return void - */ - protected final function setControllerName ($controllerName) { - $this->controllerName = $controllerName; - } - - /** - * Getter for controller name - * - * @return $controllerName Last validated controller name - */ - protected final function getControllerName () { - return $this->controllerName; - } - - /** - * Getter for protocol name - * - * @return $protocolName Name of used protocol - */ - public final function getProtocolName () { - return $this->protocolName; - } - - /** - * Setter for protocol name - * - * @param $protocolName Name of used protocol - * @return void - */ - protected final function setProtocolName ($protocolName) { - $this->protocolName = $protocolName; - } - - /** - * Checks whether an object equals this object. You should overwrite this - * method to implement own equality checks - * - * @param $objectInstance An instance of a FrameworkInterface object - * @return $equals Whether both objects equals - */ - public function equals (FrameworkInterface $objectInstance) { - // Now test it - $equals = (( - $this->__toString() == $objectInstance->__toString() - ) && ( - $this->hashCode() == $objectInstance->hashCode() - )); - - // Return the result - return $equals; - } - - /** - * Generates a generic hash code of this class. You should really overwrite - * this method with your own hash code generator code. But keep KISS in mind. - * - * @return $hashCode A generic hash code respresenting this whole class - */ - public function hashCode () { - // Simple hash code - return crc32($this->__toString()); - } - - /** - * Formats computer generated price values into human-understandable formats - * with thousand and decimal separators. - * - * @param $value The in computer format value for a price - * @param $currency The currency symbol (use HTML-valid characters!) - * @param $decNum Number of decimals after commata - * @return $price The for the current language formated price string - * @throws MissingDecimalsThousandsSeparatorException If decimals or - * thousands separator - * is missing - */ - public function formatCurrency ($value, $currency = '€', $decNum = 2) { - // Are all required attriutes set? - if ((!isset($this->decimals)) || (!isset($this->thousands))) { - // Throw an exception - throw new MissingDecimalsThousandsSeparatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING); - } // END - if - - // Cast the number - $value = (float) $value; - - // Reformat the US number - $price = number_format($value, $decNum, $this->decimals, $this->thousands) . $currency; - - // Return as string... - return $price; - } - - /** - * Appends a trailing slash to a string - * - * @param $str A string (maybe) without trailing slash - * @return $str A string with an auto-appended trailing slash - */ - public final function addMissingTrailingSlash ($str) { - // Is there a trailing slash? - if (substr($str, -1, 1) != '/') { - $str .= '/'; - } // END - if - - // Return string with trailing slash - return $str; - } - - /** - * Prepare the template engine (HtmlTemplateEngine by default) for a given - * application helper instance (ApplicationHelper by default). - * - * @param $applicationInstance An application helper instance or - * null if we shall use the default - * @return $templateInstance The template engine instance - * @throws NullPointerException If the discovered application - * instance is still null - */ - protected function prepareTemplateInstance (ManageableApplication $applicationInstance = NULL) { - // Is the application instance set? - if (is_null($applicationInstance)) { - // Get the current instance - $applicationInstance = $this->getApplicationInstance(); - - // Still null? - if (is_null($applicationInstance)) { - // Thrown an exception - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - } // END - if - - // Initialize the template engine - $templateInstance = ObjectFactory::createObjectByConfiguredName('html_template_class'); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Debugs this instance by putting out it's full content - * - * @param $message Optional message to show in debug output - * @return void - */ - public final function debugInstance ($message = '') { - // Restore the error handler to avoid trouble with missing array elements or undeclared variables - restore_error_handler(); - - // Init content - $content = ''; - - // Is a message set? - if (!empty($message)) { - // Construct message - $content = sprintf('
Message: %s
' . PHP_EOL, $message); - } // END - if - - // Generate the output - $content .= sprintf('
%s
', - trim( - htmlentities( - print_r($this, TRUE) - ) - ) - ); - - // Output it - ApplicationEntryPoint::app_exit(sprintf('
%s debug output:
%s
Loaded includes:
%s
', - $this->__toString(), - $content, - ClassLoader::getSelfInstance()->getPrintableIncludeList() - )); - } - - /** - * Replaces control characters with printable output - * - * @param $str String with control characters - * @return $str Replaced string - */ - protected function replaceControlCharacters ($str) { - // Replace them - $str = str_replace( - chr(13), '[r]', str_replace( - chr(10), '[n]', str_replace( - chr(9) , '[t]', - $str - ))); - - // Return it - return $str; - } - - /** - * Output a partial stub message for the caller method - * - * @param $message An optional message to display - * @return void - */ - protected function partialStub ($message = '') { - // Get the backtrace - $backtrace = debug_backtrace(); - - // Generate the class::method string - $methodName = 'UnknownClass->unknownMethod'; - if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { - $methodName = $backtrace[1]['class'] . '->' . $backtrace[1]['function']; - } // END - if - - // Construct the full message - $stubMessage = sprintf('[%s:] Partial stub!', - $methodName - ); - - // Is the extra message given? - if (!empty($message)) { - // Then add it as well - $stubMessage .= ' Message: ' . $message; - } // END - if - - // Debug instance is there? - if (!is_null($this->getDebugInstance())) { - // Output stub message - self::createDebugInstance(__CLASS__)->debugOutput($stubMessage); - } else { - // Trigger an error - trigger_error($stubMessage); - exit; - } - } - - /** - * Outputs a debug backtrace and stops further script execution - * - * @param $message An optional message to output - * @param $doExit Whether exit the program (TRUE is default) - * @return void - */ - public function debugBackTrace ($message = '', $doExit = TRUE) { - // Sorry, there is no other way getting this nice backtrace - if (!empty($message)) { - // Output message - printf('Message: %s
' . chr(10), $message); - } // END - if - - print('
');
-		debug_print_backtrace();
-		print('
'); - - // Exit program? - if ($doExit === TRUE) { - exit(); - } // END - if - } - - /** - * Creates an instance of a debugger instance - * - * @param $className Name of the class (currently unsupported) - * @return $debugInstance An instance of a debugger class - * @deprecated Not fully, as the new Logger facilities are not finished yet. - */ - public final static function createDebugInstance ($className) { - // Is the instance set? - if (!Registry::getRegistry()->instanceExists('debug')) { - // Init debug instance - $debugInstance = NULL; - - // Try it - try { - // Get a debugger instance - $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'), $className); - } catch (NullPointerException $e) { - // Didn't work, no instance there - exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage()); - } - - // Empty string should be ignored and used for testing the middleware - DebugMiddleware::getSelfInstance()->output(''); - - // Set it in its own class. This will set it in the registry - $debugInstance->setDebugInstance($debugInstance); - } else { - // Get instance from registry - $debugInstance = Registry::getRegistry()->getDebugInstance(); - } - - // Return it - return $debugInstance; - } - - /** - * Simple output of a message with line-break - * - * @param $message Message to output - * @return void - */ - public function outputLine ($message) { - // Simply output it - print($message . PHP_EOL); - } - - /** - * Outputs a debug message whether to debug instance (should be set!) or - * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to - * ApplicationEntryPoint::app_exit(), this would cause an endless loop. - * - * @param $message Message we shall send out... - * @param $doPrint Whether print or die here (default: print) - * @paran $stripTags Whether to strip tags (default: FALSE) - * @return void - */ - public function debugOutput ($message, $doPrint = TRUE, $stripTags = FALSE) { - // Set debug instance to NULL - $debugInstance = NULL; - - // Try it: - try { - // Get debug instance - $debugInstance = $this->getDebugInstance(); - } catch (NullPointerException $e) { - // The debug instance is not set (yet) - } - - // Is the debug instance there? - if (is_object($debugInstance)) { - // Use debug output handler - $debugInstance->output($message, $stripTags); - - if ($doPrint === FALSE) { - // Die here if not printed - exit(); - } // END - if - } else { - // Are debug times enabled? - if ($this->getConfigInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_output_timings') == 'Y') { - // Prepent it - $message = $this->getPrintableExecutionTime() . $message; - } // END - if - - // Put directly out - if ($doPrint === TRUE) { - // Print message - $this->outputLine($message); - } else { - // Die here - exit($message); - } - } - } - - /** - * Converts e.g. a command from URL to a valid class by keeping out bad characters - * - * @param $str The string, what ever it is needs to be converted - * @return $className Generated class name - */ - public static final function convertToClassName ($str) { - // Init class name - $className = ''; - - // Convert all dashes in underscores - $str = self::convertDashesToUnderscores($str); - - // Now use that underscores to get classname parts for hungarian style - foreach (explode('_', $str) as $strPart) { - // Make the class name part lower case and first upper case - $className .= ucfirst(strtolower($strPart)); - } // END - foreach - - // Return class name - return $className; - } - - /** - * Converts dashes to underscores, e.g. useable for configuration entries - * - * @param $str The string with maybe dashes inside - * @return $str The converted string with no dashed, but underscores - */ - public static final function convertDashesToUnderscores ($str) { - // Convert them all - $str = str_replace('-', '_', $str); - - // Return converted string - return $str; - } - - /** - * Marks up the code by adding e.g. line numbers - * - * @param $phpCode Unmarked PHP code - * @return $markedCode Marked PHP code - */ - public function markupCode ($phpCode) { - // Init marked code - $markedCode = ''; - - // Get last error - $errorArray = error_get_last(); - - // Init the code with error message - if (is_array($errorArray)) { - // Get error infos - $markedCode = sprintf('
File: %s, Line: %s, Message: %s, Type: %s
', - basename($errorArray['file']), - $errorArray['line'], - $errorArray['message'], - $errorArray['type'] - ); - } // END - if - - // Add line number to the code - foreach (explode(chr(10), $phpCode) as $lineNo => $code) { - // Add line numbers - $markedCode .= sprintf('%s: %s' . chr(10), - ($lineNo + 1), - htmlentities($code, ENT_QUOTES) - ); - } // END - foreach - - // Return the code - return $markedCode; - } - - /** - * Filter a given GMT timestamp (non Uni* stamp!) to make it look more - * beatiful for web-based front-ends. If null is given a message id - * null_timestamp will be resolved and returned. - * - * @param $timestamp Timestamp to prepare (filter) for display - * @return $readable A readable timestamp - */ - public function doFilterFormatTimestamp ($timestamp) { - // Default value to return - $readable = '???'; - - // Is the timestamp null? - if (is_null($timestamp)) { - // Get a message string - $readable = $this->getLanguageInstance()->getMessage('null_timestamp'); - } else { - switch ($this->getLanguageInstance()->getLanguageCode()) { - case 'de': // German format is a bit different to default - // Split the GMT stamp up - $dateTime = explode(' ', $timestamp ); - $dateArray = explode('-', $dateTime[0]); - $timeArray = explode(':', $dateTime[1]); - - // Construct the timestamp - $readable = sprintf($this->getConfigInstance()->getConfigEntry('german_date_time'), - $dateArray[0], - $dateArray[1], - $dateArray[2], - $timeArray[0], - $timeArray[1], - $timeArray[2] - ); - break; - - default: // Default is pass-through - $readable = $timestamp; - break; - } // END - switch - } - - // Return the stamp - return $readable; - } - - /** - * Filter a given number into a localized number - * - * @param $value The raw value from e.g. database - * @return $localized Localized value - */ - public function doFilterFormatNumber ($value) { - // Generate it from config and localize dependencies - switch ($this->getLanguageInstance()->getLanguageCode()) { - case 'de': // German format is a bit different to default - $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), ',', '.'); - break; - - default: // US, etc. - $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), '.', ','); - break; - } // END - switch - - // Return it - return $localized; - } - - /** - * "Getter" for databse entry - * - * @return $entry An array with database entries - * @throws NullPointerException If the database result is not found - * @throws InvalidDatabaseResultException If the database result is invalid - */ - protected final function getDatabaseEntry () { - // Is there an instance? - if (!$this->getResultInstance() instanceof SearchableResult) { - // Throw an exception here - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Rewind it - $this->getResultInstance()->rewind(); - - // Do we have an entry? - if ($this->getResultInstance()->valid() === FALSE) { - // @TODO Move the constant to e.g. BaseDatabaseResult when there is a non-cached database result available - throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), CachedDatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT); - } // END - if - - // Get next entry - $this->getResultInstance()->next(); - - // Fetch it - $entry = $this->getResultInstance()->current(); - - // And return it - return $entry; - } - - /** - * Getter for field name - * - * @param $fieldName Field name which we shall get - * @return $fieldValue Field value from the user - * @throws NullPointerException If the result instance is null - */ - public final function getField ($fieldName) { - // Default field value - $fieldValue = NULL; - - // Get result instance - $resultInstance = $this->getResultInstance(); - - // Is this instance null? - if (is_null($resultInstance)) { - // Then the user instance is no longer valid (expired cookies?) - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get current array - $fieldArray = $resultInstance->current(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':
'.print_r($fieldArray, TRUE).'
'); - - // Convert dashes to underscore - $fieldName2 = self::convertDashesToUnderscores($fieldName); - - // Does the field exist? - if ($this->isFieldSet($fieldName)) { - // Get it - $fieldValue = $fieldArray[$fieldName2]; - } elseif (defined('DEVELOPER')) { - // Missing field entry, may require debugging - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray
=' . print_r($fieldArray, TRUE) . '
,fieldName=' . $fieldName . ' not found!'); - } else { - // Missing field entry, may require debugging - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldName=' . $fieldName . ' not found!'); - } - - // Return it - return $fieldValue; - } - - /** - * Checks if given field is set - * - * @param $fieldName Field name to check - * @return $isSet Whether the given field name is set - * @throws NullPointerException If the result instance is null - */ - public function isFieldSet ($fieldName) { - // Get result instance - $resultInstance = $this->getResultInstance(); - - // Is this instance null? - if (is_null($resultInstance)) { - // Then the user instance is no longer valid (expired cookies?) - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get current array - $fieldArray = $resultInstance->current(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=
'.print_r($fieldArray, TRUE).'
'); - - // Convert dashes to underscore - $fieldName = self::convertDashesToUnderscores($fieldName); - - // Determine it - $isSet = isset($fieldArray[$fieldName]); - - // Return result - return $isSet; - } - - /** - * Flushs all pending updates to the database layer - * - * @return void - */ - public function flushPendingUpdates () { - // Get result instance - $resultInstance = $this->getResultInstance(); - - // Do we have data to update? - if ((is_object($resultInstance)) && ($resultInstance->ifDataNeedsFlush())) { - // Get wrapper class name config entry - $configEntry = $resultInstance->getUpdateInstance()->getWrapperConfigEntry(); - - // Create object instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName($configEntry); - - // Yes, then send the whole result to the database layer - $wrapperInstance->doUpdateByResult($this->getResultInstance()); - } // END - if - } - - /** - * Outputs a deprecation warning to the developer. - * - * @param $message The message we shall output to the developer - * @return void - * @todo Write a logging mechanism for productive mode - */ - public function deprecationWarning ($message) { - // Is developer mode active? - if (defined('DEVELOPER')) { - // Debug instance is there? - if (!is_null($this->getDebugInstance())) { - // Output stub message - self::createDebugInstance(__CLASS__)->debugOutput($message); - } else { - // Trigger an error - trigger_error($message . "
\n"); - exit; - } - } else { - // @TODO Finish this part! - $this->partialStub('Developer mode inactive. Message:' . $message); - } - } - - /** - * Checks whether the given PHP extension is loaded - * - * @param $phpExtension The PHP extension we shall check - * @return $isLoaded Whether the PHP extension is loaded - */ - public final function isPhpExtensionLoaded ($phpExtension) { - // Is it loaded? - $isLoaded = in_array($phpExtension, get_loaded_extensions()); - - // Return result - return $isLoaded; - } - - /** - * "Getter" as a time() replacement but with milliseconds. You should use this - * method instead of the encapsulated getimeofday() function. - * - * @return $milliTime Timestamp with milliseconds - */ - public function getMilliTime () { - // Get the time of day as float - $milliTime = gettimeofday(TRUE); - - // Return it - return $milliTime; - } - - /** - * Idles (sleeps) for given milliseconds - * - * @return $hasSlept Whether it goes fine - */ - public function idle ($milliSeconds) { - // Sleep is fine by default - $hasSlept = TRUE; - - // Idle so long with found function - if (function_exists('time_sleep_until')) { - // Get current time and add idle time - $sleepUntil = $this->getMilliTime() + abs($milliSeconds) / 1000; - - // New PHP 5.1.0 function found, ignore errors - $hasSlept = @time_sleep_until($sleepUntil); - } else { - /* - * My Sun station doesn't have that function even with latest PHP - * package. :( - */ - usleep($milliSeconds * 1000); - } - - // Return result - return $hasSlept; - } - /** - * Converts a hexadecimal string, even with negative sign as first string to - * a decimal number using BC functions. - * - * This work is based on comment #86673 on php.net documentation page at: - * - * - * @param $hex Hexadecimal string - * @return $dec Decimal number - */ - protected function hex2dec ($hex) { - // Convert to all lower-case - $hex = strtolower($hex); - - // Detect sign (negative/positive numbers) - $sign = ''; - if (substr($hex, 0, 1) == '-') { - $sign = '-'; - $hex = substr($hex, 1); - } // END - if - - // Decode the hexadecimal string into a decimal number - $dec = 0; - for ($i = strlen($hex) - 1, $e = 1; $i >= 0; $i--, $e = bcmul($e, 16)) { - $factor = self::$hexdec[substr($hex, $i, 1)]; - $dec = bcadd($dec, bcmul($factor, $e)); - } // END - for - - // Return the decimal number - return $sign . $dec; - } - - /** - * Converts even very large decimal numbers, also signed, to a hexadecimal - * string. - * - * This work is based on comment #97756 on php.net documentation page at: - * - * - * @param $dec Decimal number, even with negative sign - * @param $maxLength Optional maximum length of the string - * @return $hex Hexadecimal string - */ - protected function dec2hex ($dec, $maxLength = 0) { - // maxLength can be zero or devideable by 2 - assert(($maxLength == 0) || (($maxLength % 2) == 0)); - - // Detect sign (negative/positive numbers) - $sign = ''; - if ($dec < 0) { - $sign = '-'; - $dec = abs($dec); - } // END - if - - // Encode the decimal number into a hexadecimal string - $hex = ''; - do { - $hex = self::$dechex[($dec % (2 ^ 4))] . $hex; - $dec /= (2 ^ 4); - } while ($dec >= 1); - - /* - * Leading zeros are required for hex-decimal "numbers". In some - * situations more leading zeros are wanted, so check for both - * conditions. - */ - if ($maxLength > 0) { - // Prepend more zeros - $hex = str_pad($hex, $maxLength, '0', STR_PAD_LEFT); - } elseif ((strlen($hex) % 2) != 0) { - // Only make string's length dividable by 2 - $hex = '0' . $hex; - } - - // Return the hexadecimal string - return $sign . $hex; - } - - /** - * Converts a ASCII string (0 to 255) into a decimal number. - * - * @param $asc The ASCII string to be converted - * @return $dec Decimal number - */ - protected function asc2dec ($asc) { - // Convert it into a hexadecimal number - $hex = bin2hex($asc); - - // And back into a decimal number - $dec = $this->hex2dec($hex); - - // Return it - return $dec; - } - - /** - * Converts a decimal number into an ASCII string. - * - * @param $dec Decimal number - * @return $asc An ASCII string - */ - protected function dec2asc ($dec) { - // First convert the number into a hexadecimal string - $hex = $this->dec2hex($dec); - - // Then convert it into the ASCII string - $asc = $this->hex2asc($hex); - - // Return it - return $asc; - } - - /** - * Converts a hexadecimal number into an ASCII string. Negative numbers - * are not allowed. - * - * @param $hex Hexadecimal string - * @return $asc An ASCII string - */ - protected function hex2asc ($hex) { - // Check for length, it must be devideable by 2 - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex); - assert((strlen($hex) % 2) == 0); - - // Walk the string - $asc = ''; - for ($idx = 0; $idx < strlen($hex); $idx+=2) { - // Get the decimal number of the chunk - $part = hexdec(substr($hex, $idx, 2)); - - // Add it to the final string - $asc .= chr($part); - } // END - for - - // Return the final string - return $asc; - } - - /** - * Checks whether the given encoded data was encoded with Base64 - * - * @param $encodedData Encoded data we shall check - * @return $isBase64 Whether the encoded data is Base64 - */ - protected function isBase64Encoded ($encodedData) { - // Determine it - $isBase64 = (@base64_decode($encodedData, TRUE) !== FALSE); - - // Return it - return $isBase64; - } - - /** - * "Getter" to get response/request type from analysis of the system. - * - * @return $responseType Analyzed response type - */ - protected static function getResponseTypeFromSystem () { - // Default is console - $responseType = 'console'; - - // Is 'HTTP_HOST' set? - if (isset($_SERVER['HTTP_HOST'])) { - /* - * Then it is a HTML response/request as RSS and so on may be - * transfered over HTTP as well. - */ - $responseType = 'html'; - } // END - if - - // Return it - return $responseType; - } - - /** - * Gets a cache key from Criteria instance - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $cacheKey A cache key suitable for lookup/storage purposes - */ - protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) { - // Generate it - $cacheKey = sprintf('%s@%s', - $this->__toString(), - $criteriaInstance->getCacheKey($onlyKeys) - ); - - // And return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey); - return $cacheKey; - } - - /** - * Getter for startup time in miliseconds - * - * @return $startupTime Startup time in miliseconds - */ - protected function getStartupTime () { - return self::$startupTime; - } - - /** - * "Getter" for a printable currently execution time in nice braces - * - * @return $executionTime Current execution time in nice braces - */ - protected function getPrintableExecutionTime () { - // Caculate the execution time - $executionTime = microtime(TRUE) - $this->getStartupTime(); - - // Pack it in nice braces - $executionTime = sprintf('[ %01.5f ] ', $executionTime); - - // And return it - return $executionTime; - } - - /** - * Hashes a given string with a simple but stronger hash function (no salt) - * and hex-encode it. - * - * @param $str The string to be hashed - * @return $hash The hash from string $str - */ - public static final function hash ($str) { - // Hash given string with (better secure) hasher - $hash = bin2hex(mhash(MHASH_SHA256, $str)); - - // Return it - return $hash; - } - - /** - * "Getter" for length of hash() output. This will be "cached" to speed up - * things. - * - * @return $length Length of hash() output - */ - public static final function getHashLength () { - // Is it cashed? - if (is_null(self::$hashLength)) { - // No, then hash a string and save its length. - self::$hashLength = strlen(self::hash('abc123')); - } // END - if - - // Return it - return self::$hashLength; - } - - /** - * Checks whether the given number is really a number (only chars 0-9). - * - * @param $num A string consisting only chars between 0 and 9 - * @param $castValue Whether to cast the value to double. Do only use this to secure numbers from Requestable classes. - * @param $assertMismatch Whether to assert mismatches - * @return $ret The (hopefully) secured numbered value - */ - public function bigintval ($num, $castValue = TRUE, $assertMismatch = FALSE) { - // Filter all numbers out - $ret = preg_replace('/[^0123456789]/', '', $num); - - // Shall we cast? - if ($castValue === TRUE) { - // Cast to biggest numeric type - $ret = (double) $ret; - } // END - if - - // Assert only if requested - if ($assertMismatch === TRUE) { - // Has the whole value changed? - assert(('' . $ret . '' != '' . $num . '') && (!is_null($num))); - } // END - if - - // Return result - return $ret; - } - - /** - * Checks whether the given hexadecimal number is really a hex-number (only chars 0-9,a-f). - * - * @param $num A string consisting only chars between 0 and 9 - * @param $assertMismatch Whether to assert mismatches - * @return $ret The (hopefully) secured hext-numbered value - */ - public function hexval ($num, $assertMismatch = FALSE) { - // Filter all numbers out - $ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num); - - // Assert only if requested - if ($assertMismatch === TRUE) { - // Has the whole value changed? - assert(('' . $ret . '' != '' . $num . '') && (!is_null($num))); - } // END - if - - // Return result - return $ret; - } - - /** - * Checks whether start/end marker are set - * - * @param $data Data to be checked - * @return $isset Whether start/end marker are set - */ - public final function ifStartEndMarkersSet ($data) { - // Determine it - $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER)); - - // ... and return it - return $isset; - } - - /** - * Determines if an element is set in the generic array - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to check - * @param $element Element to check - * @return $isset Whether the given key is set - */ - protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); - - // Is it there? - $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]); - - // Return it - return $isset; - } - /** - * Determines if a key is set in the generic array - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to check - * @return $isset Whether the given key is set - */ - protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - - // Is it there? - $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]); - - // Return it - return $isset; - } - - - /** - * Determines if a group is set in the generic array - * - * @param $keyGroup Main group - * @param $subGroup Sub group - * @return $isset Whether the given group is set - */ - protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); - - // Is it there? - $isset = isset($this->genericArray[$keyGroup][$subGroup]); - - // Return it - return $isset; - } - - /** - * Getter for sub key group - * - * @param $keyGroup Main key group - * @param $subGroup Sub key group - * @return $array An array with all array elements - */ - protected final function getGenericSubArray ($keyGroup, $subGroup) { - // Is it there? - if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { - // No, then abort here - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); - exit; - } // END - if - - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], TRUE)); - - // Return it - return $this->genericArray[$keyGroup][$subGroup]; - } - - /** - * Unsets a given key in generic array - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @return void - */ - protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - - // Remove it - unset($this->genericArray[$keyGroup][$subGroup][$key]); - } - - /** - * Unsets a given element in generic array - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @param $element Element to unset - * @return void - */ - protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); - - // Remove it - unset($this->genericArray[$keyGroup][$subGroup][$key][$element]); - } - - /** - * Append a string to a given generic array key - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @param $value Value to add/append - * @return void - */ - protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') { - // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); - - // Is it already there? - if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { - // Append it - $this->genericArray[$keyGroup][$subGroup][$key] .= $appendGlue . (string) $value; - } else { - // Add it - $this->genericArray[$keyGroup][$subGroup][$key] = (string) $value; - } - } - - /** - * Append a string to a given generic array element - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @param $element Element to check - * @param $value Value to add/append - * @return void - */ - protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') { - // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); - - // Is it already there? - if ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { - // Append it - $this->genericArray[$keyGroup][$subGroup][$key][$element] .= $appendGlue . (string) $value; - } else { - // Add it - $this->setStringGenericArrayElement($keyGroup, $subGroup, $key, $element, $value); - } - } - - /** - * Sets a string in a given generic array element - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @param $element Element to check - * @param $value Value to add/append - * @return void - */ - protected final function setStringGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') { - // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); - - // Set it - $this->genericArray[$keyGroup][$subGroup][$key][$element] = (string) $value; - } - - /** - * Initializes given generic array group - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to use - * @param $forceInit Optionally force initialization - * @return void - */ - protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = FALSE) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit)); - - // Is it already set? - if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) { - // Already initialized - trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.'); - exit; - } // END - if - - // Initialize it - $this->genericArray[$keyGroup][$subGroup] = array(); - } - - /** - * Initializes given generic array key - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to use - * @param $forceInit Optionally force initialization - * @return void - */ - protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit)); - - // Is it already set? - if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) { - // Already initialized - trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.'); - exit; - } // END - if - - // Initialize it - $this->genericArray[$keyGroup][$subGroup][$key] = array(); - } - - /** - * Initializes given generic array element - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to use - * @param $element Element to use - * @param $forceInit Optionally force initialization - * @return void - */ - protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = FALSE) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit)); - - // Is it already set? - if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) { - // Already initialized - trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.'); - exit; - } // END - if - - // Initialize it - $this->genericArray[$keyGroup][$subGroup][$key][$element] = array(); - } - - /** - * Pushes an element to a generic key - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to use - * @param $value Value to add/append - * @return $count Number of array elements - */ - protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) { - // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); - - // Is it set? - if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { - // Initialize array - $this->initGenericArrayKey($keyGroup, $subGroup, $key); - } // END - if - - // Then push it - $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value); - - // Return count - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); - //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL); - return $count; - } - - /** - * Pushes an element to a generic array element - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to use - * @param $element Element to check - * @param $value Value to add/append - * @return $count Number of array elements - */ - protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) { - // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); - - // Is it set? - if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { - // Initialize array - $this->initGenericArrayElement($keyGroup, $subGroup, $key, $element); - } // END - if - - // Then push it - $count = array_push($this->genericArray[$keyGroup][$subGroup][$key][$element], $value); - - // Return count - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); - //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL); - return $count; - } - - /** - * Pops an element from a generic group - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @return $value Last "popped" value - */ - protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - - // Is it set? - if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { - // Not found - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.'); - exit; - } // END - if - - // Then "pop" it - $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]); - - // Return value - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); - //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); - return $value; - } - - /** - * Shifts an element from a generic group - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @return $value Last "popped" value - */ - protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - - // Is it set? - if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { - // Not found - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.'); - exit; - } // END - if - - // Then "shift" it - $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]); - - // Return value - //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); - //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); - return $value; - } - - /** - * Count generic array group - * - * @param $keyGroup Main group for the key - * @return $count Count of given group - */ - protected final function countGenericArray ($keyGroup) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup); - - // Is it there? - if (!isset($this->genericArray[$keyGroup])) { - // Abort here - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.'); - exit; - } // END - if - - // Then count it - $count = count($this->genericArray[$keyGroup]); - - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',count=' . $count); - - // Return it - return $count; - } - - /** - * Count generic array sub group - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @return $count Count of given group - */ - protected final function countGenericArrayGroup ($keyGroup, $subGroup) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); - - // Is it there? - if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { - // Abort here - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); - exit; - } // END - if - - // Then count it - $count = count($this->genericArray[$keyGroup][$subGroup]); - - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',count=' . $count); - - // Return it - return $count; - } - - /** - * Count generic array elements - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @para $key Key to count - * @return $count Count of given key - */ - protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - - // Is it there? - if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { - // Abort here - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); - exit; - } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) { - // Not valid - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.'); - exit; - } - - // Then count it - $count = count($this->genericArray[$keyGroup][$subGroup][$key]); - - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',count=' . $count); - - // Return it - return $count; - } - - /** - * Getter for whole generic group array - * - * @param $keyGroup Key group to get - * @return $array Whole generic array group - */ - protected final function getGenericArray ($keyGroup) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup); - - // Is it there? - if (!isset($this->genericArray[$keyGroup])) { - // Then abort here - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.'); - exit; - } // END - if - - // Return it - return $this->genericArray[$keyGroup]; - } - - /** - * Setter for generic array key - * - * @param $keyGroup Key group to get - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @param $value Mixed value from generic array element - * @return void - */ - protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) { - // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); - - // Set value here - $this->genericArray[$keyGroup][$subGroup][$key] = $value; - } - - /** - * Getter for generic array key - * - * @param $keyGroup Key group to get - * @param $subGroup Sub group for the key - * @param $key Key to unset - * @return $value Mixed value from generic array element - */ - protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - - // Is it there? - if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { - // Then abort here - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.'); - exit; - } // END - if - - // Return it - return $this->genericArray[$keyGroup][$subGroup][$key]; - } - - /** - * Sets a value in given generic array key/element - * - * @param $keyGroup Main group for the key - * @param $subGroup Sub group for the key - * @param $key Key to set - * @param $element Element to set - * @param $value Value to set - * @return void - */ - protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) { - // Debug message - //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); - - // Then set it - $this->genericArray[$keyGroup][$subGroup][$key][$element] = $value; - } - - /** - * Getter for generic array element - * - * @param $keyGroup Key group to get - * @param $subGroup Sub group for the key - * @param $key Key to look for - * @param $element Element to look for - * @return $value Mixed value from generic array element - */ - protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); - - // Is it there? - if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { - // Then abort here - trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.'); - exit; - } // END - if - - // Return it - return $this->genericArray[$keyGroup][$subGroup][$key][$element]; - } - - /** - * Checks if a given sub group is valid (array) - * - * @param $keyGroup Key group to get - * @param $subGroup Sub group for the key - * @return $isValid Whether given sub group is valid - */ - protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); - - // Determine it - $isValid = (($this->isGenericArrayGroupSet($keyGroup, $subGroup)) && (is_array($this->getGenericSubArray($keyGroup, $subGroup)))); - - // Return it - return $isValid; - } - - /** - * Checks if a given key is valid (array) - * - * @param $keyGroup Key group to get - * @param $subGroup Sub group for the key - * @param $key Key to check - * @return $isValid Whether given sub group is valid - */ - protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) { - // Debug message - //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); - - // Determine it - $isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key)))); - - // Return it - return $isValid; - } - - /** - * Initializes the web output instance - * - * @return void - */ - protected function initWebOutputInstance () { - // Get application instance - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Is this a response instance? - if ($this instanceof Responseable) { - // Then set it in application instance - $applicationInstance->setResponseInstance($this); - } // END - if - - // Init web output instance - $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance)); - - // Set it locally - $this->setWebOutputInstance($outputInstance); - } - - /** - * Translates boolean TRUE to 'Y' and FALSE to 'N' - * - * @param $boolean Boolean value - * @return $translated Translated boolean value - */ - public static final function translateBooleanToYesNo ($boolean) { - // Make sure it is really boolean - assert(is_bool($boolean)); - - // "Translate" it - $translated = ($boolean === TRUE) ? 'Y' : 'N'; - - // ... and return it - return $translated; - } - - /** - * Encodes raw data (almost any type) by "serializing" it and then pack it - * into a "binary format". - * - * @param $rawData Raw data (almost any type) - * @return $encoded Encoded data - */ - protected function encodeData ($rawData) { - // Make sure no objects or resources pass through - assert(!is_object($rawData)); - assert(!is_resource($rawData)); - - // First "serialize" it (json_encode() is faster than serialize()) - $encoded = $this->packString(json_encode($rawData)); - - // And return it - return $encoded; - } - - /** - * Pack a string into a "binary format". Please execuse me that this is - * widely undocumented. :-( - * - * @param $str Unpacked string - * @return $packed Packed string - * @todo Improve documentation - */ - protected function packString ($str) { - // Debug message - //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('str=' . $str . ' - CALLED!'); - - // First compress the string (gzcompress is okay) - $str = gzcompress($str); - - // Init variable - $packed = ''; - - // And start the "encoding" loop - for ($idx = 0; $idx < strlen($str); $idx += $this->packingData[$this->archArrayElement]['step']) { - $big = 0; - for ($i = 0; $i < $this->packingData[$this->archArrayElement]['step']; $i++) { - $factor = ($this->packingData[$this->archArrayElement]['step'] - 1 - $i); - - if (($idx + $i) <= strlen($str)) { - $ord = ord(substr($str, ($idx + $i), 1)); - - $add = $ord * pow(256, $factor); - - $big += $add; - - //print 'idx=' . $idx . ',i=' . $i . ',ord=' . $ord . ',factor=' . $factor . ',add=' . $add . ',big=' . $big . PHP_EOL; - } // END - if - } // END - for - - $l = ($big & $this->packingData[$this->archArrayElement]['left']) >>$this->packingData[$this->archArrayElement]['factor']; - $r = $big & $this->packingData[$this->archArrayElement]['right']; - - $chunk = str_pad(pack($this->packingData[$this->archArrayElement]['format'], $l, $r), 8, '0', STR_PAD_LEFT); - //* NOISY-DEBUG */ print 'big=' . $big . ',chunk('.strlen($chunk) . ')='.md5($chunk).PHP_EOL; - - $packed .= $chunk; - } // END - for - - // Return it - //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('packed=' . $packed . ' - EXIT!'); - return $packed; - } - - /** - * Checks whether the given file/path is in open_basedir(). This does not - * gurantee that the file is actually readable and/or writeable. If you need - * such gurantee then please use isReadableFile() instead. - * - * @param $filePathName Name of the file/path to be checked - * @return $isReachable Whether it is within open_basedir() - */ - public static function isReachableFilePath ($filePathName) { - // Is not reachable by default - $isReachable = FALSE; - - // Get open_basedir parameter - $openBaseDir = ini_get('open_basedir'); - - // Is it set? - if (!empty($openBaseDir)) { - // Check all entries - foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) { - // Check on existence - if (substr($filePathName, 0, strlen($dir)) == $dir) { - // Is reachable - $isReachable = TRUE; - } // END - if - } // END - foreach - } else { - // If open_basedir is not set, all is allowed - $isReachable = TRUE; - } - - // Return status - return $isReachable; - } - - /** - * Checks whether the give file is within open_basedir() (done by - * isReachableFilePath()), is actually a file and is readable. - * - * @param $fileName Name of the file to be checked - * @return $isReadable Whether the file is readable (and therefor exists) - */ - public static function isReadableFile ($fileName) { - // Default is not readable - $isReadable = FALSE; - - // Is within parameters, so check if it is a file and readable - $isReadable = ((self::isReachableFilePath($fileName)) && (file_exists($fileName)) && (is_file($fileName)) && (is_readable($fileName))); - - // Return status - return $isReadable; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/class_FrameworkArrayObject.php b/inc/classes/main/class_FrameworkArrayObject.php deleted file mode 100644 index 1bf9446f..00000000 --- a/inc/classes/main/class_FrameworkArrayObject.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkArrayObject extends ArrayObject { - /** - * Real class name - */ - private $realClass = ''; - - /** - * Public constructor for setting real class name - * - * @param $className Real class name - * @return void - */ - public function __construct ($className) { - $this->realClass = (string) $className; - } - - /** - * Get real class' name back - * - * @return $realClass The class' real name - */ - public function __toString () { - return $this->realClass; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/client/.htaccess b/inc/classes/main/client/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/client/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/client/class_ b/inc/classes/main/client/class_ deleted file mode 100644 index d44dfd16..00000000 --- a/inc/classes/main/client/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Client extends BaseClient implements Client { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Client class and prepares it for usage - * - * @return $clientInstance An instance of a Client class - */ - public final static function create???Client () { - // Get a new instance - $clientInstance = new ???Client(); - - // Return the prepared instance - return $clientInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/client/class_BaseClient.php b/inc/classes/main/client/class_BaseClient.php deleted file mode 100644 index 751b15cb..00000000 --- a/inc/classes/main/client/class_BaseClient.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseClient extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/client/http/.htaccess b/inc/classes/main/client/http/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/client/http/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/client/http/class_HttpClient.p b/inc/classes/main/client/http/class_HttpClient.p deleted file mode 100644 index c8222de7..00000000 --- a/inc/classes/main/client/http/class_HttpClient.p +++ /dev/null @@ -1,21 +0,0 @@ - - // First get a socket - // @TODO Add some DNS caching here - - // Open connection - if ($helperInstance->isProxyUsed() === TRUE) { - // Resolve hostname into IP address - $ip = $helperInstance->resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); - - // Connect to host through proxy connection - $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); - } else { - // Connect to host directly - $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); - } - - // Check if there was an error else - if ($errorNo > 0) { - // Then throw again - throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if diff --git a/inc/classes/main/client/http/class_HttpClient.ph b/inc/classes/main/client/http/class_HttpClient.ph deleted file mode 100644 index 76a31133..00000000 --- a/inc/classes/main/client/http/class_HttpClient.ph +++ /dev/null @@ -1,96 +0,0 @@ - - /** - * Determines own remote IP address (e.g. can be used to probe if we are - * reachable from outside by determining external address and then connect to it. - * This is accomblished by connecting to the IP of www.shipsimu.org which - * should default to 188.138.90.169 and requesting /ip.php which does only - * return the content of $_SERVER['REMOTE_ADDR']. Of course, this method - * requires a working Internet connection. - * - * This method is taken from a user comment on php.net and heavily rewritten. - * Compare to following link: - * http://de.php.net/manual/en/function.socket-create.php#49368 - * - * @return $externalAddress The determined external address address - * @todo Make IP, host name, port and script name configurable - */ - public static function determineExternalAddress () { - // Get helper instance - $helperInstance = new ConsoleTools(); - - // First get a socket - // @TODO Add some DNS caching here - - // Open connection - if ($helperInstance->isProxyUsed() === TRUE) { - // Resolve hostname into IP address - $ip = $helperInstance->resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); - - // Connect to host through proxy connection - $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); - } else { - // Connect to host directly - $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); - } - - // Check if there was an error else - if ($errorNo > 0) { - // Then throw again - throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Prepare the GET request - $request = 'GET ' . ($helperInstance->isProxyUsed() === TRUE ? 'http://shipsimu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL; - $request .= 'Host: shipsimu.org' . self::HTTP_EOL; - $request .= 'User-Agent: ' . $this->getUserAgent() . self::HTTP_EOL; - $request .= 'Connection: close' . self::HTTP_EOL; - - // Do we use proxy? - if ($helperInstance->isProxyUsed() === TRUE) { - // CONNECT method? - if ($helperInstance->getConfigInstance()->getConfigEntry('proxy_connect_method') == 'Y') { - // Setup proxy tunnel - $response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource); - - // If the response is invalid, abort - if ((count($response) == 3) && (empty($response[0])) && (empty($response[1])) && (empty($response[2]))) { - // Invalid response! - $helperInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, TRUE)); - } // END - if - } else { - // Add header for proxy - $request .= 'Proxy-Connection: Keep-Alive' . self::HTTP_EOL; - } - } // END - if - - // Add last HTTP_EOL - $request .= self::HTTP_EOL; - - // Send it to the socket - fwrite($socketResource, $request); - - // Init IP (this will always be the last line) - $externalAddress = 'invalid'; - - // And read the reply - while (!feof($socketResource)) { - // Get line - $externalAddress = trim(fgets($socketResource, 128)); - - // Detect HTTP response - if ((substr($externalAddress, 0, 7) == 'HTTP/1.') && (substr($externalAddress, -6, 6) != '200 OK')) { - // Stop processing - break; - } // END - if - } // END - while - - // Close socket - fclose($socketResource); - - - // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Resolved external address: ' . $externalAddress); - - // Return determined external address - return $externalAddress; - } diff --git a/inc/classes/main/client/http/class_HttpClient.php b/inc/classes/main/client/http/class_HttpClient.php deleted file mode 100644 index 04ebec46..00000000 --- a/inc/classes/main/client/http/class_HttpClient.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HttpClient extends BaseClient implements Client { - // Constants - const HTTP_EOL = "\r\n"; - const HTTP_USER_AGENT = 'HttpClient-Core/1.0'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Set default user agent string (to allow other classes to override this) - $this->setUserAgent(self::HTTP_USER_AGENT); - - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Client class and prepares it for usage - * - * @param $socketResource Resource of a socket (optional) - * @return $clientInstance An instance of a Client class - */ - public final static function createHttpClient ($socketResouce = FALSE) { - // Get a new instance - $clientInstance = new HttpClient(); - - // Set socket resource - $clientInstance->setSocketResource($socketResource); - - // Return the prepared instance - return $clientInstance; - } - - /** - * Checks wether proxy configuration is used - * - * @return $isUsed Wether proxy is used - */ - protected function isProxyUsed () { - // Do we have cache? - if (!isset($GLOBALS[__METHOD__])) { - // Determine it - $GLOBALS[__METHOD__] = (($this->getConfigInstance()->getConfigEntry('proxy_host') != '') && ($this->getConfigInstance()->getConfigEntry('proxy_port') > 0)); - } // END - if - - // Return cache - return $GLOBALS[__METHOD__]; - } - - /** - * Sets up a proxy tunnel for given hostname and through resource - * - * @param $host Host to connect to - * @param $port Port number to connect to - * @return $response Response array - */ - protected function setupProxyTunnel ($host, $port) { - // Initialize array - $response = array('', '', ''); - - // Do the connect - $respArray = $this->doConnectRequest($host, $port); - - // Analyze first header line - if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) { - // Response code is not 200 - return $response; - } // END - if - - // All fine! - return $respArray; - } - - /** - * Sends a raw HTTP request out to given IP/host and port number - * - * @param $method Request method (GET, POST, HEAD, CONNECT, ...) - * @param $host Host to connect to - * @param $port Port number to connect to - * @return $responseArray Array with raw response - */ - private function sendRawHttpRequest ($method, $host, $port, array $header = array()) { - // Minimum raw HTTP/1.1 request - $rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL; - $rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL; - - // Use login data to proxy? (username at least) - if ($this->getConfigInstance()->getConfigEntry('proxy_username') != '') { - // Add it as well - $encodedAuth = base64_encode($this->getConfigInstance()->getConfigEntry('proxy_username') . ':' . $this->getConfigInstance()->getConfigEntry('proxy_password')); - $rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL; - } // END - if - - // Add last new-line - $rawRequest .= self::HTTP_EOL; - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HTTP-CLIENT[' . __METHOD__ . ':' . __LINE__ . ']: rawRequest=' . $rawRequest); - - // Write request - fwrite($this->getSocketResource(), $rawRequest); - - // Got response? - if (feof($this->getSocketResource())) { - // No response received - return $response; - } // END - if - - // Read the first line - $resp = trim(fgets($this->getSocketResource(), 10240)); - - // "Explode" the string to an array - $responseArray = explode(' ', $resp); - - // And return it - return $responseArray; - } - - /** - * A HTTP/1.1 CONNECT request - * - * @param $host Host to connect to - * @param $port Port number to connect to - * @return $responseArray An array with the read response - */ - public function doConnectRequest ($host, $port) { - // Prepare extra header(s) - $headers = array( - 'Proxy-Connection' => 'Keep-Alive' - ); - - // Prepare raw request - $responseArray = $this->sendRawHttpRequest('CONNECT', $host, $port, $headers); - - // Return response array - return $responseArray; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/.htaccess b/inc/classes/main/commands/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/commands/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/commands/class_ b/inc/classes/main/commands/class_ deleted file mode 100644 index 424f107d..00000000 --- a/inc/classes/main/commands/class_ +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Command extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public final static function create???Command (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new ???Command(); - - // 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) { - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/class_BaseCommand.php b/inc/classes/main/commands/class_BaseCommand.php deleted file mode 100644 index ac926819..00000000 --- a/inc/classes/main/commands/class_BaseCommand.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCommand extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Sends a generic HTTP response with header, menu, content and footer - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @param $suffix Optional template suffix, e.g. '_form' for forms - * @return void - */ - protected function sendGenericGetResponse (Requestable $requestInstance, Responseable $responseInstance, $suffix = '') { - // This command doesn't handle any POST requests, so only handle get request - assert(!$requestInstance->isPostRequestMethod()); - - // Get the application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Transfer application data - $templateInstance->assignApplicationData($applicationInstance); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the content template - $templateInstance->loadCodeTemplate($this->getResolverInstance()->getCommandName() . $suffix); - - // Assign the content template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable($applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName(), 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_' . $applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_title')); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName($applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $templateInstance->transferToResponse($responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/.htaccess b/inc/classes/main/commands/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/commands/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/commands/html/class_Html b/inc/classes/main/commands/html/class_Html deleted file mode 100644 index 00341240..00000000 --- a/inc/classes/main/commands/html/class_Html +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Html???Command extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public final static function createHtml???Command (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new Html???Command(); - - // 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 - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Unfinished method.'); - } - - /** - * 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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlConfirmCommand.php b/inc/classes/main/commands/html/class_HtmlConfirmCommand.php deleted file mode 100644 index 9cc72c4f..00000000 --- a/inc/classes/main/commands/html/class_HtmlConfirmCommand.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlConfirmCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlConfirmCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlConfirmCommand(); - - // 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 application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Assign application data with template engine - $templateInstance->assignApplicationData($applicationInstance); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the home template - $templateInstance->loadCodeTemplate('confirm_link'); - - // Assign the home template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable('confirm_link', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_confirm_link_title')); - - // Get user instance - try { - $userInstance = Registry::getRegistry()->getInstance('user'); - } catch (NullPointerException $e) { - // Not found user, e.g. when the user is somehow invalid - $responseInstance->redirectToConfiguredUrl('html_cmd_user_is_null'); - } - - // Set username - $templateInstance->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME)); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('confirm_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlDoFormCommand.php b/inc/classes/main/commands/html/class_HtmlDoFormCommand.php deleted file mode 100644 index 05ece9ea..00000000 --- a/inc/classes/main/commands/html/class_HtmlDoFormCommand.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlDoFormCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlDoFormCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlDoFormCommand(); - - // 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) { - // Should never be reached... - $this->debugBackTrace('This should never be reached.'); - } - - /** - * 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) { - // Empty for now - } - -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlHomeCommand.php b/inc/classes/main/commands/html/class_HtmlHomeCommand.php deleted file mode 100644 index 847f0163..00000000 --- a/inc/classes/main/commands/html/class_HtmlHomeCommand.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlHomeCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlHomeCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlHomeCommand(); - - // 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 application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Transfer application data - $templateInstance->assignApplicationData($applicationInstance); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the home template - $templateInstance->loadCodeTemplate('home'); - - // Assign the home template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable('home', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_home_title')); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('home_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlLoginAreaCommand.php b/inc/classes/main/commands/html/class_HtmlLoginAreaCommand.php deleted file mode 100644 index e1d0eb95..00000000 --- a/inc/classes/main/commands/html/class_HtmlLoginAreaCommand.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLoginAreaCommand extends BaseCommand implements Commandable { - /** - * Name of the action - */ - private $actionName = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlLoginAreaCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlLoginAreaCommand(); - - // Set the application instance - $commandInstance->setResolverInstance($resolverInstance); - - // Load general data like user status and such - $commandInstance->prepareCommand(); - - // Return the prepared instance - return $commandInstance; - } - - /** - * Prepares some general data which shall be displayed on every page - * - * @return void - * @todo Add some stuff here: Some personal data, app/game related data - */ - protected function prepareCommand () { - } - - /** - * 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 action instance from registry - $actionInstance = Registry::getRegistry()->getInstance('action'); - - // Do we have an action here? - if ($actionInstance instanceof PerformableAction) { - // Execute the action (shall not output anything, see below why) - $actionInstance->execute($requestInstance, $responseInstance); - } // END - if - - // Get the application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - - // Assign all the application's data with template variables - $templateInstance->assignApplicationData($applicationInstance); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the matching template - $templateInstance->loadCodeTemplate('action_' . $this->actionName); - - // Assign the template with the master template as a content ... ;) - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('action_' . $this->actionName, 'login_content'); - - // Load main template - $templateInstance->loadCodeTemplate('login_main'); - - // Assign the main template with the master template as a content ... ;) - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('login_main', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($this->actionName . '_title')); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('login_area_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $templateInstance->transferToResponse($responseInstance); - } - - /** - * Adds extra filters to the given controller instance. An corresponding action class must now exist! - * - * @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) { - // Default is no action - $actionInstance = NULL; - - // Get registry - $registryInstance = Registry::getRegistry(); - - // Get our application instance from the registry - $applicationInstance = $registryInstance->getInstance('application'); - - // Default action is the one from configuration - $this->actionName = self::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $this->getConfigInstance()->getConfigEntry('login_default_action'); - - // Get "action" from request - $actReq = $requestInstance->getRequestElement('action'); - - // Do we have a "action" parameter set? - if ((is_string($actReq)) && (!empty($actReq))) { - // Then use it with prefix - $this->actionName = self::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $actReq; - } // END - if - - // Get application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Get a resolver - $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName, $applicationInstance); - - // Resolve the action - $actionInstance = $actionResolver->resolveAction(); - - // Add more action-specific filters - $actionInstance->addExtraFilters($controllerInstance, $requestInstance); - - // Remember this action in registry - Registry::getRegistry()->addInstance('action', $actionInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlLoginCommand.php b/inc/classes/main/commands/html/class_HtmlLoginCommand.php deleted file mode 100644 index e3235769..00000000 --- a/inc/classes/main/commands/html/class_HtmlLoginCommand.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLoginCommand extends BaseCommand implements Commandable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlLoginCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlLoginCommand(); - - // 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) { - // Set request instance as extra instance - Registry::getRegistry()->addInstance('extra', $this); - - // Get the application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Assign application data with template engine - $templateInstance->assignApplicationData($applicationInstance); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the home template - $templateInstance->loadCodeTemplate('login_form'); - - // Assign the home template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable('login_form', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_login_title')); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('login_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlLoginFailedCommand.php b/inc/classes/main/commands/html/class_HtmlLoginFailedCommand.php deleted file mode 100644 index 4a73bd2b..00000000 --- a/inc/classes/main/commands/html/class_HtmlLoginFailedCommand.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLoginFailedCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlLoginFailedCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlLoginFailedCommand(); - - // 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 application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Assign application data with template engine - $templateInstance->assignApplicationData($applicationInstance); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the login_failed template - $templateInstance->loadCodeTemplate('login_failed'); - - // Assign the login_failed template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable('login_failed', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('login_failed_title')); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('login_failed_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlLogoutCommand.php b/inc/classes/main/commands/html/class_HtmlLogoutCommand.php deleted file mode 100644 index 47c8fd12..00000000 --- a/inc/classes/main/commands/html/class_HtmlLogoutCommand.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLogoutCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlLogoutCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlLogoutCommand(); - - // 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 an auth instance for checking and updating the auth cookies - $authInstance = ObjectFactory::createObjectByConfiguredName('auth_method_class', array($responseInstance)); - - // Set request instance - $authInstance->setRequestInstance($requestInstance); - - // Destroy the auth data - $authInstance->destroyAuthData(); - - // Redirect to "logout done" page - $responseInstance->redirectToConfiguredUrl('logout_done'); - - // Exit here - exit(); - } - - /** - * 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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlLogoutDoneCommand.php b/inc/classes/main/commands/html/class_HtmlLogoutDoneCommand.php deleted file mode 100644 index b02ab925..00000000 --- a/inc/classes/main/commands/html/class_HtmlLogoutDoneCommand.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLogoutDoneCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlLogoutDoneCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlLogoutDoneCommand(); - - // 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 application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Assign application data - $templateInstance->assignApplicationData($applicationInstance); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the logout_done template - $templateInstance->loadCodeTemplate('logout_done'); - - // Assign the logout_done template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable('logout_done', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('logout_done_title')); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('logout_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlProblemCommand.php b/inc/classes/main/commands/html/class_HtmlProblemCommand.php deleted file mode 100644 index 1c18dc62..00000000 --- a/inc/classes/main/commands/html/class_HtmlProblemCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlProblemCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlProblemCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlProblemCommand(); - - // 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 - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->partialStub('Unfinished method.'); - } - - /** - * 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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlRegisterCommand.php b/inc/classes/main/commands/html/class_HtmlRegisterCommand.php deleted file mode 100644 index 4f8105d2..00000000 --- a/inc/classes/main/commands/html/class_HtmlRegisterCommand.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlRegisterCommand extends BaseCommand implements Commandable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlRegisterCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlRegisterCommand(); - - // 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) { - // Set request instance as extra instance - Registry::getRegistry()->addInstance('extra', $this); - - // Get the application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Assign all the application's data with template variables - $templateInstance->assignApplicationData($applicationInstance); - - // Assign base URL - $templateInstance->assignConfigVariable('base_url'); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the register template - $templateInstance->loadCodeTemplate('register_form'); - - // Assign the register template with the master template as a content ... ;) - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('register_form', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_register_title')); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('register_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $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) { - // Empty method - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlResendLinkCommand.php b/inc/classes/main/commands/html/class_HtmlResendLinkCommand.php deleted file mode 100644 index 05f66f93..00000000 --- a/inc/classes/main/commands/html/class_HtmlResendLinkCommand.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlResendLinkCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlResendLinkCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlResendLinkCommand(); - - // 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 user instance from registry - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Get an application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Get a RNG instance (Random Number Generator) - $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); - - // Generate a pseudo-random string - $randomString = $rngInstance->randomString(255); - - // Get a crypto instance - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - - // Hash and encrypt the string - $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString)); - - // Update the user class - $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString); - - // Re-set config entry to mailer engine - $this->getConfigInstance()->setConfigEntry('html_template_class', $this->getConfigInstance()->getConfigEntry('mail_template_class')); - - // Prepare the template engine - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Assign the application data with the template engine - $templateInstance->assignApplicationData($applicationInstance); - - // Get a mailer class - $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $applicationInstance, 'resend_link')); - - // Set this mailer in our template engine - $templateInstance->setMailerInstance($mailerInstance); - - // Add template variables we shall get - $mailerInstance->addConfigTemplateVariable('base_url'); - $mailerInstance->addConfigTemplateVariable('admin_email'); - $mailerInstance->addValueTemplateVariable('confirm_hash'); - $mailerInstance->addValueTemplateVariable('username'); - $mailerInstance->addValueTemplateVariable('email'); - - // Add the value instance for the confirmation hash - $mailerInstance->addValueInstance('confirm_hash', $userInstance); - $mailerInstance->addValueInstance('username', $userInstance); - $mailerInstance->addValueInstance('email', $userInstance); - - // Add the recipient - $mailerInstance->addRecipientByUserInstance($userInstance); - - // Use subject line from template - $mailerInstance->useSubjectFromTemplate(); - - // Send the email out - $mailerInstance->deliverEmail($responseInstance); - - // Send out notification to admin (depends on settings) - $mailerInstance->sendAdminNotification($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) { - // Filter for checking if account is unconfirmed - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter')); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/html/class_HtmlStatusCommand.php b/inc/classes/main/commands/html/class_HtmlStatusCommand.php deleted file mode 100644 index e27858ca..00000000 --- a/inc/classes/main/commands/html/class_HtmlStatusCommand.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlStatusCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final function createHtmlStatusCommand (CommandResolver $resolverInstance) { - // Get new instance - $commandInstance = new HtmlStatusCommand(); - - // 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 - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get the application instance - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // Transfer application data - $templateInstance->assignApplicationData($applicationInstance); - - // Load the master template - $masterTemplate = $applicationInstance->buildMasterTemplateName(); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the status template - $templateInstance->loadCodeTemplate('status'); - - // Assign the status template with the master template as a content ... ;) - $templateInstance->assignTemplateWithVariable('status', 'main_content'); - - // Load the master template - $templateInstance->loadCodeTemplate($masterTemplate); - - // Set title - $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_status_title')); - - // Construct the menu in every command. We could do this in BaseCommand class. But this means - // *every* command has a navigation system and that is want we don't want. - $menuInstance = ObjectFactory::createObjectByConfiguredName('status_menu_class', array($applicationInstance)); - - // Render the menu - $menuInstance->renderMenu(); - - // Transfer it to the template engine instance - $menuInstance->transferContentToTemplateEngine($templateInstance); - - /* - * ... and all variables. This should be merged together in a pattern - * to make things easier. A cache mechanism should be added between - * these two calls to cache compiled templates. - */ - $templateInstance->compileVariables(); - - // Get the content back from the template engine and put it in response class - $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) { - // Empty for now - } -} - -// [EOF] -?> diff --git a/inc/classes/main/commands/image/.htaccess b/inc/classes/main/commands/image/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/commands/image/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php b/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php deleted file mode 100644 index 3a02cb6b..00000000 --- a/inc/classes/main/commands/image/class_ImageCodeCaptchaCommand.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageCodeCaptchaCommand extends BaseCommand implements Commandable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $commandInstance An instance a prepared command class - */ - public static final 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 - $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); - - // Prepare a template instance - $templateInstance = $this->prepareTemplateInstance($applicationInstance); - - // 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/compressor/.htaccess b/inc/classes/main/compressor/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/compressor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/compressor/class_Bzip2Compressor.php b/inc/classes/main/compressor/class_Bzip2Compressor.php deleted file mode 100644 index 0df4b808..00000000 --- a/inc/classes/main/compressor/class_Bzip2Compressor.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor! - parent::__construct(__CLASS__); - } - - /** - * Create a new compressor channel based a given compression handler or NULL if the required PHP functions are not found. - * - * @return $compressorInstance An instance of this class or NULL if the required PHP functions are not found. - */ - public static final function createBzip2Compressor () { - // Routines not found by default - $compressorInstance = NULL; - - // Get new instance - if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) { - // Compressor can maybe be used - $compressorInstance = new Bzip2Compressor(); - } // END - if - - // Return the compressor instance - return $compressorInstance; - } - - /** - * BZIP2 compression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function compressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Return the compressed stream - return bzcompress($streamData, 1); - } - - /** - * BZIP2 decompression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function decompressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Decompress it - $streamData = bzdecompress($streamData, TRUE); - - // Return the decompressed stream - return $streamData; - } - - /** - * Getter for the file extension of this compressor - * - * @return $string Returns always 'bz2' - */ - public final function getCompressorExtension () { - return 'bz2'; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/compressor/class_GzipCompressor.php b/inc/classes/main/compressor/class_GzipCompressor.php deleted file mode 100644 index eb7dcee5..00000000 --- a/inc/classes/main/compressor/class_GzipCompressor.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class GzipCompressor extends BaseFrameworkSystem implements Compressor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor! - parent::__construct(__CLASS__); - } - - /** - * Create a new compressor channel based a given compression handler or NULL if the required PHP functions are not found. - * - * @return $compressorInstance An instance of this class or NULL if the required PHP functions are not found. - */ - public static final function createGzipCompressor () { - // Routines not found by default - $compressorInstance = NULL; - - // Get new instance - if ((function_exists('gzencode')) && (function_exists('gzdecode'))) { - // Compressor can maybe be used - $compressorInstance = new GzipCompressor(); - } // END - if - - // Return the compressor instance - return $compressorInstance; - } - - /** - * GZIP compression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function compressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Return the compressed stream - return gzencode($streamData, 1); - } - - /** - * GZIP decompression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function decompressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Return the decompressed stream - return gzdecode($streamData); - } - - /** - * Getter for the file extension of this compressor - * - * @return $string Returns always 'gz' - */ - public final function getCompressorExtension () { - return 'gz'; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/compressor/class_NullCompressor.php b/inc/classes/main/compressor/class_NullCompressor.php deleted file mode 100644 index 52fbd03d..00000000 --- a/inc/classes/main/compressor/class_NullCompressor.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NullCompressor extends BaseFrameworkSystem implements Compressor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor! - parent::__construct(__CLASS__); - } - - /** - * Create a new compressor channel based a given compression handler - * - * @return $compressorInstance An instance of this class - */ - public static final function createNullCompressor () { - // Get new instance - $compressorInstance = new NullCompressor(); - - // Return the compressor instance - return $compressorInstance; - } - - /** - * Null compression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function compressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Return the compressed stream - return $streamData; - } - - /** - * Null decompression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function decompressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Return the decompressed stream - return $streamData; - } - - /** - * Getter for the file extension of this compressor - * - * @return $string Returns always 'null' - */ - public final function getCompressorExtension () { - return 'null'; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/compressor/class_ZlibCompressor.php b/inc/classes/main/compressor/class_ZlibCompressor.php deleted file mode 100644 index 1816a40b..00000000 --- a/inc/classes/main/compressor/class_ZlibCompressor.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ZlibCompressor extends BaseFrameworkSystem implements Compressor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor! - parent::__construct(__CLASS__); - } - - /** - * Create a new compressor channel based a given compression handler or NULL if the required PHP functions are not found. - * - * @return $compressorInstance An instance of this class or NULL if the required PHP functions are not found. - */ - public static final function createZlibCompressor () { - // Routines not found by default - $compressorInstance = NULL; - - // Get new instance - if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) { - // Compressor can maybe be used - $compressorInstance = new ZlibCompressor(); - } // END - if - - // Return the compressor instance - return $compressorInstance; - } - - /** - * ZLIB compression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The compressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function compressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Return the compressed stream - return gzcompress($streamData, 1); - } - - /** - * ZLIB decompression stream - * - * @param $streamData Mixed non-object stream data - * @return $streamData The decompressed stream data - * @throws InvalidObjectException If the stream is an object - */ - public function decompressStream ($streamData) { - if (is_object($streamData)) { - // Throw an exception - throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); - } // END - if - - // Return the decompressed stream - return gzuncompress($streamData); - } - - /** - * Getter for the file extension of this compressor - * - * @return $string Returns always 'z' - */ - public final function getCompressorExtension () { - return 'z'; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/console/.htaccess b/inc/classes/main/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php deleted file mode 100644 index 7b690ef5..00000000 --- a/inc/classes/main/console/class_ConsoleTools.php +++ /dev/null @@ -1,402 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleTools extends BaseFrameworkSystem { - // Constants - const HTTP_EOL = "\r\n"; - const HTTP_USER_AGENT = 'ConsoleTools/1.0'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Tries to resolve an IP address from given hostname. Currently only IPv - * addresses are resolved. - * - * @param $hostname Host name we shall resolve - * @return $ip IP address resolved from host name - * @todo We should connect this to a caching class to cache DNS requests - */ - protected function resolveIpAddress ($hostname) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Host name to resolve is: %s', - $this->__toString(), - $hostname - )); - - // Default is an invalid one - $ip = '0.0.0.0'; - - // Resolve it - // @TODO Here should the cacher be implemented - $ipResolved = gethostbyname($hostname); - - // Was it fine? - if (($ipResolved !== FALSE) && ($ipResolved != $hostname)) { - // Okay, this works! - $ip = $ipResolved; - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Resolved IP address is: %s', - $this->__toString(), - $ip - )); - } else { - // Problem while resolving IP address - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.', - $this->__toString(), - $hostname - )); - } - - // Return resolved IP - return $ip; - } - - /** - * Checks wether proxy configuration is used - * - * @return $isUsed Wether proxy is used - */ - protected function isProxyUsed () { - // Do we have cache? - if (!isset($GLOBALS[__METHOD__])) { - // Determine it - $GLOBALS[__METHOD__] = (($this->getConfigInstance()->getConfigEntry('proxy_host') != '') && ($this->getConfigInstance()->getConfigEntry('proxy_port') > 0)); - } // END - if - - // Return cache - return $GLOBALS[__METHOD__]; - } - - /** - * Sets up a proxy tunnel for given hostname and through resource - * - * @param $host Host to connect to - * @param $port Port number to connect to - * @param $socketResource Resource of a socket - * @return $response Response array - */ - protected function setupProxyTunnel ($host, $port, $socketResource) { - // Initialize array - $response = array('', '', ''); - $proxyTunnel = ''; - - // Generate CONNECT request header - $proxyTunnel .= 'CONNECT ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL; - $proxyTunnel .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL; - $proxyTunnel .= 'Proxy-Connection: Keep-Alive' . self::HTTP_EOL; - - // Use login data to proxy? (username at least!) - if ($this->getConfigInstance()->getConfigEntry('proxy_username') != '') { - // Add it as well - $encodedAuth = base64_encode($this->getConfigInstance()->getConfigEntry('proxy_username') . ':' . $this->getConfigInstance()->getConfigEntry('proxy_password')); - $proxyTunnel .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL; - } // END - if - - // Add last new-line - $proxyTunnel .= self::HTTP_EOL; - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: proxyTunnel=' . $proxyTunnel); - - // Write request - fwrite($socketResource, $proxyTunnel); - - // Got response? - if (feof($socketResource)) { - // No response received - return $response; - } // END - if - - // Read the first line - $resp = trim(fgets($socketResource, 10240)); - $respArray = explode(' ', $resp); - if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) { - // Invalid response! - return $response; - } // END - if - - // All fine! - return $respArray; - } - - /** - * Tried to extract hostname from given raw data. On a Genntoo system, this could be multiple lines with # as comments. So try to get rid of it - * - * @param $rawData Raw data from /etc/hostname file - * @return $hostname Extracted host name - */ - protected function extractHostnameFromRawData ($rawData) { - // Default is invalid - $hostname = 'invalid'; - - // Try to "explode" it - $data = explode(PHP_EOL, $rawData); - - // "Walk" through it - foreach ($data as $line) { - // Trim it - $line = trim($line); - - // Begins with a hash (#) = comment? - if (substr($line, 0, 1) == '#') { - // Then skip it - continue; - } // END - if - - // Has an equals sign? - if (strpos($line, '=') !== FALSE) { - // Then "explode" it again, right part is hostname in quotes - $hostData = explode('=', $line); - - // Make sure only a key=value pair goes through - assert(count($hostData) == 2); - - // Try to get it and abort - $hostname = str_replace(array('"', chr(39)), array('', ''), $hostData[1]); - break; - } else { - // Use it directly - $hostname = $line; - break; - } - } // END - foreach - - // Return it - return $hostname; - } - - /** - * Aquires the IP address of this host by reading the /etc/hostname file - * and solving it. It is now stored in configuration - * - * @return $ip Aquired IP address - */ - public static function acquireSelfIPAddress () { - // Local IP by default - $ip = '127.0.0.1'; - - // Get a new instance - $helperInstance = new ConsoleTools(); - - try { - // Get a file pointer - $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($helperInstance->getConfigInstance()->getConfigEntry('hostname_file'))); - - // Read the file - $rawData = trim($fileInstance->readFromFile()); - - // Close the file - $fileInstance->closeFile(); - - // Extract hostname from it - $hostname = $helperInstance->extractHostnameFromRawData($rawData); - - // Resolve the IP number - $ip = $helperInstance->resolveIpAddress($hostname); - } catch (FileNotFoundException $e) { - // Fall-back to 'SESSION_SVR' which found on my Sun Station - if (isset($_SERVER['SESSION_SVR'])) { - // Resolve it - $ip = $helperInstance->resolveIpAddress($_SERVER['SESSION_SVR']); - } elseif (isset($_SERVER['COMPUTERNAME'])) { - // May happen on some XP systems, so also try this - $ip = $helperInstance->resolveIpAddress($_SERVER['COMPUTERNAME']); - } else { - // Could not find our hostname - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] WARNING: Cannot resolve my own IP address.', - $helperInstance->__toString() - )); - } - } catch (FrameworkException $e) { - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Problem while resolving own IP address: [%s|%s]:%s', - $helperInstance->__toString(), - $e->__toString(), - $e->getHexCode(), - $e->getMessage() - )); - } - - // Set it in configuration - FrameworkConfiguration::getSelfInstance()->setServerAddress($ip); - - // Return it - return $ip; - } - - /** - * Determines own remote IP address (e.g. can be used to probe if we are - * reachable from outside by determining external address and then connect to it. - * This is accomblished by connecting to the IP of www.shipsimu.org which - * should default to 188.138.90.169 and requesting /ip.php which does only - * return the content of $_SERVER['REMOTE_ADDR']. Of course, this method - * requires a working Internet connection. - * - * This method is taken from a user comment on php.net and heavily rewritten. - * Compare to following link: - * http://de.php.net/manual/en/function.socket-create.php#49368 - * - * @return $externalAddress The determined external address address - * @throws InvalidSocketException If socket initialization wents wrong or if an errors occurs - * @todo This should be moved out to an external class, e.g. HttpClient - * @todo Make IP, host name, port and script name configurable - */ - public static function determineExternalAddress () { - // Get helper instance - $helperInstance = new ConsoleTools(); - - // First get a socket - // @TODO Add some DNS caching here - - // Open connection - if ($helperInstance->isProxyUsed() === TRUE) { - // Resolve hostname into IP address - $ip = $helperInstance->resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); - - // Connect to host through proxy connection - $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); - } else { - // Connect to host directly - $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); - } - - // Check if there was an error else - if ($errorNo > 0) { - // Then throw again - throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET); - } // END - if - - // Prepare the GET request - $request = 'GET ' . ($helperInstance->isProxyUsed() === TRUE ? 'http://shipsimu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL; - $request .= 'Host: shipsimu.org' . self::HTTP_EOL; - $request .= 'User-Agent: ' . self::HTTP_USER_AGENT . self::HTTP_EOL; - $request .= 'Connection: close' . self::HTTP_EOL; - - // Do we use proxy? - if ($helperInstance->isProxyUsed() === TRUE) { - // CONNECT method? - if ($helperInstance->getConfigInstance()->getConfigEntry('proxy_connect_method') == 'Y') { - // Setup proxy tunnel - $response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource); - - // If the response is invalid, abort - if ((count($response) == 3) && (empty($response[0])) && (empty($response[1])) && (empty($response[2]))) { - // Invalid response! - $helperInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, TRUE)); - } // END - if - } else { - // Add header for proxy - $request .= 'Proxy-Connection: Keep-Alive' . self::HTTP_EOL; - } - } // END - if - - // Add last HTTP_EOL - $request .= self::HTTP_EOL; - - // Send it to the socket - fwrite($socketResource, $request); - - // Init IP (this will always be the last line) - $externalAddress = 'invalid'; - - // And read the reply - while (!feof($socketResource)) { - // Get line - $externalAddress = trim(fgets($socketResource, 128)); - - // Detect HTTP response - if ((substr($externalAddress, 0, 7) == 'HTTP/1.') && (substr($externalAddress, -6, 6) != '200 OK')) { - // Stop processing - break; - } // END - if - } // END - while - - // Close socket - fclose($socketResource); - - - // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Resolved external address: ' . $externalAddress); - - // Return determined external address - return $externalAddress; - } - - /** - * Analyzes the 'environment', mostly $_SERVER, for presence of elements - * which indicates clearly that e.g. this script has been executed from - * console or web. - * - * @return $type The analyzed type, can be 'http' or 'console' - */ - public static function analyzeEnvironmentForType () { - // Default is the console - $type = 'console'; - - // Now, do we have a request method, or query string set? - if ((isset($_SERVER['REQUEST_METHOD'])) || (isset($_SERVER['QUERY_STRING']))) { - // Possibly HTTP request - $type = 'http'; - } // END - if - - // Return it - return $type; - } - - /** - * Analyzes the 'environment', mostly $_SERVER, for presence of elements - * which indicates clearly that e.g. this script has been executed from - * console or web. This method should be used for class names, they - * currently are named differently. Here is a list to clarify this: - * - * Request type | Class type - * ----------------------------- - * http | web - * console | console - * - * @return $type The analyzed type, can be 'http' or 'console' - */ - public static function analyzeEnvironmentForClassType () { - // Default is the console - $type = 'console'; - - // Now, do we have a request method, or query string set? - if ((isset($_SERVER['REQUEST_METHOD'])) || (isset($_SERVER['QUERY_STRING']))) { - // Possibly HTTP request - $type = 'web'; - } // END - if - - // Return it - return $type; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/container/.htaccess b/inc/classes/main/container/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/container/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/container/class_ b/inc/classes/main/container/class_ deleted file mode 100644 index a64358c1..00000000 --- a/inc/classes/main/container/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Container extends BaseContainer implements Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Container class and prepares it for usage - * - * @return $containerInstance An instance of this Container class - */ - public final static function create???Container () { - // Get a new instance - $containerInstance = new ???Container(); - - // Return the prepared instance - return $containerInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/container/class_BaseContainer.php b/inc/classes/main/container/class_BaseContainer.php deleted file mode 100644 index ee1dc779..00000000 --- a/inc/classes/main/container/class_BaseContainer.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseContainer extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/container/socket/.htaccess b/inc/classes/main/container/socket/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/container/socket/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/container/socket/class_SocketContainer.php b/inc/classes/main/container/socket/class_SocketContainer.php deleted file mode 100644 index 07058d58..00000000 --- a/inc/classes/main/container/socket/class_SocketContainer.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketContainer extends BaseContainer implements Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Container class and prepares it for usage - * - * @param $socketResource A valid socket resource - * @param $infoInstance An instance of a ShareableInfo class - * @param $packageData Raw package data - * @return $containerInstance An instance of this Container class - */ - public static final function createSocketContainer ($socketResource, ShareableInfo $infoInstance = NULL, array $packageData = array()) { - // Get a new instance - $containerInstance = new SocketContainer(); - - // Remove unneeded entries - unset($packageData[NetworkPackage::PACKAGE_DATA_CONTENT]); - unset($packageData[NetworkPackage::PACKAGE_DATA_HASH]); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']:socketResource=' . $socketResource . ',packageData='.print_r($packageData, TRUE)); - - // Is the info instance set? - if ($infoInstance instanceof ShareableInfo) { - // Get listener/helper from info class - $listenerInstance = $infoInstance->getListenerInstance(); - $helperInstance = $infoInstance->getHelperInstance(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: listenerInstance[]=' . gettype($listenerInstance)); - - // Is there a listener instance set? - if ($listenerInstance instanceof Listenable) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...'); - - // Set it here for later usage - $containerInstance->setListenerInstance($listenerInstance); - } elseif ($helperInstance instanceof ConnectionHelper) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: Setting helperInstance=' . $helperInstance->__toString() . ' ...'); - - // Set it here for later usage - $containerInstance->setHelperInstance($helperInstance); - } - } // END - if - - // Set the resource ... - $containerInstance->setSocketResource($socketResource); - - // ... and package data - $containerInstance->setPackageData($packageData); - - // Return the prepared instance - return $containerInstance; - } - - /** - * Checks whether the given Universal Node Locator matches with the one from package data - * - * @param $unl A Universal Node Locator - * @return $matches Whether $address matches with the one from package data - */ - public final function ifAddressMatches ($unl) { - // Get current package data - $packageData = $this->getPackageData(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',packageData=' . print_r($packageData, TRUE)); - - // So, does both match? - $matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $unl)); - - // Return result - return $matches; - } - - /** - * Checks whether the given socket matches with stored - * - * @param $socketResource A valid socket resource - * @return $matches Whether given socket matches - */ - public final function ifSocketResourceMatches ($socketResource) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); - - // So, does both match? - $matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource())); - - // Return result - return $matches; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/.htaccess b/inc/classes/main/controller/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/class_ b/inc/classes/main/controller/class_ deleted file mode 100644 index 7c62f2a8..00000000 --- a/inc/classes/main/controller/class_ +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Controller extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public final static function create???Controller (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new ???Controller(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php deleted file mode 100644 index db7521a5..00000000 --- a/inc/classes/main/controller/class_BaseController.php +++ /dev/null @@ -1,296 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseController extends BaseFrameworkSystem implements Registerable { - // Exception constants - const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10; - - // Names of controller's own filter chains - const FILTER_CHAIN_PRE_COMMAND = 'controller_pre_command'; - const FILTER_CHAIN_POST_COMMAND = 'controller_post_command'; - - /** - * Generic filter chains - */ - private $filterChains = array(); - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Initialize both filter chains - $this->initFilterChain(self::FILTER_CHAIN_PRE_COMMAND); - $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND); - - // Add this controller to the registry - Registry::getRegistry()->addInstance('controller', $this); - } - - /** - * Executes a command with pre and post filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeGenericPrePostCommand (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the post filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Handles the given request and response, redirects to login_failed if - * UserAuthorizationException is thrown. - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function genericHanleRequestLoginFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) { - // Get the "form action" - $formAction = $requestInstance->getRequestElement('form'); - - // Get command instance from resolver - $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Try to run the pre filters, if auth exceptions come through redirect here - try { - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - } catch (UserAuthorizationException $e) { - // Redirect to main page - $responseInstance->redirectToConfiguredUrl('login_failed'); - - // Exit here - exit(); - } - - /* - * Is the request still valid? Post filters shall only be executed of - * the request is valid - */ - if ($requestInstance->isRequestValid()) { - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Execute *very* generic ppost filters - $this->executePostFilters($requestInstance, $responseInstance); - } // END - if - - // Flush the buffer out - $responseInstance->flushBuffer(); - } - - /** - * Generic execute of the command: pre and post filters with redirect - * but request becomes valid after pre-filters run. - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function genericHanleRequestLoginAreaFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance from the resolver by sending a request instance to the resolver - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // Add more filters by the command - $commandInstance->addExtraFilters($this, $requestInstance); - - // Try to run the pre filters, if auth exceptions come through redirect here - try { - // Run the pre filters - $this->executePreFilters($requestInstance, $responseInstance); - } catch (UserAuthorizationException $e) { - // Redirect to main page - $responseInstance->redirectToConfiguredUrl('login_failed'); - - // Exit here - exit(); - } - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Run the pre filters - $this->executePostFilters($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } - - /** - * Private method to initialize a given filter chain - * - * @param $filterChain Name of the filter chain - * @return void - */ - protected function initFilterChain ($filterChain) { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START'); - $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED'); - } - - /** - * Adds a filter to a given filter chain - * - * @param $filterChain Chain of the filter - * @param $filterInstance An instance of a filter - * @return void - * @throws InvalidFilterChainException If the filter chain is invalid - */ - protected function addFilter ($filterChain, Filterable $filterInstance) { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START'); - - // Test if the filter is there - if (!isset($this->filterChains[$filterChain])) { - // Throw an exception here - throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID); - } // END - if - - // Add the filter - $this->filterChains[$filterChain]->addFilter($filterInstance); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH'); - } - - /** - * Adds a filter to the pre filter chain - * - * @param $filterInstance An instance of a filter - * @return void - */ - public function addPreFilter (Filterable $filterInstance) { - // Add the pre filter - $this->addFilter(self::FILTER_CHAIN_PRE_COMMAND, $filterInstance); - } - - /** - * Adds a filter to the post filter chain - * - * @param $filterInstance An instance of a filter - * @return void - */ - public function addPostFilter (Filterable $filterInstance) { - // Add the post filter - $this->addFilter(self::FILTER_CHAIN_POST_COMMAND, $filterInstance); - } - - /** - * Add a shutdown filter - * - * @param $filterInstance A Filterable class - * @return void - */ - public function addShutdownFilter (Filterable $filterInstance) { - $this->addFilter('shutdown', $filterInstance); - } - - /** - * Executes given filter chain chain - * - * @param $filterChain Chain of the filter to execute - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - * @throws InvalidFilterChainException If the filter chain is invalid - */ - protected function executeFilters ($filterChain, Requestable $requestInstance, Responseable $responseInstance) { - // Test if the filter is there - if (!isset($this->filterChains[$filterChain])) { - // Throw an exception here - throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID); - } // END - if - - // Run all filters - $this->filterChains[$filterChain]->processFilters($requestInstance, $responseInstance); - } - - /** - * Executes all pre filters - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) { - // Execute all pre filters - $this->executeFilters(self::FILTER_CHAIN_PRE_COMMAND, $requestInstance, $responseInstance); - } - - /** - * Executes all post filters - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) { - // Execute all post filters - $this->executeFilters(self::FILTER_CHAIN_POST_COMMAND, $requestInstance, $responseInstance); - } - - /** - * Executes all shutdown filters - * - * @param $requestInstance A Requestable class - * @param $responseInstance A Responseable class - * @return void - */ - public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) { - $this->executeFilters('shutdown', $requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/console/.htaccess b/inc/classes/main/controller/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/console/class_ConsoleDefaultController.php b/inc/classes/main/controller/console/class_ConsoleDefaultController.php deleted file mode 100644 index 4b0ce90e..00000000 --- a/inc/classes/main/controller/console/class_ConsoleDefaultController.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This controller shall still provide some headlines for sidebars - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleDefaultController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createConsoleDefaultController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new ConsoleDefaultController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/console/class_ConsoleDefaultNewsController.php b/inc/classes/main/controller/console/class_ConsoleDefaultNewsController.php deleted file mode 100644 index 89ecb683..00000000 --- a/inc/classes/main/controller/console/class_ConsoleDefaultNewsController.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleDefaultNewsController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createConsoleDefaultNewsController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new ConsoleDefaultNewsController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add news filters to this controller - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/.htaccess b/inc/classes/main/controller/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/html/class_Html b/inc/classes/main/controller/html/class_Html deleted file mode 100644 index e9a95a4d..00000000 --- a/inc/classes/main/controller/html/class_Html +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Html???Controller extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some filters to this controller - */ - public final static function createHtml???Controller (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new Html???Controller(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add filters - //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlConfirmController.php b/inc/classes/main/controller/html/class_HtmlConfirmController.php deleted file mode 100644 index ea3e7633..00000000 --- a/inc/classes/main/controller/html/class_HtmlConfirmController.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlConfirmController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some filters to this controller - */ - public static final function createHtmlConfirmController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlConfirmController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add filters for handling confirmation code and username - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlDefaultController.php b/inc/classes/main/controller/html/class_HtmlDefaultController.php deleted file mode 100644 index f94a8c2d..00000000 --- a/inc/classes/main/controller/html/class_HtmlDefaultController.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This controller shall still provide some headlines for sidebars - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlDefaultController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHtmlDefaultController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlDefaultController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlDefaultNewsController.php b/inc/classes/main/controller/html/class_HtmlDefaultNewsController.php deleted file mode 100644 index 1d346b8a..00000000 --- a/inc/classes/main/controller/html/class_HtmlDefaultNewsController.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlDefaultNewsController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHtmlDefaultNewsController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlDefaultNewsController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add news filters to this controller - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlLoginController.php b/inc/classes/main/controller/html/class_HtmlLoginController.php deleted file mode 100644 index 0db76a75..00000000 --- a/inc/classes/main/controller/html/class_HtmlLoginController.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLoginController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some filters to this controller - */ - public static final function createHtmlLoginController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlLoginController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlLoginFailedController.php b/inc/classes/main/controller/html/class_HtmlLoginFailedController.php deleted file mode 100644 index 2061064f..00000000 --- a/inc/classes/main/controller/html/class_HtmlLoginFailedController.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLoginFailedController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHtmlLoginFailedController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlLoginFailedController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlLogoutController.php b/inc/classes/main/controller/html/class_HtmlLogoutController.php deleted file mode 100644 index 43edba06..00000000 --- a/inc/classes/main/controller/html/class_HtmlLogoutController.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This controller shall still provide some headlines for sidebars - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLogoutController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHtmlLogoutController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlLogoutController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Add user auth filter (we don't need an update of the user here because it will be redirected) - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); - - // User status filter - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlLogoutDoneController.php b/inc/classes/main/controller/html/class_HtmlLogoutDoneController.php deleted file mode 100644 index b2f93a19..00000000 --- a/inc/classes/main/controller/html/class_HtmlLogoutDoneController.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLogoutDoneController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some filters to this controller - */ - public static final function createHtmlLogoutDoneController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlLogoutDoneController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlProblemController.php b/inc/classes/main/controller/html/class_HtmlProblemController.php deleted file mode 100644 index f3c37356..00000000 --- a/inc/classes/main/controller/html/class_HtmlProblemController.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlProblemController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some filters to this controller - */ - public static final function createHtmlProblemController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlProblemController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlRegisterController.php b/inc/classes/main/controller/html/class_HtmlRegisterController.php deleted file mode 100644 index b1d5999a..00000000 --- a/inc/classes/main/controller/html/class_HtmlRegisterController.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlRegisterController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some filters to this controller - */ - public static final function createHtmlRegisterController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlRegisterController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/class_HtmlStatusController.php b/inc/classes/main/controller/html/class_HtmlStatusController.php deleted file mode 100644 index f51e8355..00000000 --- a/inc/classes/main/controller/html/class_HtmlStatusController.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This controller shall still provide some headlines for sidebars - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlStatusController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHtmlStatusController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlStatusController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/form/.htaccess b/inc/classes/main/controller/html/form/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/html/form/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/html/form/class_HtmlDoFormController.php b/inc/classes/main/controller/html/form/class_HtmlDoFormController.php deleted file mode 100644 index 2dc6b884..00000000 --- a/inc/classes/main/controller/html/form/class_HtmlDoFormController.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlDoFormController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createHtmlDoFormController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlDoFormController(); - - // Set resolver instance - $controllerInstance->setResolverInstance($resolverInstance); - - // We need the controller instance in resolver class so set it here - $resolverInstance->setControllerInstance($controllerInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic handling with redirect to 'login_failed' - $this->genericHanleRequestLoginFailedRedirect($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/html/login/.htaccess b/inc/classes/main/controller/html/login/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/html/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/html/login/class_HtmlLoginAreaController.php b/inc/classes/main/controller/html/login/class_HtmlLoginAreaController.php deleted file mode 100644 index 375bdeea..00000000 --- a/inc/classes/main/controller/html/login/class_HtmlLoginAreaController.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLoginAreaController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - * @todo Add some morer filters to this controller - */ - public static final function createHtmlLoginAreaController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new HtmlLoginAreaController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // User auth filter - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); - - // User update filter - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter')); - - // News fetcher filter - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); - - // News proccess/display-preparation - $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - /* - * Generic execute of the command: pre and post filters with redirect - * but request becomes valid after pre-filters run. - */ - $this->genericHanleRequestLoginAreaFailedRedirect($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/image/.htaccess b/inc/classes/main/controller/image/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/image/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/image/captcha/.htaccess b/inc/classes/main/controller/image/captcha/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/controller/image/captcha/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/controller/image/captcha/class_ImageCodeCaptchaController.php b/inc/classes/main/controller/image/captcha/class_ImageCodeCaptchaController.php deleted file mode 100644 index 99b044e9..00000000 --- a/inc/classes/main/controller/image/captcha/class_ImageCodeCaptchaController.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageCodeCaptchaController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final 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_filter')); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Generic pre-post command execution - $this->executeGenericPrePostCommand($requestInstance, $responseInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/controller/image/class_ImageDefaultController.php b/inc/classes/main/controller/image/class_ImageDefaultController.php deleted file mode 100644 index dc8afb97..00000000 --- a/inc/classes/main/controller/image/class_ImageDefaultController.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageDefaultController extends BaseController implements Controller { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $resolverInstance An instance of a command resolver class - * @return $controllerInstance A prepared instance of this class - */ - public static final function createImageDefaultController (CommandResolver $resolverInstance) { - // Create the instance - $controllerInstance = new ImageDefaultController(); - - // Set the command resolver - $controllerInstance->setResolverInstance($resolverInstance); - - // Return the prepared instance - return $controllerInstance; - } - - /** - * Handles the given request and response - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { - // Get the command instance - $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - - // This request was valid! :-D - $requestInstance->requestIsValid(); - - // Execute the command - $commandInstance->execute($requestInstance, $responseInstance); - - // Flush the response out - $responseInstance->flushBuffer(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/criteria/.htaccess b/inc/classes/main/criteria/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/criteria/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/criteria/class_BaseCriteria.php b/inc/classes/main/criteria/class_BaseCriteria.php deleted file mode 100644 index 6c3e7d05..00000000 --- a/inc/classes/main/criteria/class_BaseCriteria.php +++ /dev/null @@ -1,488 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCriteria extends BaseFrameworkSystem implements Criteria { - /** - * Wrapper class name stored in config entry - */ - private $wrapperConfigEntry = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Initialize all criteria arrays - foreach (array('default', 'choice', 'exclude') as $criteriaType) { - // Init it - $this->initGenericArrayKey('criteria', $criteriaType, 'entries'); - } // END - foreach - } - - /** - * Checks whether given key is set - * - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @param $criteriaKey Criteria key - * @return $isSet Whether key is set - */ - public function isKeySet ($criteriaType, $criteriaKey) { - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); - - // Determine it - $isSet = $this->isGenericArrayElementSet('criteria', $criteriaType, 'entries', $criteriaKey); - - // Return it - return $isSet; - } - - /** - * Checks whether given key is set for 'choice' type - * - * @param $criteriaKey Criteria key - * @return $isSet Whether key is set - */ - public function isChoiceKeySet ($criteriaKey) { - // Call inner method - return $this->isKeySet('choice', $criteriaKey); - } - - /** - * Checks whether given key is set for 'exclude' type - * - * @param $criteriaKey Criteria key - * @return $isSet Whether key is set - */ - public function isExcludeKeySet ($criteriaKey) { - // Call inner method - return $this->isKeySet('exclude', $criteriaKey); - } - - /** - * Setter for wrapper class name - * - * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name - * @return void - */ - public final function setWrapperConfigEntry ($wrapperConfigEntry) { - $this->wrapperConfigEntry = (string) $wrapperConfigEntry; - } - - /** - * Getter for wrapper class name - * - * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name - */ - public final function getWrapperConfigEntry () { - return $this->wrapperConfigEntry; - } - - /** - * Getter for criteria array - * - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $criteria - */ - public final function getCriteriaArray ($criteriaType = 'default') { - return $this->getGenericArrayKey('criteria', $criteriaType, 'entries'); - } - - /** - * Getter for criteria array 'choice' type - * - * @return $criteria - */ - public final function getCriteriaChoiceArray () { - return $this->getCriteriaArray('choice'); - } - - /** - * Getter for criteria array 'exclude' type - * - * @return $criteria - */ - public final function getCriteriaExcludeArray () { - return $this->getCriteriaArray('exclude'); - } - - /** - * Unsets a criteria key from all criteria types - * - * @param $criteriaKey Criteria key to unset - * @return void - */ - public final function unsetCriteria ($criteriaKey) { - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); - - // Convert dashes to underscore - $criteriaKey = self::convertDashesToUnderscores($criteriaKey); - - // "Walk" through all criterias - foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) { - // Remove it - $this->unsetGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); - } // END - foreach - } - - /** - * Add criteria, this method converts dashes to underscores because dashes - * are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return void - */ - public final function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!'); - - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); - - // Convert dashes to underscore - $criteriaKey = self::convertDashesToUnderscores($criteriaKey); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey); - - // Append it - $this->appendStringToGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue); - } - - /** - * Set criteria, this method converts dashes to underscores because dashes - * are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return void - */ - public final function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!'); - - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); - - // Convert dashes to underscore - $criteriaKey = self::convertDashesToUnderscores($criteriaKey); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey); - - // Set it - $this->setStringGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue); - } - - /** - * Add "choice" criteria, this method converts dashes to underscores because - * dashes are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @return void - */ - public final function addChoiceCriteria ($criteriaKey, $criteriaValue) { - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue); - - // Add it - $this->pushValueToGenericArrayElement('criteria', 'choice', 'entries', self::convertDashesToUnderscores($criteriaKey), (string) $criteriaValue); - } - - /** - * Add "exclude" criteria, this method converts dashes to underscores because - * dashes are not valid for criteria keys. - * - * @param $criteriaKey Criteria key - * @param $criteriaValue Criteria value - * @return void - */ - public final function addExcludeCriteria ($criteriaKey, $criteriaValue) { - // Add it with generic method - $this->addCriteria($criteriaKey, $criteriaValue, 'exclude'); - } - - /** - * Add configured criteria - * - * @param $criteriaKey Criteria key - * @param $configEntry Configuration entry - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return void - */ - public final function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default') { - // Add the configuration entry as a criteria - $value = $this->getConfigInstance()->getConfigEntry($configEntry); - $this->addCriteria($criteriaKey, $value, $criteriaType); - } - - /** - * Get criteria element or FALSE if not found - * - * @param $criteriaKey The requested criteria key - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $value Whether the value of the critera or FALSE - */ - public function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!'); - - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); - - // Convert dashes to underscore - $criteriaKey = self::convertDashesToUnderscores($criteriaKey); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)); - - // Default is not found - $value = FALSE; - - // Is the criteria there? - if ($this->isKeySet($criteriaType, $criteriaKey)) { - // Then use it - $value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: value=' . $value . ' - EXIT!'); - - // Return the value - return $value; - } - - /** - * Get criteria element or FALSE if not found for 'choice' type - * - * @param $criteriaKey The requested criteria key - * @return $value Whether the value of the critera or FALSE - */ - public function getCriteriaChoiceElemnent ($criteriaKey) { - // Call inner method - return $this->getCriteriaElemnent($criteriaKey, 'choice'); - } - - /** - * Get criteria element or FALSE if not found for 'exclude' type - * - * @param $criteriaKey The requested criteria key - * @return $value Whether the value of the critera or FALSE - */ - public function getCriteriaExcludeElemnent ($criteriaKey) { - // Call inner method - return $this->getCriteriaElemnent($criteriaKey, 'exclude'); - } - - /** - * Checks whether given array entry matches - * - * @param $entryArray Array with the entries to find - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $matches Whether the entry matches or not - */ - public function ifEntryMatches (array $entryArray, $criteriaType = 'default') { - // First nothing matches and nothing is counted - $matches = FALSE; - $counted = 0; - - // Walk through all entries - foreach ($entryArray as $key => $entry) { - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($key, 'my-') === FALSE) && (strpos($key, 'my_') === FALSE)); - - // Convert dashes to underscore - $key = self::convertDashesToUnderscores($key); - - // Then walk through all search criteria - foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) { - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); - - // Convert dashes to underscore - $criteriaKey = self::convertDashesToUnderscores($criteriaKey); - - // Is the element found and does it match? - if (($key == $criteriaKey) && ($criteriaValue == $entry)) { - // Then count this one up - $counted++; - } // END - if - } // END - foreach - } // END - foreach - - // Now check if expected criteria counts match - $matches = ($counted == $this->countGenericArrayGroup('criteria', $criteriaType)); - - // Return the result - return $matches; - } - - /** - * Checks whether given array 'choice' entry matches - * - * @param $entryArray Array with the entries to find - * @return $matches Whether the entry matches or not - */ - public function ifChoiceMatches (array $entryArray) { - // Call inner method - return $this->ifEntryMatches($entryArray, 'choice'); - } - - /** - * Checks whether given array 'exclude' entry matches - * - * @param $entryArray Array with the entries to find - * @return $matches Whether the entry matches or not - */ - public function ifExcludeMatches (array $entryArray) { - // Call inner method - return $this->ifEntryMatches($entryArray, 'exclude'); - } - - /** - * "Getter" for a cache key - * - * @param $onlyKeys Only use these keys for a cache key - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $cacheKey The key suitable for the cache system - */ - public function getCacheKey ($onlyKeys = array(), $criteriaType = 'default') { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': criteriaType=' . $criteriaType . ',count()=' . $this->countGenericArray('criteria'))); - - // Make sure the criteria is there - assert($this->isValidGenericArrayGroup('criteria', $criteriaType)); - - // Initialize the key - $cacheKey = ''; - - // Now walk through all criterias - foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) { - // Make sure no 'my-' or 'my_' passes this point - assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); - - // $criteriaValue cannot be an array - assert(!is_array($criteriaValue)); - - // Convert dashes to underscore - $criteriaKey = self::convertDashesToUnderscores($criteriaKey); - - // Is the value in array or is $onlyKeys empty? - if ((isset($onlyKeys[$criteriaKey])) || (count($onlyKeys) == 0)) { - // Add the value URL encoded to avoid any trouble with special characters - $cacheKey .= sprintf('%s=%s;', - $criteriaKey, - urlencode($criteriaValue) - ); - } // END - if - } // END - foreach - - // Remove last semicolon - $cacheKey = substr($cacheKey, 0, -1); - - // Is the instance SearchCriteria? - if ($this instanceof SearchCriteria) { - // Check if 'limit' and 'skip' are in - if (((isset($onlyKeys['limit'])) && (isset($onlyKeys['skip']))) || (count($onlyKeys) == 0)) { - // Add limit and skip values - $cacheKey .= sprintf(';%%limit%%=%s;%%skip%%=%s', - $this->getLimit(), - $this->getSkip() - ); - } // END - if - } // END - if - - // Return the cache key - return $cacheKey; - } - - /** - * "Getter" for a cache key ('choice' type) - * - * @param $onlyKeys Only use these keys for a cache key - * @return $cacheKey The key suitable for the cache system - */ - public function getCacheKeyChoice ($onlyKeys = array()) { - // Call inner method - return $this->getCacheKey($onlyKeys, 'choice'); - } - - /** - * "Getter" for a cache key ('exclude' type) - * - * @param $onlyKeys Only use these keys for a cache key - * @return $cacheKey The key suitable for the cache system - */ - public function getCacheKeyExclude ($onlyKeys = array()) { - // Call inner method - return $this->getCacheKey($onlyKeys, 'exclude'); - } - - /** - * Count the criteria, e.g. useful to find out if a database query has no - * limitation (search criteria). - * - * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' - * @return $count Count of all criteria entries - */ - public final function count ($criteriaType = 'default') { - // Return it - return $this->countGenericArrayGroup('criteria', $criteriaType); - } - - /** - * Count 'choice' criteria, e.g. useful to find out if a database query - * has no limitation (search criteria). - * - * @return $count Count of all criteria entries - */ - public final function countChoice () { - return $this->count('choice'); - } - - /** - * Count 'exclude' criteria, e.g. useful to find out if a database query - * has no limitation (search criteria). - * - * @return $count Count of all criteria entries - */ - public final function countExclude () { - return $this->count('exclude'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/criteria/dataset/.htaccess b/inc/classes/main/criteria/dataset/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/criteria/dataset/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/criteria/dataset/class_DataSetCriteria.php b/inc/classes/main/criteria/dataset/class_DataSetCriteria.php deleted file mode 100644 index 27452394..00000000 --- a/inc/classes/main/criteria/dataset/class_DataSetCriteria.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DataSetCriteria extends BaseCriteria implements StoreableCriteria { - /** - * Table name - */ - private $tableName = ''; - - /** - * Unique key - */ - private $uniqueKey = ''; - - /** - * Primary key - */ - private $primaryKey = ''; - - /** - * Primary keys - */ - private $primaryKeys = array(); - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this criteria - * - * @param $tableName Name of the table - * @return $criteriaInstance An instance of this criteria - */ - public static final function createDataSetCriteria ($tableName) { - // Get a new instance - $criteriaInstance = new DataSetCriteria(); - - // Set table name - $criteriaInstance->setTableName($tableName); - - // Return the instance - return $criteriaInstance; - } - - /** - * Setter for table name - * - * @param $tableName Name of the table to set - * @return void - */ - public final function setTableName ($tableName) { - $this->tableName = (string) $tableName; - } - - /** - * Getter for table name - * - * @return $tableName Name of the table to set - */ - public final function getTableName () { - return $this->tableName; - } - - /** - * Setter for unique key - * - * @param $uniqueKey Column to use as unique key - * @return void - */ - public final function setUniqueKey ($uniqueKey) { - $this->uniqueKey = (string) $uniqueKey; - } - - /** - * Getter for unique key - * - * @return $uniqueKey Column to use as unique key - */ - public final function getUniqueKey () { - return $this->uniqueKey; - } - - /** - * Getter for unique key value - * - * @return $uniqueValue Value of the unique key - */ - public final function getUniqueValue () { - // Get primary key(s) first - $primaryKey = trim($this->getCriteriaElemnent($this->getPrimaryKey())); - $primaryKeys = $this->getPrimaryKeys(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: tableName=' . $this->getTableName() . ',primaryKey=' . $primaryKey . ',primaryKeys()=' . count($primaryKeys)); - - /* - * If this is not set, this could mean a badly written frontend as - * tables should always have a primary key. - */ - if (count($primaryKeys) > 0) { - /* - * Init return value, this can be put all together without any - * separator as it only aids as a "unique value" for generating the - * "row file name". - */ - $return = ''; - - // Combination set, so get all - foreach ($primaryKeys as $primaryKey) { - // Add it - $return .= trim($this->getCriteriaElemnent($primaryKey)); - } // END - foreach - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: tableName=' . $this->getTableName() . ',return=' . $return . ' - EXIT!'); - - // Return it - return $return; - } elseif (!empty($primaryKey)) { - // Return primary key - return $primaryKey; - } else { - // @TODO Issue a warning - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Primary key not set for table ' . $this->getTableName() . ', please fix your table. Falling back to unique key ...'); - - // Get unique key - $uniqueKey = trim($this->getCriteriaElemnent($this->getUniqueKey())); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: tableName=' . $this->getTableName() . ',uniqueKey=' . $uniqueKey); - - // Is it empty, too? - if (empty($uniqueKey)) { - // Bad news, nothing is "unique" by design for this table - ApplicationEntryPoint::app_exit('Table ' . $this->getTableName() . ' has both no primary and unique key, but ' . __METHOD__ . ' was called. Please fix your table.'); - } else { - // Return unique key - return $uniqueKey; - } - } - } - - /** - * Getter for primary key or unique key if not set - * - * @return $primaryKey Primary key or unique key if not set - */ - public final function getPrimaryKey () { - // Get primary key by default - $primaryKey = $this->primaryKey; - - if (empty($primaryKey)) { - // Get uniqueKey - $primaryKey = $this->getUniqueKey(); - } // END - if - - // Return it - return $primaryKey; - } - - /** - * Setter for primary key - * - * @param $primaryKey Primary key to set - * @return void - */ - public final function setPrimaryKey ($primaryKey) { - $this->primaryKey = (string) $primaryKey; - } - - /** - * Setter for primary key array - * - * @param $primaryKeys Primary key array to set - * @return void - */ - public function setPrimaryKeyCombined (array $primaryKeys) { - $this->primaryKeys = $primaryKeys; - } - - /** - * Getter for primary keys - * - * @return $primaryKeys Primary key array - */ - public final function getPrimaryKeys () { - // Return it - return $this->primaryKeys; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/criteria/search/.htaccess b/inc/classes/main/criteria/search/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/criteria/search/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/criteria/search/class_SearchCriteria.php b/inc/classes/main/criteria/search/class_SearchCriteria.php deleted file mode 100644 index 3bc2ef14..00000000 --- a/inc/classes/main/criteria/search/class_SearchCriteria.php +++ /dev/null @@ -1,227 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { - /** - * Criteria to handle - */ - private $criteria = array(); - - /** - * Limitation for the search - */ - private $limit = 0; - - /** - * Skip these entries before using them - */ - private $skip = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $criteriaInstance An instance of this criteria - */ - public static final function createSearchCriteria () { - // Get a new instance - $criteriaInstance = new SearchCriteria(); - - // Return this instance - return $criteriaInstance; - } - - /** - * Setter for limit - * - * @param $limit Search limit - * @return void - * @todo Find a nice casting here. (int) allows until and including 32766. - */ - public final function setLimit ($limit) { - $this->limit = $limit; - } - - /** - * "Setter" for limit from a configuration entry - * - * @param $configEntry The configuration entry which hold a number as limit - * @return void - */ - public final function setConfiguredLimit ($configEntry) { - // Get the limit from config entry and set it - $limit = $this->getConfigInstance()->getConfigEntry($configEntry); - $this->setLimit($limit); - } - - /** - * Getter for limit - * - * @return $limit Search limit - */ - public final function getLimit () { - return $this->limit; - } - - /** - * Setter for skip - * - * @param $skip Search skip - * @return void - * @todo Find a nice casting here. (int) allows until and including 32766. - */ - public final function setSkip ($skip) { - $this->skip = $skip; - } - - /** - * Getter for skip - * - * @return $skip Search skip - */ - public final function getSkip () { - return $this->skip; - } - - /** - * Checks whether the given key/value pair is matching with 'default' and one of 'choice' and - * never with in 'exclude'. - * - * @param $key Key element to check - * @param $value Value to check - * @param $separator Separator for "exploding" $value (default: ',') - * @return $isMatching Whether the key/value is matching or excluded - */ - public function isCriteriaMatching ($key, $value, $separator = ',') { - // $key/$value cannot be array/NULL/bool, value can be NULL but then NULL must be loocked for - assert((!is_array($value)) && (!is_bool($value)) && (!is_array($key)) && (!is_null($key)) && (!is_bool($key))); - - // "Explode" value - $valueArray = explode($separator, $value); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',value[' . gettype($value) . ']=' . $value . ' - CALLED!'); - - // Get 'default' search value - $searchDefault = $this->getCriteriaElemnent($key); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaElement(' . $key . ')[' . gettype($searchDefault) . ']=' . $searchDefault); - - // 'default' check - $isMatching = (((($searchDefault !== FALSE) && ($searchDefault == $value)) || ((is_null($searchDefault)) && (is_null($value)))) || ($searchDefault === FALSE)); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaElement(' . $key . ')[' . gettype($searchDefault) . ']=' . $searchDefault . ',isMatching=' . intval($isMatching)); - - // Get 'choice' search value (can be NULL or $separator-separated string) - $searchChoice = $this->getCriteriaChoiceElemnent($key); - - // May be FALSE or array - assert(($searchChoice === FALSE) || (is_array($searchChoice))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[' . gettype($searchChoice) . ']=' . print_r($searchChoice, TRUE)); - - // 'choice' check - if ((is_array($searchChoice)) && (count($valueArray) == 1)) { - // $value is a single-search value, so use in_array() - $isMatching = ((($isMatching === TRUE) || (($searchDefault === FALSE) && (!is_null($value)))) && (in_array($value, $searchChoice))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - SINGLE-MATCH'); - } elseif ((is_array($searchChoice)) && (count($valueArray) > 1)) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',valueArray()=' . count($valueArray) . ',isMatching=' . intval($isMatching)); - - // $value is choice-search value, so check all entries - $isMatching = (($isMatching === TRUE) || (($searchDefault === FALSE) && (!is_null($value)))); - $idx = 0; - foreach ($valueArray as $idx => $match) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: match=' . $match . ',count(searchChoice)=' . count($searchChoice)); - - // Is it found? (one is okay) - $isMatching = (($isMatching === TRUE) && (in_array($match, $searchChoice))); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: match=' . $match . ',isMatching=' . intval($isMatching)); - } // END - foreach - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',valueArray()=' . count($valueArray) . ',idx=' . $idx . ',isMatching=' . intval($isMatching) . ' - CHOICE-MATCH'); - } else { - // Choice-match is FALSE - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - FALSE-MATCH'); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',isMatching=' . intval($isMatching)); - - // Get 'exclude' search value - $searchExclude = $this->getCriteriaExcludeElemnent($key); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaExcludeElement(' . $key . ')[' . gettype($searchExclude) . ']=' . $searchExclude); - - // 'exclude' check - $isMatching = ( - ( - ( - $isMatching === TRUE - ) && ( - $searchExclude === FALSE - ) - ) || ( - ( - ( - $isMatching === TRUE - ) && ( - $searchExclude !== FALSE - ) && ( - $searchExclude !== $value - ) - ) - ) - ); - - // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - EXIT!'); - return $isMatching; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/criteria/update/.htaccess b/inc/classes/main/criteria/update/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/criteria/update/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/criteria/update/class_UpdateCriteria.php b/inc/classes/main/criteria/update/class_UpdateCriteria.php deleted file mode 100644 index df4470a7..00000000 --- a/inc/classes/main/criteria/update/class_UpdateCriteria.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UpdateCriteria extends BaseCriteria implements LocalUpdateCriteria { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $criteriaInstance An instance of this criteria - */ - public static final function createUpdateCriteria () { - // Get a new instance - $criteriaInstance = new UpdateCriteria(); - - // Return this instance - return $criteriaInstance; - } - - /** - * Getter for update criteria array - * - * @return $updateCriteria Array holding the update criteria - */ - public final function getUpdateCriteria () { - return $this->getCriteriaArray(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/crypto/.htaccess b/inc/classes/main/crypto/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/crypto/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php deleted file mode 100644 index 03458ee5..00000000 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ /dev/null @@ -1,234 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CryptoHelper extends BaseFrameworkSystem implements Cryptable { - // Exception constants - const EXCEPTION_ENCRYPT_MISSING = 0x1f0; - const EXCEPTION_ENCRYPT_INVALID = 0x1f1; - - /** - * An instance of this own clas - */ - private static $selfInstance = NULL; - - /** - * Instance of the crypto stream - */ - private $cryptoStreamInstance = NULL; - - /** - * Salt for hashing operations - */ - private $salt = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $cryptoInstance An instance of this crypto helper class - */ - public static final function createCryptoHelper () { - // Get a new instance - $cryptoInstance = new CryptoHelper(); - - // Initialize the hasher - $cryptoInstance->initHasher(); - - // Attach a crypto stream - $cryptoInstance->attachCryptoStream(); - - // Return the instance - return $cryptoInstance; - } - - /** - * Get a singleton instance of this class - * - * @return $selfInstance An instance of this crypto helper class - */ - public static final function getSelfInstance () { - // Is no instance there? - if (is_null(self::$selfInstance)) { - // Then get a new one - self::$selfInstance = self::createCryptoHelper(); - } // END - if - - // Return the instance - return self::$selfInstance; - } - - /** - * Attaches a crypto stream to this crypto helper by detecting loaded - * modules. - * - * @return void - */ - protected function attachCryptoStream () { - // Do we have mcrypt loaded? - if ($this->isPhpExtensionLoaded('mcrypt')) { - // Then use it - $this->cryptoStreamInstance = ObjectFactory::createObjectByName('McryptStream', array($this->getRngInstance())); - } else { - // If nothing works ... - $this->cryptoStreamInstance = ObjectFactory::createObjectByName('NullCryptoStream'); - } - } - - /** - * Initializes the hasher for different purposes. - * - * @return void - */ - protected function initHasher () { - // Initialize the random number generator which is required by some crypto methods - $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class')); - - // Generate a salt for the hasher - $this->generateSalt(); - } - - /** - * Generates the salt based on configured length - * - * @return void - */ - private function generateSalt () { - // Get a random string from the RNG - $randomString = $this->getRngInstance()->randomString() . $this->createUuid(); - - // Get config entry for salt length - $length = $this->getConfigInstance()->getConfigEntry('salt_length'); - - // Keep only defined number of characters - $this->salt = substr(sha1($randomString), -$length, $length); - } - - /** - * Returns a UUID (Universal Unique IDentifier) if PECL extension uuid was - * found or an empty string it not. - * - * @return $uuid UUID with leading dash or empty string - */ - public function createUuid () { - // Init empty UUID - $uuid = ''; - - // Is the UUID extension loaded? (see pecl) - if ((extension_loaded('uuid')) && (function_exists('uuid_create'))) { - // Then add it as well - $uuid = uuid_create(); - } // END - if - - // Return it - return $uuid; - } - - /** - * Hashes a string with salt and returns the hash. If an old previous hash - * is supplied the method will use the first X chars of that hash for hashing - * the password. This is useful if you want to check if password is identical - * for authorization purposes. - * - * @param $str Unhashed string - * @param $oldHash A hash from previous hashed string - * @param $withFixed Whether to include a fixed salt (not recommended in p2p applications) - * @return $hashed The hashed and salted string - */ - public function hashString ($str, $oldHash = '', $withFixed = TRUE) { - // Cast the string - $str = (string) $str; - - // Default is the default salt ;-) - $salt = $this->salt; - - // Is the old password set? - if (!empty($oldHash)) { - // Use the salt from hash, first get length - $length = $this->getConfigInstance()->getConfigEntry('salt_length'); - - // Then extract the X first characters from the hash as our salt - $salt = substr($oldHash, 0, $length); - } // END - if - - // Hash the password with salt - //* DEBUG: */ echo "salt=".$salt."/plain=".$str."
\n"; - if ($withFixed === TRUE) { - // Use additional fixed salt - $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_extra_mask'), - $salt, - $this->getRngInstance()->getFixedSalt(), - $str - )); - } else { - // Use salt+string to hash - $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_normal_mask'), - $salt, - $str - )); - } - - // And return it - return $hashed; - } - - /** - * Encrypt the string with fixed salt - * - * @param $str The unencrypted string - * @param $key Optional key, if none provided, a random key will be generated - * @return $encrypted Encrypted string - */ - public function encryptString ($str, $key = NULL) { - // Encrypt the string through the stream - $encrypted = $this->cryptoStreamInstance->encryptStream($str, $key); - - // Return the string - return $encrypted; - } - - /** - * Decrypt the string with fixed salt - * - * @param $encrypted Encrypted string - * @return $str The unencrypted string - */ - public function decryptString ($encrypted) { - // Encrypt the string through the stream - $str = $this->cryptoStreamInstance->decryptStream($encrypted); - - // Return the string - return $str; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/.htaccess b/inc/classes/main/database/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/database/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/database/backend/.htaccess b/inc/classes/main/database/backend/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/database/backend/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/database/backend/class_CachedLocalFileDatabase.php b/inc/classes/main/database/backend/class_CachedLocalFileDatabase.php deleted file mode 100644 index 825a70e4..00000000 --- a/inc/classes/main/database/backend/class_CachedLocalFileDatabase.php +++ /dev/null @@ -1,673 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend { - /** - * The file's extension - */ - private $fileExtension = 'serialized'; - - /** - * The last read file's name - */ - private $lastFile = ''; - - /** - * The last read file's content including header information - */ - private $lastContents = array(); - - /** - * Whether the "connection is already up - */ - private $alreadyConnected = FALSE; - - /** - * Table information array - */ - private $tableInfo = array(); - - /** - * Element for index - */ - private $indexKey = '__idx'; - - /** - * The protected constructor. Do never instance from outside! You need to - * set a local file path. The class will then validate it. - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an object of CachedLocalFileDatabase and set the save path from - * configuration for local files. - * - * @return $databaseInstance An instance of CachedLocalFileDatabase - */ - public static final function createCachedLocalFileDatabase () { - // Get an instance - $databaseInstance = new CachedLocalFileDatabase(); - - // Get a new compressor channel instance - $compressorInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class'); - - // Set the compressor channel - $databaseInstance->setCompressorChannel($compressorInstance); - - // Get a file IO handler - $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class'); - - // ... and set it - $databaseInstance->setFileIoInstance($fileIoInstance); - - // "Connect" to the database - $databaseInstance->connectToDatabase(); - - // Return database instance - return $databaseInstance; - } - - /** - * Setter for the last read file - * - * @param $fqfn The FQFN of the last read file - * @return void - */ - private final function setLastFile ($fqfn) { - // Cast string and set it - $this->lastFile = (string) $fqfn; - } - - /** - * Getter for last read file - * - * @return $lastFile The last read file's name with full path - */ - public final function getLastFile () { - return $this->lastFile; - } - - /** - * Setter for contents of the last read file - * - * @param $contents An array with header and data elements - * @return void - */ - private final function setLastFileContents (array $contents) { - // Set array - $this->lastContents = $contents; - } - - /** - * Getter for last read file's content as an array - * - * @return $lastContent The array with elements 'header' and 'data'. - */ - public final function getLastContents () { - return $this->lastContents; - } - - /** - * Getter for file extension - * - * @return $fileExtension The array with elements 'header' and 'data'. - */ - public final function getFileExtension () { - return $this->fileExtension; - } - - /** - * Getter for index key - * - * @return $indexKey Index key - */ - public final function getIndexKey () { - return $this->indexKey; - } - - /** - * Reads a local data file and returns it's contents in an array - * - * @param $fqfn The FQFN for the requested file - * @return $dataArray - */ - private function getDataArrayFromFile ($fqfn) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Reading elements from database file ' . $fqfn . ' ...'); - - // Init compressed data - $compressedData = $this->getFileIoInstance()->loadFileContents($fqfn); - $compressedData = $compressedData['data']; - - // Close the file and throw the instance away - unset($fileInstance); - - // Decompress it - $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData); - - // Unserialize it - $dataArray = json_decode($serializedData, TRUE); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.'); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, TRUE)); - - // Finally return it - return $dataArray; - } - - /** - * Writes data array to local file - * - * @param $fqfn The FQFN of the local file - * @param $dataArray An array with all the data we shall write - * @return void - */ - private function writeDataArrayToFqfn ($fqfn, array $dataArray) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...'); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, TRUE)); - - // Serialize and compress it - $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(json_encode($dataArray)); - - // Write data - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing ' . strlen($compressedData) . ' bytes ...'); - - // Write this data BASE64 encoded to the file - $this->getFileIoInstance()->saveStreamToFile($fqfn, $compressedData, $this); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.'); - } - - /** - * Getter for table information file contents or an empty if info file was not created - * - * @param $dataSetInstance An instance of a database set class - * @return $infoArray An array with all table informations - */ - private function getContentsFromTableInfoFile (StoreableCriteria $dataSetInstance) { - // Default content is no data - $infoArray = array(); - - // Create FQFN for getting the table information file - $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); - - // Get the file contents - try { - $infoArray = $this->getDataArrayFromFile($fqfn); - } catch (FileNotFoundException $e) { - // Not found, so ignore it here - } - - // ... and return it - return $infoArray; - } - - /** - * Generates an FQFN from given dataset instance and string - * - * @param $dataSetInstance An instance of a database set class - * @param $rowName Name of the row - * @return $fqfn The FQFN for this row - */ - private function generateFqfnFromDataSet (Criteria $dataSetInstance, $rowName) { - // This is the FQFN - $fqfn = $this->getConfigInstance()->getConfigEntry('local_db_path') . $dataSetInstance->getTableName() . '/' . $rowName . '.' . $this->getFileExtension(); - - // Return it - return $fqfn; - } - - /** - * Creates the table info file from given dataset instance - * - * @param $dataSetInstance An instance of a database set class - * @return void - */ - private function createTableInfoFile (StoreableCriteria $dataSetInstance) { - // Create FQFN for creating the table information file - $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); - - // Get the data out from dataset in a local array - $this->tableInfo[$dataSetInstance->getTableName()] = array( - 'primary' => $dataSetInstance->getPrimaryKey(), - 'created' => time(), - 'last_updated' => time() - ); - - // Write the data to the file - $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$dataSetInstance->getTableName()]); - } - - /** - * Updates the table info file from given dataset instance - * - * @param $dataSetInstance An instance of a database set class - * @return void - */ - private function updateTableInfoFile (StoreableCriteria $dataSetInstance) { - // Create FQFN for creating the table information file - $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); - - // Get the data out from dataset in a local array - $this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey(); - $this->tableInfo[$tableName]['last_updated'] = time(); - - // Write the data to the file - $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$dataSetInstance->getTableName()]); - } - - /** - * Updates the primary key information or creates the table info file if not found - * - * @param $dataSetInstance An instance of a database set class - * @return void - */ - private function updatePrimaryKey (StoreableCriteria $dataSetInstance) { - // "Cache" table name - $tableName = $dataSetInstance->getTableName(); - - // Get the information array from lower method - $infoArray = $this->getContentsFromTableInfoFile($dataSetInstance); - - // Is the primary key there? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableInfo=' . print_r($this->tableInfo, TRUE)); - if (!isset($this->tableInfo[$tableName]['primary'])) { - // Then create the info file - $this->createTableInfoFile($dataSetInstance); - } elseif (($this->getConfigInstance()->getConfigEntry('db_update_primary_forced') == 'Y') && ($dataSetInstance->getPrimaryKey() != $this->tableInfo[$tableName]['primary'])) { - // Set the array element - $this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey(); - - // Update the entry - $this->updateTableInfoFile($dataSetInstance); - } - } - - /** - * Makes sure that the database connection is alive - * - * @return void - * @todo Do some checks on the database directory and files here - */ - public function connectToDatabase () { - } - - /** - * Starts a SELECT query on the database by given return type, table name - * and search criteria - * - * @param $tableName Name of the database table - * @param $searchInstance Local search criteria class - * @return $resultData Result data of the query - * @throws UnsupportedCriteriaException If the criteria is unsupported - * @throws SqlException If an 'SQL error' occurs - */ - public function querySelect ($tableName, LocalSearchCriteria $searchInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableName=' . $tableName . ' - CALLED!'); - - // The result is null by any errors - $resultData = NULL; - - // Create full path name - $pathName = $this->getConfigInstance()->getConfigEntry('local_db_path') . $tableName . '/'; - - /* - * A 'select' query is not that easy on local files, so first try to - * find the 'table' which is in fact a directory on the server - */ - try { - // Get a directory pointer instance - $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName)); - - // Initialize the result data, this need to be rewritten e.g. if a local file cannot be read - $resultData = array( - BaseDatabaseBackend::RESULT_INDEX_STATUS => self::RESULT_OKAY, - BaseDatabaseBackend::RESULT_INDEX_ROWS => array() - ); - - // Initialize limit/skip - $limitFound = 0; - $skipFound = 0; - $idx = 1; - - // Read the directory with some exceptions - while (($dataFile = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',this->getFileExtension()=' . $this->getFileExtension()); - - // Does the extension match? - if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { - // Skip this file! - continue; - } // END - if - - // Read the file - $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, TRUE)); - - // Is this an array? - if (is_array($dataArray)) { - // Default is nothing found - $isFound = TRUE; - - // Search in the criteria with FMFW (First Matches, First Wins) - foreach ($dataArray as $key => $value) { - // Make sure value is not bool - assert(!is_bool($value)); - - // Found one entry? - $isFound = (($isFound === TRUE) && ($searchInstance->isCriteriaMatching($key, $value))); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: key=' . $key . ',value=' . $value . ',isFound=' . intval($isFound)); - } // END - foreach - - // Is all found? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: isFound=' . intval($isFound) . ',limitFound=' . $limitFound . ',limit=' . $searchInstance->getLimit()); - if ($isFound === TRUE) { - // Shall we skip this entry? - if ($searchInstance->getSkip() > 0) { - // We shall skip some entries - if ($skipFound < $searchInstance->getSkip()) { - // Skip this entry - $skipFound++; - break; - } // END - if - } // END - if - - // Set id number - $dataArray[$this->getIndexKey()] = $idx; - - // Entry found! - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, TRUE)); - array_push($resultData[BaseDatabaseBackend::RESULT_INDEX_ROWS], $dataArray); - - // Count found entries up - $limitFound++; - } // END - if - } else { - // Throw an exception here - throw new SqlException(array($this, sprintf('File '%s' contains invalid data.', $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY); - } - - // Count entry up - $idx++; - } // END - while - - // Close directory and throw the instance away - $directoryInstance->closeDirectory(); - unset($directoryInstance); - - // Reset last exception - $this->resetLastException(); - } catch (PathIsNoDirectoryException $e) { - // Path not found means "table not found" for real databases... - $this->setLastException($e); - - // So throw an SqlException here with faked error message - throw new SqlException (array($this, sprintf('Table '%s' not found', $tableName), self::DB_CODE_TABLE_MISSING), self::EXCEPTION_SQL_QUERY); - } catch (FrameworkException $e) { - // Catch all exceptions and store them in last error - $this->setLastException($e); - } - - // Return the gathered result - return $resultData; - } - - /** - * "Inserts" a data set instance into a local file database folder - * - * @param $dataSetInstance A storeable data set - * @return void - * @throws SqlException If an SQL error occurs - */ - public function queryInsertDataSet (StoreableCriteria $dataSetInstance) { - // Try to save the request away - try { - // Create full path name - $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, md5($dataSetInstance->getUniqueValue())); - - // Write the data away - $this->writeDataArrayToFqfn($fqfn, $dataSetInstance->getCriteriaArray()); - - // Update the primary key - $this->updatePrimaryKey($dataSetInstance); - - // Reset last exception - $this->resetLastException(); - } catch (FrameworkException $e) { - // Catch all exceptions and store them in last error - $this->setLastException($e); - - // Throw an SQL exception - throw new SqlException(array($this, sprintf('Cannot write data to table '%s', is the table created?', $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY); - } - } - - /** - * "Updates" a data set instance with a database layer - * - * @param $dataSetInstance A storeable data set - * @return void - * @throws SqlException If an SQL error occurs - */ - public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) { - // Create full path name - $pathName = $this->getConfigInstance()->getConfigEntry('local_db_path') . $dataSetInstance->getTableName() . '/'; - - // Try all the requests - try { - // Get a file pointer instance - $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName)); - - // Initialize limit/skip - $limitFound = 0; - $skipFound = 0; - - // Get the criteria array from the dataset - $searchArray = $dataSetInstance->getCriteriaArray(); - - // Get search criteria - $searchInstance = $dataSetInstance->getSearchInstance(); - - // Read the directory with some exceptions - while (($dataFile = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) { - // Does the extension match? - if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!'); - // Skip this file! - continue; - } // END - if - - // Open this file for reading - $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, TRUE)); - - // Is this an array? - if (is_array($dataArray)) { - // Default is nothing found - $isFound = TRUE; - - // Search in the criteria with FMFW (First Matches, First Wins) - foreach ($dataArray as $key => $value) { - // Make sure value is not bool - assert(!is_bool($value)); - - // Found one entry? - $isFound = (($isFound === TRUE) && ($searchInstance->isCriteriaMatching($key, $value))); - } // END - foreach - - // Is all found? - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: isFound=' . intval($isFound)); - if ($isFound === TRUE) { - // Shall we skip this entry? - if ($searchInstance->getSkip() > 0) { - // We shall skip some entries - if ($skipFound < $searchInstance->getSkip()) { - // Skip this entry - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Found entry, but skipping ...'); - $skipFound++; - break; - } // END - if - } // END - if - - // Entry found, so update it - foreach ($searchArray as $searchKey => $searchValue) { - // Make sure the value is not bool again - assert(!is_bool($searchValue)); - assert($searchKey != $this->indexKey); - - // Debug message + add/update it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: criteriaKey=' . $searchKey . ',criteriaValue=' . $searchValue); - $dataArray[$searchKey] = $searchValue; - } // END - foreach - - // Write the data to a local file - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing dataArray()=' . count($dataArray) . ' to ' . $dataFile . ' ...'); - $this->writeDataArrayToFqfn($pathName . $dataFile, $dataArray); - - // Count found entries up - $limitFound++; - } // END - if - } // END - if - } // END - while - - // Close the file pointer - $directoryInstance->closeDirectory(); - - // Update the primary key - $this->updatePrimaryKey($dataSetInstance); - - // Reset last exception - $this->resetLastException(); - } catch (FrameworkException $e) { - // Catch all exceptions and store them in last error - $this->setLastException($e); - - // Throw an SQL exception - throw new SqlException(array($this, sprintf('Cannot write data to table '%s', is the table created? Exception: %s, message:%s', $dataSetInstance->getTableName(), $e->__toString(), $e->getMessage()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY); - } - } - - /** - * Getter for primary key of specified table or if not found null will be - * returned. This must be database-specific. - * - * @param $tableName Name of the table we need the primary key from - * @return $primaryKey Primary key column of the given table - */ - public function getPrimaryKeyOfTable ($tableName) { - // Default key is null - $primaryKey = NULL; - - // Does the table information exist? - if (isset($this->tableInfo[$tableName])) { - // Then return the primary key - $primaryKey = $this->tableInfo[$tableName]['primary']; - } // END - if - - // Return the column - return $primaryKey; - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - * @todo Add more generic non-public data for removal - */ - public function removeNonPublicDataFromArray (array $data) { - // Remove '__idx' - unset($data[$this->indexKey]); - - // Return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: data[' . gettype($data) . ']='.print_r($data, TRUE)); - return $data; - } - - /** - * Counts total rows of given table - * - * @param $tableName Table name - * @return $count Total rows of given table - */ - public function countTotalRows($tableName) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableName=' . $tableName . ' - CALLED!'); - - // Create full path name - $pathName = $this->getConfigInstance()->getConfigEntry('local_db_path') . $tableName . '/'; - - // Try all the requests - try { - // Get a file pointer instance - $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName)); - - // Initialize counter - $count = 0; - - // Read the directory with some exceptions - while ($dataFile = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) { - // Does the extension match? - if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!'); - // Skip this file! - continue; - } // END - if - - // Count this row up - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - COUNTED!'); - $count++; - } // END - while - } catch (FrameworkException $e) { - // Catch all exceptions and store them in last error - $this->setLastException($e); - - // Throw an SQL exception - throw new SqlException(array($this, sprintf('Cannot count on table '%s', is the table created?', $dataSetInstance->getTableName()), self::DB_CODE_TABLE_NOT_FOUND), self::EXCEPTION_SQL_QUERY); - } - - // Return count - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableName=' . $tableName . ',count=' . $count . ' - EXIT!'); - return $count; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/class_ b/inc/classes/main/database/class_ deleted file mode 100644 index 3a967f4c..00000000 --- a/inc/classes/main/database/class_ +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class extends BaseDatabaseBackend implements DatabaseBackendInterface { - /** - * Protected constructor - * - * @return void - */ - protected function __construct($class = __CLASS__) { - // Call parent constructor - parent::__construct($class); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/class_BaseDatabaseBackend.php b/inc/classes/main/database/class_BaseDatabaseBackend.php deleted file mode 100644 index 62805655..00000000 --- a/inc/classes/main/database/class_BaseDatabaseBackend.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend { - // Constants for exceptions - const EXCEPTION_SQL_QUERY = 0x140; - - // Result array indexes - const RESULT_INDEX_ROWS = 'rows'; - const RESULT_INDEX_STATUS = 'status'; - const RESULT_INDEX_EXCEPTION = 'exception'; - - // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!) - const DB_CODE_TABLE_MISSING = 0x100; - const DB_CODE_TABLE_UNWRITEABLE = 0x101; - const DB_CODE_DATA_FILE_CORRUPT = 0x102; - - // Status results - const RESULT_OKAY = 'ok'; - - /** - * Last thrown exception or NULL if all is fine - */ - private $lastException = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for last exception - * - * @return $lastException Last thrown exception - */ - public final function getLastException () { - return $this->lastException; - } - - /** - * Setter for last exception - * - * @param $lastException Last thrown exception - * @return void - */ - public final function setLastException (FrameworkException $exceptionInstance) { - $this->lastException = $exceptionInstance; - } - - /** - * Reset the last exception instance. This should be done after a "query" - * was completed without any errors. - * - * @return void - */ - protected final function resetLastException () { - $this->lastException = NULL; - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public abstract function removeNonPublicDataFromArray (array $data); -} - -// [EOF] -?> diff --git a/inc/classes/main/database/class_BaseDatabaseResult.php b/inc/classes/main/database/class_BaseDatabaseResult.php deleted file mode 100644 index d41bdcc8..00000000 --- a/inc/classes/main/database/class_BaseDatabaseResult.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseDatabaseResult extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @return void - */ - protected function __construct($class = __CLASS__) { - // Call parent constructor - parent::__construct($class); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/class_BaseDatabaseWrapper.php b/inc/classes/main/database/class_BaseDatabaseWrapper.php deleted file mode 100644 index c2a18b86..00000000 --- a/inc/classes/main/database/class_BaseDatabaseWrapper.php +++ /dev/null @@ -1,280 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseDatabaseWrapper extends BaseFrameworkSystem { - /** - * Cache instance - */ - private $cacheInstance = NULL; - - /** - * Current table name to use - */ - private $tableName = 'unknown'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct ($class) { - // Call parent constructor - parent::__construct($class); - - // Initialize the cache instance - $this->initCacheInstance(); - } - - /** - * Initializes the cache instance with a new object - * - * @return void - */ - private final function initCacheInstance () { - // Is the cache enabled? - if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { - // Set the new instance - $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache(); - } // END - if - } - - /** - * Setter for table name - * - * @param $tableName Name of table name to set - * @return void - */ - protected final function setTableName ($tableName) { - $this->tableName = (string) $tableName; - } - - /** - * Getter for table name - * - * @return $tableName Name of table name to set - */ - protected final function getTableName () { - return $this->tableName; - } - - /** - * 'Inserts' a data set instance into a local file database folder - * - * @param $dataSetInstance A storeable data set - * @param $onlyKeys Only use these keys for a cache key - * @return void - */ - protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) { - // Default cache key is NULL - $cacheKey = NULL; - - // Is cache enabled? - if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { - // First get a key suitable for our cache and extend it with this class name - $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); - } // END - if - - // Does this key exists in cache? - if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey))) { - // Purge the cache - $this->cacheInstance->purgeOffset($cacheKey); - } // END - if - - // Handle it over to the middleware - $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance); - } - - /** - * 'Updates' a data set instance with a database layer - * - * @param $dataSetInstance A storeable data set - * @param $onlyKeys Only use these keys for a cache key - * @return void - */ - protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) { - // Init cache key - $cacheKey = NULL; - - // Is cache enabled? - if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { - // First get a key suitable for our cache and extend it with this class name - $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); - } // END - if - - // Does this key exists in cache? - if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey))) { - // Purge the cache - $this->cacheInstance->purgeOffset($cacheKey); - } // END - if - - // Handle it over to the middleware - $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); - } - - /** - * Getter for index key - * - * @return $indexKey Index key - */ - public final function getIndexKey () { - return $this->getDatabaseInstance()->getIndexKey(); - } - - /** - * Getter for last exception - * - * @return $lastException Last exception or NULL if none occured - */ - public final function getLastException () { - return $this->getDatabaseInstance()->getLastException(); - } - - /** - * Do a "select" query on the current table with the given search criteria and - * store it in cache for later usage - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $resultInstance An instance of a database result class - */ - public function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) { - // Default cache key if cache is not enabled - $cacheKey = NULL; - - // Is the cache enabled? - if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { - // First get a key suitable for our cache and extend it with this class name - $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys); - } // END - if - - // Does this key exists in cache? - if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey . ':' . print_r($this->cacheInstance->offsetGet($cacheKey), TRUE)); - - // Then use this result - $result = $this->cacheInstance->offsetGet($cacheKey); - } else { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey); - - // Now it's time to ask the database layer for this select statement - $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: result[]=' . gettype($result)); - - // Cache the result if not null - if (!is_null($result)) { - // Is cache enabled? - if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { - // A valid result has returned from the database layer - $this->cacheInstance->offsetSet($cacheKey, $result); - } // END - if - } else { - // This invalid result must be wrapped - $result = array( - BaseDatabaseBackend::RESULT_INDEX_STATUS => 'invalid', - BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => $this->getDatabaseInstance()->getLastException() - ); - } - } - - // Create an instance of a CachedDatabaseResult class with the given result - // @TODO Minor: Update above comment to e.g. BaseDatabaseResult - $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result)); - - // And return the instance - return $resultInstance; - } - - /** - * Count the numbers of rows we shall receive - * - * @param $criteriaInstance An instance of a Criteria class - * @param $onlyKeys Only use these keys for a cache key - * @return $numRows Numbers of rows of database entries - */ - public function doSelectCountByCriteria (Criteria $criteriaInstance, $onlyKeys = array()) { - // Total numbers is -1 so we can distinglish between failed and valid queries - $numRows = 0; - - // Get the result from above method - $resultInstance = $this->doSelectByCriteria($criteriaInstance, $onlyKeys); - - // Was that query fine? - if ($resultInstance->ifStatusIsOkay()) { - // Then get the number of rows - $numRows = $resultInstance->getAffectedRows(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows); - } // END - if - - // Return the result - return $numRows; - } - - /** - * Getter for primary key used in wrapped table - * - * @return $primaryKey Primary key used in wrapped table - */ - public final function getPrimaryKeyValue () { - // Get the table name and a database instance and ask for it - $primaryKey = $this->getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName()); - - // Return value - return $primaryKey; - } - - /** - * Count rows of this table - * - * @return $count Count of total rows in this table - */ - public final function countTotalRows () { - // Get the table name and a database instance and ask for it - $count = $this->getDatabaseInstance()->countTotalRows($this->getTableName()); - - // Return value - return $count; - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public function removeNonPublicDataFromArray (array $data) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling this->getDatabaseInstance()->removeNonPublicDataFromArray(data) ...'); - $data = $this->getDatabaseInstance()->removeNonPublicDataFromArray($data); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data)); - return $data; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/frontend/.htaccess b/inc/classes/main/database/frontend/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/database/frontend/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/database/frontend/class_NewsDatabaseWrapper.php b/inc/classes/main/database/frontend/class_NewsDatabaseWrapper.php deleted file mode 100644 index 328a0e29..00000000 --- a/inc/classes/main/database/frontend/class_NewsDatabaseWrapper.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Add missing own interface for public methods - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NewsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable { - // Constants for database table names - const DB_TABLE_NEWS = 'news'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createNewsDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new NewsDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_NEWS); - - // Return the instance - return $wrapperInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/frontend/class_PaymentsDatabaseWrapper.php b/inc/classes/main/database/frontend/class_PaymentsDatabaseWrapper.php deleted file mode 100644 index 6e50f07e..00000000 --- a/inc/classes/main/database/frontend/class_PaymentsDatabaseWrapper.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Add missing own interface for public methods - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PaymentsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable { - // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; - - // Constants for database table names - const DB_TABLE_PAYMENTS = 'payments'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createPaymentsDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new PaymentsDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_PAYMENTS); - - // Return the instance - return $wrapperInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/frontend/class_UserDatabaseWrapper.php b/inc/classes/main/database/frontend/class_UserDatabaseWrapper.php deleted file mode 100644 index 263a0e87..00000000 --- a/inc/classes/main/database/frontend/class_UserDatabaseWrapper.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserDatabaseWrapper extends BaseDatabaseWrapper implements ManageableAccountWrapper, Registerable { - // Constants for exceptions - const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; - - // Constants for database columns - const DB_COLUMN_USERID = 'userid'; - const DB_COLUMN_USERNAME = 'username'; - const DB_COLUMN_EMAIL = 'email'; - const DB_COLUMN_CONFIRM_HASH = 'confirm_hash'; - const DB_COLUMN_USER_STATUS = 'user_status'; - - // Constants for database table names - const DB_TABLE_USER = 'user'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createUserDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new UserDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_USER); - - // Return the instance - return $wrapperInstance; - } - - /** - * Handles inserting the registration data from a registration instance into the database - * - * @param $registrationInstance An instance of a registration class - * @return void - */ - public function insertRegistrationObject (UserRegister $registrationInstance) { - // Generate a data set for the request - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); - - // Add registration elements to the dataset - $registrationInstance->addElementsToDataSet($dataSetInstance, NULL); - - // "Insert" this request instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - } - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a Updateable database result - * @return void - * @throws NullPointerException If $updateInstance or $searchInstance is null - */ - public function doUpdateByResult (UpdateableResult $resultInstance) { - // Get the search instance from result - $searchInstance = $resultInstance->getSearchInstance(); - - // Is this null? - if (is_null($searchInstance)) { - // Get the update instance - $updateInstance = $resultInstance->getUpdateInstance(); - - // Is this null? - if (is_null($updateInstance)) { - // Throw an exception here - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get search instance from update instance - $searchInstance = $updateInstance->getSearchInstance(); - - // Is it still null? - if (is_null($searchInstance)) { - // Throw an exception here - throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - } // END - if - - // Generate a data set object - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); - - // Add seach criteria - $dataSetInstance->setSearchInstance($searchInstance); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); - - // Add all update criteria to the database set - $resultInstance->addElementsToDataSet($dataSetInstance, NULL); - - // "Update" this request with the database - $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/frontend/class_UserPointsDatabaseWrapper.php b/inc/classes/main/database/frontend/class_UserPointsDatabaseWrapper.php deleted file mode 100644 index 18eef5b9..00000000 --- a/inc/classes/main/database/frontend/class_UserPointsDatabaseWrapper.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserPointsDatabaseWrapper extends BaseDatabaseWrapper implements BookablePointsWrapper, Registerable { - /** - * Constants for database table names - */ - const DB_TABLE_USER_POINTS = 'user_points'; - - /** - * Name of the user->points column - */ - const DB_COLUMN_POINTS_UID = 'points_uid'; - - /** - * Name of the points column - */ - const DB_COLUMN_POINTS = 'points'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this database wrapper by a provided user class - * - * @return $wrapperInstance An instance of the created wrapper class - */ - public static final function createUserPointsDatabaseWrapper () { - // Get a new instance - $wrapperInstance = new UserPointsDatabaseWrapper(); - - // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_USER_POINTS); - - // Return the instance - return $wrapperInstance; - } - - /** - * Inserts the given points for the given user in the database - * - * @param $pointsInstance An instance of a user class - * @return void - */ - public function insertUserPoints (BookablePoints $pointsInstance) { - // Generate a data set for the request - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); - - // Add registration elements to the dataset - $pointsInstance->addElementsToDataSet($dataSetInstance, NULL); - - // "Insert" this request instance completely into the database - $this->queryInsertDataSet($dataSetInstance); - } - - /** - * Updates an user database entry with given result - * - * @param $resultInstance An instance of a Updateable database result - * @return void - */ - public function doUpdateByResult (UpdateableResult $resultInstance) { - // Generate a data set object - $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); - - // Add all update criteria to the database set - $resultInstance->addElementsToDataSet($dataSetInstance, NULL); - - // Add seach criteria - $dataSetInstance->setSearchInstance($resultInstance->getUpdateInstance()->getSearchInstance()); - - // Set the primary key - $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); - - // "Update" this request with the database - $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/database/result/.htaccess b/inc/classes/main/database/result/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/database/result/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/database/result/class_CachedDatabaseResult.php b/inc/classes/main/database/result/class_CachedDatabaseResult.php deleted file mode 100644 index a2e1d2cd..00000000 --- a/inc/classes/main/database/result/class_CachedDatabaseResult.php +++ /dev/null @@ -1,419 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResult, UpdateableResult, SeekableIterator { - // Exception constants - const EXCEPTION_INVALID_DATABASE_RESULT = 0x1c0; - const EXCEPTION_RESULT_UPDATE_FAILED = 0x1c1; - - /** - * Current position in array - */ - private $currentPos = -1; - - /** - * Current row - */ - private $currentRow = NULL; - - /** - * Result array - */ - private $resultArray = array(); - - /** - * Array of out-dated entries - */ - private $outDated = array(); - - /** - * Affected rows - */ - private $affectedRows = 0; - - /** - * Found value - */ - private $foundValue = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this result by a provided result array - * - * @param $resultArray The array holding the result from query - * @return $resultInstance An instance of this class - */ - public static final function createCachedDatabaseResult (array $resultArray) { - // Get a new instance - $resultInstance = new CachedDatabaseResult(); - - // Set the result array - $resultInstance->setResultArray($resultArray); - - // Set affected rows - $resultInstance->setAffectedRows(count($resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS])); - - // Return the instance - return $resultInstance; - } - - /** - * Setter for result array - * - * @param $resultArray The array holding the result from query - * @return void - */ - protected final function setResultArray (array $resultArray) { - $this->resultArray = $resultArray; - } - - /** - * Updates the current entry by given update criteria - * - * @param $updateInstance An instance of an Updateable criteria - * @return void - */ - private function updateCurrentEntryByCriteria (LocalUpdateCriteria $updateInstance) { - // Get the current entry key - $entryKey = $this->key(); - - // Now get the update criteria array and update all entries - foreach ($updateInstance->getUpdateCriteria() as $criteriaKey => $criteriaValue) { - // Update data - $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$entryKey][$criteriaKey] = $criteriaValue; - - // Mark it as out-dated - $this->outDated[$criteriaKey] = 1; - } // END - foreach - } - - /** - * "Iterator" method next() to advance to the next valid entry. This method - * does also check if result is invalid - * - * @return $nextValid Whether the next entry is valid - */ - public function next () { - // Default is not valid - $nextValid = FALSE; - - // Is the result valid? - if ($this->valid()) { - // Next entry found, so count one up and cache it - $this->currentPos++; - $this->currentRow = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos]; - $nextValid = TRUE; - } // END - if - - // Return the result - return $nextValid; - } - - /** - * Seeks for to a specified position - * - * @param $index Index to seek for - * @return void - */ - public function seek ($index) { - // Rewind to beginning - $this->rewind(); - - // Search for the entry - while (($this->currentPos < $index) && ($this->valid())) { - // Continue on - $this->next(); - } // END - while - } - - /** - * Gives back the current position or null if not found - * - * @return $current Current element to give back - */ - public function current () { - // Default is not found - $current = NULL; - - // Does the current enty exist? - if (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos])) { - // Then get it - $current = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos]; - } // END - if - - // Return the result - return $current; - } - - /** - * Checks if next() and rewind will give a valid result - * - * @return $isValid Whether the next/rewind entry is valid - */ - public function valid () { - // By default nothing is valid - $isValid = FALSE; - - // Debug message - //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] this->currentPos=' . $this->currentPos); - - // Check if all is fine ... - if (($this->ifStatusIsOkay()) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][($this->currentPos + 1)])) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][0]))) { - // All fine! - $isValid = TRUE; - } // END - if - - // Return the result - return $isValid; - } - - /** - * Returns count of entries - * - * @return $isValid Whether the next/rewind entry is valid - */ - public function count () { - // Return it - return count($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS]); - } - - /** - * Determines whether the status of the query was fine (BaseDatabaseBackend::RESULT_OKAY) - * - * @return $ifStatusOkay Whether the status of the query was okay - */ - public function ifStatusIsOkay () { - $ifStatusOkay = ((isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS])) && ($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS] === BaseDatabaseBackend::RESULT_OKAY)); - //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] ifStatusOkay=' . intval($ifStatusOkay)); - return $ifStatusOkay; - } - - /** - * Gets the current key of iteration - * - * @return $currentPos Key from iterator - */ - public function key () { - return $this->currentPos; - } - - /** - * Rewind to the beginning and clear array $currentRow - * - * @return void - */ - public function rewind () { - $this->currentPos = -1; - $this->currentRow = array(); - } - - /** - * Searches for an entry in data result and returns it - * - * @param $criteriaInstance The criteria to look inside the data set - * @return $result Found result entry - * @todo 0% done - */ - public function searchEntry (LocalSearchCriteria $criteriaInstance) { - $this->debugBackTrace('[' . '[' . __METHOD__ . ':' . __LINE__ . ']: Unfinished!'); - } - - /** - * Adds an update request to the database result for writing it to the - * database layer - * - * @param $criteriaInstance An instance of a updateable criteria - * @return void - * @throws ResultUpdateException If no result was updated - */ - public function add2UpdateQueue (LocalUpdateCriteria $criteriaInstance) { - // Rewind the pointer - $this->rewind(); - - // Get search criteria - $searchInstance = $criteriaInstance->getSearchInstance(); - - // And start looking for the result - $foundEntries = 0; - while (($this->valid()) && ($foundEntries < $searchInstance->getLimit())) { - // Get next entry - $this->next(); - $currentEntry = $this->current(); - - // Is this entry found? - if ($searchInstance->ifEntryMatches($currentEntry)) { - // Update this entry - $this->updateCurrentEntryByCriteria($criteriaInstance); - - // Count one up - $foundEntries++; - } // END - if - } // END - while - - // If no entry is found/updated throw an exception - if ($foundEntries == 0) { - // Throw an exception here - throw new ResultUpdateException($this, self::EXCEPTION_RESULT_UPDATE_FAILED); - } // END - if - - // Set affected rows - $this->setAffectedRows($foundEntries); - - // Set update instance - $this->setUpdateInstance($criteriaInstance); - } - - /** - * Setter for affected rows - * - * @param $rows Number of affected rows - * @return void - */ - public final function setAffectedRows ($rows) { - $this->affectedRows = $rows; - } - - /** - * Getter for affected rows - * - * @return $rows Number of affected rows - */ - public final function getAffectedRows () { - return $this->affectedRows; - } - - /** - * Getter for found value of previous found() call - * - * @return $foundValue Found value of previous found() call - */ - public final function getFoundValue () { - return $this->foundValue; - } - - /** - * Checks whether we have out-dated entries or not - * - * @return $needsUpdate Whether we have out-dated entries - */ - public function ifDataNeedsFlush () { - $needsUpdate = (count($this->outDated) > 0); - return $needsUpdate; - } - - /** - * Adds registration elements to a given dataset instance - * - * @param $criteriaInstance An instance of a StoreableCriteria class - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { - // Walk only through out-dated columns - foreach ($this->outDated as $key => $dummy) { - // Does this key exist? - //* DEBUG: */ echo "outDated: {$key}
\n"; - if ($this->find($key)) { - // Then update it - $criteriaInstance->addCriteria($key, $this->getFoundValue()); - } // END - if - } // END - foreach - } - - /** - * Find a key inside the result array - * - * @param $key The key we shall find - * @return $found Whether the key was found or not - */ - public function find ($key) { - // By default nothing is found - $found = FALSE; - - // Rewind the pointer - $this->rewind(); - - // Walk through all entries - while ($this->valid()) { - // Advance to next entry - $this->next(); - - // Get the whole array - $currentEntry = $this->current(); - - // Is the element there? - if (isset($currentEntry[$key])) { - // Okay, found! - $found = TRUE; - - // So "cache" it - $this->foundValue = $currentEntry[$key]; - - // And stop searching - break; - } // END - if - } // END - while - - // Return the result - return $found; - } - - /** - * Solver for result index value with call-back method - * - * @param $databaseColumn Database column where the index might be found - * @param $wrapperInstance The wrapper instance to ask for array element - * @para $callBack Call-back object for setting the index; - * 0=object instance,1=method name - * @return void - * @todo Find a caching way without modifying the result array - */ - public function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack) { - // By default nothing is found - $indexValue = 0; - - // Is the element in result itself found? - if ($this->find($databaseColumn)) { - // Use this value - $indexValue = $this->getFoundValue(); - } elseif ($this->find($wrapperInstance->getIndexKey())) { - // Use this value - $indexValue = $this->getFoundValue(); - } - - // Set the index - call_user_func_array($callBack, array($indexValue)); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/decorator/.htaccess b/inc/classes/main/decorator/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/decorator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/decorator/cache/.htaccess b/inc/classes/main/decorator/cache/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/decorator/cache/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/decorator/class_BaseDecorator.php b/inc/classes/main/decorator/class_BaseDecorator.php deleted file mode 100644 index 3ef6c49a..00000000 --- a/inc/classes/main/decorator/class_BaseDecorator.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseDecorator extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/decorator/template/.htaccess b/inc/classes/main/decorator/template/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/decorator/template/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php b/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php deleted file mode 100644 index e96a111d..00000000 --- a/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php +++ /dev/null @@ -1,445 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableTemplate { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @param $innerTemplateInstance A CompileableTemplate instance - * @return $templateInstance An instance of TemplateEngine - */ - public static final function createXmlRewriterTemplateDecorator (CompileableTemplate $innerTemplateInstance) { - // Get a new instance - $templateInstance = new XmlRewriterTemplateDecorator(); - - // Set the inner template engine - $templateInstance->setTemplateInstance($innerTemplateInstance); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Settter for variable group - * - * @param $groupName Name of variable group - * @param $add Whether add this group - * @return void - */ - public function setVariableGroup ($groupName, $add = TRUE) { - // Call the inner class' method - $this->getTemplateInstance()->setVariableGroup($groupName, $add); - } - - /** - * Adds a variable to current group - * - * @param $var Variable to set - * @param $value Value to store in variable - * @return void - */ - public function addGroupVariable ($var, $value) { - // Call the inner class' method - $this->getTemplateInstance()->addGroupVariable($var, $value); - } - - /** - * Getter for base path - * - * @return $templateBasePath The relative base path for all templates - */ - public final function getTemplateBasePath () { - // Call the inner class' method - return $this->getTemplateInstance()->getTemplateBasePath(); - } - - /** - * Getter for generic base path - * - * @return $templateBasePath The relative base path for all templates - */ - public final function getGenericBasePath () { - // Call the inner class' method - return $this->getTemplateInstance()->getGenericBasePath(); - } - - /** - * Getter for template extension - * - * @return $templateExtension The file extension for all uncompiled templates - */ - public final function getRawTemplateExtension () { - // Call the inner class' method - return $this->getTemplateInstance()->getRawTemplateExtension(); - } - - /** - * Getter for given variable group - * - * @param $variableGroup Variable group to check - * @return $varStack Found variable group - */ - public function getVarStack ($variableGroup) { - // Call the inner class' method - return $this->getTemplateInstance()->getVarStack($variableGroup); - } - - /** - * Getter for code-template extension - * - * @return $codeExtension The file extension for all code templates - */ - public final function getCodeTemplateExtension () { - // Call the inner class' method - return $this->getTemplateInstance()->getCodeTemplateExtension(); - } - - /** - * Getter for template type - * - * @return $templateType The current template's type - */ - public final function getTemplateType () { - // Call the inner class' method - return $this->getTemplateInstance()->getTemplateType(); - } - - /** - * Assign (add) a given variable with a value - * - * @param $var The variable we are looking for - * @param $value The value we want to store in the variable - * @return void - * @throws EmptyVariableException If the variable name is left empty - */ - public function assignVariable ($var, $value) { - // Call the inner class' method - $this->getTemplateInstance()->assignVariable($var, $value); - } - - /** - * Removes a given variable - * - * @param $variableName The variable we are looking for - * @param $variableGroup Name of variable group (default: 'general') - * @return void - */ - public function removeVariable ($variableName, $variableGroup = 'general') { - // Call the inner class' method - $this->getTemplateInstance()->removeVariable($variableName, $variableGroup); - } - - /** - * Load a specified HTML template into the engine - * - * @param $template The web template we shall load which is located in - * 'html' by default - * @return void - */ - public function loadHtmlTemplate ($template) { - // Call the inner class' method - $this->getTemplateInstance()->loadHtmlTemplate($template); - } - - /** - * Assign a given congfiguration variable with a value - * - * @param $variableName The configuration variable we want to assign - * @return void - */ - public function assignConfigVariable ($variableName) { - // Call the inner class' method - $this->getTemplateInstance()->assignConfigVariable($variableName); - } - - /** - * Load a specified code template into the engine - * - * @param $template The code template we shall load which is - * located in 'code' by default - * @return void - */ - public function loadCodeTemplate ($template) { - // Call the inner class' method - $this->getTemplateInstance()->loadCodeTemplate($template); - } - - /** - * Load a specified email template into the engine for later compilation - * with other code/web/email templates. - * - * @param $template The email template we shall load which is - * located in "html" by default - * @return void - */ - public function loadEmailTemplate ($template) { - // Call the inner class' method - $this->getTemplateInstance()->loadEmailTemplate($template); - } - - /** - * Compiles configuration place-holders in all variables. This 'walks' - * through the variable stack 'general'. It interprets all values from that - * variables as configuration entries after compiling them. - * - * @return void - */ - public function compileConfigInVariables () { - // Call the inner class' method - $this->getTemplateInstance()->compileConfigInVariables(); - } - - /** - * Compile all variables by inserting their respective values - * - * @return void - */ - public function compileVariables () { - // Call the inner class' method - $this->getTemplateInstance()->compileVariables(); - } - - /** - * Compile all required templates into the current loaded one - * - * @return void - */ - public function compileTemplate () { - // Call the inner class' method - $this->getTemplateInstance()->compileTemplate(); - } - - /** - * Assigns the last loaded raw template content with a given variable - * - * @param $templateName Name of the template we want to assign - * @param $variableName Name of the variable we want to assign - * @return void - */ - public function assignTemplateWithVariable ($templateName, $variableName) { - // Call the inner class' method - $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName); - } - - /** - * Transfers the content of this template engine to a given response instance - * - * @param $responseInstance An instance of a response class - * @return void - */ - public function transferToResponse (Responseable $responseInstance) { - // Call the inner class' method - $this->getTemplateInstance()->transportToResponse($responseInstance); - } - - /** - * Assigns all the application data with template variables - * - * @param $applicationInstance A manageable application instance - * @return void - */ - public function assignApplicationData (ManageableApplication $applicationInstance) { - // Call the inner class' method - $this->getTemplateInstance()->assignApplicationData($applicationInstance); - } - - /** - * "Compiles" a variable by replacing {?var?} with it's content - * - * @param $rawCode Raw code to compile - * @param $setMatchAsCode Sets $match if readVariable() returns empty result - * @return $rawCode Compile code with inserted variable value - */ - public function compileRawCode ($rawCode, $setMatchAsCode = FALSE) { - return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode); - } - - /** - * Getter for variable group array - * - * @return $variableGroups All variable groups - */ - public final function getVariableGroups () { - // Call the inner class' method - return $this->getTemplateInstance()->getVariableGroups(); - } - - /** - * Getter for raw template data - * - * @return $rawTemplateData The raw data from the template - */ - public function getRawTemplateData () { - // Call the inner class' method - return $this->getTemplateInstance()->getRawTemplateData(); - } - - /** - * Renames a variable in code and in stack - * - * @param $oldName Old name of variable - * @param $newName New name of variable - * @return void - */ - public function renameVariable ($oldName, $newName) { - // Call the inner class' method - $this->getTemplateInstance()->renameVariable($oldName, $newName); - } - - /** - * Renders the given XML content - * - * @param $content Valid XML content or if not set the current loaded raw content - * @return void - * @throws XmlParserException If an XML error was found - */ - public function renderXmlContent ($content = NULL) { - // Call the inner class' method - $this->getTemplateInstance()->renderXmlContent($content); - } - - /** - * Enables or disables language support - * - * @param $languageSupport New language support setting - * @return void - */ - public function enableLanguageSupport ($languageSupport = TRUE) { - // Call the inner class' method - $this->getTemplateInstance()->enableLanguageSupport($languageSupport); - } - - /** - * Checks whether language support is enabled - * - * @return $languageSupport Whether language support is enabled or disabled - */ - public function isLanguageSupportEnabled () { - // Call the inner class' method - return $this->getTemplateInstance()->isLanguageSupportEnabled(); - } - - /** - * Enables or disables XML compacting - * - * @param $xmlCompacting New XML compacting setting - * @return void - */ - public function enableXmlCompacting ($xmlCompacting = TRUE) { - // Call the inner class' method - $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting); - } - - /** - * Checks whether XML compacting is enabled - * - * @return $xmlCompacting Whether XML compacting is enabled or disabled - */ - public function isXmlCompactingEnabled () { - // Call the inner class' method - return $this->getTemplateInstance()->isXmlCompactingEnabled(); - } - - /** - * Handles the start element of an XML resource - * - * @param $resource XML parser resource (currently ignored) - * @param $element The element we shall handle - * @param $attributes All attributes - * @return void - * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found - */ - public function startElement ($resource, $element, array $attributes) { - // Call the inner class' method - $this->getTemplateInstance()->startElement($resource, $element, $attributes); - } - - /** - * Ends the main or sub node by sending out the gathered data - * - * @param $resource An XML resource pointer (currently ignored) - * @param $nodeName Name of the node we want to finish - * @return void - * @throws XmlNodeMismatchException If current main node mismatches the closing one - */ - public function finishElement ($resource, $nodeName) { - // Call the inner class' method - $this->getTemplateInstance()->finishElement($resource, $nodeName); - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Call the inner class' method but trim the characters before - $this->getTemplateInstance()->characterHandler($resource, trim($characters)); - } - - /** - * Removes all comments, tabs and new-line charcters to compact the content - * - * @param $uncompactedContent The uncompacted content - * @return $compactedContent The compacted content - */ - public function compactContent ($uncompactedContent) { - // Compact it ... - $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent); - - // ... and return it - return $compactedContent; - } - - /** - * Assigns a lot variables into the stack of currently loaded template. - * This method should only be used in very rare circumstances, e.g. when - * you have to copy a whole set of variables into the template engine. - * Before you use this method, please make sure you have considered all - * other possiblities. - * - * @param $variables An array with variables to be assigned - * @return void - */ - public function assignMultipleVariables (array $variables) { - // Call the inner class' method but trim the characters before - $this->getTemplateInstance()->assignMultipleVariables($variables); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/decorator/xml/.htaccess b/inc/classes/main/decorator/xml/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/decorator/xml/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/decorator/xml/class_XmlCompactorDecorator.php b/inc/classes/main/decorator/xml/class_XmlCompactorDecorator.php deleted file mode 100644 index 8d7eea8e..00000000 --- a/inc/classes/main/decorator/xml/class_XmlCompactorDecorator.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlCompactorDecorator extends BaseDecorator implements Parseable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class Parser and prepares it for usage - * - * @param $innerParserInstance A Parseable instance - * @return $parserInstance An instance of this parser - */ - public static final function createXmlCompactorDecorator (Parseable $innerParserInstance) { - // Get a new instance - $parserInstance = new XmlCompactorDecorator(); - - // Get a new decorator instance for the template engine - $templateInstance = ObjectFactory::createObjectByConfiguredName('deco_xml_rewriter_template_class', array($innerParserInstance->getTemplateInstance())); - - // Re-set the parser's template instance to the decorator instance - $innerParserInstance->setTemplateInstance($templateInstance); - - // Set the inner parser instance - $parserInstance->setParserInstance($innerParserInstance); - - // Return the prepared instance - return $parserInstance; - } - - /** - * Parses the given XML content - * - * @param $content Valid XML content - * @return void - * @throws XmlCompactorDecoratorException If an XML error was found - */ - public function parseXmlContent ($content) { - // Remove all comments for better compacting - $content = $this->getParserInstance()->getTemplateInstance()->compactContent($content); - - // Parse the content - $this->getParserInstance()->parseXmlContent($content); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/discovery/.htaccess b/inc/classes/main/discovery/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/discovery/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/discovery/class_ b/inc/classes/main/discovery/class_ deleted file mode 100644 index 0bc50eb8..00000000 --- a/inc/classes/main/discovery/class_ +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Discovery extends BaseDiscovery implements Discoverable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @return $discoveryInstance An instance of this discovery class - */ - public final static function create???Discovery () { - // Get an instance of this class - $discoveryInstance = new ???Discovery(); - - // Return the prepared instance - return $discoveryInstance; - } - - /** - * Discovers the request - * - * @param $requestInstance An instance of a Requestable class - * @return void - * @todo 0% done - */ - public function discover (Requestable $requestInstance) { - $this->partialStub("Please implement this method."); - } - - /** - * Adds the database result in a human-readable format to the helper class - * - * @param $helperInstance An instance of a helper class - * @return void - * @todo 0% done - */ - public function addResultsToHelper (HelpableTemplate $helperInstance) { - $this->partialStub("Please implement this method."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/discovery/class_BaseDiscovery.php b/inc/classes/main/discovery/class_BaseDiscovery.php deleted file mode 100644 index 0ec5f465..00000000 --- a/inc/classes/main/discovery/class_BaseDiscovery.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseDiscovery extends BaseFrameworkSystem { - /** - * Action name for payment discovery - */ - private $actionName = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Protected setter for action name - * - * @param $actionName Action name to set - * @return void - */ - protected final function setActionName ($actionName) { - $this->actionName = (string) $actionName; - } - - /** - * Private getter for action name - * - * @return $actionName Action name to set - */ - protected final function getActionName () { - return $this->actionName; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/discovery/payment/.htaccess b/inc/classes/main/discovery/payment/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/discovery/payment/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php b/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php deleted file mode 100644 index 9785bef4..00000000 --- a/inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create an instance of this class - * - * @param $filterInstance An instance of a filter - * @return $discoveryInstance An instance of this discovery class - */ - public static final function createLocalPaymentDiscovery (Filterable $filterInstance) { - // Get an instance of this class - $discoveryInstance = new LocalPaymentDiscovery(); - - // Set the action from filter - $discoveryInstance->setActionName($filterInstance->getActionName()); - - // Return the prepared instance - return $discoveryInstance; - } - - /** - * Discovers the request - * - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public function discover (Requestable $requestInstance) { - // Now get a search criteria and set app name and payment action as search critera - $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - $criteriaInstance->addCriteria('app_name', $requestInstance->getRequestElement('app')); - $criteriaInstance->addCriteria('payment_action', $this->getActionName() . '_action'); - $criteriaInstance->setLimit(1); - - // Get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('payment_db_wrapper_class'); - - // Get result back - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); - - // Advanced to next entry and assert on it as it should always be there - assert($resultInstance->valid()); - - // Set the result instance - $this->setResultInstance($resultInstance); - } - - /** - * Adds the database result in a human-readable format to the helper class - * - * @param $helperInstance An instance of a helper class - * @return void - * @todo 0% done - */ - public function addResultsToHelper (HelpableTemplate $helperInstance) { - // Undone part - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/.htaccess b/inc/classes/main/factories/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/cache/.htaccess b/inc/classes/main/factories/cache/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/cache/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/cache/class_CacheFactory.php b/inc/classes/main/factories/cache/class_CacheFactory.php deleted file mode 100644 index 06016528..00000000 --- a/inc/classes/main/factories/cache/class_CacheFactory.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CacheFactory extends BaseFactory { - /** - * Singleton instance - */ - private static $selfInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Singleton getter for this class - * - * @return $selfInstance An instance of this class - */ - public static final function getFactory () { - // Is the instance null? - if (is_null(self::$selfInstance)) { - // Set a new one - self::$selfInstance = new CacheFactory(); - } // END - if - - // Return the instance - return self::$selfInstance; - } - - /** - * Creates a configured cache instance - * - * @return $cacheInstance An instance of the configured cache - */ - public function createConfiguredCache () { - // Read the config entry - $cacheType = $this->getConfigInstance()->getConfigEntry('cache_class'); - - // And get a new instance - $cacheInstance = ObjectFactory::createObjectByName($cacheType); - - // Return the instance - return $cacheInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/class_ b/inc/classes/main/factories/class_ deleted file mode 100644 index d05b8441..00000000 --- a/inc/classes/main/factories/class_ +++ /dev/null @@ -1,37 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Factory extends BaseFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/class_BaseFactory.php b/inc/classes/main/factories/class_BaseFactory.php deleted file mode 100644 index 4d5d274b..00000000 --- a/inc/classes/main/factories/class_BaseFactory.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseFactory extends BaseFrameworkSystem { - /** - * Total objects generated - */ - private static $total = 0; - - /** - * Counter of all objects - */ - private static $objectCounters = array(); - - /** - * Protected constructor - * - * @param $className Name of the real class (not BaseFactory) - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Count given object - * - * @param $className Name of the class we shall count - */ - protected static final function countObject ($className) { - // Count it up in total sum - self::$total++; - - // Do we have an entry? - if (!isset(self::$objectCounters[$className])) { - // No, then generate one - self::$objectCounters[$className] = 0; - } // END - if - - // Count it up again - //* NOISY-DEBUG: */ print __METHOD__.': className=' .$className . PHP_EOL; - self::$objectCounters[$className]++; - } - - /** - * Static getter for total object count - * - * @return $total Total amount of generated objects - */ - public static final function getTotal () { - return self::$total; - } - - /** - * Static getter for all object counters - * - * @return $objectCounters An array with all object counters - */ - public static final function getAllCounters () { - return self::$objectCounters; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/client/.htaccess b/inc/classes/main/factories/client/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/client/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/client/class_ClientFactory.php b/inc/classes/main/factories/client/class_ClientFactory.php deleted file mode 100644 index 113a9e25..00000000 --- a/inc/classes/main/factories/client/class_ClientFactory.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ClientFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates a client object for given protocol. This method uses the - * registry pattern to cache those instances. - * - * @param $protocolInstance An instance of a HandleableProtocol class to create a client object for (e.g. 'http' for a HTTP/1.1 client) - * @param $socketResource A valid socket resource (optional) - * @return $clientInstance An instance of the requested client - */ - public static final function createClientByProtocolInstance (HandleableProtocol $protocolInstance, $socketResource = FALSE) { - // Default is NULL (to initialize variable) - $clientInstance = NULL; - - // Generate registry key - $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client'; - - // Is the key already in registry? - if (Registry::getRegistry()->instanceExists($registryKey)) { - // Then use that instance - $clientInstance = Registry::getRegistry()->getInstance($registryKey); - - // Set socket resource - $clientInstance->setSocketResource($socketResource); - } else { - // Generate object instance - $clientInstance = self::createObjectByConfiguredName($registryKey, array($socketResource)); - - // Set it in registry for later re-use - Registry::getRegistry()->addInstance($registryKey, $clientInstance); - } - - // Return the prepared instance - return $clientInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/database/.htaccess b/inc/classes/main/factories/database/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/database/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/database/class_DatabaseWrapperFactory.php b/inc/classes/main/factories/database/class_DatabaseWrapperFactory.php deleted file mode 100644 index 5ecdea49..00000000 --- a/inc/classes/main/factories/database/class_DatabaseWrapperFactory.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DatabaseWrapperFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton socket registry instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $wrapperInstance A database wrapper instance - */ - public static final function createWrapperByConfiguredName ($wrapperName) { - // Get registry instance - $registryInstance = Registry::getRegistry(); - - // Do we have an instance in the registry? - if ($registryInstance->instanceExists($wrapperName)) { - // Then use this instance - $wrapperInstance = $registryInstance->getInstance($wrapperName); - } else { - // Get the registry instance - $wrapperInstance = self::createObjectByConfiguredName($wrapperName); - - // Set the instance in registry for further use - $registryInstance->addInstance($wrapperName, $wrapperInstance); - } - - // Return the instance - return $wrapperInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/html/.htaccess b/inc/classes/main/factories/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/html/class_HtmlNewsFactory.php b/inc/classes/main/factories/html/class_HtmlNewsFactory.php deleted file mode 100644 index 135409de..00000000 --- a/inc/classes/main/factories/html/class_HtmlNewsFactory.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlNewsFactory extends BaseFactory { - /** - * Instance of a request class - */ - private $requestInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Singleton getter for a special factory instance depending on the given - * request - * - * @param $requestInstance An instance of a request class - * @return $factoryInstance An instance of a HtmlNewsFactory class - */ - public static final function createFactoryByRequest (Requestable $requestInstance) { - // Set default news reader class - $configEntry = 'news_reader_class'; - - // Get "page" - $command = $requestInstance->getRequestElement('command'); - - // Is 'command' used? - if (!empty($command)) { - // Then add it - $configEntry = sprintf('news_reader_%s_class', $command); - - // Get 'action' - $action = $requestInstance->getRequestElement('action'); - - // Is it also there? - if (!empty($action)) { - // Then use both for config entry - $configEntry = sprintf('news_reader_%s_%s_class', $command, $action); - } // END - if - } // END - if - - // Get the news reader class name from config - $className = $requestInstance->getConfigInstance()->getConfigEntry($configEntry); - - // Once we have that name, try to load initialize it - $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); - - // Initialize the reader - $newsInstance->initializeReader(); - - // Return the prepared factory instance - return $newsInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/index/.htaccess b/inc/classes/main/factories/index/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/index/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/index/class_FileStackIndexFactory.php b/inc/classes/main/factories/index/class_FileStackIndexFactory.php deleted file mode 100644 index 7a9f23b0..00000000 --- a/inc/classes/main/factories/index/class_FileStackIndexFactory.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileStackIndexFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) StackableFile instance - * - * @param $stackName Name of the stack's file - * @return $indexInstance An instance of a IndexableStack class - */ - public static final function createFileStackIndexInstance ($fileName, $type) { - // If there is no handler? - if (Registry::getRegistry()->instanceExists($type . '_index')) { - // Get handler from registry - $indexInstance = Registry::getRegistry()->getInstance($type . '_index'); - } else { - // Get the handler instance - $indexInstance = self::createObjectByConfiguredName($type . '_file_stack_index_class', array($fileName)); - - // Add check for interface - assert($indexInstance instanceof IndexableStack); - - // Add it to the registry - Registry::getRegistry()->addInstance($type . '_index', $indexInstance); - } - - // Return the instance - return $indexInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/logger/.htaccess b/inc/classes/main/factories/logger/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/logger/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/logger/class_LoggerFactory.php b/inc/classes/main/factories/logger/class_LoggerFactory.php deleted file mode 100644 index 202f23d0..00000000 --- a/inc/classes/main/factories/logger/class_LoggerFactory.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LoggerFactory extends BaseFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates a logger instance for given FrameworkInterface. This allows every - * class that implements FrameworkInterface to have an own logger. Surely - * this factory and the logger itself cannot have an own logger as this would - * lead to an endless loop: Get factory instance, get a logger for the factory - * instance which ivokes the factory's method again. - * - * @param $objectInstance An instance of a FrameworkInterface class - * @return $loggerInstance An instance of a Logger class - */ - public static final function createLoggerInstance (FrameworkInterface $objectInstance) { - // @TODO Unfinished work - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/login/.htaccess b/inc/classes/main/factories/login/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/login/class_LoginFactory.php b/inc/classes/main/factories/login/class_LoginFactory.php deleted file mode 100644 index 3faf50eb..00000000 --- a/inc/classes/main/factories/login/class_LoginFactory.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LoginFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton login instance for given request instance. - * - * @param $requestInstance An instance of a Requestable class - * @return $loginInstance An instance of a login helper (@TODO Use actual interface name) - */ - public static final function createLoginObjectByRequest (Requestable $requestInstance) { - // Get registry instance - $registryInstance = Registry::getRegistry(); - - // Do we have an instance in the registry? - if ($registryInstance->instanceExists('login_helper')) { - // Then use this instance - $loginInstance = $registryInstance->getInstance('login_helper'); - } else { - // Probe on member instance - try { - // Try to instance member login class - $loginInstance = self::createObjectByConfiguredName('user_login_class'); - - // Test login - $loginInstance->testLogin($requestInstance); - } catch (UnexpectedGuestAccountException $e) { - // Then try guest login - $loginInstance = self::createObjectByConfiguredName('guest_login_class'); - - // Test login again - $loginInstance->testLogin($requestInstance); - } - - // Set the instance in registry for further use - $registryInstance->addInstance('login_helper', $loginInstance); - } - - // Return the instance - return $loginInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/objects/.htaccess b/inc/classes/main/factories/objects/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/objects/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/objects/class_ObjectFactory.php b/inc/classes/main/factories/objects/class_ObjectFactory.php deleted file mode 100644 index 718b9403..00000000 --- a/inc/classes/main/factories/objects/class_ObjectFactory.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ObjectFactory extends BaseFactory { - /** - * Protected constructor - * - * @param $className Name of this class - * @return void - */ - protected function __construct ($className = __CLASS__) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Creates a new object given by the name or throws an exception if - * the class was not found. No parameters for the object are currently - * supported. - * - * @param $className Name of the class we shall construct - * @param $args Arguments in an indexed array - * @return $objectInstance An instance of the requested object - * @throws NoClassException If the requested class was not found - * @throws EmptyVariableException If a variable is empty unexpectly - */ - public static final function createObjectByName ($className, array $args=array()) { - // First get an instance of this factory - $factoryInstance = new ObjectFactory(); - - // Is the class name valid and is the class there? - if (empty($className)) { - // Throw an exception here - throw new EmptyVariableException(array($factoryInstance, 'className'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!class_exists($className)) { - // Then throw an exception - throw new NoClassException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND); - } - - // Create method name - $methodName = sprintf('create%s', $className); - - // Run the user function - $objectInstance = call_user_func_array(array($className, $methodName), $args); - - // Count this one up - self::countObject($className); - - // Return the prepared instance - return $objectInstance; - } - - /** - * Creates an object by it's configured name - * - * @param $configEnttry Configuration entry to read - * @param $args Arguments in an indexed array - * @return $objectInstance An instance of the requested object - */ - public static final function createObjectByConfiguredName ($configEntry, array $args=array()) { - // Read the configuration entry - $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($configEntry); - - // Send this to the other factory... - $objectInstance = self::createObjectByName($className, $args); - - // Return the instance - return $objectInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/registry/.htaccess b/inc/classes/main/factories/registry/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/registry/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/registry/class_SocketRegistryFactory.php b/inc/classes/main/factories/registry/class_SocketRegistryFactory.php deleted file mode 100644 index 4d2c1dad..00000000 --- a/inc/classes/main/factories/registry/class_SocketRegistryFactory.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SocketRegistryFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton socket registry instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @return $registryInstance A socket registry instance - */ - public static final function createSocketRegistryInstance () { - // Get registry instance - $registryInstance = Registry::getRegistry(); - - // Do we have an instance in the registry? - if ($registryInstance->instanceExists('socket_registry')) { - // Then use this instance - $registryInstance = $registryInstance->getInstance('socket_registry'); - } else { - // Get the registry instance - $registryInstance = ObjectFactory::createObjectByConfiguredName('socket_registry_class'); - - // Set the instance in registry for further use - $registryInstance->addInstance('socket_registry', $registryInstance); - } - - // Return the instance - return $registryInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/stacks/.htaccess b/inc/classes/main/factories/stacks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/stacks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/stacks/class_FileStackFactory.php b/inc/classes/main/factories/stacks/class_FileStackFactory.php deleted file mode 100644 index 81aea448..00000000 --- a/inc/classes/main/factories/stacks/class_FileStackFactory.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileStackFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton (registry-based) StackableFile instance - * - * @param $prefix Class prefix - * @param $stackName Name of the stack - * @return $stackInstance An instance of a StackableFile class - */ - public static final function createFileStackInstance ($prefix, $stackName) { - // Construct file stack name - $stackFileName = sprintf('%s%s/%s.%s', - FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path'), - FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_file_stacks_path'), - $stackName, - FrameworkConfiguration::getSelfInstance()->getConfigEntry('file_stacks_extension') - ); - - // If there is no handler? - if (Registry::getRegistry()->instanceExists($stackName . '_stack')) { - // Get handler from registry - $stackInstance = Registry::getRegistry()->getInstance($stackName . '_stack'); - } else { - // Get the handler instance - $stackInstance = self::createObjectByConfiguredName($prefix . '_' . $stackName . '_stack_class', array($stackFileName, $prefix . '_' . $stackName)); - - // Add it to the registry - Registry::getRegistry()->addInstance($stackName . '_stack', $stackInstance); - } - - // Return the instance - return $stackInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/user/.htaccess b/inc/classes/main/factories/user/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/user/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/user/class_UserFactory.php b/inc/classes/main/factories/user/class_UserFactory.php deleted file mode 100644 index 929038dc..00000000 --- a/inc/classes/main/factories/user/class_UserFactory.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton user instance for given request instance. - * - * @param $requestInstance An instance of a Requestable class - * @return $userInstance An instance of a user class (@TODO use actual interface name) - */ - public static final function createUserByRequest (Requestable $requestInstance) { - // Get registry instance - $registryInstance = Registry::getRegistry(); - - // Do we have an instance in the registry? - if ($registryInstance->instanceExists('user')) { - // Then use this instance - $userInstance = $registryInstance->getInstance('user'); - } else { - // Probe on member instance - try { - // Get class name - $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry('user_class'); - - // Try to instance it - $userInstance = call_user_func_array(array($className, 'createMemberByRequest'), array($requestInstance)); - } catch (UnexpectedGuestAccountException $e) { - // Then try it with guest account - $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry('guest_class'); - - // Try to instance it - $userInstance = call_user_func_array(array($className, 'createGuestByRequest'), array($requestInstance)); - } - - // Set the instance in registry for further use - $registryInstance->addInstance('user', $userInstance); - } - - // Return the instance - return $userInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/factories/xml/.htaccess b/inc/classes/main/factories/xml/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/factories/xml/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/factories/xml/class_XmlTemplateEngineFactory.php b/inc/classes/main/factories/xml/class_XmlTemplateEngineFactory.php deleted file mode 100644 index 7c1e2008..00000000 --- a/inc/classes/main/factories/xml/class_XmlTemplateEngineFactory.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlTemplateEngineFactory extends ObjectFactory { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Returns a singleton network package instance. If an instance is found in - * the registry it will be returned, else a new instance is created and - * stored in the same registry entry. - * - * @param $configEntry Config entry name for the template engine - * @return $templateInstance A template engine instance - */ - public static final function createXmlTemplateEngineInstance ($configEntry) { - // Do we have an instance in the registry? - if (Registry::getRegistry()->instanceExists($configEntry)) { - // Then use this instance - $templateInstance = Registry::getRegistry()->getInstance($configEntry); - } else { - // Now prepare the tags instance - $templateInstance = ObjectFactory::createObjectByConfiguredName($configEntry); - - // Disable language support - $templateInstance->enableLanguageSupport(FALSE); - - /* - * Enable compacting/rewriting of the XML to save bandwidth from XML - * comments. This is expensive and should be avoided in general. - */ - $templateInstance->enableXmlCompacting(); - - // Set the instance in registry for further use - Registry::getRegistry()->addInstance($configEntry, $templateInstance); - } - - // Return the instance - return $templateInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/feature/.htaccess b/inc/classes/main/feature/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/feature/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/feature/class_ b/inc/classes/main/feature/class_ deleted file mode 100644 index d1cb3a69..00000000 --- a/inc/classes/main/feature/class_ +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Feature extends BaseFeature implements Feature { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Feature class and prepares it for usage - * - * @return $featureInstance An instance of this Feature class - */ - public final static function create???Feature () { - // Get a new instance - $featureInstance = new ???Feature(); - - // Return the prepared instance - return $featureInstance; - } - - /** - * Checks whether this feature can be made available to other classes. - * - * @return $isAvailable Whether this feature is available - * @todo 0% done - */ - public function isFeatureAvailable () { - // Default is not available - $isAvailable = FALSE; - - // Unfinished: - $this->partialSub('Please implement this method.'); - - // Return status - return $isAvailable; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/feature/class_BaseFeature.php b/inc/classes/main/feature/class_BaseFeature.php deleted file mode 100644 index 11870cff..00000000 --- a/inc/classes/main/feature/class_BaseFeature.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseFeature extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/feature/class_FrameworkFeature.php b/inc/classes/main/feature/class_FrameworkFeature.php deleted file mode 100644 index 4c16afe6..00000000 --- a/inc/classes/main/feature/class_FrameworkFeature.php +++ /dev/null @@ -1,170 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkFeature extends BaseFrameworkSystem { - // Exception code constants - const EXCEPTION_FEATURE_METHOD_NOT_CALLABLE = 0x400; - - /** - * "Cache" for enabled, available feature instances - * - * A typical available entry looks like this: - * - * array( - * 'is_enabled' => TRUE, - * 'is_available' => TRUE, - * 'instance' => SomeFeature Object - * ) - * - * And a typical disabled entry looks like this: - * - * array( - * 'is_enabled' => FALSE, - * 'is_available' => FALSE, - * 'instance' => NULL - * ) - */ - private static $enabledFeatures = array(); - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Checks whether the given feature is enabled in configuration. The user - * shall be able to disable features, even when they *could* be available. - * - * @param $featureName Name of the feature to be checked - * @return $isEnabled Whether the given feature is enabled - */ - public static function isFeatureEnabled ($featureName) { - // Is the cache set? - if (!isset(self::$enabledFeatures[$featureName]['is_enabled'])) { - // Generate config key - $configKey = sprintf('enable_feature_%s', $featureName); - - // Check configuration - self::$enabledFeatures[$featureName]['is_enabled'] = (FrameworkConfiguration::getSelfInstance()->getConfigEntry($configKey) === 'Y'); - } // END - if - - // Return "cached" status - return self::$enabledFeatures[$featureName]['is_enabled']; - } - - /** - * Checks whether the given feature is enabled and available. It may be - * enabled by the user, but is not available due to e.g. a missing PECL - * extension or whatever is needed to have this feature available. If you - * don't write a pre filters for checking PHP requirements, this is the - * method you want to use. - * - * @param $featureName Name of the feature to be checked on availability - * @return $isAvailable Whether the given feature is available - */ - public static function isFeatureAvailable ($featureName) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: featureName=%s - CALLED!', __METHOD__, __LINE__, $featureName)); - - // Is the cache set? - if (!isset(self::$enabledFeatures[$featureName]['is_available'])) { - // Default is not available - self::$enabledFeatures[$featureName]['is_available'] = FALSE; - self::$enabledFeatures[$featureName]['instance'] = NULL; - - // Is the feature enabled? - if (!self::isFeatureEnabled($featureName)) { - // Then it can't be available - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Feature "%s"is not enabled.', __METHOD__, __LINE__, $featureName)); - return FALSE; - } // END - if - - // Create config key (for feature class lookup) - $configKey = sprintf('feature_%s_class', $featureName); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: configKey=%s', __METHOD__, __LINE__, $configKey)); - - // Now try to get the instance - try { - // Try to get an instance - self::$enabledFeatures[$featureName]['instance'] = ObjectFactory::createObjectByConfiguredName($configKey); - - // Now let the feature test itself's availability - self::$enabledFeatures[$featureName]['is_available'] = self::$enabledFeatures[$featureName]['instance']->isFeatureAvailable(); - } catch (NoClassException $e) { - // Feature class not found - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Feature "%s"is not available due to missing feature class. Disabling feature ...', __METHOD__, __LINE__, $featureName)); - } - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: featureName=%s,isAvailable=%d - EXIT!', __METHOD__, __LINE__, $featureName, intval(self::$enabledFeatures[$featureName]['is_available']))); - - // Return "cached" status - return self::$enabledFeatures[$featureName]['is_available']; - } - - /** - * Calls the feature's method and handles some arguments (if not given, - * NULL) to it. Any returned value is being forwarded to the caller, even - * when the doc-tag says 'void' as returned value. - * - * @param $featureName Name of the feature, it must be available at this point - * @param $featureMethod Method name of the feature's class - * @param $args Any arguments that should be handled over - * @return $return Anything the feature's method has returned - * @throws FeatureMethodNotCallableException If the requested method cannot be called - */ - public static function callFeature ($featureName, $featureMethod, array $args = NULL) { - /* - * Please make sure that isFeatureAvailable() has been called and it has - * returned TRUE before calling this method. - */ - assert(self::isFeatureAvailable($featureName)); - - // Array for call-back - $callable = array(self::$enabledFeatures[$featureName]['instance'], 'featureMethod' . self::convertToClassName($featureMethod)); - - // So is the feature's method callable? - if (!is_callable($callable)) { - // Not callable method requested - throw new FeatureMethodNotCallableException(array(self::$enabledFeatures[$featureName]['instance'], $featureMethod), self::EXCEPTION_FEATURE_METHOD_NOT_CALLABLE); - } // END - if - - // Then call it - $return = call_user_func_array($callable, $args); - - // Return any returned value - return $return; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/.htaccess b/inc/classes/main/file_directories/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/binary/.htaccess b/inc/classes/main/file_directories/binary/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/binary/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/binary/class_BaseBinaryFile.php b/inc/classes/main/file_directories/binary/class_BaseBinaryFile.php deleted file mode 100644 index e4c3aeb5..00000000 --- a/inc/classes/main/file_directories/binary/class_BaseBinaryFile.php +++ /dev/null @@ -1,854 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseBinaryFile extends BaseAbstractFile { - /** - * Separator for header data - */ - const SEPARATOR_HEADER_DATA = 0x01; - - /** - * Separator header->entries - */ - const SEPARATOR_HEADER_ENTRIES = 0x02; - - /** - * Separator group->hash - */ - const SEPARATOR_GROUP_HASH = 0x03; - - /** - * Separator hash->value - */ - const SEPARATOR_HASH_VALUE = 0x04; - - /** - * Separator entry->entry - */ - const SEPARATOR_ENTRIES = 0x05; - - /** - * Separator type->position - */ - const SEPARATOR_TYPE_POSITION = 0x06; - - /** - * Length of count - */ - const LENGTH_COUNT = 20; - - /** - * Length of position - */ - const LENGTH_POSITION = 20; - - /** - * Length of group - */ - const LENGTH_GROUP = 10; - - /** - * Maximum length of entry type - */ - const LENGTH_TYPE = 20; - - //***** Array elements for 'gaps' array ***** - - /** - * Start of gap - */ - const GAPS_INDEX_START = 'start'; - - /** - * End of gap - */ - const GAPS_INDEX_END = 'end'; - - /** - * Current seek position - */ - private $seekPosition = 0; - - /** - * Size of header - */ - private $headerSize = 0; - - /** - * File header - */ - private $header = array(); - - /** - * Seek positions for gaps ("fragmentation") - */ - private $gaps = array(); - - /** - * Seek positions for damaged entries (e.g. mismatching hash sum, ...) - */ - private $damagedEntries = array(); - - /** - * Back-buffer - */ - private $backBuffer = ''; - - /** - * Currently loaded block (will be returned by current()) - */ - private $currentBlock = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init counters and gaps array - $this->initCountersGapsArray(); - } - - /** - * Checks whether the abstracted file only contains gaps by counting all - * gaps' bytes together and compare it to total length. - * - * @return $isGapsOnly Whether the abstracted file only contains gaps - */ - private function isFileOnlyGaps () { - // First/last gap found? - /* Only for debugging - if (isset($this->gaps[0])) { - // Output first and last gap - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] this->gaps[0]=%s,this->gaps[%s]=%s', __METHOD__, __LINE__, print_r($this->gaps[0], TRUE), (count($this->gaps) - 1), print_r($this->gaps[count($this->gaps) - 1], TRUE))); - } // END - if - */ - - // Now count every gap - $gapsSize = 0; - foreach ($this->gaps as $gap) { - // Calculate size of found gap: end-start including both - $gapsSize += ($gap[self::GAPS_INDEX_END] - $gap[self::GAPS_INDEX_START]); - } // END - if - - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] gapsSize=%s,this->headerSize=%s', __METHOD__, __LINE__, $gapsSize, $this->getHeaderSize())); - - // Total gap size + header size must be same as file size - $isGapsOnly = (($this->getHeaderSize() + $gapsSize) == $this->getFileSize()); - - // Return status - return $isGapsOnly; - } - - /** - * Initializes counter for valid entries, arrays for damaged entries and - * an array for gap seek positions. If you call this method on your own, - * please re-analyze the file structure. So you are better to call - * analyzeFile() instead of this method. - * - * @return void - */ - public function initCountersGapsArray () { - // Init counter and seek position - $this->setCounter(0); - $this->setSeekPosition(0); - - // Init arrays - $this->gaps = array(); - $this->damagedEntries = array(); - } - - /** - * Getter for header size - * - * @return $totalEntries Size of file header - */ - public final function getHeaderSize () { - // Get it - return $this->headerSize; - } - - /** - * Setter for header size - * - * @param $headerSize Size of file header - * @return void - */ - public final function setHeaderSize ($headerSize) { - // Set it - $this->headerSize = $headerSize; - } - - /** - * Getter for header array - * - * @return $totalEntries Size of file header - */ - public final function getHeader () { - // Get it - return $this->header; - } - - /** - * Setter for header - * - * @param $header Array for a file header - * @return void - */ - public final function setHeader (array $header) { - // Set it - $this->header = $header; - } - - /** - * Getter for seek position - * - * @return $seekPosition Current seek position (stored here in object) - */ - public final function getSeekPosition () { - // Get it - return $this->seekPosition; - } - - /** - * Setter for seek position - * - * @param $seekPosition Current seek position (stored here in object) - * @return void - */ - protected final function setSeekPosition ($seekPosition) { - // And set it - $this->seekPosition = $seekPosition; - } - - /** - * Updates seekPosition attribute from file to avoid to much access on file. - * - * @return void - */ - public function updateSeekPosition () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Get key (= seek position) - $seekPosition = $this->key(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Setting seekPosition=%s', __METHOD__, __LINE__, $seekPosition)); - - // And set it here - $this->setSeekPosition($seekPosition); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Seeks to beginning of file, updates seek position in this object and - * flushes the header. - * - * @return void - */ - protected function rewindUpdateSeekPosition () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // flushFileHeader must be callable - assert(is_callable(array($this, 'flushFileHeader'))); - - // Seek to beginning of file - $this->rewind(); - - // And update seek position ... - $this->updateSeekPosition(); - - // ... to write it back into the file - $this->flushFileHeader(); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Seeks to old position - * - * @return void - */ - protected function seekToOldPosition () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Seek to currently ("old") saved position - $this->seek($this->getSeekPosition()); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Checks whether the block separator has been found - * - * @param $str String to look in - * @return $isFound Whether the block separator has been found - */ - public static function isBlockSeparatorFound ($str) { - // Determine it - $isFound = (strpos($str, chr(self::SEPARATOR_ENTRIES)) !== FALSE); - - // Return result - return $isFound; - } - - /** - * Initializes the back-buffer by setting it to an empty string. - * - * @return void - */ - private function initBackBuffer () { - // Simply call the setter - $this->setBackBuffer(''); - } - - /** - * Setter for backBuffer field - * - * @param $backBuffer Characters to "store" in back-buffer - * @return void - */ - private function setBackBuffer ($backBuffer) { - // Cast to string (so no arrays or objects) - $backBuffer = (string) $backBuffer; - - // ... and set it - $this->backBuffer = $backBuffer; - } - - /** - * Getter for backBuffer field - * - * @return $backBuffer Characters "stored" in back-buffer - */ - private function getBackBuffer () { - return $this->backBuffer; - } - - /** - * Setter for currentBlock field - * - * @param $currentBlock Characters to set a currently loaded block - * @return void - */ - private function setCurrentBlock ($currentBlock) { - // Cast to string (so no arrays or objects) - $currentBlock = (string) $currentBlock; - - // ... and set it - $this->currentBlock = $currentBlock; - } - - /** - * Gets currently read data - * - * @return $current Currently read data - */ - public function getCurrentBlock () { - // Return it - return $this->currentBlock; - } - - /** - * Initializes this file class - * - * @param $fileName Name of this abstract file - * @return void - */ - protected function initFile ($fileName) { - // Get a file i/o pointer instance - $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileName)); - - // ... and set it here - $this->setPointerInstance($pointerInstance); - } - - /** - * Writes data at given position - * - * @param $seekPosition Seek position - * @param $data Data to be written - * @param $flushHeader Whether to flush the header (default: flush) - * @return void - */ - public function writeData ($seekPosition, $data, $flushHeader = TRUE) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data()=%d - CALLED!', __METHOD__, __LINE__, $seekPosition, strlen($data))); - - // Write data at given position - $this->getPointerInstance()->writeAtPosition($seekPosition, $data); - - // Increment counter - $this->incrementCounter(); - - // Update seek position - $this->updateSeekPosition(); - - // Flush the header? - if ($flushHeader === TRUE) { - // Flush header - $this->flushFileHeader(); - - // Seek to old position - $this->seekToOldPosition(); - } // END - if - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Marks the currently loaded block as empty (with length of the block) - * - * @param $length Length of the block - * @return void - */ - protected function markCurrentBlockAsEmpty ($length) { - // Get current seek position - $currentPosition = $this->key(); - - // Now add it as gap entry - array_push($this->gaps, array( - self::GAPS_INDEX_START => ($currentPosition - $length), - self::GAPS_INDEX_END => $currentPosition, - )); - } - - /** - * Checks whether the file header is initialized - * - * @return $isInitialized Whether the file header is initialized - */ - public function isFileHeaderInitialized () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Default is not initialized - $isInitialized = FALSE; - - // Is the file initialized? - if ($this->isFileInitialized()) { - // Some bytes has been written, so rewind to start of it. - $rewindStatus = $this->rewind(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] rewindStatus=%s', __METHOD__, __LINE__, $rewindStatus)); - - // Is the rewind() call successfull? - if ($rewindStatus != 1) { - // Something bad happened - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Could not rewind().', __METHOD__, __LINE__)); - } // END - if - - // Read file header - $this->readFileHeader(); - - // The above method does already check the header - $isInitialized = TRUE; - } // END - if - - // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] isInitialized=%d - EXIT!', __METHOD__, __LINE__, intval($isInitialized))); - return $isInitialized; - } - - /** - * Checks whether the assigned file has been initialized - * - * @return $isInitialized Whether the file's size is zero - */ - public function isFileInitialized () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Get it from iterator which holds the pointer instance. If FALSE is returned - $fileSize = $this->size(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] fileSize=%s', __METHOD__, __LINE__, $fileSize)); - - /* - * The returned file size should not be FALSE or NULL as this means - * that the pointer class does not work correctly. - */ - assert(is_int($fileSize)); - - // Is more than 0 returned? - $isInitialized = ($fileSize > 0); - - // Return result - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] isInitialized=%d - EXIT!', __METHOD__, __LINE__, intval($isInitialized))); - return $isInitialized; - } - - /** - * Creates the assigned file - * - * @return void - */ - public function createFileHeader () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // The file's header should not be initialized here - assert(!$this->isFileHeaderInitialized()); - - // Simple flush file header which will create it. - $this->flushFileHeader(); - - // Rewind seek position (to beginning of file) and update/flush file header - $this->rewindUpdateSeekPosition(); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Pre-allocates file (if enabled) with some space for later faster write access. - * - * @param $type Type of the file - * @return void - */ - public function preAllocateFile ($type) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Is it enabled? - if ($this->getConfigInstance()->getConfigEntry($type . '_pre_allocate_enabled') != 'Y') { - // Not enabled - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Not pre-allocating file.', __METHOD__, __LINE__)); - - // Don't continue here. - return; - } // END - if - - // Message to user - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Pre-allocating file ...', __METHOD__, __LINE__)); - - // Calculate minimum length for one entry - $minLengthEntry = $this->getBlockInstance()->calculateMinimumBlockLength(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] minLengthEntry=%s', __METHOD__, __LINE__, $minLengthEntry)); - - // Calulcate seek position - $seekPosition = $minLengthEntry * $this->getConfigInstance()->getConfigEntry($type . '_pre_allocate_count'); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s', __METHOD__, __LINE__, $seekPosition)); - - // Now simply write a NUL there. This will pre-allocate the file. - $this->writeData($seekPosition, chr(0)); - - // Rewind seek position (to beginning of file) and update/flush file header - $this->rewindUpdateSeekPosition(); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - */ - public function determineSeekPosition () { - // Call pointer instance - return $this->getPointerInstance()->determineSeekPosition(); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - */ - public function seek ($offset, $whence = SEEK_SET) { - // Call pointer instance - return $this->getPointerInstance()->seek($offset, $whence); - } - - /** - * Reads given amount of bytes from file. - * - * @param $bytes Amount of bytes to read - * @return $data Data read from file - */ - public function read ($bytes = NULL) { - // $bytes shall be integer - assert(is_int($bytes)); - - // Call pointer instance - return $this->getPointerInstance()->read($bytes); - } - - /** - * Rewinds to the beginning of the file - * - * @return $status Status of this operation - */ - public function rewind () { - // Call pointer instance - return $this->getPointerInstance()->rewind(); - } - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - */ - public function analyzeFile () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Make sure the file is initialized - assert($this->isFileInitialized()); - - // Init counters and gaps array - $this->initCountersGapsArray(); - - // Output message (as this may take some time) - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Analyzing file structure ... (this may take some time)', __METHOD__, __LINE__)); - - // First rewind to the begining - $this->rewind(); - - // Then try to load all entries - while ($this->valid()) { - // Go to next entry - $this->next(); - - // Get current entry - $current = $this->getCurrentBlock(); - - /* - * If the block is empty, maybe the whole file is? This could mean - * that the file has been pre-allocated. - */ - if (empty($current)) { - // Then skip this part - continue; - } // END - if - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] current()=%d', __METHOD__, __LINE__, strlen($current))); - } // END - while - - // If the last read block is empty, check gaps - if (empty($current)) { - // Output message - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Found a total of %s gaps.', __METHOD__, __LINE__, count($this->gaps))); - - // Check gaps, if the whole file is empty. - if ($this->isFileOnlyGaps()) { - // Only gaps, so don't continue here. - return; - } // END - if - - /* - * The above call has calculated a total size of all gaps. If the - * percentage of gaps passes a "soft" limit and last - * defragmentation is to far in the past, or if a "hard" limit has - * reached, run defragmentation. - */ - if ($this->isDefragmentationNeeded()) { - // Run "defragmentation" - $this->doRunDefragmentation(); - } // END - if - } // END - if - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Advances to next "block" of bytes - * - * @return void - */ - public function next () { - // Is there nothing to read? - if (!$this->valid()) { - // Nothing to read - return; - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] key()=%d', __FUNCTION__, __LINE__, $this->key())); - - // Make sure the block instance is set - assert($this->getBlockInstance() instanceof CalculatableBlock); - - // First calculate minimum block length - $length = $this->getBlockInstance()->calculateMinimumBlockLength(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] length=%s', __FUNCTION__, __LINE__, $length)); - - // Short be more than zero! - assert($length > 0); - - // Read possibly back-buffered bytes from previous call of next(). - $data = $this->getBackBuffer(); - - /* - * Read until a entry/block separator has been found. The next read - * "block" may not fit, so this loop will continue until the EOB or EOF - * has been reached whatever comes first. - */ - while ((!$this->isEndOfFileReached()) && (!self::isBlockSeparatorFound($data))) { - // Then read the next possible block - $block = $this->read($length); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] block()=%d,length=%s', __FUNCTION__, __LINE__, strlen($block), $length)); - - // Is it all empty? - if (strlen(trim($block)) == 0) { - // Mark this block as empty - $this->markCurrentBlockAsEmpty(strlen($block)); - - // Skip to next block - continue; - } // END - if - - // At this block then - $data .= $block; - - // A debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] data()=%d', __FUNCTION__, __LINE__, strlen($data))); - } // END - while - - // EOF reached? - if ($this->isEndOfFileReached()) { - // Set whole data as current read block - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('Calling setCurrentBlock(' . strlen($data) . ') ...'); - $this->setCurrentBlock($data); - - // Then abort here silently - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('EOF reached.'); - return; - } // END - if - - /* - * Init back-buffer which is the data that has been found beyond the - * separator. - */ - $this->initBackBuffer(); - - // Separate data - $dataArray = explode(chr(self::SEPARATOR_ENTRIES), $data); - - // This array must contain two elements - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('dataArray=' . print_r($dataArray, TRUE)); - assert(count($dataArray) == 2); - - // Left part is the actual block, right one the back-buffer data - $this->setCurrentBlock($dataArray[0]); - $this->setBackBuffer($dataArray[1]); - } - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - */ - public function valid () { - // Make sure the block instance is set - assert($this->getBlockInstance() instanceof Block); - - // First calculate minimum block length - $length = $this->getBlockInstance()->calculateMinimumBlockLength(); - - // Short be more than zero! - assert($length > 0); - - // Get current seek position - $seekPosition = $this->key(); - - // Then try to read it - $data = $this->read($length); - - // If some bytes could be read, all is fine - $isValid = ((is_string($data)) && (strlen($data) > 0)); - - // Get header size - $headerSize = $this->getHeaderSize(); - - // Is the seek position at or beyond the header? - if ($seekPosition >= $headerSize) { - // Seek back to old position - $this->seek($seekPosition); - } else { - // Seek directly behind the header - $this->seek($headerSize); - } - - // Return result - return $isValid; - } - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - */ - public function key () { - // Call pointer instance - return $this->getPointerInstance()->determineSeekPosition(); - } - - /** - * Reads the file header - * - * @return void - */ - public function readFileHeader () { - // Make sure the block instance is set - assert($this->getBlockInstance() instanceof Block); - - // Call block instance - $this->getBlockInstance()->readFileHeader(); - } - - /** - * Flushes the file header - * - * @return void - */ - public function flushFileHeader () { - // Make sure the block instance is set - assert($this->getBlockInstance() instanceof Block); - - // Call block instance - $this->getBlockInstance()->flushFileHeader(); - } - - /** - * Searches for next suitable gap the given length of data can fit in - * including padding bytes. - * - * @param $length Length of raw data - * @return $seekPosition Found next gap's seek position - */ - public function searchNextGap ($length) { - // If the file is only gaps, no need to seek - if ($this->isFileOnlyGaps()) { - // The first empty block is the first one right after the header - return ($this->getHeaderSize() + 1); - } // END - if - - // @TODO Unfinished - $this->partialStub('length=' . $length); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/binary/index/.htaccess b/inc/classes/main/file_directories/binary/index/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/binary/index/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/binary/index/class_IndexFile.php b/inc/classes/main/file_directories/binary/index/class_IndexFile.php deleted file mode 100644 index 8fd85d3d..00000000 --- a/inc/classes/main/file_directories/binary/index/class_IndexFile.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class IndexFile extends BaseBinaryFile implements Block { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this File class and prepares it for usage - * - * @param $fileName Name of the index file - * @param $blockInstance An instance of a Block class - * @return $fileInstance An instance of this File class - */ - public final static function createIndexFile ($fileName, Block $blockInstance) { - // Get a new instance - $fileInstance = new IndexFile(); - - // Set block instance here for callbacks - $fileInstance->setBlockInstance($blockInstance); - - // Init this abstract file - $fileInstance->initFile($fileName); - - // Return the prepared instance - return $fileInstance; - } - - /** - * Writes given value to the file and returns a hash and gap position for it - * - * @param $groupId Group identifier - * @param $value Value to be added to the stack - * @return $data Hash and gap position - * @throws UnsupportedOperationException If this method is called - */ - public function writeValueToFile ($groupId, $value) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Writes given raw data to the file and returns a gap position and length - * - * @param $groupId Group identifier - * @param $hash Hash from encoded value - * @param $encoded Encoded value to be written to the file - * @return $data Gap position and length of the raw data - * @throws UnsupportedOperationException If this method is called - */ - public function writeDataToFreeGap ($groupId, $hash, $encoded) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',encoded()=' . strlen($encoded)); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/binary/stack/.htaccess b/inc/classes/main/file_directories/binary/stack/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/binary/stack/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/binary/stack/class_StackFile.php b/inc/classes/main/file_directories/binary/stack/class_StackFile.php deleted file mode 100644 index cf562b87..00000000 --- a/inc/classes/main/file_directories/binary/stack/class_StackFile.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class StackFile extends BaseBinaryFile implements Block { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this File class and prepares it for usage - * - * @param $fileName Name of the stack file - * @param $blockInstance An instance of a Block class - * @return $fileInstance An instance of this File class - */ - public final static function createStackFile ($fileName, Block $blockInstance) { - // Get a new instance - $fileInstance = new StackFile(); - - // Set block instance here for callbacks - $fileInstance->setBlockInstance($blockInstance); - - // Init this abstract file - $fileInstance->initFile($fileName); - - // Return the prepared instance - return $fileInstance; - } - - /** - * Writes given value to the file and returns a hash and gap position for it - * - * @param $groupId Group identifier - * @param $value Value to be added to the stack - * @return $data Hash and gap position - */ - public function writeValueToFile ($groupId, $value) { - // Make sure no objects/resources are added as the serialization may fail - assert(!is_object($value)); - assert(!is_resource($value)); - - // Encode/convert the value into a "binary format" - $encoded = $this->encodeData($value); - - // Get a strong hash for the "encoded" data - $hash = self::hash($encoded); - - // Then write it to the next free gap - $data = $this->getBlockInstance()->writeDataToFreeGap($groupId, $hash, $encoded); - - // Return info - return $data; - } - - /** - * Writes given raw data to the file and returns a gap position and length - * - * @param $groupId Group identifier - * @param $hash Hash from encoded value - * @param $encoded Encoded value to be written to the file - * @return $data Gap position and length of the raw data - * @throws UnsupportedOperationException If this method is called - */ - public function writeDataToFreeGap ($groupId, $hash, $encoded) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',hash=' . $hash . ',encoded()=' . strlen($encoded)); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/class_BaseAbstractFile.php b/inc/classes/main/file_directories/class_BaseAbstractFile.php deleted file mode 100644 index e26c58bb..00000000 --- a/inc/classes/main/file_directories/class_BaseAbstractFile.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseAbstractFile extends BaseFrameworkSystem { - /** - * Counter for total entries - */ - private $totalEntries = 0; - - /** - * The current file we are working in - */ - private $fileName = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Destructor for cleaning purposes, etc - * - * @return void - */ - public final function __destruct() { - // Try to close a file - $this->closeFile(); - - // Call the parent destructor - parent::__destruct(); - } - - /** - * "Getter" for abstracted file size - * - * @return $fileSize Size of abstracted file - */ - public function getFileSize () { - // Call pointer instanze - return $this->getPointerInstance()->getFileSize(); - } - - /** - * Getter for total entries - * - * @return $totalEntries Total entries in this file - */ - public final function getCounter () { - // Get it - return $this->totalEntries; - } - - /** - * Setter for total entries - * - * @param $totalEntries Total entries in this file - * @return void - */ - protected final function setCounter ($counter) { - // Set it - $this->totalEntries = $counter; - } - - /** - * Increment counter - * - * @return void - */ - protected final function incrementCounter () { - // Get it - $this->totalEntries++; - } - - /** - * Getter for the file pointer - * - * @return $filePointer The file pointer which shall be a valid file resource - * @throws UnsupportedOperationException If this method is called - */ - public final function getPointer () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Setter for file name - * - * @param $fileName The new file name - * @return void - */ - protected final function setFileName ($fileName) { - $fileName = (string) $fileName; - $this->fileName = $fileName; - } - - /** - * Getter for file name - * - * @return $fileName The current file name - */ - public final function getFileName () { - return $this->fileName; - } - - /** - * Close a file source and set it's instance to null and the file name - * to empty - * - * @return void - */ - private function closeFile () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName())); - - // Close down pointer instance as well by unsetting it - $this->unsetPointerInstance(); - - // Remove file name - $this->setFileName(''); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__)); - } - - /** - * Size of this file - * - * @return $size Size (in bytes) of file - * @todo Handle seekStatus - */ - public function size () { - // Call pointer instance - return $this->getPointerInstance()->size(); - } - - /** - * Read data a file pointer - * - * @return mixed The result of fread() - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - */ - public function readFromFile () { - // Call pointer instance - return $this->getPointerInstance()->readFromFile(); - } - - /** - * Write data to a file pointer - * - * @param $dataStream The data stream we shall write to the file - * @return mixed Number of writes bytes or FALSE on error - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - * an invalid file resource - */ - public function writeToFile ($dataStream) { - // Call pointer instance - return $this->getPointerInstance()->writeToFile($dataStream); - } - - /** - * Determines whether the EOF has been reached - * - * @return $isEndOfFileReached Whether the EOF has been reached - */ - public final function isEndOfFileReached () { - // Call pointer instance - return $this->getPointerInstance()->isEndOfFileReached(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/class_BaseFileIo.php b/inc/classes/main/file_directories/class_BaseFileIo.php deleted file mode 100644 index d52d02fa..00000000 --- a/inc/classes/main/file_directories/class_BaseFileIo.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseFileIo extends BaseFrameworkSystem { - /** - * The current file we are working in - */ - private $fileName = ''; - - /** - * The file pointer - */ - private $filePointer = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Destructor for cleaning purposes, etc - * - * @return void - */ - public final function __destruct() { - // Is there a resource pointer? Then we have to close the file here! - if (is_resource($this->getPointer())) { - // Try to close a file - $this->closeFile(); - } // END - if - - // Call the parent destructor - parent::__destruct(); - } - - /** - * Close a file source and set it's instance to null and the file name - * to empty. - * - * @return void - * @throws NullPointerException If the file pointer instance is not set by setPointer() - * @throws InvalidResourceException If there is being set - */ - private function closeFile () { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName())); - - if (is_null($this->getPointer())) { - // Pointer not initialized - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_resource($this->getPointer())) { - // Pointer is not a valid resource! - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Closing file %s ...', __METHOD__, __LINE__, $this->getFileName())); - - // Close the file pointer and reset the instance variable - @fclose($this->getPointer()); - $this->setPointer(NULL); - $this->setFileName(''); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__)); - } - - /** - * Setter for the file pointer - * - * @param $filePointer File resource - * @return void - */ - protected final function setPointer ($filePointer) { - $this->filePointer = $filePointer; - } - - /** - * Getter for the file pointer - * - * @return $filePointer The file pointer which shall be a valid file resource - */ - public final function getPointer () { - return $this->filePointer; - } - - /** - * Setter for file name - * - * @param $fileName The new file name - * @return void - */ - protected final function setFileName ($fileName) { - $fileName = (string) $fileName; - $this->fileName = $fileName; - } - - /** - * Getter for file name - * - * @return $fileName The current file name - */ - public final function getFileName () { - return $this->fileName; - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - */ - public final function determineSeekPosition () { - return ftell($this->getPointer()); - } - - /** - * Determines whether the EOF has been reached - * - * @return $isEndOfFileReached Whether the EOF has been reached - */ - public final function isEndOfFileReached () { - return feof($this->getPointer()); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - */ - public function seek ($offset, $whence = SEEK_SET) { - // Seek to position - $status = fseek($this->getPointer(), $offset, $whence); - - // Return status - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] status=%d', __METHOD__, __LINE__, $status)); - return $status; - } - - /** - * Size of this file - * - * @return $size Size (in bytes) of file - * @todo Handle seekStatus - */ - public function size () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Get current seek position - $seekPosition = $this->determineSeekPosition(); - - // Seek to end - $seekStatus = $this->seek(0, SEEK_END); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus)); - - // Get position again (which is the end of the file) - $size = $this->determineSeekPosition(); - - // Reset seek position to old - $this->seek($seekPosition); - - // Return size - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] size=%s - EXIT!', __METHOD__, __LINE__, $size)); - return $size; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/directory/.htaccess b/inc/classes/main/file_directories/directory/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/directory/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/directory/class_FrameworkDirectoryPointer.php b/inc/classes/main/file_directories/directory/class_FrameworkDirectoryPointer.php deleted file mode 100644 index b855a62c..00000000 --- a/inc/classes/main/file_directories/directory/class_FrameworkDirectoryPointer.php +++ /dev/null @@ -1,256 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkDirectoryPointer extends BaseFrameworkSystem implements FrameworkDirectory { - /** - * The current path we are working in - */ - private $pathName = ''; - - /** - * The directory iterator instance - */ - private $iteratorInstance = NULL; - - /** - * Protected constructor - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Destructor for cleaning purposes, etc - */ - public function __destruct() { - // Is there a resource pointer? Then we have to close the directory here! - if ($this->getDirectoryIteratorInstance() instanceof DirectoryIterator) { - // Try to close a directory - $this->closeDirectory(); - } // END - if - - // Call the parent destructor - parent::__destruct(); - } - - /** - * Create a directory pointer based on the given path. The path will also - * be verified here. - * - * @param $pathName The path name we shall pass to opendir() - * @param $inConstructor If we are in de/con-structor or from somewhere else - * @return $pointerInstance A prepared instance of FrameworkDirectoryPointer - * @throws PathIsEmptyException If the provided path name is empty - * @throws InvalidPathStringException If the provided path name is not a string - * @throws PathIsNoDirectoryException If the provided path name is not valid - * @throws PathReadProtectedException If the provided path name is read-protected - * @todo Get rid of inConstructor, could be old-lost code. - */ - public static final function createFrameworkDirectoryPointer ($pathName, $inConstructor = FALSE) { - // Some pre-sanity checks... - if (is_null($pathName)) { - // No pathname given - if ($inConstructor) { - return NULL; - } else { - throw new PathIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } - } elseif (!is_string($pathName)) { - // Is not a string - if ($inConstructor) { - return NULL; - } else { - throw new InvalidPathStringException(NULL, self::EXCEPTION_INVALID_STRING); - } - } elseif (!is_dir($pathName)) { - // Not a directory - if ($inConstructor) { - return NULL; - } else { - throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME); - } - } elseif (!is_readable($pathName)) { - // Not readable - if ($inConstructor) { - return NULL; - } else { - throw new PathReadProtectedException($pathName, self::EXCEPTION_READ_PROTECED_PATH); - } - } - - // Create new instance - $pointerInstance = new FrameworkDirectoryPointer(); - - // Get an iterator for the directory - $iteratorInstance = new DirectoryIterator($pathName); - - // ... and rewind back - $iteratorInstance->rewind(); - - // Set directory pointer and path name - $pointerInstance->setDirectoryIteratorInstance($iteratorInstance); - $pointerInstance->setPathName($pathName); - - // Return the instance - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: Opened pathName=' . $pathName . ' - EXIT!'); - return $pointerInstance; - } - - /** - * Read raw lines of data from a directory pointer and return the data - * - * @return $currentEntry Current entry from encapsulated iterator - */ - public function readRawDirectory () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . '] - CALLED!'); - - // Can the next entry be read? - assert($this->getDirectoryIteratorInstance()->valid()); - - // Read data from the directory pointer and return it - $currentEntry = $this->getDirectoryIteratorInstance()->current(); - - // Return found entry - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: currentEntry[]=' . gettype($currentEntry) . ' - EXIT!'); - return $currentEntry; - } - - /** - * Read lines from the current directory pointer except some parts - * - * @param $except Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored - * @return string Directory and/or file names read from the current directory pointer - */ - public function readDirectoryExcept (array $except = array()) { - // No exceptions given? - if (count($except) == 0) { - // No exception given, so read all files and directories, but not recursive - self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: No exceptions given, please use readRawDirectory() instead!'); - return $this->readRawDirectory(); - } elseif (!$this->getDirectoryIteratorInstance()->valid()) { - // No more left to read - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: EOD reached.'); - return NULL; - } - - // Init raw line - $rawLine = NULL; - - // Read a raw line... - $currentEntry = $this->readRawDirectory(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: currentEntry[]=' . gettype($currentEntry)); - - // Shall we exclude directories? - if (is_object($currentEntry)) { - // Get file name - $rawLine = $currentEntry->getFilename(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine . ',isDot=' . intval($this->getDirectoryIteratorInstance()->isDot())); - - // Is it a dot-directory or excluded? - if (($this->getDirectoryIteratorInstance()->isDot()) || (in_array($rawLine, $except))) { - // To next entry - $this->getDirectoryIteratorInstance()->next(); - - // Exclude this part - $rawLine = $this->readDirectoryExcept($except); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!'); - } // END - if - } // END - if - - // To next entry - $this->getDirectoryIteratorInstance()->next(); - - // Return read line - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine); - return $rawLine; - } - - /** - * Close a directory source and set it's instance to null and the path name - * to empty - * - * @return void - */ - public function closeDirectory () { - // Close the directory by unsetting it - $this->unsetDirectoryIteratorInstance(); - $this->setPathName(''); - } - - /** - * Setter for the directory pointer - * - * @param $iteratorInstance An instanceof a DirectoryIterator class - * @return void - */ - protected final function setDirectoryIteratorInstance (DirectoryIterator $iteratorInstance) { - // Set instance - $this->iteratorInstance = $iteratorInstance; - } - - /** - * Getter for the directory pointer - * - * @return $iteratorInstance The directory pointer which shall be a valid directory resource - */ - public final function getDirectoryIteratorInstance () { - return $this->iteratorInstance; - } - - /** - * Remove directory iterator instance (effectively closing it) by setting - * it to NULL. This will trigger a call on the destructor which will then - * "close" the iterator. - * - * @param $iteratorInstance An instanceof a DirectoryIterator class - * @return void - */ - protected final function unsetDirectoryIteratorInstance () { - // "Unset" the instance - $this->iteratorInstance = NULL; - } - - /** - * Setter for path name - * - * @param $pathName The new path name - * @return void - */ - protected final function setPathName ($pathName) { - $pathName = (string) $pathName; - $this->pathName = $pathName; - } - - /** - * Getter for path name - * - * @return $pathName The current path name - */ - public final function getPathName () { - return $this->pathName; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/input/.htaccess b/inc/classes/main/file_directories/input/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/input/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/input/raw/.htaccess b/inc/classes/main/file_directories/input/raw/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/input/raw/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/input/raw/class_FrameworkRawFileInputPointer.php b/inc/classes/main/file_directories/input/raw/class_FrameworkRawFileInputPointer.php deleted file mode 100644 index 9fb6e1db..00000000 --- a/inc/classes/main/file_directories/input/raw/class_FrameworkRawFileInputPointer.php +++ /dev/null @@ -1,174 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a file pointer based on the given file. The file will also - * be verified here. - * - * @param $fileName The file name we shall pass to fopen() - * @throws FileIsEmptyException If the provided file name is empty. - * @throws FileIoException If the file is not reachable - * @throws FileReadProtectedException If the file is not found or cannot be read - * @throws FileNotFoundException If the file does not exist - * @return void - */ - public static final function createFrameworkRawFileInputPointer ($fileName) { - // Some pre-sanity checks... - if ((is_null($fileName)) || (empty($fileName))) { - // No filename given - throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) { - // File cannot be accessed (due to open_basedir restriction) - throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE); - } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (file_exists($fileName))) { - // File exists but cannot be read from - throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); - } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (!file_exists($fileName))) { - // File does not exist - throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_NOT_FOUND); - } - - // Try to open a handler - $filePointer = fopen($fileName, 'rb'); - if ((is_null($filePointer)) || ($filePointer === FALSE)) { - // Something bad happend - throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID); - } // END - if - - // Create new instance - $pointerInstance = new FrameworkRawFileInputPointer(); - - // Set file pointer and file name - $pointerInstance->setPointer($filePointer); - $pointerInstance->setFileName($fileName); - - // Return the instance - return $pointerInstance; - } - - /** - * Read data a file pointer - * - * @return mixed The result of fread() - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - */ - public function readFromFile () { - if (is_null($this->getPointer())) { - // Pointer not initialized - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_resource($this->getPointer())) { - // Pointer is not a valid resource! - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } - - // Read data from the file pointer and return it - return $this->read(1024); - } - - /** - * Reads a line, maximum 4096 Bytes from current file pointer - * - * @return $data Read data from file - * @throws UnsupportedOperationException If this method is called - */ - public function readLine () { - // Not supported in binary files ... - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Reads given amount of bytes from file. - * - * @param $bytes Amount of bytes to read - * @return $data Data read from file - */ - public function read ($bytes = NULL) { - // $bytes shall be integer - assert(is_int($bytes)); - - // Try to read given characters - $data = fread($this->getPointer(), $bytes); - - // Then return it - return $data; - } - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function analyzeFile () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Advances to next "block" of bytes - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function next () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - * @throws UnsupportedOperationException If this method is called - */ - public function valid () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - * @throws UnsupportedOperationException If this method is called - */ - public function key () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/input/text/.htaccess b/inc/classes/main/file_directories/input/text/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/input/text/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/input/text/class_FrameworkTextFileInputPointer.php b/inc/classes/main/file_directories/input/text/class_FrameworkTextFileInputPointer.php deleted file mode 100644 index 16e43d52..00000000 --- a/inc/classes/main/file_directories/input/text/class_FrameworkTextFileInputPointer.php +++ /dev/null @@ -1,176 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a file pointer based on the given file. The file will also - * be verified here. - * - * @param $fileName The file name we shall pass to fopen() - * @throws FileIsEmptyException If the provided file name is empty. - * @throws FileIoException If the file is not reachable - * @throws FileReadProtectedException If the file cannot be read from - * @return void - */ - public static final function createFrameworkTextFileInputPointer ($fileName) { - // Some pre-sanity checks... - if ((is_null($fileName)) || (empty($fileName))) { - // No filename given - throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) { - // File cannot be reached - throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE); - } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (!file_exists($fileName))) { - // File does not exist! - throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); - } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (file_exists($fileName))) { - // File cannot be read from (but exists) - throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); - } - - // Try to open a handler - $filePointer = fopen($fileName, 'r'); - if ((is_null($filePointer)) || ($filePointer === FALSE)) { - // Something bad happend - throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID); - } // END - if - - // Create new instance - $pointerInstance = new FrameworkTextFileInputPointer(); - - // Set file pointer and file name - $pointerInstance->setPointer($filePointer); - $pointerInstance->setFileName($fileName); - - // Return the instance - return $pointerInstance; - } - - /** - * Read data a file pointer - * - * @return $data Read data from file - */ - public function readFromFile () { - // Read 1024 Byte data from the file pointer and return it - return $this->read(1024); - } - - /** - * Reads a line, maximum 4096 Bytes from current file pointer - * - * @return $data Read data from file - */ - public function readLine () { - // Read whole line from the file pointer and return it - return $this->read(); - } - - /** - * Reads given amount of bytes from file. - * - * @param $bytes Amount of bytes to read or whole line (only text files) - * @return $data Data read from file - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - */ - public function read ($bytes = NULL) { - // Some sanity checks - if (is_null($this->getPointer())) { - // Pointer not initialized - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_resource($this->getPointer())) { - // Pointer is not a valid resource! - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } - - // Is $bytes set? - if (is_int($bytes)) { - // Try to read given characters - $data = fgets($this->getPointer(), $bytes); - } else { - // Try to read whole line - $data = fgets($this->getPointer()); - } - - // Then return it - return $data; - } - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function analyzeFile () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Advances to next "block" of bytes - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function next () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - * @throws UnsupportedOperationException If this method is called - */ - public function valid () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - * @throws UnsupportedOperationException If this method is called - */ - public function key () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/io/.htaccess b/inc/classes/main/file_directories/io/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/io/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/io/class_FrameworkFileInputOutputPointer.php b/inc/classes/main/file_directories/io/class_FrameworkFileInputOutputPointer.php deleted file mode 100644 index ae372f35..00000000 --- a/inc/classes/main/file_directories/io/class_FrameworkFileInputOutputPointer.php +++ /dev/null @@ -1,274 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputPointer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a file pointer based on the given file. The file will also - * be verified here. - * - * @param $fileName The file name we shall pass to fopen() - * @return void - * @throws FileIsEmptyException If the given file name is NULL or empty - * @throws FileReadProtectedException If PHP cannot read an existing file - * @throws FileWriteProtectedException If PHP cannot write an existing file - * @throws PathWriteProtectedException If PHP cannot write to an existing path - * @throws FileIoException If fopen() returns not a file resource - */ - public static final function createFrameworkFileInputOutputPointer ($fileName) { - // Some pre-sanity checks... - if ((is_null($fileName)) || (empty($fileName))) { - // No filename given - throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) { - // File exists but cannot be read - throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE); - } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (file_exists($fileName))) { - // File exists but cannot be read - throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); - } elseif ((file_exists($fileName)) && (!is_writable($fileName))) { - // File exists but cannot be written - throw new FileWriteProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_WRITTEN); - } elseif (!is_writable(dirname($fileName))) { - // Path is not writable - throw new PathWriteProtectedException($fileName, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); - } - - // Try to open a handler - $filePointer = fopen($fileName, 'c+b'); - if ((is_null($filePointer)) || ($filePointer === FALSE)) { - // Something bad happend - throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID); - } // END - if - - // Create new instance - $pointerInstance = new FrameworkFileInputOutputPointer(); - - // Set file pointer and file name - $pointerInstance->setPointer($filePointer); - $pointerInstance->setFileName($fileName); - - // Return the instance - return $pointerInstance; - } - - /** - * Validates file pointer and throws exceptions. This method does not return - * anything (not reliable) as this method checks the file pointer and on - * case of an error it throws an exception. If this method does not throw - * any exceptions, the file pointer seems to be fine. - * - * @return void - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - */ - private function validateFilePointer () { - if (is_null($this->getPointer())) { - // Pointer not initialized - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_resource($this->getPointer())) { - // Pointer is not a valid resource! - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } - - // All fine here - } - - /** - * Read 1024 bytes data from a file pointer - * - * @return mixed The result of fread() - */ - public function readFromFile () { - // Validate the pointer - $this->validateFilePointer(); - - // Read data from the file pointer and return it - return $this->read(1024); - } - - /** - * Write data to a file pointer - * - * @param $dataStream The data stream we shall write to the file - * @return mixed Number of writes bytes or FALSE on error - */ - public function writeToFile ($dataStream) { - // Validate the pointer - $this->validateFilePointer(); - - // Write data to the file pointer and return written bytes - return fwrite($this->getPointer(), $dataStream, strlen($dataStream)); - } - - /** - * Writes at given position by seeking to it. - * - * @param $seekPosition Seek position in file - * @param $data Data to be written - * @return mixed Number of writes bytes or FALSE on error - */ - public function writeAtPosition ($seekPosition, $data) { - // First seek to it - $this->seek($seekPosition); - - // Then write the data at that position - return $this->writeToFile($data); - } - - /** - * Rewinds to the beginning of the file - * - * @return $status Status of this operation - */ - public function rewind () { - // Validate the pointer - $this->validateFilePointer(); - - // Rewind the pointer - return rewind($this->getPointer()); - } - - /** - * Seeks to given position - * - * @param $seekPosition Seek position in file - * @param $whence "Seek mode" (see http://de.php.net/fseek) - * @return $status Status of this operation - */ - public function seek ($seekPosition, $whence = SEEK_SET) { - // Validate the pointer - $this->validateFilePointer(); - - // Move the file pointer - return fseek($this->getPointer(), $seekPosition, $whence); - } - - /** - * Reads a line, maximum 4096 Bytes from current file pointer - * - * @return $data Read data from file - */ - public function readLine () { - // Read whole line - return $this->read(); - } - - /** - * Reads given amount of bytes from file. - * - * @param $bytes Amount of bytes to read - * @return $data Data read from file - */ - public function read ($bytes = NULL) { - // Validate the pointer - $this->validateFilePointer(); - - // Is $bytes set? - if (is_int($bytes)) { - // Try to read given characters - $data = fread($this->getPointer(), $bytes); - } else { - // Try to read whole line - $data = fread($this->getPointer()); - } - - // Then return it - return $data; - } - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function analyzeFile () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Advances to next "block" of bytes - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function next () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - * @throws UnsupportedOperationException If this method is called - */ - public function valid () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - * @throws UnsupportedOperationException If this method is called - */ - public function key () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * "Getter" for file size - * - * @return $fileSize Size of currently loaded file - */ - public function getFileSize () { - // Check if the pointer is still valid - $this->validateFilePointer(); - - // Get file's data - $fileData = fstat($this->getPointer()); - - // Make sure the required array key is there - assert(isset($fileData['size'])); - - // Return size - return $fileData['size']; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/io_stream/.htaccess b/inc/classes/main/file_directories/io_stream/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/io_stream/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/io_stream/class_FileIoStream.php b/inc/classes/main/file_directories/io_stream/class_FileIoStream.php deleted file mode 100644 index d0ff5490..00000000 --- a/inc/classes/main/file_directories/io_stream/class_FileIoStream.php +++ /dev/null @@ -1,292 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer { - /** - * File header indicator - */ - const FILE_IO_FILE_HEADER_ID = '@head'; - - /** - * Data block indicator - */ - const FILE_IO_DATA_BLOCK_ID = '@data'; - - /** - * Separator #1 - */ - const FILE_IO_CHUNKER = ':'; - - /** - * Separator #2 - */ - const FILE_IO_SEPARATOR = '^'; - - /** - * Protected constructor - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a file IO stream. This is a class for performing all actions - * on files like creating, deleting and loading them. - * - * @return $ioInstance An instance of FileIoStream - */ - public static final function createFileIoStream () { - // Create new instance - $ioInstance = new FileIoStream(); - - // Return the instance - return $ioInstance; - } - - /** - * Saves data to a given local file and create missing directory structures - * - * @param $fileName The file name for the to be saved file - * @param $dataArray The data we shall store to the file - * @return void - * @see FileOutputStreamer - * @todo This method needs heavy rewrite - */ - public final function saveFile ($fileName, array $dataArray) { - // Try it five times - $dirName = ''; - $fileInstance = NULL; - - for ($idx = 0; $idx < 5; $idx++) { - // Get a file output pointer - try { - $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', array($fileName, 'wb')); - } catch (FileNotFoundException $e) { - // Bail out - ApplicationEntryPoint::app_exit('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage()); - } - } // END - for - - // Write a header information for validation purposes - $fileInstance->writeToFile(sprintf('%s%s%s%s%s%s%s%s%s' . PHP_EOL, - self::FILE_IO_FILE_HEADER_ID, - self::FILE_IO_SEPARATOR, - $dataArray[0], - self::FILE_IO_CHUNKER, - time(), - self::FILE_IO_CHUNKER, - strlen($dataArray[1]), - self::FILE_IO_CHUNKER, - md5($dataArray[1]) - )); - - // Encode the (maybe) binary stream with Base64 - $b64Stream = base64_encode($dataArray[1]); - - // write the data line by line - $line = str_repeat(' ', 50); $idx = 0; - while (strlen($line) == 50) { - // Get 50 chars or less - $line = substr($b64Stream, $idx, 50); - - // Save it to the stream - $fileInstance->writeToFile(sprintf('%s%s%s%s%s' . PHP_EOL, - self::FILE_IO_DATA_BLOCK_ID, - self::FILE_IO_SEPARATOR, - $line, - self::FILE_IO_CHUNKER, - md5($line) - )); - - // Advance to the next 50-chars block - $idx += 50; - } // END - while - - // Close the file - unset($fileInstance); - } - - /** - * Reads from a local file - * - * @param $fqfn The full-qualified file-name which we shall load - * @return $array An array with the element 'header' and 'data' - * @see FileInputStreamer - */ - public final function loadFileContents ($fqfn) { - // Initialize some variables and arrays - $inputBuffer = ''; - $lastBuffer = ''; - $header = array(); - $data = array(); - $readData = ''; // This will contain our read data - - // Get a file input handler - $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($fqfn)); - - // Read all it's contents (we very and transparently decompress it below) - while ($readRawLine = $fileInstance->readFromFile()) { - // Add the read line to the buffer - $inputBuffer .= $readRawLine; - - // Break infinite loop maybe caused by the input handler - if ($lastBuffer == $inputBuffer) { - break; - } // END - if - - // Remember last read line for avoiding possible infinite loops - $lastBuffer = $inputBuffer; - } // END - while - - // Close directory handle - unset($fileInstance); - - // Convert it into an array - $inputBuffer = explode(chr(10), $inputBuffer); - - // Now process the read lines and verify it's content - foreach ($inputBuffer as $rawLine) { - // Trim it a little but not the leading spaces/tab-stops - $rawLine = rtrim($rawLine); - - // Analyze this line - if (substr($rawLine, 0, 5) == self::FILE_IO_FILE_HEADER_ID) { - // Header found, so let's extract it - $header = explode(self::FILE_IO_SEPARATOR, $rawLine); - $header = trim($header[1]); - - // Now we must convert it again into an array - $header = explode(self::FILE_IO_CHUNKER, $header); - - // Is the header (maybe) valid? - if (count($header) != 4) { - // Throw an exception - throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } // END - if - } elseif (substr($rawLine, 0, 5) == self::FILE_IO_DATA_BLOCK_ID) { - // Is a data line! - $data = explode(self::FILE_IO_SEPARATOR, $rawLine); - $data = $data[1]; - - // First element is the data, second the MD5 checksum - $data = explode(self::FILE_IO_CHUNKER, $data); - - // Validate the read line - if (count($data) == 2) { - if (md5($data[0]) != $data[1]) { - // MD5 hash did not match! - throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); - } // END - if - } else { - // Invalid count! - throw new InvalidArrayCountException(array($this, 'data', count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } - - // Add this to the readData string - $readData .= $data[0]; - } else { - // Other raw lines than header/data tagged lines and re-add the new-line char - $readData .= $rawLine . PHP_EOL; - } - } // END - foreach - - // Was raw lines read and no header/data? - if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) { - // Return raw lines back - return $readData; - } // END - if - - // Was a header found? - if (count($header) != 4) { - // Throw an exception - throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); - } // END - if - - // Decode all from Base64 - $readData = @base64_decode($readData); - - // Does the size match? - if (strlen($readData) != $header[2]) { - // Size did not match - throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE); - } // END - if - - // Validate the decoded data with the final MD5 hash - if (md5($readData) != $header[3]) { - // MD5 hash did not match! - throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); - } // END - if - - // Return all in an array - return array( - 'header' => $header, - 'data' => $readData - ); - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - * @todo 0% done - */ - public function determineSeekPosition () { - $this->partialStub(); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - */ - public function seek ($offset, $whence = SEEK_SET) { - $this->partialStub('offset=' . $offset . ',whence=' . $whence); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - public function size () { - $this->partialStub(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/output/.htaccess b/inc/classes/main/file_directories/output/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/output/raw/.htaccess b/inc/classes/main/file_directories/output/raw/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/output/raw/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php b/inc/classes/main/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php deleted file mode 100644 index 42eebfd5..00000000 --- a/inc/classes/main/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php +++ /dev/null @@ -1,150 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a file pointer based on the given file. The file will also - * be verified here. - * - * @param $fileName The file name we shall pass to fopen() - * @param $mode The output mode ('w', 'a' are valid) - * @throws FileIsEmptyException If the provided file name is empty. - * @throws FileIoException If fopen() returns not a file resource - * @return void - */ - public static final function createFrameworkRawFileOutputPointer ($fileName, $mode) { - // Some pre-sanity checks... - if (is_null($fileName)) { - // No filename given - throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - - // Try to open a handler - $filePointer = @fopen($fileName, $mode); - if ((is_null($filePointer)) || ($filePointer === FALSE)) { - // Something bad happend - throw new FileIoException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID); - } // END - if - - // Create new instance - $pointerInstance = new FrameworkRawFileOutputPointer(); - - // Set file pointer and file name - $pointerInstance->setPointer($filePointer); - $pointerInstance->setFileName($fileName); - - // Return the instance - return $pointerInstance; - } - - /** - * Write data to a file pointer - * - * @param $dataStream The data stream we shall write to the file - * @return mixed Number of writes bytes or FALSE on error - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - * an invalid file resource - */ - public function writeToFile ($dataStream) { - if (is_null($this->getPointer())) { - // Pointer not initialized - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_resource($this->getPointer())) { - // Pointer is not a valid resource! - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } - - // Write data to the file pointer and return written bytes - return fwrite($this->getPointer(), $dataStream); - } - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function analyzeFile () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Writes at given position by seeking to it. - * - * @param $seekPosition Seek position in file - * @param $data Data to be written - * @return mixed Number of writes bytes or FALSE on error - * @throws UnsupportedOperationException If this method is called - */ - public function writeAtPosition ($seedPosition, $data) { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Advances to next "block" of bytes - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function next () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - * @throws UnsupportedOperationException If this method is called - */ - public function valid () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - * @throws UnsupportedOperationException If this method is called - */ - public function key () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/output/text/.htaccess b/inc/classes/main/file_directories/output/text/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/output/text/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/output/text/class_FrameworkTextFileOutputPointer.php b/inc/classes/main/file_directories/output/text/class_FrameworkTextFileOutputPointer.php deleted file mode 100644 index 42eebfd5..00000000 --- a/inc/classes/main/file_directories/output/text/class_FrameworkTextFileOutputPointer.php +++ /dev/null @@ -1,150 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a file pointer based on the given file. The file will also - * be verified here. - * - * @param $fileName The file name we shall pass to fopen() - * @param $mode The output mode ('w', 'a' are valid) - * @throws FileIsEmptyException If the provided file name is empty. - * @throws FileIoException If fopen() returns not a file resource - * @return void - */ - public static final function createFrameworkRawFileOutputPointer ($fileName, $mode) { - // Some pre-sanity checks... - if (is_null($fileName)) { - // No filename given - throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - - // Try to open a handler - $filePointer = @fopen($fileName, $mode); - if ((is_null($filePointer)) || ($filePointer === FALSE)) { - // Something bad happend - throw new FileIoException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID); - } // END - if - - // Create new instance - $pointerInstance = new FrameworkRawFileOutputPointer(); - - // Set file pointer and file name - $pointerInstance->setPointer($filePointer); - $pointerInstance->setFileName($fileName); - - // Return the instance - return $pointerInstance; - } - - /** - * Write data to a file pointer - * - * @param $dataStream The data stream we shall write to the file - * @return mixed Number of writes bytes or FALSE on error - * @throws NullPointerException If the file pointer instance - * is not set by setPointer() - * @throws InvalidResourceException If there is being set - * an invalid file resource - */ - public function writeToFile ($dataStream) { - if (is_null($this->getPointer())) { - // Pointer not initialized - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } elseif (!is_resource($this->getPointer())) { - // Pointer is not a valid resource! - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } - - // Write data to the file pointer and return written bytes - return fwrite($this->getPointer(), $dataStream); - } - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function analyzeFile () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Writes at given position by seeking to it. - * - * @param $seekPosition Seek position in file - * @param $data Data to be written - * @return mixed Number of writes bytes or FALSE on error - * @throws UnsupportedOperationException If this method is called - */ - public function writeAtPosition ($seedPosition, $data) { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Advances to next "block" of bytes - * - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function next () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - * @throws UnsupportedOperationException If this method is called - */ - public function valid () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - * @throws UnsupportedOperationException If this method is called - */ - public function key () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/text/.htaccess b/inc/classes/main/file_directories/text/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/text/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/text/class_BaseTextFile.php b/inc/classes/main/file_directories/text/class_BaseTextFile.php deleted file mode 100644 index ca7ff6ef..00000000 --- a/inc/classes/main/file_directories/text/class_BaseTextFile.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseTextFile extends BaseAbstractFile { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - */ - public function determineSeekPosition () { - // Not possible in text files - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - */ - public function seek ($offset, $whence = SEEK_SET) { - // Not possible in text files - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Reads from a local or remote file - * - * @param $fqfn The file's FQFN we shall load - * @return $array An array containing all read lines - * @throws InvalidArrayCountException If an array has not the expected size - * @throws InvalidMD5ChecksumException If two MD5 hashes did not match - */ - public function loadFileContents ($fqfn) { - /* - * This class (or its implementations) are special file readers/writers. - * There is no need to read/write the whole file. - */ - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fqfn=' . $fqfn); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/text/input/.htaccess b/inc/classes/main/file_directories/text/input/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/text/input/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/text/input/class_BaseInputTextFile.php b/inc/classes/main/file_directories/text/input/class_BaseInputTextFile.php deleted file mode 100644 index a35b6cce..00000000 --- a/inc/classes/main/file_directories/text/input/class_BaseInputTextFile.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseInputTextFile extends BaseTextFile { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Initializes this text file for reading - * - * @param $fileName File's name - * @return void - */ - protected function initFile ($fileName) { - // Get a file i/o pointer instance - $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_input_class', array($fileName)); - - // ... and set it here - $this->setPointerInstance($pointerInstance); - } - - /** - * Reads a line from currently referenced file - * - * @return $data Read data from referenced file - */ - public function readLine () { - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/text/input/csv/.htaccess b/inc/classes/main/file_directories/text/input/csv/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/text/input/csv/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/text/input/csv/class_CsvInputFile.php b/inc/classes/main/file_directories/text/input/csv/class_CsvInputFile.php deleted file mode 100644 index 9792c663..00000000 --- a/inc/classes/main/file_directories/text/input/csv/class_CsvInputFile.php +++ /dev/null @@ -1,172 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CsvInputFile extends BaseInputTextFile implements CsvInputStreamer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this File class and prepares it for usage - * - * @param $fileName Name of the index file - * @return $fileInstance An instance of this File class - */ - public final static function createCsvInputFile ($fileName) { - // Get a new instance - $fileInstance = new CsvInputFile(); - - // Set file name - $fileInstance->setFileName($fileName); - - // Init this abstract file - $fileInstance->initFile($fileName); - - // Return the prepared instance - return $fileInstance; - } - - /** - * Reads a line from CSV file and returns it as an indexed array. Please - * note that strings *must* be always in double-quotes, else any found - * column separators will be parsed or they may be interpreted incorrectly. - * - * @param $columnSeparator Character to use separting columns - * @return $lineArray An indexed array with the read line - */ - public function readCsvFileLine ($columnSeparator) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] columnSeparator=%s - CALLED!', __METHOD__, __LINE__, $columnSeparator)); - - // Read raw line - $data = $this->getPointerInstance()->readLine(); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data()=%d', __METHOD__, __LINE__, strlen($data))); - - // Parse data - $lineArray = $this->parseDataToIndexedArray($data, $columnSeparator); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - EXIT!', __METHOD__, __LINE__, count($lineArray))); - - // Return it - return $lineArray; - } - - /** - * Parses given data into an array - * - * @param $data Raw data e.g. returned from readLine() - * @param $columnSeparator Character to use separting columns - * @return $lineArray An indexed array with the read line - */ - private function parseDataToIndexedArray ($data, $columnSeparator) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data()=%d,columnSeparator=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $columnSeparator)); - - // Init return array - $lineArray = array(); - - // Whether the parser reads a quoted string (which may contain the column separator again) - $isInQuotes = FALSE; - - // Init column data - $column = ''; - - // Now parse the line - for ($idx = 0; $idx < strlen($data); $idx++) { - // "Cache" char - $char = substr($data, $idx, 1); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] idx=%s,char=%s ...', __METHOD__, __LINE__, $idx, $char)); - - // Is the column separator found and not within quotes? - if (($isInQuotes === FALSE) && ($char == $columnSeparator)) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Adding column=%s ...', __METHOD__, __LINE__, $column)); - - // Add this line to the array - array_push($lineArray, $column); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - After add!', __METHOD__, __LINE__, count($lineArray))); - - // Clear variable ... - $column = ''; - - // ... and skip it - continue; - } elseif ($char == chr(34)) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] column=%s ...', __METHOD__, __LINE__, $column)); - - // $column must be empty at this point if we are at starting quote - assert(($isInQuotes === TRUE) || (empty($column))); - - // Double-quote found, so flip variable - $isInQuotes = (!$isInQuotes); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] isInQuotes=%d ...', __METHOD__, __LINE__, intval($isInQuotes))); - - // Skip double-quote (escaping of them is not yet supported) - continue; - } - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Adding char=%s ...', __METHOD__, __LINE__, $idx, $char)); - - // Add char to column - $column .= $char; - } // END - for - - // Is there something outstanding? - if (!empty($column)) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Adding column=%s ...', __METHOD__, __LINE__, $column)); - - // Then don't forget this. :-) - array_push($lineArray, $column); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - After add!', __METHOD__, __LINE__, count($lineArray))); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - EXIT!', __METHOD__, __LINE__, count($lineArray))); - - // Return it - return $lineArray; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/file_directories/text/output/.htaccess b/inc/classes/main/file_directories/text/output/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/file_directories/text/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/file_directories/text/output/class_BaseOutputTextFile.php b/inc/classes/main/file_directories/text/output/class_BaseOutputTextFile.php deleted file mode 100644 index df3857e2..00000000 --- a/inc/classes/main/file_directories/text/output/class_BaseOutputTextFile.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseOutputTextFile extends BaseAbstractFile { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Initializes this text file for reading - * - * @param $fileName File's name - * @return void - */ - protected function initFile ($fileName) { - // Get a file i/o pointer instance - $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_output_class', array($fileName)); - - // ... and set it here - $this->setPointerInstance($pointerInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/.htaccess b/inc/classes/main/filter/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/auth/.htaccess b/inc/classes/main/filter/auth/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/auth/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/auth/class_UserAuthFilter.php b/inc/classes/main/filter/auth/class_UserAuthFilter.php deleted file mode 100644 index bdefcd96..00000000 --- a/inc/classes/main/filter/auth/class_UserAuthFilter.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserAuthFilter extends BaseFilter implements Filterable { - // Exception constants - const EXCEPTION_AUTH_DATA_INVALID = 0x1b0; - - /** - * The login method we shall choose - */ - private $authMethod = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserAuthFilter () { - // Get a new instance - $filterInstance = new UserAuthFilter(); - - // Set default auth method - $filterInstance->setDefaultAuthMethod(); - - // Return the instance - return $filterInstance; - } - - /** - * Setter for default login method from config - * - * @return void - */ - protected function setDefaultAuthMethod () { - $this->authMethod = $this->getConfigInstance()->getConfigEntry('auth_method_class'); - } - - /** - * 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 UserAuthorizationException If the auth login was not found or if it was invalid - * @throws UserPasswordMismatchException If the supplied password hash does not match - * @throws NoClassException If the user (guest/member) class was not found - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Then get an auth instance for checking and updating the auth cookies - $authInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance)); - - // Set request instance - $authInstance->setRequestInstance($requestInstance); - - // Now, get the auth data for comparison - $authLogin = $authInstance->getUserAuth(); - $authHash = $authInstance->getPasswordAuth(); - - // If one is empty stop here - if ((empty($authLogin)) || (empty($authHash))) { - // Destroy the auth data - $authInstance->destroyAuthData(); - - // Mark the request as invalid - $requestInstance->requestIsValid(FALSE); - - // Add fatal message - $responseInstance->addFatalMessage('auth_data_incomplete'); - - // Stop here - throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID); - } // END - if - - // Regular user account - $className = $this->getConfigInstance()->getConfigEntry('user_class'); - $methodName = 'createMemberByUserName'; - - // Now, try to get a user or guest instance - if ($authLogin == $this->getConfigInstance()->getConfigEntry('guest_login_user')) { - // Set class - $className = $this->getConfigInstance()->getConfigEntry('guest_class'); - $methodName = 'createGuestByUserName'; - } // END - if - - // Does the guest class exist? - if (!class_exists($className)) { - // Then abort here - throw new NoClassException (array($this, $className), self::EXCEPTION_CLASS_NOT_FOUND); - } // END - if - - // Now try the dynamic login - $userInstance = call_user_func_array(array($className, $methodName), array($authLogin)); - - // Is the password correct? - if ($userInstance->getPasswordHash() !== $authHash) { - // Mismatching password - throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH); - } // END - if - - // Remember auth and user instances in registry - Registry::getRegistry()->addInstance('auth', $authInstance); - Registry::getRegistry()->addInstance('user', $userInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/change/.htaccess b/inc/classes/main/filter/change/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/change/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/change/class_EmailChangeFilter.php b/inc/classes/main/filter/change/class_EmailChangeFilter.php deleted file mode 100644 index a7c4ef7e..00000000 --- a/inc/classes/main/filter/change/class_EmailChangeFilter.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class EmailChangeFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createEmailChangeFilter () { - // Get a new instance - $filterInstance = new EmailChangeFilter(); - - // 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 FilterChainException If this filter fails to operate - * @todo Implement email change of the user here. HINT: Use the User class! - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get both emails - $email1 = $requestInstance->getRequestElement('email1'); - $email2 = $requestInstance->getRequestElement('email2'); - - // Is only first email set? - if ((!empty($email1)) && (empty($email2))) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Email 2 is empty - $responseInstance->addFatalMessage('email2_empty'); - - // Stop processing here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Is only second email set? - if ((empty($email1)) && (!empty($email2))) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Email 1 is empty - $responseInstance->addFatalMessage('email1_empty'); - - // Stop processing here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Do both match? - if ($email1 != $email2) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Emails are mismatching - $responseInstance->addFatalMessage('emails_mismatch'); - - // Stop processing here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Are email and confirmation empty? - if ((empty($email1)) && (empty($email2))) { - // No email change required! - return TRUE; - } // END - if - - // Now, get a user instance for comparison - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Get the email field - $userEmail = $userInstance->getField('email'); - - // Are they different? - if ($userEmail == $email1) { - // Nothing has been changed is fine... - return TRUE; - } // END - if - - // Update the "new_email" field - $this->partialStub('Unfinished part.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/change/class_PasswordChangeFilter.php b/inc/classes/main/filter/change/class_PasswordChangeFilter.php deleted file mode 100644 index 9693f6ce..00000000 --- a/inc/classes/main/filter/change/class_PasswordChangeFilter.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PasswordChangeFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @param $controllerInstance An instance of a controller class - * @return $filterInstance An instance of this filter class - */ - public static final function createPasswordChangeFilter () { - // Get a new instance - $filterInstance = new PasswordChangeFilter(); - - // 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 - * @todo Finished updating user password hash here. HINT: Use the User class again. - * @throws FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get both passwords - $pass1 = $requestInstance->getRequestElement('pass1'); - $pass2 = $requestInstance->getRequestElement('pass2'); - - // Is only first email set? - if ((!empty($pass1)) && (empty($pass2))) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Email 2 is empty - $responseInstance->addFatalMessage('pass2_empty'); - - // Stop processing here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Is only second pass set? - if ((empty($pass1)) && (!empty($pass2))) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Email 1 is empty - $responseInstance->addFatalMessage('pass1_empty'); - - // Stop processing here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Are password and confirmation empty? - if ((empty($pass1)) && (empty($pass2))) { - // Don't change password here - return TRUE; - } // END - if - - // Do both match? - if ($pass1 != $pass2) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Emails are mismatching - $responseInstance->addFatalMessage('pass_mismatch'); - - // Stop processing here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Now, get a user instance for comparison - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Update the "password" field - $this->partialStub('Unfinished part.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/checkboxes/.htaccess b/inc/classes/main/filter/checkboxes/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/checkboxes/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php b/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php deleted file mode 100644 index 95650659..00000000 --- a/inc/classes/main/filter/checkboxes/class_RulesAcceptedFilter.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RulesAcceptedFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createRulesAcceptedFilter () { - // Get a new instance - $filterInstance = new RulesAcceptedFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get the "rules" value from request - $rules = $requestInstance->getRequestElement('rules'); - - // Was the "rules" value found in form? And is it set? - if (is_null($rules)) { - // Not found in form so stop processing here - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('rules_unchecked'); - - // Skip further processing - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/class_ b/inc/classes/main/filter/class_ deleted file mode 100644 index 39a538cf..00000000 --- a/inc/classes/main/filter/class_ +++ /dev/null @@ -1,64 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Filter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public final static function create???Filter () { - // Get a new instance - $filterInstance = new ???Filter(); - - // 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 FilterChainException If this filter fails to operate - * @todo 0% done - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Implement this! - $this->partialStub("Please implement this method."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/class_BaseFilter.php b/inc/classes/main/filter/class_BaseFilter.php deleted file mode 100644 index 0a067a48..00000000 --- a/inc/classes/main/filter/class_BaseFilter.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseFilter extends BaseFrameworkSystem { - // Exception constants - const EXCEPTION_FILTER_CHAIN_ABORTED = 0x1a0; - - /** - * Protected constructor - * - * @param $className Name of the filter class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/class_BaseFilterDecorator.php b/inc/classes/main/filter/class_BaseFilterDecorator.php deleted file mode 100644 index 81b987a6..00000000 --- a/inc/classes/main/filter/class_BaseFilterDecorator.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -abstract class BaseFilterDecorator extends BaseFrameworkSystem implements Filterable { - /** - * The decorated filter instance - */ - private $filterInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of the real class' name - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for the decorated filter instance - * - * @param $filterInstance An instance of a filter - * @return void - */ - protected final function setFilterInstance (Filterable $filterInstance) { - $this->filterInstance = $filterInstance; - } - - /** - * Getter for the decorated filter instance - * - * @return $filterInstance An instance of a filter - */ - protected final function getFilterInstance () { - return $this->filterInstance; - } - - /** - * Execute the inner filter - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public final function execute (Requestable $requestInstance, Responseable $responseInstance) { - $this->getFilterInstance()->execute($requestInstance, $responseInstance); - } - - - /** - * Do the execution of the filter - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance); -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/class_FilterChain.php b/inc/classes/main/filter/class_FilterChain.php deleted file mode 100644 index e80c956d..00000000 --- a/inc/classes/main/filter/class_FilterChain.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FilterChain extends BaseFrameworkSystem implements Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $chainInstance An instance of this class - */ - public static final function createFilterChain () { - // Get a new instance - $chainInstance = new FilterChain(); - - // Return the prepared instance - return $chainInstance; - } - - /** - * Add a new filter - * - * @param $filerInstance An instance of a filter class - * @return void - */ - public final function addFilter (Filterable $filterInstance) { - $this->pushValueToGenericArrayKey('filters', 'generic', 'dummy', $filterInstance); - } - - /** - * Add a new post-filter - * - * @param $filerInstance An instance of a post-filter class - * @return void - */ - public final function addPostFilter (Filterable $filterInstance) { - $this->pushValueToGenericArrayKey('filters', 'post', 'dummy', $filterInstance); - } - - /** - * "Getter" for filters array - * - * @return $filters The filters array holding all filter instances - */ - protected function getFilters () { - // Default is nothing found - $filters = array(); - - // Are some filters set? - if ($this->isValidGenericArrayKey('filters', 'generic', 'dummy')) { - // Then get them - $filters = $this->getGenericArrayKey('filters', 'generic', 'dummy'); - } // END - if - - // Return it - return $filters; - } - - /** - * "Getter" for post-filters array - * - * @return $filters The filters array holding all post-filter instances - */ - protected function getPostFilters () { - // Default is nothing found - $filters = array(); - - // Are some filters set? - if ($this->isValidGenericArrayKey('filters', 'post', 'dummy')) { - // Then get them - $filters = $this->getGenericArrayKey('filters', 'post', 'dummy'); - } // END - if - - // Return it - return $filters; - } - - /** - * Process all added filters. Please note that filters must throw - * FilterChainException if they need to interrupt the filter chain. - * - * @param $requestInstance An instance of a request class - * @param $responseInstance An instance of a response class - * @return void - */ - public function processFilters (Requestable $requestInstance, Responseable $responseInstance) { - // Run all filters - //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('COUNT=' . $this->countGenericArray('filters')); - foreach ($this->getFilters() as $filterInstance) { - // Must be an instance of Filterable - assert($filterInstance instanceof Filterable); - - // Try to execute this filter - try { - //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing started.'); - $filterInstance->execute($requestInstance, $responseInstance); - //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing ended.'); - } catch (FilterChainException $e) { - // This exception can be thrown to just skip any further processing - self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); - break; - } - } // END - foreach - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/crypto/.htaccess b/inc/classes/main/filter/crypto/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/crypto/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php b/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php deleted file mode 100644 index e019b35b..00000000 --- a/inc/classes/main/filter/crypto/class_CaptchaEncryptFilter.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CaptchaEncryptFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final 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()->getConfigEntry('captcha_string_length')) { - // Not found, so request is invalid - $requestInstance->requestIsValid(FALSE); - - // Throw exception - throw new EncryptInvalidLengthException($this, CryptoHelper::EXCEPTION_ENCRYPT_INVALID); - } // END - if - - // Write it to the request - $requestInstance->setRequestElement('decrypted', $decryptedString); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/decorator/.htaccess b/inc/classes/main/filter/decorator/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/decorator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/guest/.htaccess b/inc/classes/main/filter/guest/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/guest/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php b/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php deleted file mode 100644 index 1382f2ca..00000000 --- a/inc/classes/main/filter/guest/class_UserNameIsGuestFilter.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserNameIsGuestFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserNameIsGuestFilter () { - // Get a new instance - $filterInstance = new UserNameIsGuestFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get username from request - $userName = $requestInstance->getRequestElement('username'); - - // Does the user name match the guest login? - if ($userName == $this->getConfigInstance()->getConfigEntry('guest_login_user')) { - // Then set the password to the configured password - $requestInstance->setRequestElement('pass1', $this->getConfigInstance()->getConfigEntry('guest_login_passwd')); - $requestInstance->setRequestElement('pass2', $this->getConfigInstance()->getConfigEntry('guest_login_passwd')); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/news/.htaccess b/inc/classes/main/filter/news/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/news/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/news/class_NewsDownloadFilter.php b/inc/classes/main/filter/news/class_NewsDownloadFilter.php deleted file mode 100644 index 2e1fb8df..00000000 --- a/inc/classes/main/filter/news/class_NewsDownloadFilter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NewsDownloadFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNewsDownloadFilter () { - // Get a new instance - $filterInstance = new NewsDownloadFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a news instance - $newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance); - - // Store the news instance in registry - Registry::getRegistry()->addInstance('news', $newsInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/news/class_NewsProcessFilter.php b/inc/classes/main/filter/news/class_NewsProcessFilter.php deleted file mode 100644 index 27ea97e8..00000000 --- a/inc/classes/main/filter/news/class_NewsProcessFilter.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NewsProcessFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNewsProcessFilter () { - // Get a new instance - $filterInstance = new NewsProcessFilter(); - - // 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 - * @todo Unfinished stub, add functionality here - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/null/.htaccess b/inc/classes/main/filter/null/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/null/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/null/class_NullFilter.php b/inc/classes/main/filter/null/class_NullFilter.php deleted file mode 100644 index c340c6f3..00000000 --- a/inc/classes/main/filter/null/class_NullFilter.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NullFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createNullFilter () { - // Get a new instance - $filterInstance = new NullFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Not implemented, just passing through - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/payment/.htaccess b/inc/classes/main/filter/payment/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/payment/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php b/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php deleted file mode 100644 index 7a016ece..00000000 --- a/inc/classes/main/filter/payment/class_PaymentDiscoveryFilter.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PaymentDiscoveryFilter extends BaseFilter implements Filterable { - /** - * Action name for payment discovery - */ - private $actionName = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @param $actionInstance A performable action - * @return $filterInstance An instance of this filter class - * @throws NullPointerException If the resolver is not set - */ - public static final function createPaymentDiscoveryFilter (PerformableAction $actionInstance) { - // Get a new instance - $filterInstance = new PaymentDiscoveryFilter(); - - // Get resolver from action - $resolverInstance = $actionInstance->getResolverInstance(); - - // Is the resolver set? - if (is_null($resolverInstance)) { - // Throw an exception here - throw new NullPointerException($filterInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get the action name from resolver - $actionName = $resolverInstance->getActionName(); - - // Store it away in this class - $filterInstance->setActionName($actionName); - - // Return the instance - return $filterInstance; - } - - /** - * Protected setter for action name - * - * @param $actionName Action name to set - * @return void - */ - protected final function setActionName ($actionName) { - $this->actionName = (string) $actionName; - } - - /** - * Getter for action name - * - * @return $actionName Action name to set - */ - public final function getActionName () { - return $this->actionName; - } - - /** - * 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 - * @todo 0% done - * @throws FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Try to get real discovery class - try { - // Get an instance from the object factory - $discoveryInstance = ObjectFactory::createObjectByConfiguredName($this->getActionName() . '_payment_discovery', array($this)); - - // Call the discovery method - $discoveryInstance->discover($requestInstance); - - // Remember this instance if all wents fine - Registry::getRegistry()->addInstance('payments', $discoveryInstance); - } catch (NoConfigEntryException $e) { - // Something bad happend - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('payment_config_entry_error'); - $responseInstance->addFatalMessagePlain($e->getMessage()); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } catch (NoClassException $e) { - // Something bad happend - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('payment_class_error'); - $responseInstance->addFatalMessagePlain($e->getMessage()); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/update/.htaccess b/inc/classes/main/filter/update/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/update/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php b/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php deleted file mode 100644 index 810103e6..00000000 --- a/inc/classes/main/filter/update/class_UserStatusConfimedUpdateFilter.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserStatusConfimedUpdateFilter () { - // Get a new instance - $filterInstance = new UserStatusConfimedUpdateFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get user instance from registry - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Get "confirmed" status from config - $confirmed = $this->getConfigInstance()->getConfigEntry('user_status_confirmed'); - - // Update the user status to "confirmed" here - $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $confirmed); - - // Wipe out the confirm hash for extra security - $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, ''); - - // Write all updates to the database - $userInstance->flushPendingUpdates(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/update/class_UserUpdateFilter.php b/inc/classes/main/filter/update/class_UserUpdateFilter.php deleted file mode 100644 index c9a054db..00000000 --- a/inc/classes/main/filter/update/class_UserUpdateFilter.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserUpdateFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserUpdateFilter () { - // Get a new instance - $filterInstance = new UserUpdateFilter(); - - // 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 - * @todo Add more user updates here - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get user instance from registry - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Now update last activity - $userInstance->updateLastActivity($requestInstance); - - // Update auth data as well - $authInstance = Registry::getRegistry()->getInstance('auth'); - $authInstance->updateAuthData(); - - // Write all updates to the database - $userInstance->flushPendingUpdates(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/validator/.htaccess b/inc/classes/main/filter/validator/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/validator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php b/inc/classes/main/filter/validator/class_EmailValidatorFilter.php deleted file mode 100644 index d01d8256..00000000 --- a/inc/classes/main/filter/validator/class_EmailValidatorFilter.php +++ /dev/null @@ -1,169 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class EmailValidatorFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createEmailValidatorFilter () { - // Get a new instance - $filterInstance = new EmailValidatorFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get Email from request - $email = $requestInstance->getRequestElement('email'); - - // Is the Email set? - if ((is_null($email)) || ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y')) { - // Try it again - $email1 = $requestInstance->getRequestElement('email1'); - $email2 = $requestInstance->getRequestElement('email2'); - - // Is the email still not set? - if ((is_null($email1)) || (is_null($email2))) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('email_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ((empty($email1)) || (empty($email2))) { - // Email is empty - $requestInstance->requestIsValid(FALSE); - - // Is the email empty? - if (empty($email1)) { - // Add a message to the response - $responseInstance->addFatalMessage('email1_empty'); - } // END - if - - // Is the confirmation empty? - if (empty($email2)) { - // Add a message to the response - $responseInstance->addFatalMessage('email2_empty'); - } // END - if - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ($this->ifEmailIsTaken($email1)) { - // Email is already taken - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('email_taken'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ($email1 != $email2) { - // Emails didn't match - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('emails_mismatch'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - elseif - } elseif (empty($email)) { - // Empty field! - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('email_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - elseif - } - - /** - * Check whether the email as already been taken - * - * @param $email Email to check for existence - * @return $alreadyTaken Whether the email has been taken - */ - private function ifEmailIsTaken ($email) { - // Default is already taken - $alreadyTaken = TRUE; - - // Initialize instance - $userInstance = NULL; - - // Get a registry instance - $registry = Registry::getRegistry(); - - // Is the user already there? - if ($registry->instanceExists('user')) { - // Use the instance for checking for the email - $userInstance = $registry->getInstance('user'); - $userInstance->setEmailAddress($email); - } else { - // If this instance is created then the username *does* exist - $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByEmail'), array($email)); - - // Remember this user instance in our registry for later usage - $registry->addInstance('user', $userInstance); - } - - // Does the email exist? - if ($userInstance->ifEmailAddressExists() === FALSE) { - // This email has not being used yet - $alreadyTaken = FALSE; - } - - // Return the result - return $alreadyTaken; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php b/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php deleted file mode 100644 index e8c381a7..00000000 --- a/inc/classes/main/filter/validator/class_PasswordValidatorFilter.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PasswordValidatorFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createPasswordValidatorFilter () { - // Get a new instance - $filterInstance = new PasswordValidatorFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get passwords - $password1 = $requestInstance->getRequestElement('pass1'); - $password2 = $requestInstance->getRequestElement('pass2'); - - // Is the password still not set? - if ((is_null($password1)) || (is_null($password2))) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('password_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ((empty($password1)) || (empty($password2))) { - // Password is empty - $requestInstance->requestIsValid(FALSE); - - // Is the password empty? - if (empty($password1)) { - // Add a message to the response - $responseInstance->addFatalMessage('pass1_empty'); - } // END - if - - // Is the confirmation empty? - if (empty($password2)) { - // Add a message to the response - $responseInstance->addFatalMessage('pass2_empty'); - } // END - if - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ($password1 != $password2) { - // Passwords didn't match - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('pass_mismatch'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - elseif - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php b/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php deleted file mode 100644 index 256bf3d6..00000000 --- a/inc/classes/main/filter/validator/class_UserNameValidatorFilter.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserNameValidatorFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserNameValidatorFilter () { - // Get a new instance - $filterInstance = new UserNameValidatorFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get username from request - $userName = $requestInstance->getRequestElement('username'); - - // Is the username set? - if (is_null($userName)) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($userName)) { - // Empty field! - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ($this->ifUserNameIsTaken($userName)) { - // Username is already taken - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_taken'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - } - - /** - * Check whether the username as already been taken - * - * @param $userName Username to check for existence - * @return $alreadyTaken Whether the username has been taken - */ - private function ifUserNameIsTaken ($userName) { - // Default is already taken - $alreadyTaken = TRUE; - - // Initialize instance - $userInstance = NULL; - - // Get a registry instance - $registry = Registry::getRegistry(); - - // Is the user already there? - if ($registry->instanceExists('user')) { - // Use the instance for checking for the email - $userInstance = $registry->getInstance('user'); - $userInstance->setUserName($userName); - } else { - // If this instance is created then the username *does* exist - try { - // Get a new instance - $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByUsername'), array($userName)); - - // Remember this user instance in our registry for later usage - $registry->addInstance('user', $userInstance); - } catch (UsernameMissingException $e) { - // User was not found - } - } - - // Does the username exist? - if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === FALSE)) { - // This username is still available - $alreadyTaken = FALSE; - } // END - if - - // Return the result - return $alreadyTaken; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/.htaccess b/inc/classes/main/filter/verifier/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/filter/verifier/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php b/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php deleted file mode 100644 index 80ca36fd..00000000 --- a/inc/classes/main/filter/verifier/class_AccountPasswordVerifierFilter.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class AccountPasswordVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createAccountPasswordVerifierFilter () { - // Get a new instance - $filterInstance = new AccountPasswordVerifierFilter(); - - // 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 AccountPasswordMismatchException If the account password does not match - * @throws FilterChainException If this filter fails to operate - * @todo Rewrite handling of different password fields - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get password - $password = $requestInstance->getRequestElement('pass_old'); - - // Is the password still not set? - if (is_null($password)) { - // Get password from alternative location - $password = $requestInstance->getRequestElement('password'); - - // Is the password still not set? - if (is_null($password)) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('password_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - } // END - if - - if (empty($password)) { - // Password is empty - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('password_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Get a user instance - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Get current hash - $currentHash = $userInstance->getField('pass_hash'); - - // Get an encryption helper and encrypt the password - $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash); - - // Does it match? - if ($currentHash != $passHash) { - // Throw an exception here to stop the proccessing - throw new AccountPasswordMismatchException($this, BaseUser::EXCEPTION_USER_PASS_MISMATCH); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_BirthdayVerifierFilter.php b/inc/classes/main/filter/verifier/class_BirthdayVerifierFilter.php deleted file mode 100644 index eb7122df..00000000 --- a/inc/classes/main/filter/verifier/class_BirthdayVerifierFilter.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BirthdayVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createBirthdayVerifierFilter () { - // Get a new instance - $filterInstance = new BirthdayVerifierFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Day of birth set? - if (!$requestInstance->isRequestElementSet('birth_day')) { - // Day of birth isn't set - $requestInstance->requestIsValid(false); - - // Add a message to the response - $responseInstance->addFatalMessage('day_of_birth_unset'); - } // END - if - - // Month of birth set? - if (!$requestInstance->isRequestElementSet('birth_month')) { - // Month of birth isn't set - $requestInstance->requestIsValid(false); - - // Add a message to the response - $responseInstance->addFatalMessage('month_of_birth_unset'); - } // END - if - - // Year of birth set? - if (!$requestInstance->isRequestElementSet('birth_year')) { - // Year of birth isn't set - $requestInstance->requestIsValid(false); - - // Add a message to the response - $responseInstance->addFatalMessage('year_of_birth_unset'); - } // END - if - - // Is the request still valid? - if (!$requestInstance->isRequestValid()) { - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Now comes the final check - $birthCheck = mktime( - 0, - 0, - 0, - (int) $requestInstance->getRequestElement('birth_day'), - (int) $requestInstance->getRequestElement('birth_month'), - (int) $requestInstance->getRequestElement('birth_year') - ); - - // Is there a number or such? (we don't care about the value itself here) - if (empty($birthCheck)) { - // Validation has failed - $requestInstance->requestIsValid(false); - - // Add a message to the response - $responseInstance->addFatalMessage('birthday_invalid'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php b/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php deleted file mode 100644 index 36d9e1c4..00000000 --- a/inc/classes/main/filter/verifier/class_ConfirmCodeVerifierFilter.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createConfirmCodeVerifierFilter () { - // Get a new instance - $filterInstance = new ConfirmCodeVerifierFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get confirmation code from request - $confirmCode = $requestInstance->getRequestElement('confirm'); - - // Is this code set? - if (is_null($confirmCode)) { - // Is not in request - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('confirm_code_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($confirmCode)) { - // Email is empty - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('confirm_code_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - - // Get a user instance from registry - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Get the confirm code from user for comparison - $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH); - - // Do we have the same code or different? - if ($userCode != $confirmCode) { - // Email is empty - $requestInstance->requestIsValid(FALSE); - - // Redirect to error page - $responseInstance->redirectToConfiguredUrl('confirm_code_invalid'); - - // Stop processing here - exit(); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php b/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php deleted file mode 100644 index 5dc0f575..00000000 --- a/inc/classes/main/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class GraphicalCodeCaptchaVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createGraphicalCodeCaptchaVerifierFilter () { - // Get a new instance - $filterInstance = new GraphicalCodeCaptchaVerifierFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Is the form set? - if (($requestInstance->getRequestElement('command') !== 'do_form') || (!$requestInstance->isRequestElementSet('form'))) { - // Required field not set - $requestInstance->requestIsValid(FALSE); - - // Add fatal message - $responseInstance->addFatalMessage('command_form_invalid'); - - // Skip further processing - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - if - - // Create config entry - $configKey = sprintf('%s_captcha_secured', - $requestInstance->getRequestElement('form') - ); - - // Is the CAPTCHA enabled? - if ($this->getConfigInstance()->getConfigEntry($configKey) != 'Y') { - // Not enabled, so don't check - return; - } // END - if - - // Get the captcha code - $captchaCode = $requestInstance->getRequestElement('c_code'); - - // Is this set? - if (is_null($captchaCode)) { - // Not set so request is invalid - $requestInstance->requestIsValid(FALSE); - - // Add fatal message - $responseInstance->addFatalMessage('captcha_code_unset'); - - // Skip further processing - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($captchaCode)) { - // Empty value so request is invalid - $requestInstance->requestIsValid(FALSE); - - // Add fatal message - $responseInstance->addFatalMessage('captcha_code_empty'); - - // Skip further processing - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - - // Get the hash as well - $captchaHash = $requestInstance->getRequestElement('hash'); - - // Is this set? - if (is_null($captchaHash)) { - // Not set so request is invalid - $requestInstance->requestIsValid(FALSE); - - // Add fatal message - $responseInstance->addFatalMessage('captcha_hash_unset'); - - // Skip further processing - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($captchaHash)) { - // Empty value so request is invalid - $requestInstance->requestIsValid(FALSE); - - // Add fatal message - $responseInstance->addFatalMessage('captcha_hash_empty'); - - // Skip further processing - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - - // Now, both are set hash the given one. First get a crypto instance - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - - // Then hash the code - $hashedCode = $cryptoInstance->hashString($captchaCode, $captchaHash); - - // Is this CAPTCHA valid? - if ($hashedCode != $captchaHash) { - // Not the same so request is invalid - $requestInstance->requestIsValid(FALSE); - - // Add fatal message - $responseInstance->addFatalMessage('captcha_hash_mismatch'); - - // Skip further processing - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } // END - not the same! - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php b/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php deleted file mode 100644 index 0f085da6..00000000 --- a/inc/classes/main/filter/verifier/class_PasswordGuestVerifierFilter.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PasswordGuestVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createPasswordGuestVerifierFilter () { - // Get a new instance - $filterInstance = new PasswordGuestVerifierFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get password - $password = $requestInstance->getRequestElement('passwd'); - - // Is the password still not set? - if (is_null($password)) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('password_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($password)) { - // Password is empty - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('password_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php b/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php deleted file mode 100644 index d5db67df..00000000 --- a/inc/classes/main/filter/verifier/class_PasswordVerifierFilter.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PasswordVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createPasswordVerifierFilter () { - // Get a new instance - $filterInstance = new PasswordVerifierFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get password - $password = $requestInstance->getRequestElement('pass'); - - // Is the password still not set? - if (is_null($password)) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('password_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($password)) { - // Password is empty - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('password_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php deleted file mode 100644 index dde15e7f..00000000 --- a/inc/classes/main/filter/verifier/class_UserGuestVerifierFilter.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserGuestVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserGuestVerifierFilter () { - // Get a new instance - $filterInstance = new UserGuestVerifierFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - * @throws FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get username from request - $userName = $requestInstance->getRequestElement('user'); - - // Is the username set? - if (is_null($userName)) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_guest_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($userName)) { - // Empty field! - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_guest_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ($this->ifUserGuestIsTaken($userName) === FALSE) { - // Username is already taken - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_guest_not_found'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - - // Set the element for compatiblity reasons - $requestInstance->setRequestElement('username', $userName); - } - - /** - * Check whether the username as already been taken - * - * @param $userName Username to check for existence - * @return $alreadyTaken Whether the username has been taken - */ - private function ifUserGuestIsTaken ($userName) { - // Default is already taken - $alreadyTaken = TRUE; - - // Initialize instance - $userInstance = NULL; - - // Get a registry instance - $registry = Registry::getRegistry(); - - // Is the user already there? - if ($registry->instanceExists('user')) { - // Use the instance for checking for the email - $userInstance = $registry->getInstance('user'); - $userInstance->setUserGuest($userName); - } else { - // If this instance is created then the username *does* exist - try { - // Get a new instance - $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('guest_class'), 'createGuestByUsername'), array($userName)); - - // Remember this user instance in our registry for later usage - $registry->addInstance('user', $userInstance); - } catch (UsernameMissingException $e) { - // User was not found - } - } - - // Does the username exist? - if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === FALSE)) { - // This username is still available - $alreadyTaken = FALSE; - } - - // Return the result - return $alreadyTaken; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php deleted file mode 100644 index ffa45412..00000000 --- a/inc/classes/main/filter/verifier/class_UserNameVerifierFilter.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserNameVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserNameVerifierFilter () { - // Get a new instance - $filterInstance = new UserNameVerifierFilter(); - - // 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 FilterChainException If this filter fails to operate - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get username from request - $userName = $requestInstance->getRequestElement('username'); - - // Is the username set? - if (is_null($userName)) { - // Not found in form so stop the filtering process - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_unset'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif (empty($userName)) { - // Empty field! - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_empty'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } elseif ($this->ifUserNameIsTaken($userName) === FALSE) { - // Username is already taken - $requestInstance->requestIsValid(FALSE); - - // Add a message to the response - $responseInstance->addFatalMessage('username_not_found'); - - // Abort here - throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); - } - } - - /** - * Check whether the username as already been taken - * - * @param $userName Username to check for existence - * @return $alreadyTaken Whether the username has been taken - */ - private function ifUserNameIsTaken ($userName) { - // Default is already taken - $alreadyTaken = TRUE; - - // Initialize instance - $userInstance = NULL; - - // Get a registry instance - $registry = Registry::getRegistry(); - - // Is the user already there? - if ($registry->instanceExists('user')) { - // Use the instance for checking for the email - $userInstance = $registry->getInstance('user'); - $userInstance->setUserName($userName); - } else { - // If this instance is created then the username *does* exist - try { - // Get a new instance - $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByUsername'), array($userName)); - - // Remember this user instance in our registry for later usage - $registry->addInstance('user', $userInstance); - } catch (UsernameMissingException $e) { - // User was not found - } - } - - // Does the username exist? - if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === FALSE)) { - // This username is still available - $alreadyTaken = FALSE; - } // END - if - - // Return the result - return $alreadyTaken; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php deleted file mode 100644 index 94b62a23..00000000 --- a/inc/classes/main/filter/verifier/class_UserStatusVerifierFilter.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserStatusVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserStatusVerifierFilter () { - // Get a new instance - $filterInstance = new UserStatusVerifierFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a user instance for comparison - $userInstance = Registry::getRegistry()->getInstance('user'); - - // Is the user account confirmed? - if ((!$userInstance->isConfirmed()) && (!$userInstance->isGuest()) && ($requestInstance->getRequestElement('action') != $this->getConfigInstance()->getConfigEntry('action_status_problem'))) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Redirect to configured URL - $responseInstance->redirectToConfiguredUrl('login_user_status'); - - // Stop processing here - exit(); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php deleted file mode 100644 index 897951d4..00000000 --- a/inc/classes/main/filter/verifier/class_UserUnconfirmedVerifierFilter.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this filter class - * - * @return $filterInstance An instance of this filter class - */ - public static final function createUserUnconfirmedVerifierFilter () { - // Get a new instance - $filterInstance = new UserUnconfirmedVerifierFilter(); - - // Return the instance - return $filterInstance; - } - - /** - * Executes the filter with given request and response objects - * - * @param $requestInstance An instance of a class with an Requestable interface - * @param $responseInstance An instance of a class with an Responseable interface - * @return void - */ - public function execute (Requestable $requestInstance, Responseable $responseInstance) { - // Get a user instance for comparison - $userInstance = UserFactory::createUserByRequest($requestInstance); - - // Is the email address valid? - if ($userInstance->ifEmailAddressExists() === FALSE) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Redirect to configured URL - $responseInstance->redirectToConfiguredUrl('user_unconfirmed_email_missing'); - - // Stop processing here - exit(); - } // END - if - - // Is the user account confirmed? - if ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed')) { - // Request is invalid! - $requestInstance->requestIsValid(FALSE); - - // Redirect to configured URL - $responseInstance->redirectToConfiguredUrl('user_not_unconfirmed'); - - // Stop processing here - exit(); - } // END - if - - // Add this instance to registry - Registry::getRegistry()->addInstance('user', $userInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/handler/.htaccess b/inc/classes/main/handler/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/handler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/handler/class_ b/inc/classes/main/handler/class_ deleted file mode 100644 index 8bb9ced3..00000000 --- a/inc/classes/main/handler/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Handler extends BaseHandler implements Handleable___ { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('!!!'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a !!! class - */ - public final static function create???Handler () { - // Get new instance - $handlerInstance = new ???Handler(); - - // Return the prepared instance - return $handlerInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/handler/class_BaseHandler.php b/inc/classes/main/handler/class_BaseHandler.php deleted file mode 100644 index e9512006..00000000 --- a/inc/classes/main/handler/class_BaseHandler.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHandler extends BaseFrameworkSystem implements HandleableDataSet { - /** - * Handler name - */ - private $handlerName = 'invalid'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for handler name - * - * @return $handlerName Name of this handler - */ - public final function getHandlerName () { - return $this->handlerName; - } - - /** - * Setter for handler name - * - * @param $handlerName Name of this handler - * @return void - */ - protected final function setHandlerName ($handlerName) { - $this->handlerName = $handlerName; - } - - /** - * Adds all required elements from given array into data set instance - * - * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data - * @return void - * @todo Rewrite this to use DHT - */ - public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { - // Add some generic data all messageData arrays provide - /* - $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]); - $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_MESSAGE_TYPE , $messageData[NetworkPackage::MESSAGE_ARRAY_TYPE]); - */ - } -} - -// [EOF] -?> diff --git a/inc/classes/main/handler/raw_data/.htaccess b/inc/classes/main/handler/raw_data/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/handler/raw_data/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/handler/raw_data/class_ b/inc/classes/main/handler/raw_data/class_ deleted file mode 100644 index 1a215b06..00000000 --- a/inc/classes/main/handler/raw_data/class_ +++ /dev/null @@ -1,73 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('!!!'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a Networkable class - */ - public final static function create???NetworkPackageHandler () { - // Get new instance - $handlerInstance = new ???NetworkPackageHandler(); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Processes a package from given resource. This is mostly useful for TCP - * package handling and is implemented in the TcpListener class - * - * @param $resource A valid resource identifier - * @return void - * @throws InvalidResourceException If the given resource is invalid - * @todo 0% - */ - public function processResourcePackage ($resource) { - // Check the resource - if (!is_resource($resource)) { - // Throw an exception - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } // END - if - - // Implement processing here - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/handler/tasks/.htaccess b/inc/classes/main/handler/tasks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/handler/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/handler/tasks/class_TaskHandler.php b/inc/classes/main/handler/tasks/class_TaskHandler.php deleted file mode 100644 index da7c2af6..00000000 --- a/inc/classes/main/handler/tasks/class_TaskHandler.php +++ /dev/null @@ -1,347 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TaskHandler extends BaseHandler implements Registerable, HandleableTask { - // Exception constants - const EXCEPTION_TASK_IS_INVALID = 0xb00; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set handler name - $this->setHandlerName('task'); - } - - /** - * Creates an instance of this class - * - * @return $handlerInstance An instance of a HandleableTask class - */ - public static final function createTaskHandler () { - // Get new instance - $handlerInstance = new TaskHandler(); - - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Initializing task handler.'); - - // Init the task list - $handlerInstance->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class')); - - // Get default instance - $handlerInstance->setIteratorInstance($handlerInstance->getListInstance()->getIterator()); - - // Init visitor instance for faster loop - $handlerInstance->setVisitorInstance(ObjectFactory::createObjectByConfiguredName('active_task_visitor_class')); - - // Register the first (and generic) idle-loop task - $taskInstance = ObjectFactory::createObjectByConfiguredName('idle_task_class'); - $handlerInstance->registerTask('idle_loop', $taskInstance); - - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task handler initialized.'); - - // Return the prepared instance - return $handlerInstance; - } - - /** - * Tries to execute the given task. If as task should not be started (yet) - * or the interval time (see task_interval_delay) is not yet reached the - * task is quietly skipped. - * - * @return void - * @throws InvalidTaskException If the current task is invalid - */ - private function executeCurrentTask () { - // Update no task by default - $updateTask = FALSE; - - // Is the current task valid? - if (!$this->getListInstance()->getIterator()->valid()) { - // Not valid! - throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID); - } // END - if - - // Get current task - $currentTask = $this->getListInstance()->getIterator()->current(); - - // Is the task not yet started? - if ($currentTask['task_started'] === FALSE) { - // Determine difference between current time and registration - $diff = ($this->getMilliTime() - $currentTask['task_registered']) * 1000; - - // Should we start now? - if ($diff < $currentTask['task_startup_delay']) { - // Skip this silently - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' not started: diff=' . $diff . ',task_startup_delay=' . $currentTask['task_startup_delay']); - return; - } // END - if - - // Launch the task and mark it as updated - $currentTask['task_started'] = TRUE; - $updateTask = TRUE; - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms'); - } // END - if - - // Get time difference from interval delay - $diff = ($this->getMilliTime() - $currentTask['task_last_activity']) * 1000; - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' diff=' . $diff . ',task_interval_delay=' . $currentTask['task_interval_delay'] . ',task_max_runs=' . $currentTask['task_max_runs'] . ',task_total_runs=' . $currentTask['task_total_runs']); - - // Is the interval delay reached? - if ((($diff < $currentTask['task_interval_delay']) && ($currentTask['task_max_runs'] == 0)) || (($currentTask['task_max_runs'] > 0) && ($currentTask['task_total_runs'] == $currentTask['task_max_runs']))) { - // Should we update the task from startup? - if ($updateTask === TRUE) { - // Update the task before leaving - $this->updateTask($currentTask); - } // END - if - - // Skip this silently - return; - } // END - if - - // Set last activity - $currentTask['task_last_activity'] = $this->getMilliTime(); - - // Count this run - $currentTask['task_total_runs']++; - - // Update the task - $this->updateTask($currentTask); - - // And visit/run it - // @TODO Messurement can be added around this call - $currentTask['task_instance']->accept($this->getVisitorInstance()); - } - - /** - * Updates given task by updating the underlaying list - * - * @param $taskEntry An array with a task - * @return void - */ - private function updateTask (array $taskEntry) { - // Get the key from current iteration - $key = $this->getListInstance()->getIterator()->key(); - - // Get the hash from key - $hash = $this->getListInstance()->getHash($key); - - // Update the entry - $this->getListInstance()->updateCurrentEntryByHash($hash, $taskEntry); - } - - /** - * Unregisters the given task - * - * @param $taskData Data of the task - * @return void - */ - private function unregisterTask (array $taskData) { - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - CALLED!'); - - // Remove the entry - $this->getListInstance()->removeEntry('tasks', $taskData); - - // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - EXIT!'); - } - - /** - * Searches a task by given instance - * - * @param $taskInstanc An instanceof a Taskable class - * @return $taskName Name of the task as used while registration - */ - public function searchTask (Taskable $taskInstance) { - // Default is an empty (not found) task name - $taskName = ''; - - // Get whole list - $taskList = $this->getListInstance()->getArrayFromList('tasks'); - - // Search all instances - foreach ($taskList as $currentTask) { - // Does it match given task instance? - if ($currentTask['task_instance']->equals($taskInstance)) { - // Found it - $taskName = $currentTask['id']; - - // Abort here - break; - } // END - if - } // END - foreach - - // Return found name - return $taskName; - } - - /** - * Registers a task with a task handler. - * - * @param $taskName A task name to register the task on - * @param $taskInstance The instance we should register as a task - * @return void - */ - public function registerTask ($taskName, Visitable $taskInstance) { - // Get interval delay - $intervalDelay = $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_interval_delay'); - $startupDelay = $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_startup_delay'); - - // If the task is 'idle_loop', a deplay of zero seconds is fine - assert($intervalDelay >= 0); - assert(($taskName === 'idle_loop') || (($taskName != 'idle_loop') && ($intervalDelay > 0))); - assert(($taskName === 'idle_loop') || (($taskName != 'idle_loop') && ($startupDelay > 0))); - - // Create the entry - $taskEntry = array( - // Identifier for the generateHash() method - 'id' => $taskName, - // Whether the task is started - 'task_started' => FALSE, - // Whether the task is paused (not yet implemented) - 'task_paused' => FALSE, - // Whether the task can be paused (not yet implemented) - 'task_pauseable' => TRUE, - // Timestamp of registration - 'task_registered' => $this->getMilliTime(), - // Last activity timestamp - 'task_last_activity' => 0, - // Total runs of this task - 'task_total_runs' => 0, - // Task instance itself - 'task_instance' => $taskInstance, - // Startup delay in milliseconds - 'task_startup_delay' => $startupDelay, - // Interval time (delay) in milliseconds before this task is executed again - 'task_interval_delay' => $intervalDelay, - // How often should this task run? - 'task_max_runs' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_max_runs'), - ); - - // Add the entry - $this->getListInstance()->addEntry('tasks', $taskEntry); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task registered: taskName=' . $taskName . - ' (taskInstance=' . $taskInstance->__toString() . ')' . - ', startupDelay=' . $taskEntry['task_startup_delay'] . 'ms' . - ', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms' . - ', maxRuns=' . $taskEntry['task_max_runs'] . ' ...' - ); - } - - /** - * Checks whether tasks are left including idle task - * - * @return $tasksLeft Whether there are tasks left to handle - */ - public function hasTasksLeft () { - // Do we have tasks there? - $tasksLeft = (($this->getListInstance() instanceof Listable) && ($this->getListInstance()->count() > 0)); - - // Return result - return $tasksLeft; - } - - /** - * Handles all tasks by checking if they should startup or if it is their - * turn to run. You should use this method in a while() loop in conjuntion - * with hasTasksLeft() so you can e.g. shutdown by adding a ShutdownTask - * which will attempt to remove all tasks from the task handler. - * - * @return void - */ - public function handleTasks () { - // Should we rewind? - if (!$this->getListInstance()->getIterator()->valid()) { - // Rewind to the beginning for next loop - $this->getListInstance()->getIterator()->rewind(); - } // END - if - - // Try to execute the task - $this->executeCurrentTask(); - - // Go to next entry - $this->getListInstance()->getIterator()->next(); - } - - /** - * Shuts down all tasks and the task handler itself. This method should be - * called from a corresponding filter class. - * - * @return void - */ - public function doShutdown () { - // Always rewind to the beginning for next loop - $this->getListInstance()->getIterator()->rewind(); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down all ' . $this->getListInstance()->count() . ' tasks...'); - - // Remember all tasks that has been shutdown for removal - $tasks = array(); - - // Instance a visitor - $this->setVisitorInstance(ObjectFactory::createObjectByConfiguredName('shutdown_task_visitor_class')); - - // Shutdown all tasks in once go - while ($this->getListInstance()->getIterator()->valid()) { - // Get current entry - $currentTask = $this->getListInstance()->getIterator()->current(); - - // Output debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...'); - - // Shutdown the task - $currentTask['task_instance']->accept($this->getVisitorInstance()); - - // Remember this task - array_push($tasks, $currentTask); - - // Advance to next one - $this->getListInstance()->getIterator()->next(); - } // END - while - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutdown of all tasks completed.'); - - // Remove all tasks - foreach ($tasks as $entry) { - $this->unregisterTask($entry); - } // END - foreach - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/.htaccess b/inc/classes/main/helper/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/captcha/.htaccess b/inc/classes/main/helper/captcha/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/captcha/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/captcha/class_ b/inc/classes/main/helper/captcha/class_ deleted file mode 100644 index 939cdf6d..00000000 --- a/inc/classes/main/helper/captcha/class_ +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Captcha extends BaseCaptcha implements SolveableCaptcha { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this captcha class - * - * @param $templateInstance An instance of a template engine - * @param $extraInstance An extra instance, just for better hash data - * @return $captchaInstance An instance of this captcha class - */ - public final static function create???Captcha (CompileableTemplate $templateInstance, FrameworkInterface $extraInstance = null) { - // Get a new instance - $captchaInstance = new ???Captcha(); - - // Set template instance - $captchaInstance->setTemplateInstance($templateInstance); - - // Initialize the RNG - $captchaInstance->initializeRandomNumberGenerator($extraInstance); - - // Return the instance - return $captchaInstance; - } - - /** - * Initiates the CAPTCHA - * - * @return void - * @todo 0% done - */ - public function initiateCaptcha () { - $this->partialStub("Please implement this method."); - } - - /** - * Render the CAPTCHA code - * - * @return void - * @todo 0% done - */ - public function renderCode () { - $this->partialStub("Please implement this method."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/captcha/class_BaseCaptcha.php b/inc/classes/main/helper/captcha/class_BaseCaptcha.php deleted file mode 100644 index 836190e2..00000000 --- a/inc/classes/main/helper/captcha/class_BaseCaptcha.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCaptcha extends BaseHelper { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Initializes the random number generator (RNG) - * - * @param $extraInstance An extra instance, just for better hash data - * @return void - */ - protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) { - // Get an RNG from factory - $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance))); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/captcha/images/.htaccess b/inc/classes/main/helper/captcha/images/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/captcha/images/.htaccess +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index cfe97e28..00000000 --- a/inc/classes/main/helper/captcha/images/class_ImageHelper.php +++ /dev/null @@ -1,396 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class 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 = ''; - - /** - * Base image - */ - private $baseImage = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__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 helper - */ - public static final 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 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 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(4, 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->loadImageTemplate($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 to keep this helper in sync with template engine - $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->renderXmlContent($imageContent); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/captcha/web/.htaccess b/inc/classes/main/helper/captcha/web/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/captcha/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php b/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php deleted file mode 100644 index 3d097bdb..00000000 --- a/inc/classes/main/helper/captcha/web/class_GraphicalCodeCaptcha.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha { - /** - * Hash of the CAPTCHA string - */ - private $hashedString = ''; - - /** - * Encrypted string - */ - private $encryptedString = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this captcha class - * - * @param $helperInstance An instance of a helper class - * @param $extraInstance An extra instance, just for better hash data - * @return $captchaInstance An instance of this captcha class - */ - public static final function createGraphicalCodeCaptcha (HelpableTemplate $helperInstance, FrameworkInterface $extraInstance = NULL) { - // Get a new instance - $captchaInstance = new GraphicalCodeCaptcha(); - - // Set template instance - $captchaInstance->setHelperInstance($helperInstance); - - // Initialize the RNG - $captchaInstance->initializeRandomNumberGenerator($extraInstance); - - // Return the instance - return $captchaInstance; - } - - /** - * Initiates the CAPTCHA - * - * @return void - */ - public function initiateCaptcha () { - // Get total length - $captchaLength = $this->getConfigInstance()->getConfigEntry('captcha_string_length'); - - // Get max string length - $strLength = $this->getConfigInstance()->getConfigEntry('random_string_length'); - - // Calculate starting position based on random place - $start = $this->getRngInstance()->randomNumber(0, ($strLength - $captchaLength)); - - // Test it - assert($start >= 0); - - // Generate a random string for confirmation - $randomString = $this->getRngInstance()->randomString($strLength); - - // Encode the string with BASE64 - $base64String = base64_encode($randomString); - - // Make this string a bit more readable for humans - $captchaString = substr($base64String, $start, $captchaLength); - - // Get all characters we want to replace - $searchChars = $this->getConfigInstance()->getConfigEntry('captcha_search_chars'); - - // Get fixed salt and use it as "replacement characters" - $replaceChars = $this->getRngInstance()->getExtraSalt(); - - // Remove any plus, equals or slashes - for ($searchIdx = 0; $searchIdx < strlen($searchChars); $searchIdx++) { - // Get search character - $search = substr($searchChars, $searchIdx, 1); - - // Random array index - $charIdx = $this->getRngInstance()->randomNumber(0, (strlen($replaceChars) - 1)); - - // Get replacement - $replace = substr($replaceChars, $charIdx, 1); - - // Replace character - $captchaString = str_replace($search, $replace, $captchaString, $captchaLength); - } // END - foreach - - // Get crypto instance - $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); - - // Hash the CAPTCHA code for later comparison - $this->hashedString = $cryptoInstance->hashString($captchaString); - - // Encrypt the string for later usage - $this->encryptedString = $cryptoInstance->encryptString($captchaString); - } - - /** - * Render the CAPTCHA code - * - * @return void - */ - public function renderCode () { - // Get helper instance - $helperInstance = $this->getHelperInstance(); - - // Get template instance - $templateInstance = $helperInstance->getTemplateInstance(); - - // Load a template for this CAPTCHA - $templateInstance->loadCodeTemplate('captch_graphic_code'); - - // Rename variable - $templateInstance->renameVariable('captcha_code', $helperInstance->getFormName() . '_captcha'); - $templateInstance->renameVariable('captcha_hash', $helperInstance->getFormName() . '_hash'); - $templateInstance->renameVariable('encrypted_code', $helperInstance->getFormName() . '_encrypt'); - - // Assign variables - $templateInstance->assignVariable($helperInstance->getFormName() . '_encrypt', urlencode(base64_encode($this->encryptedString))); - $templateInstance->assignVariable($helperInstance->getFormName() . '_hash', $this->hashedString); - - // Compile the template - $templateInstance->compileTemplate(); - - // Get the content back - $this->addContent($templateInstance->getRawTemplateData()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/class_ b/inc/classes/main/helper/class_ deleted file mode 100644 index 283d1d50..00000000 --- a/inc/classes/main/helper/class_ +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Helper extends BaseHelper { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function create???Helper () { - // Get new instance - $helperInstance = new ???Helper(); - - // Return the prepared instance - return $helperInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php deleted file mode 100644 index c06f86fd..00000000 --- a/inc/classes/main/helper/class_BaseHelper.php +++ /dev/null @@ -1,554 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHelper extends BaseFrameworkSystem { - /** - * Instance to the class which provides field values - */ - private $valueInstance = NULL; - - /** - * Extra instance to the class which provides field values - */ - private $extraInstance = NULL; - - /** - * Rendered content created by the helper class - */ - private $content = ''; - - /** - * Array with groups - */ - private $groups = array(); - - /** - * Array with sub group - */ - private $subGroups = array(); - - /** - * Previously opened group - */ - private $previousGroupId = ''; - - /** - * Previously opened sub group - */ - private $previousSubGroupId = ''; - - /** - * Total counter for groups and sub groups - */ - private $totalCounter = 0; - - // Exception constants - const EXCEPTION_GROUP_NOT_OPENED = 0x1e3; - const EXCEPTION_GROUP_ALREADY_FOUND = 0x1e4; - const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e5; - const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e6; - const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e7; - - /** - * Protected constructor - * - * @param $className Real name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Adds content directly - * - * @param $newContent New content to add - * @return void - */ - protected final function addContent ($newContent) { - $this->content .= (string) trim($newContent) . PHP_EOL; - } - - /** - * Add header content to the helper - * - * @param $content Content to to the base - * @return void - */ - protected function addHeaderContent ($content) { - // Add the header content - $this->groups['header']['content'] = (string) trim($content); - } - - /** - * Add footer content to the helper - * - * @param $content Content to to the base - * @return void - */ - protected function addFooterContent ($content) { - // Add the footer content - $this->groups['footer']['content'] = (string) trim($content); - } - - /** - * Adds content to the previously opened group or sub group. If a sub group - * was found it will be taken. If no group/sub group is opened at the moment - * the code will be passed to addContent(). - * - * @param $newContent New content to add - * @return void - */ - protected final function addContentToPreviousGroup ($newContent) { - // Check for sub/group - if ($this->ifSubGroupOpenedPreviously()) { - // Get sub group id - $subGroupId = $this->getPreviousSubGroupId(); - - // Add the content - $this->subGroups[$subGroupId]['content'] .= $newContent; - } elseif ($this->ifGroupOpenedPreviously()) { - // Get group id - $groupId = $this->getPreviousGroupId(); - - // Add the content - $this->groups[$groupId]['content'] .= $newContent; - } else { - // Add it directly - $this->addContent($newContent); - } - } - - /** - * Getter for content - * - * @return $content The rendered content by this helper - */ - protected final function getContent () { - return $this->content; - } - - /** - * Public setter for extra instance - * - * @param $extraInstance An extra instance of FrameworkInterface to set - * @return void - */ - public final function setExtraInstance (FrameworkInterface $extraInstance) { - $this->extraInstance = $extraInstance; - } - - /** - * Assigns a field from the value instance with a template variable - * - * @param $fieldName Name of the field to assign - * @return void - */ - public function assignField ($fieldName) { - // Get the value from value instance - $fieldValue = $this->getValueField($fieldName); - - // Assign it with a template variable - $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $fieldValue); - } - - /** - * Assigns a field from the value instance with a template variable but - * parses its content through a given filter method of the value instance - * - * @param $fieldName Name of the field to assign - * @param $filterMethod Method name to call of the value instance - * @return void - * @todo Rewrite this method using a helper class for filtering data - */ - public function assignFieldWithFilter ($fieldName, $filterMethod) { - // Get the value - $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'='.$fieldValue); - - // Now filter it through the value through the filter method - $filteredValue = call_user_func_array(array($this, 'doFilter' . self::convertToClassName($filterMethod)), array($fieldValue)); - - // Assign it with a template variable - $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $filteredValue); - } - - /** - * Pre-fetches field default values from the given registry key instance into this class - * - * @param $registryKey Registry key which holds an object with values - * @param $extraKey Extra value instance key used if registryKey is null - * @return void - * @throws NullPointerException If recovery of requested value instance failed - */ - public function prefetchValueInstance ($registryKey, $extraKey = NULL) { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('O:'.$registryKey.'/'.$extraKey); - try { - // Get the required instance - $this->valueInstance = Registry::getRegistry()->getInstance($registryKey); - } catch (NullPointerException $e) { - // Not set in registry - // @TODO Try to log it here - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($registryKey.'=NULL!'); - } - - // Shall we get an extra instance? - if (!is_null($extraKey)) { - try { - // Get the extra instance. - $this->extraInstance = Registry::getRegistry()->getInstance($extraKey); - } catch (NullPointerException $e) { - // Try to create it - $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance)); - } - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!'); - } // END - if - - // Is the value instance valid? - if (is_null($this->valueInstance)) { - // Get the requested instance - $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance)); - } // END - if - } - - /** - * Opens a helper group with given group id and content or throws an - * exception if that group is already found regardless if it is open or - * closed. - * - * @param $groupId Group id to open - * @param $content Initial content to add to the group - * @param $tag HTML tag used to open this group - * @return void - * @throws HelperGroupAlreadyCreatedException If the group was already created before - */ - protected function openGroupByIdContent ($groupId, $content, $tag) { - //* DEBUG: */ echo "OPEN:groupId={$groupId},content=
".htmlentities($content)."
\n"; - // Is the group already there? - if (isset($this->groups[$groupId])) { - // Then throw an exception here - throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND); - } // END - if - - // Count one up - $this->totalCounter++; - - // Add the group to the stack - $this->groups[$this->totalCounter] = $groupId; - $this->groups[$groupId]['opened'] = TRUE; - $this->groups[$groupId]['content'] = sprintf( - '%s' . PHP_EOL, - $groupId, - strlen($content), - $tag, - $content - ); - $this->groups[$groupId]['tag'] = $tag; - - // Mark this group as previously opened - $this->setPreviousGroupId($groupId); - } - - /** - * Closes the previously opened group by added given content to it or - * throws an exception if no previous group was opened - * - * @param $content Content for previously opened group, or empty to use tag of opener - * @return void - * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found - */ - public function closePreviousGroupByContent ($content = '') { - // Check if any sub group was opened before - if ($this->ifSubGroupOpenedPreviously()) { - // Close it automatically - $this->closePreviousSubGroupByContent(); - } // END - if - - // Check if any group was opened before - if ($this->ifGroupOpenedPreviously() === FALSE) { - // Then throw an exception - throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); - } // END - if - - // Get previous group - $groupId = $this->getPreviousGroupId(); - - // Is the content empty? - if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) { - // Get it from opener - $content = sprintf( - "", - $groupId, - $this->groups[$groupId]['tag'] - ); - } // END - if - - // Add content to it and mark it as closed - $this->groups[$groupId]['content'] .= sprintf( - "%s\n", - $groupId, - strlen($content), - $this->groups[$groupId]['tag'], - $content - ); - $this->groups[$groupId]['opened'] = FALSE; - - // Mark previous group as closed - $this->setPreviousGroupId(''); - //* DEBUG: */ echo "CLOSE:groupId={$groupId}
\n"; - } - - /** - * Opens a helper sub group with given group id and content or throws an - * exception if that sub group is already found regardless if it is open or - * closed. - * - * @param $subGroupId Sub group id to open - * @param $content Initial content to add to the sub group - * @param $tag HTML tag used to open this group - * @return void - * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before - */ - protected function openSubGroupByIdContent ($subGroupId, $content, $tag) { - //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."
\n"; - // Is the group already there? - if (isset($this->subGroups[$subGroupId])) { - // Then throw an exception here - throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND); - } // END - if - - // Count one up - $this->totalCounter++; - - // Add the group to the stack - $this->subGroups[$this->totalCounter] = $subGroupId; - $this->subGroups[$subGroupId]['opened'] = TRUE; - $this->subGroups[$subGroupId]['content'] = sprintf("%s\n", $subGroupId, strlen($content), $tag, $content); - $this->subGroups[$subGroupId]['tag'] = $tag; - - // Mark this group as previously opened - $this->setPreviousSubGroupId($subGroupId); - } - - /** - * Closes the previously opened sub group by added given content to it or - * throws an exception if no previous sub group was opened - * - * @param $content Content for previously opened sub group, or leave empty to use div/span of openener - * @return void - * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found - */ - public function closePreviousSubGroupByContent ($content = '') { - // Check if any sub group was opened before - if ($this->ifSubGroupOpenedPreviously() === FALSE) { - // Then throw an exception - throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); - } // END - if - - // Get previous sub group - $subGroupId = $this->getPreviousSubGroupId(); - - // Is the content empty? - if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) { - // Get it from opener - $content = sprintf('', $subGroupId, $this->subGroups[$subGroupId]['tag']); - } // END - if - - // Add content to it and mark it as closed - $this->subGroups[$subGroupId]['content'] .= sprintf('%s' . PHP_EOL, $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content); - $this->subGroups[$subGroupId]['opened'] = FALSE - ; - - // Mark previous sub group as closed - $this->setPreviousSubGroupId(''); - //* DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}
\n"; - } - - /** - * Renders all group and sub group in their order - * - * @return $content Rendered HTML content - */ - public function renderContent () { - // Initialize content - $content = ''; - - // Is header content there? - if (isset($this->groups['header'])) { - // Then add it - $content .= $this->groups['header']['content'] . PHP_EOL; - } // END - if - - // Initiate content - $content .= $this->getContent(); - - // Now "walk" through all groups and sub-groups - for ($idx = 1; $idx <= $this->totalCounter; $idx++) { - // Is this a sub/group and is it closed? - if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === FALSE)) { - // Then add it's content - $groupContent = trim($this->groups[$this->groups[$idx]]['content']); - //* DEBUG: */ echo "group={$this->groups[$idx]},content=
".htmlentities($groupContent)."

\n"; - $content .= $groupContent; - } elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === FALSE)) { - // Then add it's content - $subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content']; - //* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=
".htmlentities($subGroupContent)."

\n"; - $content .= trim($subGroupContent); - } else { - // Something went wrong - $this->debugInstance(__METHOD__ . '(): Something unexpected happened here.'); - } - } // END - for - - // Is footer content there? - if (isset($this->groups['footer'])) { - // Then add it - $content .= $this->groups['footer']['content'] . PHP_EOL; - } // END - if - - // Return it - //* DEBUG: */ echo "content=
".htmlentities($content)."
(".strlen($content).")
\n"; - return $content; - } - - /** - * Checks whether the specified group is opened - * - * @param $groupId Id of group to check - * @return $isOpened Whether the specified group is open - */ - protected function ifGroupIsOpened ($groupId) { - // Is the group open? - $isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === TRUE)); - - // Return status - return $isOpened; - } - - /** - * Getter for direct field values - * - * @param $fieldName Name of the field we shall fetch - * @return $fieldValue Value from field - * @throws NullPointerException Thrown if $valueInstance is null - */ - public function getValueField ($fieldName) { - // Init value - $fieldValue = NULL; - - // The $valueInstance attribute should not be null! - if (is_null($this->getValueInstance())) { - // Throws an exception here - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Is the field set? - if ($this->getValueInstance()->isFieldSet($fieldName)) { - // Get the field value - $fieldValue = $this->getValueInstance()->getField($fieldName); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!'); - } elseif ((!is_null($this->extraInstance)) && ($this->extraInstance->isFieldSet($fieldName))) { - // So try the extra instance - $fieldValue = $this->extraInstance->getField($fieldName); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!'); - } else { - // Field is not set - $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fieldName=' . $fieldName . ' is not set! - @TODO'); - } // END - if - - // Return it - return $fieldValue; - } - - /** - * Getter for value instance - * - * @return $valueInstance Instance of the class holding our values - */ - public final function getValueInstance () { - return $this->valueInstance; - } - - /** - * Check whether a group was opened previously - * - * @return $groupOpened Whether any group was opened before - */ - protected final function ifGroupOpenedPreviously () { - $groupOpened = (!empty($this->previousGroupId)); - return $groupOpened; - } - - /** - * Check whether a group was opened previously - * - * @return $subGroupOpened Whether any group was opened before - */ - protected final function ifSubGroupOpenedPreviously () { - $subGroupOpened = (!empty($this->previousSubGroupId)); - return $subGroupOpened; - } - - /** - * Getter for previous group id - * - * @return $previousGroupId Id of previously opened group - */ - protected final function getPreviousGroupId () { - return $this->previousGroupId; - } - - /** - * Setter for previous group id - * - * @param $previousGroupId Id of previously opened group - * @return void - */ - protected final function setPreviousGroupId ($previousGroupId) { - $this->previousGroupId = (string) $previousGroupId; - } - - /** - * Getter for previous sub group id - * - * @return $previousSubGroupId Id of previously opened sub group - */ - protected final function getPreviousSubGroupId () { - return $this->previousSubGroupId; - } - - /** - * Setter for previous sub group id - * - * @param $previousSubGroupId Id of previously opened sub group - * @return void - */ - protected final function setPreviousSubGroupId ($previousSubGroupId) { - $this->previousSubGroupId = (string) $previousSubGroupId; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/html/.htaccess b/inc/classes/main/helper/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/html/blocks/.htaccess b/inc/classes/main/helper/html/blocks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/html/blocks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/html/blocks/class_HtmlBlockHelper.php b/inc/classes/main/helper/html/blocks/class_HtmlBlockHelper.php deleted file mode 100644 index b0fc6605..00000000 --- a/inc/classes/main/helper/html/blocks/class_HtmlBlockHelper.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlBlockHelper extends BaseHtmlHelper implements HelpableTemplate { - /** - * Name of the block - */ - private $blockName = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates the helper class - * - * @param $templateInstance An instance of a template engine - * @param $blockName Name of the block we shall generate - * @return $helperInstance A prepared instance of this helper - */ - public static final function createHtmlBlockHelper (CompileableTemplate $templateInstance, $blockName) { - // Get new instance - $helperInstance = new HtmlBlockHelper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Set block name - $helperInstance->setBlockName($blockName); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Setter for block name - * - * @param $blockName Name of the block we shall generate - * @return void - */ - protected final function setBlockName ($blockName) { - $this->blockName = (string) $blockName; - } - - /** - * Getter for block name - * - * @return $blockName Name of the block we shall generate - */ - public final function getBlockName () { - return $this->blockName; - } - - /** - * Checks whether include registration date in this block - * - * @return $withRegistration Whether with registration date - */ - public function ifIncludeRegistrationStamp () { - $withRegistration = ($this->getConfigInstance()->getConfigEntry('block_shows_registration') == 'Y'); - return $withRegistration; - } - - /** - * Assignes a template variable with a message from a given message id - * - * @param $templateVariable Template variable to assign - * @param $messageId Message id to load an assign - * @return void - */ - public function assignMessageField ($templateVariable, $messageId) { - // Get message - $message = $this->getLanguageInstance()->getMessage($messageId); - - // And assign it - $this->getTemplateInstance()->assignVariable($templateVariable, $message); - } - - /** - * Assigns a link field with a given value - * - * @param $linkField "Link field" (variable) to assign - * @param $actionValue Action value to assign - * @return void - */ - public function assignLinkFieldWithAction ($linkField, $actionValue) { - $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); - } - - /** - * "Filter" method for translating the raw user status into something human-readable - * - * @param $userStatus Raw user status from database layer - * @return $translated Translated user status - */ - protected function doFilterUserStatusTranslator ($userStatus) { - // Generate message id - $messageId = 'user_status_' . strtolower($userStatus); - - // Get that message - $translated = $this->getLanguageInstance()->getMessage($messageId); - - // Return it - return $translated; - } - - /** - * Flush the content out,e g. to a template variable - * - * @return void - */ - public function flushContent () { - // Get template instance - $templateInstance = $this->getTemplateInstance(); - - // Get the template named like this block - $templateInstance->loadCodeTemplate('block_' . $this->getBlockName()); - - // Transfer it to the template instance - $templateInstance->assignVariable($this->getBlockName(), $templateInstance->getRawTemplateData()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/html/class_ b/inc/classes/main/helper/html/class_ deleted file mode 100644 index 09466e18..00000000 --- a/inc/classes/main/helper/html/class_ +++ /dev/null @@ -1,76 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Html???Helper extends BaseHtmlHelper implements HelpableTemplate { - /** - * Name of the ??? - */ - private $???Name = ""; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set part description - $this->setObjectDescription(""); - } - - /** - * Creates the helper class - * - * @param $templateInstance An instance of a template engine - * @param $???Name Name of the ??? we shall generate - * @return $helperInstance A prepared instance of this helper - */ - public final static function createHtml???Helper (CompileableTemplate $templateInstance, $???Name) { - // Get new instance - $helperInstance = new Html???Helper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Set ??? name - $helperInstance->set???Name($???Name); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Flush the content out,e g. to a template variable - * - * @return void - * @todo 0% done - */ - public function flushContent () { - $this->partialStub("Please implement this method."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/html/class_BaseHtmlHelper.php b/inc/classes/main/helper/html/class_BaseHtmlHelper.php deleted file mode 100644 index 02497dde..00000000 --- a/inc/classes/main/helper/html/class_BaseHtmlHelper.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHtmlHelper extends BaseHelper { - /** - * Protected constructor - * - * @param $className The real class name - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/html/forms/.htaccess b/inc/classes/main/helper/html/forms/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/html/forms/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/html/forms/class_HtmlFormHelper.php b/inc/classes/main/helper/html/forms/class_HtmlFormHelper.php deleted file mode 100644 index 3f4bc598..00000000 --- a/inc/classes/main/helper/html/forms/class_HtmlFormHelper.php +++ /dev/null @@ -1,938 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { - /** - * Whether the form tag is opened (keep at FALSE or else your forms will - * never work!) - */ - private $formOpened = FALSE; - - /** - * Name of the form - */ - private $formName = ''; - - /** - * Whether form tag is enabled (default: TRUE) - */ - private $formEnabled = TRUE; - - // Class Constants - const EXCEPTION_FORM_NAME_INVALID = 0x120; - const EXCEPTION_CLOSED_FORM = 0x121; - const EXCEPTION_OPENED_FORM = 0x122; - const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates the helper class with the given template engine instance and form name - * - * @param $templateInstance An instance of a valid template engine - * @param $formName Name of the form - * @param $formId Value for 'id' attribute (default: $formName) - * @param $withForm Whether include the form tag - * @return $helperInstance A preparedf instance of this helper - */ - public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = FALSE, $withForm = TRUE) { - // Get new instance - $helperInstance = new HtmlFormHelper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Is the form id not set? - if ($formId === FALSE) { - // Use form id from form name - $formId = $formName; - } // END - if - - // Set form name - $helperInstance->setFormName($formName); - - // A form-less field may say 'FALSE' here... - if ($withForm === TRUE) { - // Create the form - $helperInstance->addFormTag($formName, $formId); - } else { - // Disable form - $helperInstance->enableForm(FALSE); - } - - // Return the prepared instance - return $helperInstance; - } - - /** - * Add the form tag or close it an already opened form tag - * - * @param $formName Name of the form (default: FALSE) - * @param $formId Id of the form (attribute 'id'; default: FALSE) - * @return void - * @throws InvalidFormNameException If the form name is invalid ( = FALSE) - * @todo Add some unique PIN here to bypass problems with some browser and/or extensions - */ - public function addFormTag ($formName = FALSE, $formId = FALSE) { - // When the form is not yet opened at least form name must be valid - if (($this->formOpened === FALSE) && ($formName === FALSE)) { - // Thrown an exception - throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID); - } // END - if - - // Close the form is default - $formContent = ''; - - // Check whether we shall open or close the form - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Add HTML code - $formContent = sprintf("
getConfigInstance()->getConfigEntry('base_url'), - $this->getConfigInstance()->getConfigEntry('form_action'), - $this->getConfigInstance()->getConfigEntry('form_method'), - $this->getConfigInstance()->getConfigEntry('form_target') - ); - - // Add form id as well - $formContent .= sprintf(" id=\"%s_form\"", - $formId - ); - - // Add close bracket - $formContent .= '>'; - - // Open the form and remeber the form name - $this->formOpened = TRUE; - - // Add it to the content - $this->addHeaderContent($formContent); - } else { - // Add the hidden field required to identify safely this form - $this->addInputHiddenField('form', $this->getFormName()); - - // Is a group open? - if ($this->ifGroupOpenedPreviously()) { - // Then automatically close it here - $this->addFormGroup(); - } // END - if - - // Simply close it - $this->formOpened = FALSE; - - // Add it to the content - $this->addFooterContent($formContent); - } - } - - /** - * Add a text input tag to the form or throw an exception if it is not yet - * opened. The field's name will be set as id. - * - * @param $fieldName Input field name - * @param $fieldValue Input default value (default: empty) - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputTextField ($fieldName, $fieldValue = '') { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldName, - $fieldValue - ); - - // And add it maybe with a 'li' tag - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a text input tag to the form with pre-loaded default value - * - * @param $fieldName Input field name - * @return void - */ - public function addInputTextFieldWithDefault ($fieldName) { - // Get the value from instance - $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; - - // Add the text field - $this->addInputTextField($fieldName, $fieldValue); - } - - /** - * Add a password input tag to the form or throw an exception if it is not - * yet opened. The field's name will be set as id. - * - * @param $fieldName Input field name - * @param $fieldValue Input default value (default: empty) - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputPasswordField ($fieldName, $fieldValue = '') { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldName, - $fieldValue - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a hidden input tag to the form or throw an exception if it is not - * yet opened. The field's name will be set as id. - * - * @param $fieldName Input field name - * @param $fieldValue Input default value (default: empty) - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputHiddenField ($fieldName, $fieldValue = '') { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldValue - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a hidden input tag to the form with pre-loaded default value - * - * @param $fieldName Input field name - * @return void - */ - public function addInputHiddenFieldWithDefault ($fieldName) { - // Get the value from instance - $fieldValue = $this->getValueField($fieldName); - //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; - - // Add the text field - $this->addInputHiddenField($fieldName, $fieldValue); - } - - /** - * Add a hidden input tag to the form with configuration value - * - * @param $fieldName Input field name - * @param $prefix Prefix for configuration without trailing _ - * @return void - */ - public function addInputHiddenConfiguredField ($fieldName, $prefix) { - // Get the value from instance - $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}"); - //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
\n"; - - // Add the text field - $this->addInputHiddenField($fieldName, $fieldValue); - } - - /** - * Add a checkbox input tag to the form or throw an exception if it is not - * yet opened. The field's name will be set as id. - * - * @param $fieldName Input field name - * @param $fieldChecked Whether the field is checked (defaut: checked) - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputCheckboxField ($fieldName, $fieldChecked = TRUE) { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Set whether the check box is checked... - $checked = " checked=\"checked\""; - if ($fieldChecked === FALSE) $checked = ' '; - - // Generate the content - $inputContent = sprintf("", - $fieldName, - $fieldName, - $checked - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a reset input tag to the form or throw an exception if it is not - * yet opened. The field's name will be set as id. - * - * @param $buttonText Text displayed on the button - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputResetButton ($buttonText) { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $this->getFormName(), - $buttonText - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a reset input tag to the form or throw an exception if it is not - * yet opened. The field's name will be set as id. - * - * @param $buttonText Text displayed on the button - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputSubmitButton ($buttonText) { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("", - $this->getFormName(), - $this->getFormName(), - $buttonText - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add a form group or close an already opened and open a new one - * - * @param $groupId Name of the group or last opened if empty - * @param $groupText Text including HTML to show above this group - * @return void - * @throws FormClosedException If no form has been opened before - * @throws EmptyVariableException If $groupId is not set - */ - public function addFormGroup ($groupId = '', $groupText = '') { - // Is a form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw exception here - throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // At least the group name should be set - if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === FALSE)) { - // Throw exception here - throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (empty($groupId)) { - // Close the last opened - $groupId = $this->getPreviousGroupId(); - } - - // Same group to open? - if (($this->ifGroupOpenedPreviously() === FALSE) && ($groupId === $this->getPreviousGroupId())) { - // Abort here silently - return FALSE; - } // END - if - - // Initialize content with closing div by default - $content = " \n"; - - // Is this group opened? - if ($this->ifGroupOpenedPreviously() === FALSE) { - // Begin the div/span blocks - $content = sprintf(" -
- - %s - -
", - $groupId, - $groupId, - $groupId, - $groupText, - $groupId - ); - - // Switch the state - $this->openGroupByIdContent($groupId, $content, "div"); - } else { - // Is a sub group opened? - if ($this->ifSubGroupOpenedPreviously()) { - // Close it here - $this->addFormSubGroup(); - } // END - if - - // Get previous group id - $prevGroupId = $this->getPreviousGroupId(); - - // Switch the state - $this->closePreviousGroupByContent($content); - - // All call it again if group name is not empty - if ((!empty($groupId)) && ($groupId != $prevGroupId)) { - //* DEBUG: */ echo $groupId.'/'.$prevGroupId."
\n"; - $this->addFormGroup($groupId, $groupText); - } // END - if - } - } - - /** - * Add a form sub group or close an already opened and open a new one or - * throws an exception if no group has been opened before or if sub group - * name is empty. - * - * @param $subGroupId Name of the group or last opened if empty - * @param $subGroupText Text including HTML to show above this group - * @return void - * @throws FormFormClosedException If no group has been opened before - * @throws EmptyVariableException If $subGroupId is not set - */ - public function addFormSubGroup ($subGroupId = '', $subGroupText = '') { - // Is a group opened? - if ($this->ifGroupOpenedPreviously() === FALSE) { - // Throw exception here - throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP); - } // END - if - - // At least the sub group name should be set - if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === FALSE)) { - // Throw exception here - throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (empty($subGroupId)) { - // Close the last opened - $subGroupId = $this->getPreviousSubGroupId(); - } - - // Same sub group to open? - if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($subGroupId == $this->getPreviousSubGroupId())) { - // Abort here silently - return FALSE; - } // END - if - - // Initialize content with closing div by default - $content = "
\n
"; - - // Is this group opened? - if ($this->ifSubGroupOpenedPreviously() === FALSE) { - // Begin the span block - $content = sprintf(" -
- - %s - -
", - $subGroupId, - $subGroupId, - $subGroupId, - $subGroupText, - $subGroupId - ); - - // Switch the state and remeber the name - $this->openSubGroupByIdContent($subGroupId, $content, "div"); - } else { - // Get previous sub group id - $prevSubGroupId = $this->getPreviousSubGroupId(); - - // Switch the state - $this->closePreviousSubGroupByContent($content); - - // All call it again if sub group name is not empty - if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) { - $this->addFormSubGroup($subGroupId, $subGroupText); - } // END - if - } - } - - /** - * Add text surrounded by a span block when there is a group opened before - * or else by a div block. - * - * @param $fieldName Field name - * @param $fieldText Text for the field - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addFieldText ($fieldName, $fieldText) { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Set the block type - $block = 'div'; - if ($this->ifGroupOpenedPreviously()) $block = 'span'; - - // Generate the content - $inputContent = sprintf(" <%s id=\"%s_text\"> - %s - ", - $block, - $fieldName, - $fieldText, - $block - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Add text (notes) surrounded by a div block. Still opened groups or sub - * groups will be automatically closed. - * - * @param $noteId Id for this note - * @param $formNotes The form notes we shell addd - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addFormNote ($noteId, $formNotes) { - // Is the form opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Generate the content - $inputContent = sprintf("
- %s -
", - $noteId, - $formNotes - ); - - // And add it - $this->addContentToPreviousGroup($inputContent); - } - - /** - * Adds a selection box as a sub group to the form. Do not box this into - * another sub group. Sub-sub groups are not (yet) supported. - * - * @param $selectId Id of the selection box - * @param $firstEntry Content to be added as first non-selectable entry - * @return void - * @throws FormClosedException If the form is not yet opened - */ - public function addInputSelectField ($selectId, $firstEntry) { - // Is the form group opened? - if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { - // Throw an exception - throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); - } // END - if - - // Shall we close or open the sub group? - if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($this->getPreviousSubGroupId() !== $selectId)) { - // Initialize first entry (which might be non-selectable if content is provided - if (!empty($firstEntry)) { - // Add selection around it - $firstEntry = sprintf("\n", - $firstEntry - ); - } // END - if - - // Construct the opening select tag - $content = sprintf(""); - } - } - - /** - * Adds a non-selectable sub option to a previously added selection box. - * This method does *not* validate if there is already a sub option added - * with the same name. We need to finish this here! - * - * @param $subName Name of the sub action - * @param $subValue Value of the sub action - * @return void - * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found - * @todo Add checking if sub option is already added - */ - public function addSelectSubOption ($subName, $subValue) { - // Is there a sub group (shall be a selection box!) - if ($this->ifSubGroupOpenedPreviously() === FALSE) { - // Then throw an exception here - throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); - } // END - if - - // Render the content - $content = sprintf("\n", - $subName, - $subValue - ); - - // Add the content to the previously opened sub group - $this->addContentToPreviousGroup($content); - } - - /** - * Adds a selectable option to a previously added selection box. This method - * does *not* validate if there is already a sub option added with the same - * name. We need to finish this here! - * - * @param $optionName Name of the sub action - * @param $optionValue Value of the sub action - * @return void - * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found - * @todo Add checking if sub option is already added - */ - public function addSelectOption ($optionName, $optionValue) { - // Is there a sub group (shall be a selection box!) - if ($this->ifSubGroupOpenedPreviously() === FALSE) { - // Then throw an exception here - throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); - } // END - if - - // Render the content - $content = sprintf("\n", - $optionName, - $optionName, - $optionValue - ); - - // Add the content to the previously opened sub group - $this->addContentToPreviousGroup($content); - } - - /** - * Adds a pre-configured CAPTCHA - * - * @return void - */ - public function addCaptcha () { - // Init instance - $extraInstance = NULL; - - try { - // Get last executed pre filter - $extraInstance = Registry::getRegistry()->getInstance('extra'); - } catch (NullPointerException $e) { - // Instance in registry is not set (NULL) - // @TODO We need to log this later - } - - // Get a configured instance - $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha_class', array($this, $extraInstance)); - - // Initiate the CAPTCHA - $captchaInstance->initiateCaptcha(); - - // Render the CAPTCHA code - $captchaInstance->renderCode(); - - // Get the content and add it to the helper - $this->addContentToPreviousGroup($captchaInstance->renderContent()); - } - - /** - * Enables/disables the form tag usage - * - * @param $formEnabled Whether form is enabled or disabled - * @return void - */ - public final function enableForm ($formEnabled = TRUE) { - $this->formEnabled = (bool) $formEnabled; - } - - /** - * Setter for form name - * - * @param $formName Name of this form - * @return void - */ - public final function setFormName ($formName) { - $this->formName = (string) $formName; - } - - /** - * Getter for form name - * - * @return $formName Name of this form - */ - public final function getFormName () { - return $this->formName; - } - - /** - * Checks whether the registration requires a valid email address - * - * @return $required Whether the email address is required - */ - public function ifRegisterRequiresEmailVerification () { - $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y'); - return $required; - } - - /** - * Checks whether profile data shall be asked - * - * @return $required Whether profile data shall be asked - */ - public function ifRegisterIncludesProfile () { - $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y'); - return $required; - } - - /** - * Checks whether this form is secured by a CAPTCHA - * - * @return $isSecured Whether this form is secured by a CAPTCHA - */ - public function ifFormSecuredWithCaptcha () { - $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y'); - return $isSecured; - } - - /** - * Checks whether personal data shall be asked - * - * @return $required Whether personal data shall be asked - */ - public function ifRegisterIncludesPersonaData () { - $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y'); - return $required; - } - - /** - * Checks whether for birthday shall be asked - * - * @return $required Whether birthday shall be asked - */ - public function ifProfileIncludesBirthDay () { - $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y'); - return $required; - } - - /** - * Checks whether email addresses can only be once used - * - * @return $isUnique - */ - public function ifEmailMustBeUnique () { - $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y'); - return $isUnique; - } - - /** - * Checks whether the specified chat protocol is enabled in this form - * - * @return $required Whether the specified chat protocol is enabled - */ - public function ifChatEnabled ($chatProtocol) { - $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y'); - return $required; - } - - /** - * Checks whether login is enabled or disabled - * - * @return $isEnabled Whether the login is enabled or disabled - */ - public function ifLoginIsEnabled () { - $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y'); - return $isEnabled; - } - - /** - * Checks whether login shall be done by username - * - * @return $isEnabled Whether the login shall be done by username - */ - public function ifLoginWithUsername () { - $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username"); - return $isEnabled; - } - - /** - * Checks whether login shall be done by email - * - * @return $isEnabled Whether the login shall be done by email - */ - public function ifLoginWithEmail () { - $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email"); - return $isEnabled; - } - - /** - * Checks whether guest login is allowed - * - * @return $isAllowed Whether guest login is allowed - */ - public function ifGuestLoginAllowed () { - $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y'); - return $isAllowed; - } - - /** - * Checks whether the email address change must be confirmed - * - * @return $requireConfirm Whether email change must be confirmed - */ - public function ifEmailChangeRequireConfirmation () { - $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y'); - return $requireConfirm; - } - - /** - * Checks whether the rules has been updated - * - * @return $rulesUpdated Whether rules has been updated - * @todo Implement check if rules have been changed - */ - public function ifRulesHaveChanged () { - return FALSE; - } - - /** - * Checks whether email change is allowed - * - * @return $emailChange Whether changing email address is allowed - */ - public function ifEmailChangeAllowed () { - $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y'); - return $emailChange; - } - - /** - * Checks whether the user account is unconfirmed - * - * @return $isUnconfirmed Whether the user account is unconfirmed - */ - public function ifUserAccountUnconfirmed () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed')); - return $isUnconfirmed; - } - - /** - * Checks whether the user account is locked - * - * @return $isUnconfirmed Whether the user account is locked - */ - public function ifUserAccountLocked () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked')); - return $isUnconfirmed; - } - - /** - * Checks whether the user account is a guest - * - * @return $isUnconfirmed Whether the user account is a guest - */ - public function ifUserAccountGuest () { - $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest')); - return $isUnconfirmed; - } - - /** - * Checks whether the refill page is active which should be not the default - * on non-web applications. - * - * @return $refillActive Whether the refill page is active - */ - public function ifRefillPageActive () { - $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y'); - return $refillActive; - } - - /** - * Flushs the content out (not yet secured against open forms, etc.!) or - * close the form automatically - * - * @return void - * @throws FormOpenedException If the form is still open - */ - public function flushContent () { - // Is the form still open? - if (($this->formOpened === TRUE) && ($this->formEnabled === TRUE)) { - // Close the form automatically - $this->addFormTag(); - } elseif ($this->formEnabled === FALSE) { - if ($this->ifSubGroupOpenedPreviously()) { - // Close sub group - $this->addFormSubGroup(); - } elseif ($this->ifGroupOpenedPreviously()) { - // Close group - $this->addFormGroup(); - } - } - - // Send content to template engine - //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."
\n"; - $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/html/links/.htaccess b/inc/classes/main/helper/html/links/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/html/links/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/html/links/class_HtmlLinkHelper.php b/inc/classes/main/helper/html/links/class_HtmlLinkHelper.php deleted file mode 100644 index 5ac067e5..00000000 --- a/inc/classes/main/helper/html/links/class_HtmlLinkHelper.php +++ /dev/null @@ -1,345 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { - /** - * Name of the link - */ - private $linkName = ''; - - /** - * Base of the link - */ - private $linkBase = ''; - - /** - * First parameter separator - */ - const FIRST_PARAMETER_SEPARATOR = '?'; - - /** - * SEPARATOR for more paraemters - */ - const EXTRA_PARAMETER_SEPARATOR = '&'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates the helper class - * - * @param $templateInstance An instance of a template engine - * @param $linkName Name of the link we shall generate - * @param $linkBase Link base for the link. This parameter is deprecated. - * @return $helperInstance A prepared instance of this helper - * @throws NoConfigEntryException A deprecated exception at this point - */ - public static final function createHtmlLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = NULL) { - // Get new instance - $helperInstance = new HtmlLinkHelper(); - - // Set template instance - $helperInstance->setTemplateInstance($templateInstance); - - // Set link name - $helperInstance->setLinkName($linkName); - - // Get the application instance - $applicationInstance = Registry::getRegistry()->getInstance('application'); - - // Get the request instance - $requestInstance = $applicationInstance->getRequestInstance(); - - // Sanity-check on it - if (is_null($requestInstance)) { - // Throw an exception here - throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get page (this will throw an exception if not set) - $command = $helperInstance->convertDashesToUnderscores($requestInstance->getRequestElement('command')); - - // Construct config entry - $configEntry = $command . '_' . $linkName . '_action_url'; - - // Is the deprecated parameter set? - if (!is_null($linkBase)) { - // Then output a deprecation message - $helperInstance->deprecationWarning('[' . __METHOD__ . ':' . __LINE__ . ']: linkBase is deprecated. Please remove it from your templates and add a config entry ' . $configEntry . ' in your config.php file.'); - } // END - if - - // Determine link base from config now and 'command' request - try { - $newLinkBase = $helperInstance->getConfigInstance()->getConfigEntry($configEntry); - $linkBase = $newLinkBase; - } catch (NoConfigEntryException $e) { - // Is the deprecated linkBase not set? - if (is_null($linkBase)) { - // Then throw again the exception - throw new NoConfigEntryException(array(__CLASS__, ($configEntry)), FrameworkConfiguration::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); - } // END - if - } - - // Set link base - $helperInstance->setLinkBase($linkBase); - - // Add default group - $helperInstance->openGroupByIdContent('main', '', ''); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Renders the link content (HTML code) with given link text and optional - * extra content - * - * @param $linkText Link text to set in link - * @param $linkTitle Link title to set in link - * @param $extraContent Optional extra HTML content - * @return $linkContent Rendered text link content - */ - private function renderLinkContentWithTextExtraContent ($linkText, $linkTitle, $extraContent='') { - // Construct link content - $linkContent = sprintf('%s', - $this->getLinkBase(), - $extraContent, - $linkTitle, - $linkText - ); - - // Return it - return $linkContent; - } - - /** - * Setter for link name - * - * @param $linkName Name of the link we shall generate - * @return void - */ - protected final function setLinkName ($linkName) { - $this->linkName = (string) $linkName; - } - - /** - * Getter for link name - * - * @return $linkName Name of the link we shall generate - */ - public final function getLinkName () { - return $this->linkName; - } - - /** - * Setter for link base - * - * @param $linkBase Base of the link we shall generate - * @return void - */ - protected final function setLinkBase ($linkBase) { - $this->linkBase = (string) $linkBase; - } - - /** - * Getter for link base - * - * @return $linkBase Base of the link we shall generate - */ - public final function getLinkBase () { - return $this->linkBase; - } - - /** - * Flush the content out,e g. to a template variable - * - * @return void - * @todo Completely unimplemented - */ - public function flushContent () { - // Is a previous opened group still open? - if ($this->ifGroupOpenedPreviously()) { - // Then close it - $this->closePreviousGroupByContent(''); - } // END - if - - // Get the content - $content = $this->renderContent(); - - // Get template engine - $templateInstance = $this->getTemplateInstance(); - - // Add content to variable - $templateInstance->assignVariable($this->getLinkName(), $content); - } - - /** - * Adds a link group (like the form group is) with some raw language to the - * helper. - * - * @param $groupId Id string of the group - * @param $groupText Text for this group to add - * @param $groupCode Code to open and close groups - * @return void - */ - public function addLinkGroup ($groupId, $groupText, $groupCode = 'div') { - // Is a group with that name open? - if ($this->ifGroupOpenedPreviously()) { - // Then close it here - $this->closePreviousGroupByContent(''); - } // END - if - - // Generate the group content - $content = sprintf('<%s id="group_%s_%s">%s', - $groupCode, - $this->getLinkName(), - $groupId, - $groupText - ); - - // Open the new group - $this->openGroupByIdContent($groupId, $content, $groupCode); - } - - /** - * Adds text (note) to the previously opened group or throws an exception - * if no previous group was opened. - * - * @param $groupId Group id to set - * @param $groupNote Note to be added to a group - * @param $groupCode Code to open and close groups - * @return void - * @throws NoGroupOpenedException If no previous group was opened - */ - public function addLinkNote ($groupId, $groupNote, $groupCode = 'div') { - // Check if a previous group was opened - if ($this->ifGroupOpenedPreviously() === FALSE) { - // No group was opened before! - throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); - } // END - if - - // Is a previous sub group open? - if ($this->ifSubGroupOpenedPreviously()) { - // Then close it - $this->closePreviousSubGroupByContent(''); - } // END - if - - // Generate the group content - $content = sprintf('<%s id="subgroup_%s_%s">%s', - $groupCode, - $this->getLinkName(), - $groupId, - $groupNote - ); - - // Open the sub group - $this->openSubGroupByIdContent($groupId, $content, $groupCode); - } - - /** - * Adds a link to the previously opened group or throws an exception if no group has been opened - * - * @param $linkAction Action (action=xxx) value for the link - * @param $linkText Link text and title (title="xxx") for the link - * @return void - * @throws NoGroupOpenedException If no previous group was opened - */ - protected function addActionLink ($linkAction, $linkText, $linkTitle) { - // Check if a previous group was opened - if ($this->ifGroupOpenedPreviously() === FALSE) { - // No group was opened before! - throw new NoGroupOpenedException(array($this, $linkAction . '(' . $linkText . ')'), self::EXCEPTION_GROUP_NOT_OPENED); - } // END - if - - // Default parameter SEPARATOR is & - $separator = self::EXTRA_PARAMETER_SEPARATOR; - - // Is there a question mark in? - $linkArray = explode(self::FIRST_PARAMETER_SEPARATOR, $this->getLinkBase()); - if (count($linkArray) == 0) { - // No question mark - $separator = self::FIRST_PARAMETER_SEPARATOR; - } // END - if - - // Prepare action - $action = sprintf('%saction=%s', - $separator, - $linkAction - ); - - // Renders the link content - $linkContent = $this->renderLinkContentWithTextExtraContent($linkText, $linkTitle, $action); - - // Add the content to the previous group - $this->addContentToPreviousGroup($linkContent); - } - - /** - * Adds a link to the previously opened group with a text from language system - * - * @param $linkAction Action (action=xxx) value for the link - * @param $languageId Language id string to use - * @return void - */ - public function addActionLinkById ($linkAction, $languageId) { - // Resolve the language string - $languageResolvedText = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_text'); - - // Resolve the language string - $languageResolvedTitle = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_title'); - - // Add the action link - $this->addActionLink($linkAction, $languageResolvedText, $languageResolvedTitle); - } - - /** - * Adds a default link (no extra parameters) to the content with specified - * language id string. - * - * @param $languageId Language id string to use - * @return void - */ - public function addLinkWithTextById ($languageId) { - // Resolve the language string - $languageResolvedText = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_text'); - - // Resolve the language string - $languageResolvedTitle = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_title'); - - // Now add the link - $linkContent = $this->renderLinkContentWithTextExtraContent($languageResolvedText, $languageResolvedTitle); - - // Add the content to the previous group - $this->addContentToPreviousGroup($linkContent); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/helper/login/.htaccess b/inc/classes/main/helper/login/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/helper/login/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/helper/login/class_BaseLoginHelper.php b/inc/classes/main/helper/login/class_BaseLoginHelper.php deleted file mode 100644 index 6f6bee44..00000000 --- a/inc/classes/main/helper/login/class_BaseLoginHelper.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseLoginHelper extends BaseHelper { - /** - * Protected constructor - * - * @param $className Real name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/images/.htaccess b/inc/classes/main/images/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/images/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/images/class_ b/inc/classes/main/images/class_ deleted file mode 100644 index 77dbf732..00000000 --- a/inc/classes/main/images/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Image extends BaseImage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this image class - * - * @return $imageInstance An instance of this image class - */ - public final static function create???Image() { - // Get a new instance - $imageInstance = new ???Image(); - - // Set image type - $imageInstance->setImageType("???"); - - // Return the instance - return $imageInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/images/class_BaseImage.php b/inc/classes/main/images/class_BaseImage.php deleted file mode 100644 index 3c44ef60..00000000 --- a/inc/classes/main/images/class_BaseImage.php +++ /dev/null @@ -1,561 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseImage extends BaseFrameworkSystem implements Registerable { - /** - * Image type - */ - private $imageType = ''; - - /** - * Width of the image - */ - private $width = ''; - - /** - * Height of the image - */ - private $height = ''; - - /** - * X/Y - */ - private $x = ''; - private $y = ''; - - /** - * Font size - */ - private $fontSize = ''; - - /** - * Image string - */ - private $imageString = ''; - - /** - * Background color in RGB - */ - private $backgroundColor = array( - 'red' => '', - 'green' => '', - 'blue' => '' - ); - - /** - * Foreground color in RGB - */ - private $foregroundColor = array( - 'red' => '', - 'green' => '', - 'blue' => '' - ); - - /** - * Current choosen color array - */ - private $colorMode = ''; - - /** - * Image resource - */ - private $imageResource = NULL; - - /** - * Image name - */ - private $imageName = ''; - - /** - * String name - */ - private $stringName = ''; - - /** - * Groupable image strings? - */ - private $groupable = 'single'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Private setter for all colors - * - * @param $colorMode Whether background or foreground color - * @param $colorChannel Red, green or blue channel? - * @param $colorValue Value to set - */ - private final function setColor ($colorMode, $colorChannel, $colorValue) { - // Construct the eval() command - $eval = sprintf("\$this->%s['%s'] = \"%s\";", - $colorMode, - $colorChannel, - $colorValue - ); - - // Run the command - //* DEBUG: */ echo "mode={$colorMode}, channel={$colorChannel}, value={$colorValue}
\n"; - eval($eval); - } - - /** - * Setter for image width - * - * @param $width Width of the image - * @return void - */ - public final function setWidth ($width) { - $this->width = $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 = $height; - } - - /** - * Getter for image height - * - * @return $height Height of the image - */ - public final function getHeight () { - return $this->height; - } - - /** - * Finish the type handling (unused at the moment) - * - * @return void - * @todo Find something usefull for this method. - */ - public function finishType () { - // Empty at the momemt - } - - /** - * Prepares the class for resolution (unused at the moment) - * - * @return void - * @todo Find something usefull for this method. - */ - public function initResolution () { - // Empty at the momemt - } - - /** - * Finish resolution handling (unused at the moment) - * - * @return void - * @todo Find something usefull for this method. - */ - public function finishResolution () { - // Empty at the momemt - } - - /** - * Prepares the class for base (unused at the moment) - * - * @return void - * @todo Find something usefull for this method. - */ - public function initBase () { - // Empty at the momemt - } - - /** - * Finish base handling (unused at the moment) - * - * @return void - * @todo Find something usefull for this method. - */ - public function finishBase () { - // Empty at the momemt - } - - /** - * Prepares the class for background color - * - * @return void - */ - public function initBackgroundColor () { - $this->colorMode = 'backgroundColor'; - } - - /** - * Finish background color handling - * - * @return void - * @todo Find something usefull for this method. - */ - public function finishBackgroundColor () { - // Empty at the moment - } - - /** - * Prepares the class for foreground color - * - * @return void - */ - public function initForegroundColor () { - $this->colorMode = 'foregroundColor'; - } - - /** - * Finish foreground color handling - * - * @return void - * @todo Find something usefull for this method. - */ - public function finishForegroundColor () { - // Empty at the moment - } - - /** - * Prepares the class for string (unused at the moment) - * - * @param $groupable Whether this image string is groupable or single - * @return void - * @todo Find something usefull for this method. - */ - public function initImageString ($groupable = 'single') { - $this->groupable = $groupable; - } - - /** - * Finish string handling (unused at the moment) - * - * @return void - * @todo Find something usefull for this method. - */ - public function finishImageString () { - // Empty at the momemt - } - - /** - * Setter for red color - * - * @param $red Red color value - * @return void - */ - public final function setRed ($red) { - // Get array name - $arrayName = $this->colorMode; - - // Set image color - $this->setColor($arrayName, 'red', $red); - } - - /** - * Setter for green color - * - * @param $green Green color value - * @return void - */ - public final function setGreen ($green) { - // Get array name - $arrayName = $this->colorMode; - - // Set image color - $this->setColor($arrayName, 'green', $green); - } - - /** - * Setter for blue color - * - * @param $blue Blue color value - * @return void - */ - public final function setBlue ($blue) { - // Get array name - $arrayName = $this->colorMode; - - // Set image color - $this->setColor($arrayName, 'blue', $blue); - } - - /** - * Setter for image string - * - * @param $string String to set in image - * @return void - */ - public final function setString ($string) { - $this->imageString = (string) $string; - } - - /** - * Getter for image string - * - * @return $string String to set in image - */ - public final function getString () { - return $this->imageString; - } - - /** - * Setter for image type - * - * @param $imageType Type to set in image - * @return void - */ - protected final function setImageType ($imageType) { - $this->imageType = (string) $imageType; - } - - /** - * Getter for image type - * - * @return $imageType Type to set in image - */ - public final function getImageType () { - return $this->imageType; - } - - /** - * Setter for image name - * - * @param $name Name of the image - * @return void - */ - public final function setImageName ($name) { - $this->imageName = (string) $name; - } - - /** - * Getter for image name - * - * @return $name Name of the image - */ - public final function getImageName () { - return $this->imageName; - } - - /** - * Getter for image resource - * - * @return $imageResource An image resource from imagecreatetruecolor() function - */ - public final function getImageResource() { - return $this->imageResource; - } - - /** - * Setter for X coordinate - * - * @param $x X coordinate - * @return void - */ - public final function setX ($x) { - $this->x = $x; - } - - /** - * Getter for X coordinate - * - * @return $x X coordinate - */ - public final function getX () { - return $this->x; - } - - /** - * Setter for Y coordinate - * - * @param $y Y coordinate - * @return void - */ - public final function setY ($y) { - $this->y = $y; - } - - /** - * Getter for Y coordinate - * - * @return $y Y coordinate - */ - public final function getY () { - return $this->y; - } - - /** - * Setter for font size - * - * @param $fontSize Font size for strings - * @return void - */ - public final function setFontSize ($fontSize) { - $this->fontSize = $fontSize; - } - - /** - * Getter for font size - * - * @return $fontSize Font size for strings - */ - public final function getFontSize () { - return $this->fontSize; - } - - /** - * Setter for string name - * - * @param $stringName String name to set - * @return void - */ - public final function setStringName($stringName) { - $this->stringName = $stringName; - } - - /** - * Finish this image by producing it - * - * @return void - */ - public function finishImage () { - // Get template instance - $templateInstance = $this->getTemplateInstance(); - - // Compile width and height - $width = $templateInstance->compileRawCode($this->getWidth()); - $height = $templateInstance->compileRawCode($this->getHeight()); - - // Set both again - $this->setWidth($width); - $this->setHeight($height); - - // Get a image resource - $this->imageResource = imagecreatetruecolor($width, $height); - - // Compile background colors - $red = $templateInstance->compileRawCode($this->backgroundColor['red']); - $green = $templateInstance->compileRawCode($this->backgroundColor['green']); - $blue = $templateInstance->compileRawCode($this->backgroundColor['blue']); - - // Set all back - $this->initBackgroundColor(); - $this->setRed($red); - $this->setGreen($green); - $this->setBlue($blue); - - // Get a pointer for background color - $backColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue); - - // Fill the image - imagefill($this->getImageResource(), 0, 0, $backColor); - - // Compile foreground colors - $red = $templateInstance->compileRawCode($this->foregroundColor['red']); - $green = $templateInstance->compileRawCode($this->foregroundColor['green']); - $blue = $templateInstance->compileRawCode($this->foregroundColor['blue']); - - // Set all fore - $this->initForegroundColor(); - $this->setRed($red); - $this->setGreen($green); - $this->setBlue($blue); - - // Get a pointer for foreground color - $foreColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue); - - switch ($this->groupable) { - case 'single': // Single image string - // Compile image string - $imageString = $templateInstance->compileRawCode($this->getString()); - - // Set it back - $this->setString($imageString); - - // Compile X/Y coordinates and font size - $x = $templateInstance->compileRawCode($this->getX()); - $y = $templateInstance->compileRawCode($this->getY()); - $size = $templateInstance->compileRawCode($this->getFontSize()); - - // Set the image string - imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor); - break; - - case 'groupable': // More than one string allowed - // Walk through all groups - foreach ($templateInstance->getVariableGroups() as $group => $set) { - // Set the group - $templateInstance->setVariableGroup($group, FALSE); - - // Compile image string - $imageString = $templateInstance->compileRawCode($this->getString()); - - // Compile X/Y coordinates and font size - $x = $templateInstance->compileRawCode($this->getX()); - $y = $templateInstance->compileRawCode($this->getY()); - $size = $templateInstance->compileRawCode($this->getFontSize()); - - // Set the image string - //* DEBUG: */ print __METHOD__.": size={$size}, x={$x}, y={$y}, string={$imageString}
\n"; - imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor); - } // END - foreach - break; - } - - // You need finishing in your image class! - } - - /** - * Getter for full created image content - * - * @return $imageContent The raw image content - */ - public function getContent () { - // Get cache file name - $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn(); - - // Load the content - $imageContent = file_get_contents($cacheFile); - - // And return it - return $imageContent; - } -} -// [EOF] -?> diff --git a/inc/classes/main/images/extended/.htaccess b/inc/classes/main/images/extended/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/images/extended/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/images/extended/class_PngImage.php b/inc/classes/main/images/extended/class_PngImage.php deleted file mode 100644 index ec0b89f1..00000000 --- a/inc/classes/main/images/extended/class_PngImage.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class PngImage extends BaseImage { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this image class - * - * @param $templateInstance A template instance - * @return $imageInstance An instance of this image class - */ - public static final function createPngImage(CompileableTemplate $templateInstance) { - // Get a new instance - $imageInstance = new PngImage(); - - // Set template instance - $imageInstance->setTemplateInstance($templateInstance); - - // Set image type - $imageInstance->setImageType('png'); - - // Return the instance - return $imageInstance; - } - - /** - * Finish this image by producing it - * - * @return void - */ - public function finishImage () { - // Call parent method - parent::finishImage(); - - // Get a file name for our image - $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn(); - - // Does it exist? - if (BaseFrameworkSystem::isReadableFile($cacheFile)) { - // Remove it - @unlink($cacheFile); - } // END - if - - // Finish the image and send it to a cache file - imagepng($this->getImageResource(), $cacheFile, 9, PNG_ALL_FILTERS); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/index/.htaccess b/inc/classes/main/index/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/index/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/index/class_ b/inc/classes/main/index/class_ deleted file mode 100644 index b4736931..00000000 --- a/inc/classes/main/index/class_ +++ /dev/null @@ -1,54 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Index extends BaseIndex implements Indexable, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Index class and prepares it for usage - * - * @param $fileName Name of the file stack to create an index file for - * @return $indexInstance An instance of this Index class - */ - public final static function create???Index ($fileName) { - // Get a new instance - $indexInstance = new ???Index(); - - // Initialize index - $indexInstance->initIndex($fileName); - - // Return the prepared instance - return $indexInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/index/class_BaseIndex.php b/inc/classes/main/index/class_BaseIndex.php deleted file mode 100644 index d853bca0..00000000 --- a/inc/classes/main/index/class_BaseIndex.php +++ /dev/null @@ -1,355 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseIndex extends BaseFrameworkSystem { - /** - * Magic for this index - */ - const INDEX_MAGIC = 'INDEXv0.1'; - - /** - * Separator group->hash - */ - const SEPARATOR_GROUP_HASH = 0x01; - - /** - * Separator hash->gap position - */ - const SEPARATOR_HASH_GAP_POSITION = 0x02; - - /** - * Separator gap position->length - */ - const SEPARATOR_GAP_LENGTH = 0x03; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Reads the file header - * - * @return void - */ - public function readFileHeader () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // First rewind to beginning as the header sits at the beginning ... - $this->getIteratorInstance()->rewind(); - - // Then read it (see constructor for calculation) - $data = $this->getIteratorInstance()->read($this->getIteratorInstance()->getHeaderSize()); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getIteratorInstance()->getHeaderSize())); - - // Have all requested bytes been read? - assert(strlen($data) == $this->getIteratorInstance()->getHeaderSize()); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Last character must be the separator - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data(-1)=%s', __METHOD__, __LINE__, dechex(ord(substr($data, -1, 1))))); - assert(substr($data, -1, 1) == chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Okay, then remove it - $data = substr($data, 0, -1); - - // And update seek position - $this->getIteratorInstance()->updateSeekPosition(); - - /* - * Now split it: - * - * 0 => magic - * 1 => total entries - */ - $header = explode(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), $data); - - // Set it here - $this->getIteratorInstance()->setHeader($header); - - // Check if the array has only 3 elements - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, TRUE))); - assert(count($header) == 2); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Check magic - assert($header[0] == self::INDEX_MAGIC); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Check length of count - assert(strlen($header[1]) == BaseBinaryFile::LENGTH_COUNT); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Decode count - $header[1] = hex2bin($header[1]); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Flushes the file header - * - * @return void - */ - public function flushFileHeader () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Put all informations together - $header = sprintf('%s%s%s%s', - // Magic - self::INDEX_MAGIC, - - // Separator header data - chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), - - // Total entries - str_pad($this->dec2hex($this->getIteratorInstance()->getCounter()), BaseBinaryFile::LENGTH_COUNT, '0', STR_PAD_LEFT), - - // Separator header<->entries - chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES) - ); - - // Write it to disk (header is always at seek position 0) - $this->getIteratorInstance()->writeData(0, $header, FALSE); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Initializes this index - * - * @param $fileName File name of this index - * @return void - * @todo Currently the index file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole index file. - */ - protected function initIndex ($fileName) { - // Append index file extension - $fileName .= $this->getConfigInstance()->getConfigEntry('index_extension'); - - // Get a file i/o pointer instance for index file - $fileInstance = ObjectFactory::createObjectByConfiguredName('index_file_class', array($fileName, $this)); - - // Get iterator instance - $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', array($fileInstance)); - - // Is the instance implementing the right interface? - assert($iteratorInstance instanceof SeekableWritableFileIterator); - - // Set iterator here - $this->setIteratorInstance($iteratorInstance); - - // Calculate header size - $this->getIteratorInstance()->setHeaderSize( - strlen(self::INDEX_MAGIC) + - strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) + - BaseBinaryFile::LENGTH_COUNT + - strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)) - ); - - // Init counters and gaps array - $this->getIteratorInstance()->initCountersGapsArray(); - - // Is the file's header initialized? - if (!$this->getIteratorInstance()->isFileHeaderInitialized()) { - // No, then create it (which may pre-allocate the index) - $this->getIteratorInstance()->createFileHeader(); - - // And pre-allocate a bit - $this->getIteratorInstance()->preAllocateFile('index'); - } // END - if - - // Load the file header - $this->readFileHeader(); - - // Count all entries in file - $this->getIteratorInstance()->analyzeFile(); - } - - /** - * Calculates minimum length for one entry/block - * - * @return $length Minimum length for one entry/block - */ - public function calculateMinimumBlockLength () { - // Calulcate it - $length = BaseBinaryFile::LENGTH_TYPE + strlen(chr(BaseBinaryFile::SEPARATOR_TYPE_POSITION)) + BaseBinaryFile::LENGTH_POSITION + strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES)); - - // Return it - return $length; - } - - /** - * Determines whether the EOF has been reached - * - * @return $isEndOfFileReached Whether the EOF has been reached - * @throws UnsupportedOperationException If this method is called - */ - public function isEndOfFileReached () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for file name - * - * @return $fileName The current file name - * @throws UnsupportedOperationException If this method is called - */ - public function getFileName () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Initializes counter for valid entries, arrays for damaged entries and - * an array for gap seek positions. If you call this method on your own, - * please re-analyze the file structure. So you are better to call - * analyzeFile() instead of this method. - * - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function initCountersGapsArray () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for header size - * - * @return $totalEntries Size of file header - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function getHeaderSize () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Setter for header size - * - * @param $headerSize Size of file header - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function setHeaderSize ($headerSize) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for header array - * - * @return $totalEntries Size of file header - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function getHeader () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Setter for header - * - * @param $header Array for a file header - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function setHeader (array $header) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Updates seekPosition attribute from file to avoid to much access on file. - * - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function updateSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for total entries - * - * @return $totalEntries Total entries in this file - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function getCounter () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * "Getter" for file size - * - * @return $fileSize Size of currently loaded file - */ - public function getFileSize () { - // Call iterator's method - return $this->getIteratorInstance()->getFileSize(); - } - - /** - * Writes data at given position - * - * @param $seekPosition Seek position - * @param $data Data to be written - * @param $flushHeader Whether to flush the header (default: flush) - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function writeData ($seekPosition, $data, $flushHeader = TRUE) { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data[]=%s,flushHeader=%d', __METHOD__, __LINE__, $seekPosition, gettype($data), intval($flushHeader))); - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Writes given value to the file and returns a hash and gap position for it - * - * @param $groupId Group identifier - * @param $value Value to be added to the stack - * @return $data Hash and gap position - * @throws UnsupportedOperationException If this method is called - */ - public function writeValueToFile ($groupId, $value) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Writes given raw data to the file and returns a gap position and length - * - * @param $groupId Group identifier - * @param $hash Hash from encoded value - * @param $encoded Encoded value to be written to the file - * @return $data Gap position and length of the raw data - */ - public function writeDataToFreeGap ($groupId, $hash, $encoded) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',hash=' . $hash . ',encoded()=' . strlen($encoded)); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/index/file_stack/.htaccess b/inc/classes/main/index/file_stack/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/index/file_stack/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/index/file_stack/class_FileStackIndex.php b/inc/classes/main/index/file_stack/class_FileStackIndex.php deleted file mode 100644 index f5a4585d..00000000 --- a/inc/classes/main/index/file_stack/class_FileStackIndex.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileStackIndex extends BaseIndex implements IndexableStack, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this Index class and prepares it for usage - * - * @param $fileName Name of the file stack to create an index file for - * @return $indexInstance An instance of this Index class - */ - public final static function createFileStackIndex ($fileName) { - // Get a new instance - $indexInstance = new FileStackIndex(); - - // Initialize index - $indexInstance->initIndex($fileName); - - // Return the prepared instance - return $indexInstance; - } - - /** - * Adds given hash to an index file - * - * @param $groupId Name of stack to add hash for - * @param $data Hash and gap position to be added to the index - * @return void - */ - public function addHashToIndex ($groupId, array $data) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,gap=%d,length=%d - CALLED!', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], $data[BaseFileStack::ARRAY_INDEX_GAP_POSITION], $data[BaseFileStack::ARRAY_INDEX_DATA_LENGTH])); - - // Raw data been written to the file - $rawData = sprintf('%s%s%s%s%s%s%s', - $groupId, - self::SEPARATOR_GROUP_HASH, - hex2bin($data[BaseFileStack::ARRAY_INDEX_HASH]), - self::SEPARATOR_HASH_GAP_POSITION, - $data[BaseFileStack::ARRAY_INDEX_GAP_POSITION], - self::SEPARATOR_GAP_LENGTH, - $data[BaseFileStack::ARRAY_INDEX_DATA_LENGTH] - ); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], strlen($rawData))); - - // Search for next free gap - $gapPosition = $this->getIteratorInstance()->searchNextGap(strlen($rawData)); - - // Gap position cannot be smaller than header length + 1 - assert($gapPosition > $this->getIteratorInstance()->getHeaderSize()); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,gapPosition=%s', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], $gapPosition)); - - // Then write the data at that gap - $this->getIteratorInstance()->writeData($gapPosition, $rawData); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d - EXIT!', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], strlen($rawData))); - } - - /** - * Searches for next suitable gap the given length of data can fit in - * including padding bytes. - * - * @param $length Length of raw data - * @return $seekPosition Found next gap's seek position - */ - public function searchNextGap ($length) { - $this->partialStub('length=' . $length); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/iterator/.htaccess b/inc/classes/main/iterator/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/iterator/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/iterator/class_ b/inc/classes/main/iterator/class_ deleted file mode 100644 index 22122d4a..00000000 --- a/inc/classes/main/iterator/class_ +++ /dev/null @@ -1,107 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Iterator extends BaseIterator implements Iterator { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $iteratorInstance An instance of a Iterator class - */ - public final static function create???Iterator () { - // Get new instance - $iteratorInstance = new ???Iterator(); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - */ - public function current () { - // Default is null - $current = null; - - $this->partialStub('Please implement this method.'); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $key Current key in iteration - */ - public function key () { - // Default is null - $key = null; - - $this->partialStub('Please implement this method.'); - - // Return it - return $key; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->partialStub('Please implement this method.'); - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->partialStub('Please implement this method.'); - } - - /** - * Checks wether the current entry is valid (not at the end of the list) - * - * @return void - */ - public function valid () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/iterator/class_BaseIterator.php b/inc/classes/main/iterator/class_BaseIterator.php deleted file mode 100644 index 80513e77..00000000 --- a/inc/classes/main/iterator/class_BaseIterator.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseIterator extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/iterator/default/.htaccess b/inc/classes/main/iterator/default/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/iterator/default/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/iterator/default/class_DefaultIterator.php b/inc/classes/main/iterator/default/class_DefaultIterator.php deleted file mode 100644 index 81050c5f..00000000 --- a/inc/classes/main/iterator/default/class_DefaultIterator.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DefaultIterator extends BaseIterator implements Iterator { - /** - * Key for the global list index - */ - private $indexKey = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $listInstance A list of a Listable - * @return $iteratorInstance An instance a Iterator class - */ - public static final function createDefaultIterator (Listable $listInstance) { - // Get new instance - $iteratorInstance = new DefaultIterator(); - - // Set the list - $iteratorInstance->setListInstance($listInstance); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - * @throws IndexOutOfBoundsException If $indexKey is out of bounds - */ - public function current () { - // Default is null - $current = NULL; - - // Is the entry valid? - if (!$this->valid()) { - // Throw an exception here - throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); - } // END - if - - // Now get the entry - $current = $this->getListInstance()->getEntry($this->key()); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $indexKey Current key in iteration - */ - public function key () { - return $this->indexKey; - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->indexKey++; - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - */ - public function rewind () { - $this->indexKey = 0; - } - - /** - * Checks whether the current entry is valid (not at the end of the list) - * - * @return $isValid Whether the current entry is there - */ - public function valid () { - // Check for total active peers and if we are not at the end - $isValid = ($this->key() < $this->getListInstance()->count()); - - // Return result - return $isValid; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/iterator/file/.htaccess b/inc/classes/main/iterator/file/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/iterator/file/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/iterator/file/class_FileIterator.php b/inc/classes/main/iterator/file/class_FileIterator.php deleted file mode 100644 index ff981732..00000000 --- a/inc/classes/main/iterator/file/class_FileIterator.php +++ /dev/null @@ -1,330 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileIterator extends BaseIterator implements SeekableWritableFileIterator { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $pointerInstance An instance of a Block class - * @return $iteratorInstance An instance of a Iterator class - */ - public final static function createFileIterator (Block $blockInstance) { - // Get new instance - $iteratorInstance = new FileIterator(); - - // Set the instance here - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] Setting blockInstance=%s ...', __METHOD__, __LINE__, $blockInstance->__toString())); - $iteratorInstance->setBlockInstance($blockInstance); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Gets currently read data - * - * @return $current Currently read data - */ - public function current () { - // Call block instance - return $this->getBlockInstance()->current(); - } - - /** - * Gets current seek position ("key"). - * - * @return $key Current key in iteration - */ - public function key () { - // Return it - return $this->getBlockInstance()->determineSeekPosition(); - } - - /** - * Advances to next "block" of bytes - * - * @return void - */ - public function next () { - // Call block instance - $this->getBlockInstance()->next(); - } - - /** - * Rewinds to the beginning of the file - * - * @return $status Status of this operation - */ - public function rewind () { - // Call block instance - return $this->getBlockInstance()->rewind(); - } - - /** - * Checks wether the current entry is valid (not at the end of the file). - * This method will return TRUE if an emptied (nulled) entry has been found. - * - * @return $isValid Whether the next entry is valid - */ - public function valid () { - // Call block instance - return $this->getBlockInstance()->valid(); - } - - /** - * Seeks to given position - * - * @param $seekPosition Seek position in file - * @return $status Status of this operation - */ - public function seek ($seekPosition) { - // Call block instance - return $this->getBlockInstance()->seek($seekPosition); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - public function size () { - // Call the block object - $size = $this->getBlockInstance()->size(); - - // Return result - return $size; - } - - /** - * Reads given amount of bytes from file. - * - * @param $bytes Amount of bytes to read - * @return $data Data read from file - */ - public function read ($bytes = NULL) { - // Call block instance - return $this->getBlockInstance()->read($bytes); - } - - /** - * Analyzes entries in index file. This will count all found (and valid) - * entries, mark invalid as damaged and count gaps ("fragmentation"). If - * only gaps are found, the file is considered as "virgin" (no entries). - * - * @return void - */ - public function analyzeFile () { - // Just call the block instance - $this->getBlockInstance()->analyzeFile(); - } - - /** - * Checks whether the file header is initialized - * - * @return $isInitialized Whether the file header is initialized - */ - public function isFileHeaderInitialized () { - // Just call the block instance - return $this->getBlockInstance()->isFileHeaderInitialized(); - } - - /** - * Creates the assigned file - * - * @return void - */ - public function createFileHeader () { - // Just call the block instance - $this->getBlockInstance()->createFileHeader(); - } - - /** - * Pre-allocates file (if enabled) with some space for later faster write access. - * - * @param $type Type of the file - * @return void - */ - public function preAllocateFile ($type) { - // Just call the block instance - $this->getBlockInstance()->preAllocateFile($type); - } - - /** - * Initializes counter for valid entries, arrays for damaged entries and - * an array for gap seek positions. If you call this method on your own, - * please re-analyze the file structure. So you are better to call - * analyzeFile() instead of this method. - * - * @return void - */ - public function initCountersGapsArray () { - // Call block instance - $this->getBlockInstance()->initCountersGapsArray(); - } - - /** - * Getter for header size - * - * @return $totalEntries Size of file header - */ - public final function getHeaderSize () { - // Call block instance - return $this->getBlockInstance()->getHeaderSize(); - } - - /** - * Setter for header size - * - * @param $headerSize Size of file header - * @return void - */ - public final function setHeaderSize ($headerSize) { - // Call block instance - $this->getBlockInstance()->setHeaderSize($headerSize); - } - - /** - * Getter for header array - * - * @return $totalEntries Size of file header - */ - public final function getHeader () { - // Call block instance - return $this->getBlockInstance()->getHeader(); - } - - /** - * Setter for header - * - * @param $header Array for a file header - * @return void - */ - public final function setHeader (array $header) { - // Call block instance - $this->getBlockInstance()->setHeader($header); - } - - /** - * Updates seekPosition attribute from file to avoid to much access on file. - * - * @return void - */ - public function updateSeekPosition () { - // Call block instance - $this->getBlockInstance()->updateSeekPosition(); - } - - /** - * Getter for total entries - * - * @return $totalEntries Total entries in this file - */ - public final function getCounter () { - // Call block instance - return $this->getBlockInstance()->getCounter(); - } - - /** - * "Getter" for file size - * - * @return $fileSize Size of currently loaded file - */ - public function getFileSize () { - // Call block instance - return $this->getBlockInstance()->getFileSize(); - } - - /** - * Writes data at given position - * - * @param $seekPosition Seek position - * @param $data Data to be written - * @param $flushHeader Whether to flush the header (default: flush) - * @return void - */ - public function writeData ($seekPosition, $data, $flushHeader = TRUE) { - // Call block instance - $this->getBlockInstance()->writeData($seekPosition, $data, $flushHeader); - } - - /** - * Getter for seek position - * - * @return $seekPosition Current seek position (stored here in object) - */ - public function getSeekPosition () { - // Call block instance - return $this->getBlockInstance()->getSeekPosition(); - } - - /** - * Writes given value to the file and returns a hash and gap position for it - * - * @param $groupId Group identifier - * @param $value Value to be added to the stack - * @return $data Hash and gap position - */ - public function writeValueToFile ($groupId, $value) { - // Call block instance - return $this->getBlockInstance()->writeValueToFile($groupId, $value); - } - - /** - * Writes given raw data to the file and returns a gap position and length - * - * @param $groupId Group identifier - * @param $hash Hash from encoded value - * @param $encoded Encoded value to be written to the file - * @return $data Gap position and length of the raw data - */ - public function writeDataToFreeGap ($groupId, $hash, $encoded) { - // Call block instance - return $this->getBlockInstance()->writeDataToFreeGap($groupId, $hash, $encoded); - } - - /** - * Searches for next suitable gap the given length of data can fit in - * including padding bytes. - * - * @param $length Length of raw data - * @return $seekPosition Found next gap's seek position - */ - public function searchNextGap ($length) { - // Call block instance - print $this->getBlockInstance()->__toString() . PHP_EOL; - return $this->getBlockInstance()->searchNextGap($length); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/language/.htaccess b/inc/classes/main/language/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/language/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/language/class_LanguageSystem.php b/inc/classes/main/language/class_LanguageSystem.php deleted file mode 100644 index ece1ad57..00000000 --- a/inc/classes/main/language/class_LanguageSystem.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, Registerable { - /** - * The full-qualified base path for the language include files - */ - private $languageBasePath = ''; - - /** - * The 2-char language code - */ - private $langCode = 'xx'; // This will later be overwritten! - - /** - * The array-object for all language strings - */ - private $langStrings = NULL; - - /** - * An instance of this class - */ - private static $selfInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class LanguageSystem and prepares it for usage - * - * @param $languageBasePath The local base path for all language strings or emty for auto-detection - * @return $langInstance An instance of LanguageSystem - * @throws LanguagePathIsEmptyException If the provided $languageBasePath is empty - * @throws InvalidLanguagePathStringException If $languageBasePath is no string - * @throws LanguagePathIsNoDirectoryException If $languageBasePath is no - * directory or not found - * @throws LanguagePathReadProtectedException If $languageBasePath is - * read-protected - */ - public static final function createLanguageSystem ($languageBasePath = '') { - // Get a new instance - $langInstance = new LanguageSystem(); - - // Is the base path set? - if (empty($languageBasePath)) { - // No, then attempt "auto-dection": - // 1) Get application - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // 2) Try to build it - $languageBasePath = sprintf('%sapplication/%s/language/', - $langInstance->getConfigInstance()->getConfigEntry('base_path'), - // Don't allow any underscores/dashes in application names - str_replace(array('_', '-'), array('', ''), $applicationInstance->getAppShortName()) - ); - } // END - if - - // Is the base path valid? - if (empty($languageBasePath)) { - // Language path is empty - throw new LanguagePathIsEmptyException($langInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($languageBasePath)) { - // Is not a string - throw new InvalidLanguagePathStringException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($languageBasePath)) { - // Is not a path - throw new LanguagePathIsNoDirectoryException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($languageBasePath)) { - // Is not readable - throw new LanguagePathReadProtectedException(array($langInstance, $languageBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $langInstance->setLanguageBasePath($languageBasePath); - - // Initialize the variable stack - $langInstance->initLanguageStrings(); - - // Set language code from default config - $langInstance->setLanguageCode(FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_lang')); - - // Remember this instance - self::$selfInstance = $langInstance; - - // Return the prepared instance - return $langInstance; - } - - /** - * Singleton getter for this instance - * - * @return $selfInstance An instance of this class - */ - public static final function getSelfInstance () { - return self::$selfInstance; - } - - /** - * Setter for base path - * - * @param $languageBasePath The relative base path for all language files - * @return void - */ - protected final function setLanguageBasePath ($languageBasePath) { - // And set it - $this->languageBasePath = (string) $languageBasePath; - } - - /** - * Setter for language code - * - * @param $langCode The language code for the current application - * @return void - */ - protected final function setLanguageCode ($langCode) { - // Cast it - $langCode = (string) $langCode; - - // And set it (only 2 chars) - $this->langCode = substr($langCode, 0, 2); - } - - /** - * Initialize the array-object for all later language strings - * - * @return void - */ - public function initLanguageStrings () { - $this->langStrings = new FrameworkArrayObject('FakedLanguageStrings'); - } - - /** - * Getter for language code - * - * @return $langCode The language code for the current application - */ - public final function getLanguageCode () { - return $this->langCode; - } - - /** - * Get the plain message from the cache variable for the given message id - * - * @param $messageId The message id we shall find in the cache variable - * @return $messageText The plain message text - */ - public function getMessage ($messageId) { - // Default is missing message text - $messageText = sprintf('!%s!', - $messageId - ); - - // Try to look it up in the cache variable - if ($this->langStrings->offsetExists($messageId)) { - // Return the message string - $messageText = $this->langStrings->offsetGet($messageId); - } // END - if - - // Return the text - return $messageText; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/listener/.htaccess b/inc/classes/main/listener/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/listener/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/listener/class_ b/inc/classes/main/listener/class_ deleted file mode 100644 index 5d3309f5..00000000 --- a/inc/classes/main/listener/class_ +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Listener extends BaseListener implements Listenable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $nodeInstance A NodeHelper instance - * @return $listenerInstance An instance a prepared listener class - */ - public final static function create???Listener (NodeHelper $nodeInstance) { - // Get new instance - $listenerInstance = new ???Listener(); - - // Set the application instance - $listenerInstance->setNodeInstance($nodeInstance); - - // Return the prepared instance - return $listenerInstance; - } - - /** - * Initializes the listener by setting up the required socket server - * - * @return void - * @todo 0% done - */ - public function initListener() { - $this->partialStub('Need to implement this method.'); - } - - /** - * "Listens" for incoming network packages - * - * @return void - * @todo 0% done - */ - public function doListen() { - $this->partialStub('Need to implement this method.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/listener/class_BaseListener.php b/inc/classes/main/listener/class_BaseListener.php deleted file mode 100644 index 5a572135..00000000 --- a/inc/classes/main/listener/class_BaseListener.php +++ /dev/null @@ -1,292 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseListener extends BaseFrameworkSystem implements Visitable { - // Exception code constants - const EXCEPTION_INVALID_SOCKET = 0xa00; - const EXCEPTION_SOCKET_ALREADY_REGISTERED = 0xa01; - const EXCEPTION_SOCKET_CREATION_FAILED = 0xa02; - const EXCEPTION_NO_SOCKET_ERROR = 0xa03; - const EXCEPTION_CONNECTION_ALREADY_REGISTERED = 0xa04; - const EXCEPTION_UNEXPECTED_PACKAGE_STATUS = 0xa05; - const EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER = 0xa06; - const EXCEPTION_FINAL_CHUNK_VERIFICATION = 0xa07; - const EXCEPTION_INVALID_DATA_CHECKSUM = 0xa08; - - /** - * Address (IP mostly) we shall listen on - */ - private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces - - /** - * Port we shall listen on (or wait for incoming data) - */ - private $listenPort = 0; // This port MUST be changed by your application - - /** - * Whether we are in blocking or non-blocking mode (default: non-blocking - */ - private $blockingMode = FALSE; - - /** - * A peer pool instance - */ - private $poolInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Checks whether the given socket resource is a server socket - * - * @param $socketResource A valid socket resource - * @return $isServerSocket Whether the socket resource is a server socket - */ - protected function isServerSocketResource ($socketResource) { - // Check it - $isServerSocket = ((is_resource($socketResource)) && (!@socket_getpeername($socketResource, $peerName))); - - // We need to clear the error here if it is a resource - if ($isServerSocket === TRUE) { - // Clear the error - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[]=' . gettype($socketResource)); - socket_clear_error($socketResource); - } // END - if - - // Check peer name, it must be empty - $isServerSocket = (($isServerSocket) && (empty($peerName))); - - // Return result - return $isServerSocket; - } - - /** - * Setter for listen address - * - * @param $listenAddress The address this listener should listen on - * @return void - */ - protected final function setListenAddress ($listenAddress) { - $this->listenAddress = (string) $listenAddress; - } - - /** - * Getter for listen address - * - * @return $listenAddress The address this listener should listen on - */ - public final function getListenAddress () { - return $this->listenAddress; - } - - /** - * Setter for listen port - * - * @param $listenPort The port this listener should listen on - * @return void - */ - protected final function setListenPort ($listenPort) { - $this->listenPort = (int) $listenPort; - } - - /** - * Getter for listen port - * - * @return $listenPort The port this listener should listen on - */ - public final function getListenPort () { - return $this->listenPort; - } - - /** - * "Setter" to set listen address from configuration entry - * - * @param $configEntry The configuration entry holding our listen address - * @return void - */ - public final function setListenAddressByConfiguration ($configEntry) { - $this->setListenAddress($this->getConfigInstance()->getConfigEntry($configEntry)); - } - - /** - * "Setter" to set listen port from configuration entry - * - * @param $configEntry The configuration entry holding our listen port - * @return void - */ - public final function setListenPortByConfiguration ($configEntry) { - $this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry)); - } - - /** - * Setter for blocking-mode - * - * @param $blockingMode Whether blocking-mode is disabled (default) or enabled - * @return void - */ - protected final function setBlockingMode ($blockingMode) { - $this->blockingMode = (boolean) $blockingMode; - } - - /** - * Checks whether blocking-mode is enabled or disabled - * - * @return $blockingMode Whether blocking mode is disabled or enabled - */ - public final function isBlockingModeEnabled () { - return $this->blockingMode; - } - - /** - * Setter for peer pool instance - * - * @param $poolInstance The peer pool instance we shall set - * @return void - */ - protected final function setPoolInstance (PoolablePeer $poolInstance) { - $this->poolInstance = $poolInstance; - } - - /** - * Getter for peer pool instance - * - * @return $poolInstance The peer pool instance we shall set - */ - public final function getPoolInstance () { - return $this->poolInstance; - } - - /** - * Getter for connection type - * - * @return $connectionType Connection type for this listener - */ - public final function getConnectionType () { - // Wrap the real getter - return $this->getProtocolName(); - } - - /** - * Registeres the given socket resource for "this" listener instance. This - * will be done in a seperate class to allow package writers to use it - * again. - * - * @param $socketResource A valid server socket resource - * @return void - * @throws InvalidServerSocketException If the given resource is no server socket - * @throws SocketAlreadyRegisteredException If the given resource is already registered - */ - protected function registerServerSocketResource ($socketResource) { - // First check if it is valid - if (!$this->isServerSocketResource($socketResource)) { - // No server socket - throw new InvalidServerSocketException(array($this, $socketResource), self::EXCEPTION_INVALID_SOCKET); - } elseif ($this->isServerSocketRegistered($socketResource)) { - // Already registered - throw new SocketAlreadyRegisteredException($this, self::EXCEPTION_SOCKET_ALREADY_REGISTERED); - } - - // Get a socket registry instance (singleton) - $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); - - // Get a connection info instance - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); - - // Will the info instance with listener data - $infoInstance->fillWithListenerInformation($this); - - // Register the socket - $registryInstance->registerSocket($infoInstance, $socketResource); - - // And set it here - $this->setSocketResource($socketResource); - } - - /** - * Checks whether given socket resource is registered in socket registry - * - * @param $socketResource A valid server socket resource - * @return $isRegistered Whether given server socket is registered - */ - protected function isServerSocketRegistered ($socketResource) { - // Get a socket registry instance (singleton) - $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); - - // Get a connection info instance - $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); - - // Will the info instance with listener data - $infoInstance->fillWithListenerInformation($this); - - // Check it - $isRegistered = $registryInstance->isSocketRegistered($infoInstance, $socketResource); - - // Return result - return $isRegistered; - } - - /** - * Accepts the visitor to process the visit "request" - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!'); - - // Visit this listener - $visitorInstance->visitListener($this); - - // Visit the pool if set - if ($this->getPoolInstance() instanceof Poolable) { - $this->getPoolInstance()->accept($visitorInstance); - } // END - if - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); - } - - /** - * Monitors incoming raw data from the handler and transfers it to the - * given receiver instance. This method should not be called, please call - * the decorator's version instead to separator node/client traffic. - * - * @return void - * @throws UnsupportedOperatorException If this method is called by a mistake - */ - public function monitorIncomingRawData () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/lists/.htaccess b/inc/classes/main/lists/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/lists/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/lists/class_ b/inc/classes/main/lists/class_ deleted file mode 100644 index 4e0a5e8f..00000000 --- a/inc/classes/main/lists/class_ +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???List extends BaseList implements Listable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $listInstance An instance a Listable class - */ - public final static function create???List () { - // Get new instance - $listInstance = new ???List(); - - // Return the prepared instance - return $listInstance; - } - - /** - * "Getter" for an iterator instance of this list - * - * @return $iteratorInstance An instance of a Iterator class - * @todo 0% done - */ - public function getListIterator () { - $this->partialStub('Please implement this method.'); - } - - /** - * Clears this list by cleaning up all groups together. - * - * @return void - * @todo 0% done - */ - public function clearList () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/lists/class_BaseList.php b/inc/classes/main/lists/class_BaseList.php deleted file mode 100644 index cdeaf33b..00000000 --- a/inc/classes/main/lists/class_BaseList.php +++ /dev/null @@ -1,481 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countable { - // Exception constants - const EXCEPTION_GROUP_ALREADY_ADDED = 0xf20; - const EXCEPTION_GROUP_NOT_FOUND = 0xf21; - const EXCEPTION_INVALID_HASH = 0xf22; - - /** - * List groups array - */ - private $listGroups = array(); - - /** - * List entries array - */ - private $listEntries = array(); - - /** - * List index array - */ - private $listIndex = array(); - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for iterator instance from this list - * - * @return $iteratorInstance An instance of a Iterator class - */ - public function getIterator () { - // Get iterator from here - $iteratorInstance = $this->getIteratorInstance(); - - // Is the instance set? - if (is_null($iteratorInstance)) { - // Prepare a default iterator - $iteratorInstance = ObjectFactory::createObjectByConfiguredName('default_iterator_class', array($this)); - - // Set it here - $this->setIteratorInstance($iteratorInstance); - } // END - if - - // And return it - return $iteratorInstance; - } - - /** - * Checks whether the given group is set - * - * @param $groupName Group to check if found in list - * @return $isset Whether the group is valid - */ - public function isGroupSet ($groupName) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName); - return isset($this->listGroups[$groupName]); - } - - /** - * Adds the given group or if already added issues a ListGroupAlreadyAddedException - * - * @param $groupName Group to add - * @return void - * @throws ListGroupAlreadyAddedException If the given group is already added - */ - public function addGroup ($groupName) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); - // Is the group already added? - if ($this->isGroupSet($groupName)) { - // Throw the exception here - throw new ListGroupAlreadyAddedException(array($this, $groupName), self::EXCEPTION_GROUP_ALREADY_ADDED); - } // END - if - - // Add the group which is a simple array - $this->listGroups[$groupName] = ObjectFactory::createObjectByConfiguredName('list_group_class'); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); - } - - /** - * Adds the given instance to list group and sub group - * - * @param $groupName Group to add instance to - * @param $subGroup Sub group to add instance to - * @param $visitableInstance An instance of Visitable - * @return void - * @throws NoListGroupException If the given group is not found - */ - public function addInstance ($groupName, $subGroup, Visitable $visitableInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); - - // Is the group there? - if (!$this->isGroupSet($groupName)) { - // Throw the exception here - throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); - } // END - if - - // Is the sub group there? - if (!$this->listGroups[$groupName]->isGroupSet($subGroup)) { - // Automatically add it - $this->listGroups[$groupName]->addGroup($subGroup); - } // END - if - - // Generate the hash - $hash = $this->generateHash($groupName, $subGroup, $visitableInstance); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ',hash=' . $hash . ' - Calling addEntry() ...'); - - // Now add it to the group list and hash it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString()); - //$this->listGroups[$groupName]->addEntry($subGroup, $hash); - - // Add the hash to the index - array_push($this->listIndex, $hash); - - // Add the instance itself to the list - $this->listEntries[$hash] = $visitableInstance; - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ' - EXIT!'); - } - - /** - * Gets an array from given list - * - * @param $list The requested list - * @return $array The requested array - * @throws NoListGroupException If the given group is not found - */ - public final function getArrayFromList ($list) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ' - CALLED!'); - - // Is the group there? - if ((!is_null($list)) && (!$this->isGroupSet($list))) { - // Throw the exception here - throw new NoListGroupException(array($this, $list), self::EXCEPTION_GROUP_NOT_FOUND); - } // END - if - - // Init array - $array = array(); - - // Is there another list? - if (!is_null($list)) { - // Then get it as well - $array = $this->listGroups[$list]->getArrayFromList(NULL); - } // END - if - - // Walk through all entries - foreach ($this->listIndex as $hash) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash); - - // Is the list entry set? - if ($this->isHashValid($hash)) { - // Add it - array_push($array, $this->listEntries[$hash]); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash . ',array(' . count($array) . ')=' . print_r($array, TRUE) . ' - ADDED!'); - } // END - if - } // END - foreach - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ',array()=' . count($array) . ' - EXIT!'); - - // Return it - return $array; - } - - /** - * Adds the given entry to list group - * - * @param $groupName Group to add instance to - * @param $entry An entry of any type - * @return void - * @throws NoListGroupException If the given group is not found - */ - public function addEntry ($groupName, $entry) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); - - // Is the group already added? - if (!$this->isGroupSet($groupName)) { - // Throw the exception here - throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); - } // END - if - - // Generate hash - $hash = $this->generateHash($groupName, $groupName, $entry); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . print_r($entry, TRUE) . ', hash=' . $hash); - - // Add the hash to the index - array_push($this->listIndex, $hash); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries)); - - // Now add the entry to the list - $this->listEntries[$hash] = $entry; - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries) . ' - EXIT!'); - } - - /** - * Removes given entry from the list group - * - * @param $groupName Group where we should remove the entry from - * @param $entry The entry we should remove - * @return void - * @throws NoListGroupException If the given group is not found - */ - public function removeEntry ($groupName, $entry) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); - - // Is the group already added? - if (!$this->isGroupSet($groupName)) { - // Throw the exception here - throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); - } // END - if - - // Generate hash - $hash = $this->generateHash($groupName, $groupName, $entry); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . $entry . ', hash=' . $hash); - - // Remove it from the list ... - unset($this->listEntries[$hash]); - - // ... and hash list as well - unset($this->listIndex[array_search($hash, $this->listIndex)]); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); - } - - /** - * Generates a hash from given group, sub group and entry - * - * @param $groupName Group to add instance to - * @param $subGroup Sub group to add instance to - * @param $entry An entry of any type - * @return $hash The generated - */ - private function generateHash ($groupName, $subGroup, $entry) { - // Created entry, 'null' is default - $entry2 = 'null'; - - // Determine type of entry - if (is_null($entry)) { - // Ignore this - } elseif ($entry instanceof FrameworkInterface) { - // Own instance detected - $entry2 = $entry->hashCode(); - } elseif ((is_int($entry)) || (is_float($entry)) || (is_resource($entry))) { - // Integer/float/resource detected - $entry2 = gettype($entry) . ':' . $entry; - } elseif (is_string($entry)) { - // String found - $entry2 = crc32($entry) . ':' . strlen($entry); - } elseif ((is_array($entry)) && (isset($entry['id']))) { - // Supported array found - $entry2 = crc32($entry['id']) . ':' . count($entry); - } elseif ((is_array($entry)) && (isset($entry[BasePool::SOCKET_ARRAY_RESOURCE])) && (isset($entry[BasePool::SOCKET_ARRAY_CONN_TYPE]))) { - // Is a socket resource array - $entry2 = crc32($entry[BasePool::SOCKET_ARRAY_RESOURCE] . ':' . $entry[BasePool::SOCKET_ARRAY_CONN_TYPE]); - } else { - // Unsupported type detected - self::createDebugInstance(__CLASS__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.'); - - // @TODO Extend this somehow? - $entry2 = gettype($entry); - } - - // Construct string which we shall hash - $hashString = $groupName . ':' . $subGroup . ':' . $entry2; - - // Hash it with fastest hasher - $hash = crc32($hashString); - - // And return it - return $hash; - } - - /** - * Clears an array of groups, all are being checked for existence - * - * @param $groupNames An array with existing list groups - * @return void - */ - protected function clearGroups (array $groupNames) { - // Walk through all groups - foreach ($groupNames as $groupName) { - // Clear this group - $this->clearGroup($groupName); - } // END - foreach - } - - /** - * Clears a single group by resetting it to its initial state (empty array) - * - * @param $groupName Name of an existing group to clear - * @return void - */ - protected function clearGroup ($groupName) { - // Does this group exist? - if (!$this->isGroupSet($groupName)) { - // Throw the exception here - throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); - } // END - if - - // Then clear this group list - $this->listGroups[$groupName]->clearList(); - - // Clear this list - $this->listIndex = array(); - $this->listEntries = array(); - } - - /** - * Counts all entries in this list - * - * @return $count All entries in this list - */ - public final function count () { - return count($this->listIndex); - } - - /** - * Checks whether the given hash is valid - * - * @param $hash The hash we should validate - * @return $isValid Whether the given hash is valid - */ - public final function isHashValid ($hash) { - // Check it - $isValid = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash]))); - - // Return the result - return $isValid; - } - - /** - * Getter for hash from given hash index - * - * @param $hashIndex Index holding the hash - * @return $hash The hash - */ - public final function getHash ($hashIndex) { - // Get it ... - $hash = $this->listIndex[$hashIndex]; - - // ... and return it - return $hash; - } - - /** - * Gets an entry from given hash index - * - * @param $hashIndex The hash index to resolve the mapped entry - * @return $entry Solved entry from list - * @throws InvalidListHashException If the solved hash index is invalid - */ - public function getEntry ($hashIndex) { - // Get the hash value - $hash = $this->getHash($hashIndex); - - // Is the hash valid? - if (!$this->isHashValid($hash)) { - // Throw an exception here - throw new InvalidListHashException(array($this, $hash, $hashIndex), self::EXCEPTION_INVALID_HASH); - } // END - if - - // Now copy the entry - $entry = $this->listEntries[$hash]; - - // Return it - return $entry; - } - - /** - * Gets a full array from given group name - * - * @param $groupName The group name to get a list for - * @return $entries The array with all entries - * @throws NoListGroupException If the specified group is invalid - */ - public function getArrayFromProtocolInstance ($groupName) { - // Is the group valid? - if (!$this->isGroupSet($groupName)) { - // Throw the exception here - throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); - } // END - if - - // Init the entries' array - $entries = array(); - - // Get an iterator - $iteratorInstance = $this->listGroups[$groupName]->getIterator(); - - // Rewind the iterator for this round - $iteratorInstance->rewind(); - - // Go through all entries - while ($iteratorInstance->valid()) { - // Get key - $entryIndex = $iteratorInstance->key(); - - // ... and the final entry which is the stored instance - $entry = $this->getEntry($entryIndex); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('LIST: Adding entry ' . $entry . ' ...'); - - // Add it to the list - $entries[$iteratorInstance->current()] = $entry; - - // Skip to next one - $iteratorInstance->next(); - } // END - while - - // Return the list - return $entries; - } - - /** - * Updates the given entry by hash with given array - * - * @param $hash Hash for this entry - * @param $entryArray Array with entry we should update - * @return void - * @throws InvalidListHashException If the solved hash index is invalid - */ - public function updateCurrentEntryByHash ($hash, array $entryArray) { - // Is the hash valid? - if (!$this->isHashValid($hash)) { - // Throw an exception here, hashIndex is unknown at this point - throw new InvalidListHashException(array($this, $hash, -999), self::EXCEPTION_INVALID_HASH); - } // END - if - - // Set the entry - $this->listEntries[$hash] = $entryArray; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/lists/groups/.htaccess b/inc/classes/main/lists/groups/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/lists/groups/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/lists/groups/class_ListGroupList.php b/inc/classes/main/lists/groups/class_ListGroupList.php deleted file mode 100644 index 666bd0bd..00000000 --- a/inc/classes/main/lists/groups/class_ListGroupList.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ListGroupList extends BaseList implements Listable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $listInstance An instance a Listable class - */ - public static final function createListGroupList () { - // Get new instance - $listInstance = new ListGroupList(); - - // Return the prepared instance - return $listInstance; - } - - /** - * "Getter" for an iterator instance of this list (not implemented) - * - * @return $iteratorInstance An instance of a Iterator class - */ - public function getListIterator () { - $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); - } - - /** - * Clears this list by cleaning up all groups together. - * - * @return void - * @todo 0% done - */ - public function clearList () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/lists/tasks/.htaccess b/inc/classes/main/lists/tasks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/lists/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/lists/tasks/class_TaskList.php b/inc/classes/main/lists/tasks/class_TaskList.php deleted file mode 100644 index 5e3fc8fd..00000000 --- a/inc/classes/main/lists/tasks/class_TaskList.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class TaskList extends BaseList implements Listable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $listInstance An instance a Listable class - */ - public static final function createTaskList () { - // Get new instance - $listInstance = new TaskList(); - - // Add tasks group - $listInstance->addGroup('tasks'); - - // Return the prepared instance - return $listInstance; - } - - /** - * "Getter" for an iterator instance of this list (not implemented) - * - * @return $iteratorInstance An instance of a Iterator class - */ - public function getListIterator () { - $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); - } - - /** - * Clears this list by cleaning up all groups together. - * - * @return void - */ - public function clearList () { - // Clear the only one group - $this->clearGroup('tasks'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/mailer/.htaccess b/inc/classes/main/mailer/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/mailer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/mailer/class_ b/inc/classes/main/mailer/class_ deleted file mode 100644 index c3b3e13b..00000000 --- a/inc/classes/main/mailer/class_ +++ /dev/null @@ -1,70 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Mailer extends BaseMailer implements DeliverableMail { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this mailer class - * - * @return $mailerInstance An instance of this mailer class - */ - public final static function create???Mailer () { - // Get a new instance - $mailerInstance = new ???Mailer(); - - // Return the instance - return $mailerInstance; - } - - /** - * Deliver email to the recipient(s) - * - * @return void - * @todo 0% done - */ - public function deliverEmail() { - $this->partialStub("You have to implement this method."); - } - - /** - * Send notification to the admin - * - * @return void - * @todo 0% done - */ - public function sendAdminNotification() { - $this->partialStub("You have to implement this method."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/mailer/class_BaseMailer.php b/inc/classes/main/mailer/class_BaseMailer.php deleted file mode 100644 index db07b20d..00000000 --- a/inc/classes/main/mailer/class_BaseMailer.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseMailer extends BaseFrameworkSystem { - /** - * Template name - */ - private $templateName = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Loads a text or HTML template depending on configuration into the template engine - * - * @param $templateName Name of the template we shall load - * @return void - */ - protected final function loadTemplate ($templateName) { - // Set template name - $this->setTemplateName($templateName); - - // Get configuration entry - $templatePrefix = $this->getConfigInstance()->getConfigEntry('email_tpl_' . $templateName); - - // Load this email template - $this->getTemplateInstance()->loadEmailTemplate($templatePrefix . '_' . $templateName); - } - - /** - * Adds a user class to the recipient list for current template - * - * @param $userInstance An instance of a user class - * @return void - */ - public function addRecipientByUserInstance (ManageableMember $userInstance) { - // Get template name - $templateName = $this->getTemplateName(); - - // Is the list initialized? - $this->pushValueToGenericArrayKey('recipients', $templateName, 'recipients', $userInstance); - } - - /** - * Adds a template variable (just the name) to the recipient list in given section of current template - * - * @param $section Section can be 'config' or "value" currently - * @param $variableName Template variable name to add - * @return void - */ - private final function addTemplateVariable ($section, $variableName) { - // Get template name - $templateName = $this->getTemplateName(); - - // Generate full section name - $sectionName = $section . '_vars'; - - // Is the list initialized? - $this->setGenericArrayElement('recipients', $templateName, $sectionName, $variableName, 'OK'); - } - - /** - * Adds a config template variable to the recipient list of current template - * - * @param $variableName Template variable name to add - * @return void - */ - public final function addConfigTemplateVariable ($variableName) { - $this->addTemplateVariable('config', $variableName); - } - - /** - * Adds a 'value' template variable to the recipient list of current template - * - * @param $variableName Template variable name to add - * @return void - */ - public final function addValueTemplateVariable ($variableName) { - $this->addTemplateVariable('value', $variableName); - } - - /** - * Adds a value instance for a given variable name. It should be set! - * - * @param $variableName Template variable we want to assign a value instance - * @param $valueInstance An object instance which can provide "field values" - * @return void - */ - public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) { - $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'values', $variableName, $valueInstance); - } - - /** - * Protected setter for template name - * - * @param $templateName Name of email template - * @return void - */ - public final function setTemplateName ($templateName) { - $this->templateName = (string) $templateName; - } - - /** - * Protected getter for template name - * - * @return $templateName Name of email template - */ - protected final function getTemplateName () { - return $this->templateName; - } - - /** - * Setter for subject line - * - * @param $subjectLine Subject line to set - * @return void - */ - public final function setSubjectLine ($subjectLine) { - $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'generic', 'subject', $subjectLine); - } - - /** - * Getter for subject line or null if not found - * - * @return $subjectLine Subject line to set - */ - public final function getSubjectLine () { - // Default subject is null - $subjectLine = NULL; - - // Get template name - $templateName = $this->getTemplateName(); - - // Does the subject line exist? - if ((!empty($templateName)) && ($this->isGenericArrayElementSet('recipients', $templateName, 'generic', 'subject'))) { - // Then use it - $subjectLine = $this->getGenericArrayElement('recipients', $templateName, 'generic', 'subject'); - } // END - if - - // Return it - return $subjectLine; - } - - /** - * Use subject line provided by the (XML) template otherwise a subject line must be set - * - * @return void - */ - public function useSubjectFromTemplate () { - // Set the subject line - $this->setSubjectLine('{?subject?}'); - } - - /** - * Getter for recipient list array - * - * @return $recipientList Array with reciepients - */ - public final function getRecipientList () { - return $this->getGenericArray('recipients'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/mailer/debug/.htaccess b/inc/classes/main/mailer/debug/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/mailer/debug/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/mailer/debug/class_DebugMailer.php b/inc/classes/main/mailer/debug/class_DebugMailer.php deleted file mode 100644 index 3a37c02a..00000000 --- a/inc/classes/main/mailer/debug/class_DebugMailer.php +++ /dev/null @@ -1,175 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DebugMailer extends BaseMailer implements DeliverableMail { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this mailer class - * - * @param $templateInstance A template instance - * @param $applicationInstance An application helper class - * @param $templateName Name of email template to set - * @return $mailerInstance An instance of this mailer class - */ - public static final function createDebugMailer (CompileableTemplate $templateInstance, ManageableApplication $applicationInstance, $templateName) { - // Get a new instance - $mailerInstance = new DebugMailer(); - - // Set template instance - $mailerInstance->setTemplateInstance($templateInstance); - - // Set application instance - $mailerInstance->setApplicationInstance($applicationInstance); - - // Set template name - $mailerInstance->setTemplateName($templateName); - - // Return the instance - return $mailerInstance; - } - - /** - * Deliver email to the recipient(s) - * - * @return void - * @throws InvalidInterfaceException If the recipient instance does not implement ManageableMember - */ - public function deliverEmail () { - // Get template instance - $templateInstance = $this->getTemplateInstance(); - - // "Deliver" all emails - foreach ($this->getRecipientList() as $templateName => $recipientList) { - // Walk through all recipients and "sent", or better print, it out - foreach ($recipientList['recipients'] as $recipientInstance) { - // The recipient should be a user instance, right? - if (!$recipientInstance instanceof ManageableMember) { - // Invalid entry found! - throw new InvalidInterfaceException(array($this, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING); - } // END - if - - // User class found, so entry is valid, first load the template - $this->loadTemplate($templateName); - - // Set subject line - $templateInstance->assignVariable('subject', $this->getSubjectLine()); - - // Walk through all variables, first config to assign them - foreach ($recipientList['config_vars'] as $variable => $dummy) { - // Load the config value and set it - $templateInstance->assignConfigVariable($variable); - } // END - if - - // Now do the same with the values but ask the "value instance" instead! - foreach ($recipientList['value_vars'] as $variable => $dummy) { - // Is the value instance there? - if (!isset($recipientList['values'][$variable])) { - // Throw exception - throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get the field from the value instance - $fieldValue = $recipientList['values'][$variable]->getField($variable); - - // Set it in template engine - $templateInstance->assignVariable($variable, $fieldValue); - } - - // Render the content - $templateInstance->renderXmlContent(); - - // Get responce instance - $responseInstance = $this->getApplicationInstance()->getResponseInstance(); - - // Transfer the data to the response - $templateInstance->transferToResponse($responseInstance); - } // END - foreach - } // END - foreach - } - - /** - * Send notification to the admin - * - * @return void - * @todo 0% done - */ - public function sendAdminNotification () { - // Unfinished work - } - - /** - * Invokes the mail delivery process which will prepare the output of the message in a code template - * - * @return void - */ - public function invokeMailDelivery () { - // Get template instance - $templateInstance = $this->getTemplateInstance(); - - // Get the compiled message and set it as new template variable - $message = $templateInstance->getCompiledData(); - $templateInstance->assignVariable('message', $message); - - // Load the code template - $templateInstance->loadCodeTemplate('mail_debug'); - - // Compile the template - $templateInstance->compileTemplate(); - - // Assign this template with variable - $templateInstance->assignTemplateWithVariable('mail_debug', 'main_content'); - - // Load header template - $templateInstance->loadCodeTemplate('header'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('header', 'header'); - - // Load footer template - $templateInstance->loadCodeTemplate('footer'); - - // Compile and assign it with a variable - $templateInstance->compileTemplate(); - $templateInstance->assignTemplateWithVariable('footer', 'footer'); - - // Load the master template - $templateInstance->loadCodeTemplate($this->getApplicationInstance()->buildMasterTemplateName()); - - // Then compile it again - $templateInstance->compileVariables(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/menu/.htaccess b/inc/classes/main/menu/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/menu/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/menu/class_BaseMenu.php b/inc/classes/main/menu/class_BaseMenu.php deleted file mode 100644 index 7bb97e16..00000000 --- a/inc/classes/main/menu/class_BaseMenu.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseMenu extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Renders the menu by loading the base template and a menu-specific - * template. - * - * @return void - */ - public function renderMenu () { - // Initialize the menu system by preparing it's template instance - $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this)); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Load the menu template for all - $templateInstance->loadMenuTemplate('generic_menu_entries'); - - // Get the 'command' from request instance - $command = $this->getApplicationInstance()->getRequestInstance()->getRequestElement('command'); - - // If page is empty, choose default - if (empty($command)) { - // Use default page as none has been specified - $command = $this->getConfigInstance()->getConfigEntry('default_' . $this->getApplicationInstance()->getAppShortName() . '_' . self::getResponseTypeFromSystem() . '_command'); - } // END - if - - // Load the menu template for this page - try { - $templateInstance->loadMenuTemplate($command . '_menu_entries'); - } catch (FileNotFoundException $e) { - // Log exception @TODO Maybe to intrusive? - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Exception caught: ' . $e->__toString() . ', with message: ' . $e->getMessage()); - } - - // Render template data here - $templateInstance->renderXmlContent(); - //exit(__METHOD__ . ':!OK'); - } - - /** - * Transfers the rendered menu to a given template engine by assigning - * the rendered content with a template variable. - * - * @param $templateInstance An instance of a CompileableTemplate class - * @return void - */ - public function transferContentToTemplateEngine (CompileableTemplate $templateInstance) { - // Assign menu content to variable - $templateInstance->assignVariable('menu', $this->getTemplateInstance()->getMenuContent()); - //* DEBUG */ $templateInstance->debugInstance(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/.htaccess b/inc/classes/main/output/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/class_ b/inc/classes/main/output/class_ deleted file mode 100644 index 01161ac5..00000000 --- a/inc/classes/main/output/class_ +++ /dev/null @@ -1,113 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Output extends BaseOutput implements OutputStreamer, Registerable { - /** - * The instance for the singleton design pattern - */ - private static $!!!Instance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a new !!! output system and set the content type - * - * @param $applicationInstance An instance of a ManageableApplication class - * @return $debugInstance An instance of this middleware class - */ - public static final function createWebOutput (ManageableApplication $applicationInstance) { - // Is the self-instance already set? - if (is_null(self::$!!!Instance)) { - // Get a new instance and set it - self::$!!!Instance = new WebOutput(); - - // Get the content type - $contentType = self::$!!!Instance->getConfigInstance()->getConfigEntry('!!!_content_type'); - - // Set the content type - if (!empty($contentType)) { - // Set the header - $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType); - } // END - if - } // END - if - - // Return instance - return self::$!!!Instance; - } - - /** - * Output the code - * - * @param $outStream Stream to output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - * @todo 0% done - */ - public final function output ($outStream = FALSE, $stripTags = FALSE) { - $this->partialStub('Please implement this method. outStream()=' . strlen($outStream) . ',stripTags=' . intval($stripTags)); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - * @throws UnsupportedOperationException If this method is called - */ - public function determineSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - * @throws UnsupportedOperationException If this method is called - */ - public function seek ($offset, $whence = SEEK_SET) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - * @throws UnsupportedOperationException If this method is called - */ - public function size () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/class_BaseOutput.php b/inc/classes/main/output/class_BaseOutput.php deleted file mode 100644 index 484db423..00000000 --- a/inc/classes/main/output/class_BaseOutput.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseOutput extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/console/.htaccess b/inc/classes/main/output/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/console/class_ConsoleOutput.php b/inc/classes/main/output/console/class_ConsoleOutput.php deleted file mode 100644 index 7d93422b..00000000 --- a/inc/classes/main/output/console/class_ConsoleOutput.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleOutput extends BaseOutput implements OutputStreamer { - /** - * The instance for the singleton design pattern - */ - private static $consoleInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a new web output system and set the content type - * - * @param $contentType A valid content-type - * @return $debugInstance An instance of this middleware class - */ - public static final function createConsoleOutput ($contentType) { - // Cast the content-type to string - $contentType = (string) $contentType; - $contentType = trim($contentType); - - // Get instance - self::$consoleInstance = new ConsoleOutput(); - - // Set the content type - // @TODO Need to rewrite this to $requestInstance->addHeader() - if (!empty($contentType)) { - @header(sprintf('Content-type: %s', - $contentType - )); - } // END - if - - // Return instance - return self::$consoleInstance; - } - - /** - * Getter for an instance of this class - * - * @return $consoleInstance An instance of this class - */ - public static final function getInstance() { - // Is the self-instance already set? - if (is_null(self::$consoleInstance)) { - $contentType = FrameworkConfiguration::getSelfInstance()->getConfigEntry('web_content_type'); - self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType); - } // END - if - - // Return the instance - return self::$consoleInstance; - } - - /** - * Output the code - * - * @param $outStream Something we shall sent to the console - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function output ($outStream = FALSE, $stripTags = FALSE) { - print trim($outStream) . PHP_EOL; - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - * @throws UnsupportedOperationException If this method is called - */ - public function determineSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - * @throws UnsupportedOperationException If this method is called - */ - public function seek ($offset, $whence = SEEK_SET) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - * @throws UnsupportedOperationException If this method is called - */ - public function size () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/debug/.htaccess b/inc/classes/main/output/debug/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/debug/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/debug/class_BaseDebugOutput.php b/inc/classes/main/output/debug/class_BaseDebugOutput.php deleted file mode 100644 index 9440e384..00000000 --- a/inc/classes/main/output/debug/class_BaseDebugOutput.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseDebugOutput extends BaseOutput { - /** - * Class name for this output class is being used for logging - */ - private $loggerClassName = FALSE; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for logger class name - * - * @param $loggerClassName Class name this output class is being used for logging - * @return void - */ - public final function setLoggerClassName ($loggerClassName) { - $this->loggerClassName = $loggerClassName; - } - - /** - * Getter for logger class name - * - * @return $loggerClassName Class name this output class is being used for logging - */ - public final function getLoggerClassName () { - return $this->loggerClassName; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/debug/console/.htaccess b/inc/classes/main/output/debug/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/debug/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/debug/console/class_DebugConsoleOutput.php b/inc/classes/main/output/debug/console/class_DebugConsoleOutput.php deleted file mode 100644 index 3598cc18..00000000 --- a/inc/classes/main/output/debug/console/class_DebugConsoleOutput.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStreamer, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $debugInstance The prepared debug instance - */ - public static final function createDebugConsoleOutput () { - // Get a new instance - $debugInstance = new DebugConsoleOutput(); - - // Return it - return $debugInstance; - } - - /** - * Outputs the given data without HTML tags - * - * @param $output The HTML'ed output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function outputStream ($output, $stripTags = FALSE) { - // Strip HTML tags out? - if ($stripTags === TRUE) { - // Prepare the output without HTML tags - $output = trim(html_entity_decode(strip_tags(stripslashes($output)))); - } else { - // Prepare the output with HTML tags - $output = trim(stripslashes($output)); - } - - // Are debug times enabled? - if ($this->getConfigInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_output_timings') == 'Y') { - // Output it first - $output = $this->getPrintableExecutionTime() . $output; - } // END - if - - // And print it out... - printf('%s%s', $output, chr(10)); - } - - /** - * Output the code - * - * @param $outStream Stream to output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function output ($outStream = FALSE, $stripTags = FALSE) { - // Empty output will be silently ignored - if ($outStream !== FALSE) { - $this->outputStream($outStream, $stripTags); - } // END - if - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - * @throws UnsupportedOperationException If this method is called - */ - public function determineSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - * @throws UnsupportedOperationException If this method is called - */ - public function seek ($offset, $whence = SEEK_SET) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - * @throws UnsupportedOperationException If this method is called - */ - public function size () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/debug/error/.htaccess b/inc/classes/main/output/debug/error/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/debug/error/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/debug/error/class_DebugErrorLogOutput.php b/inc/classes/main/output/debug/error/class_DebugErrorLogOutput.php deleted file mode 100644 index 7124250c..00000000 --- a/inc/classes/main/output/debug/error/class_DebugErrorLogOutput.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DebugErrorLogOutput extends BaseDebugOutput implements Debugger, OutputStreamer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $debugInstance The prepared debug instance - */ - public static final function createDebugErrorLogOutput () { - // Get a new instance - $debugInstance = new DebugErrorLogOutput(); - - // Return it - return $debugInstance; - } - - /** - * Outputs the given data without HTML tags, ignores $stripTags - * - * @param $output The HTML'ed output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function outputStream ($output, $stripTags = FALSE) { - // Split multiple lines into and array to put them out line-by-line - $errorLines = explode(chr(10), $output); - - // "Walk" through all lines - foreach ($errorLines as $err) { - // Trim any spaces, \n, \r etc. out - $err = trim($err); - - // Log only none-empty lines - if (!empty($err)) { - // Log this line - error_log(html_entity_decode(strip_tags($err)), 0); - } // END - if - } // END - foreach - } - - /** - * Output the code - * - * @param $outStream Stream to output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function output ($outStream = FALSE, $stripTags = FALSE) { - // Empty output will be silently ignored - if ($outStream !== FALSE) { - $this->outputStream($outStream); - } - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Determines for seek position - * - * @return $seekPosition Current seek position - * @throws UnsupportedOperationException If this method is called - */ - public function determineSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - * @throws UnsupportedOperationException If this method is called - */ - public function seek ($offset, $whence = SEEK_SET) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - * @throws UnsupportedOperationException If this method is called - */ - public function size () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/debug/web/.htaccess b/inc/classes/main/output/debug/web/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/debug/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/debug/web/class_DebugWebOutput.php b/inc/classes/main/output/debug/web/class_DebugWebOutput.php deleted file mode 100644 index b8c34cb6..00000000 --- a/inc/classes/main/output/debug/web/class_DebugWebOutput.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DebugWebOutput extends BaseDebugOutput implements Debugger, OutputStreamer { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $debugInstance The prepared debug instance - */ - public static final function createDebugWebOutput () { - // Get a new instance - $debugInstance = new DebugWebOutput(); - - // Return it - return $debugInstance; - } - - /** - * Outputs the given data directly, ignores $stripTags - * - * @param $output The HTML output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function outputStream ($output, $stripTags = FALSE) { - // Strip out
- $output = str_replace('
', '', $output); - print(stripslashes($output)."
\n"); - } - - /** - * Output the code - * - * @param $outStream Stream to output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function output ($outStream = FALSE, $stripTags = FALSE) { - // Empty output will be silently ignored - if ($outStream !== FALSE) { - $this->outputStream($outStream, $stripTags); - } // END - if - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - * @throws UnsupportedOperationException If this method is called - */ - public function determineSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - * @throws UnsupportedOperationException If this method is called - */ - public function seek ($offset, $whence = SEEK_SET) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - * @throws UnsupportedOperationException If this method is called - */ - public function size () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/output/log_file/.htaccess b/inc/classes/main/output/log_file/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/log_file/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/web/.htaccess b/inc/classes/main/output/web/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/output/web/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/output/web/class_WebOutput.php b/inc/classes/main/output/web/class_WebOutput.php deleted file mode 100644 index 76f9be52..00000000 --- a/inc/classes/main/output/web/class_WebOutput.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WebOutput extends BaseOutput implements OutputStreamer, Registerable { - /** - * The instance for the singleton design pattern - */ - private static $webInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Create a new web output system and set the content type - * - * @param $applicationInstance An instance of a ManageableApplication class - * @return $debugInstance An instance of this middleware class - */ - public static final function createWebOutput (ManageableApplication $applicationInstance) { - // Is the self-instance already set? - if (is_null(self::$webInstance)) { - // Get a new instance and set it - self::$webInstance = new WebOutput(); - - // Get the content type - $contentType = self::$webInstance->getConfigInstance()->getConfigEntry('web_content_type'); - - // Set the content type - if (!empty($contentType)) { - // Set the header - $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType); - } // END - if - } // END - if - - // Return instance - return self::$webInstance; - } - - /** - * Output the code - * - * @param $outStream Stream to output - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function output ($outStream = FALSE, $stripTags = FALSE) { - print(stripslashes($outStream)); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - * @throws UnsupportedOperationException If this method is called - */ - public function determineSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - * @throws UnsupportedOperationException If this method is called - */ - public function seek ($offset, $whence = SEEK_SET) { - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - * @throws UnsupportedOperationException If this method is called - */ - public function size () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/parser/.htaccess b/inc/classes/main/parser/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/parser/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/parser/class_ b/inc/classes/main/parser/class_ deleted file mode 100644 index 3fe153d8..00000000 --- a/inc/classes/main/parser/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Parser extends BaseParser implements Parseable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class Parser and prepares it for usage - * - * @param $templateInstance A CompileableTemplate instance - * @return $parserInstance An instance of this parser - public final static function create???Parser (CompileableTemplate $templateInstance) { - // Get a new instance - $parserInstance = new ???Parser(); - - // Set the template instance - $parserInstance->setTemplateInstance($templateInstance); - - // Return the prepared instance - return $parserInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/parser/class_BaseParser.php b/inc/classes/main/parser/class_BaseParser.php deleted file mode 100644 index 23bb8051..00000000 --- a/inc/classes/main/parser/class_BaseParser.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseParser extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/parser/xml/.htaccess b/inc/classes/main/parser/xml/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/parser/xml/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/parser/xml/class_XmlParser.php b/inc/classes/main/parser/xml/class_XmlParser.php deleted file mode 100644 index 82d0d15a..00000000 --- a/inc/classes/main/parser/xml/class_XmlParser.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class XmlParser extends BaseParser implements Parseable { - // Exception constants - const EXCEPTION_XML_PARSER_ERROR = 0x1e0; - const EXCEPTION_XML_NODE_UNKNOWN = 0x1e1; - const EXCEPTION_XML_NODE_MISMATCH = 0x1e2; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class Parser and prepares it for usage - * - * @param $templateInstance A CompileableTemplate instance - * @return $parserInstance An instance of this parser - */ - public static final function createXmlParser (CompileableTemplate $templateInstance) { - // Get a new instance - $parserInstance = new XmlParser(); - - // Set the template instance - $parserInstance->setTemplateInstance($templateInstance); - - // Return the prepared instance - return $parserInstance; - } - - /** - * Parses the given XML content - * - * @param $content Valid XML content - * @return void - * @throws XmlParserException If an XML error was found - */ - public function parseXmlContent ($content) { - // Convert all to UTF8 - if (empty($content)) { - // No empty content! - self::createDebugInstance(__CLASS__)->debugOutput('Empty content! Backtrace:
');
-			debug_print_backtrace();
-			self::createDebugInstance(__CLASS__)->debugOutput('
'); - exit(); - } elseif (function_exists('recode')) { - // Recode found, so use it - $content = recode('html..utf8', $content); - } elseif (function_exists('mb_convert_encoding')) { - // Use mb_convert_encoding() - $content = mb_convert_encoding($content, 'UTF-8', 'auto'); - } else { - // @TODO We need to find a fallback solution here - $this->partialStub('Cannot find recode/mbstring extension!'); - } // END - if - - // Get an XML parser - $xmlParser = xml_parser_create(); - - // Force case-folding to on - xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, TRUE); - - // Set UTF-8 - xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); - - // Get instance (we need this :( ) - $templateInstance = $this->getTemplateInstance(); - - // Set object - xml_set_object($xmlParser, $templateInstance); - - // Set handler call-backs - xml_set_element_handler($xmlParser, 'startElement', 'finishElement'); - xml_set_character_data_handler($xmlParser, 'characterHandler'); - - // Now parse the XML tree - if (!xml_parse($xmlParser, $content)) { - // Error found in XML! - //* DEBUG: */ exit(__METHOD__ . ':
'.htmlentities($content).'
'); - throw new XmlParserException(array($this, $xmlParser), self::EXCEPTION_XML_PARSER_ERROR); - } // END - if - - // Free the parser - xml_parser_free($xmlParser); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/points/.htaccess b/inc/classes/main/points/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/points/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/points/class_UserPoints.php b/inc/classes/main/points/class_UserPoints.php deleted file mode 100644 index 428868d8..00000000 --- a/inc/classes/main/points/class_UserPoints.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePoints { - /** - * Amount of points - */ - private $amount = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this points class - * - * @param $userInstance An instance of a user class - * @return $pointsInstance An instance of this class - */ - public static final function createUserPoints (ManageableAccount $userInstance) { - // Get a new instance - $pointsInstance = new UserPoints(); - - // Set user instance - $pointsInstance->setUserInstance($userInstance); - - // Get a critieria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add search criteria - $searchInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $userInstance->getUserId()); - $searchInstance->setLimit(1); - - // Get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('user_points_db_wrapper_class'); - - // Get result back - $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance); - - // Advance to first entry by default - $resultInstance->next(); - - // Set it in this instance - $pointsInstance->setResultInstance($resultInstance); - - // Return instance - return $pointsInstance; - } - - /** - * Setter for amount - * - * @param $amount Amount of points to store - * @return void - */ - public final function setAmount ($amount) { - $this->amount = (float) $amount; - } - - /** - * Getter for amount - * - * @return $amount Amount of points to store - */ - public final function getAmount () { - return $this->amount; - } - - /** - * Checks whether the user has the required amount of points left for the specified action - * - * @param $action The action or configuration entry plus prefix the user wants to perform - * @return $hasRequired Whether the user has the required points - * @todo Finish loading part of points - */ - public function ifUserHasRequiredPoints ($action) { - // Default is that everyone is poor... ;-) - $hasRequired = FALSE; - - // Get the required points entry - $requiredPoints = $this->getConfigInstance()->getConfigEntry($action . '_action_points'); - - // Rewind always - $this->getResultInstance()->rewind(); - - // Do we have an entry? - if ($this->getResultInstance()->next()) { - // Get the entry - $currEntry = $this->getResultInstance()->current(); - - // Has he enought points? - $hasRequired = ($currEntry['points'] >= $requiredPoints); - } // END - if - - // Return the result - return $hasRequired; - } - - /** - * "Books" the given points amount on the current user's account - * - * @param $amount Amount of points we shall book - * @return void - */ - public function bookPointsDirectly ($amount) { - // Rewind always - $this->getResultInstance()->rewind(); - - // Do we have an entry? - if ($this->getResultInstance()->next()) { - // Get the entry - $entry = $this->getResultInstance()->current(); - - // Add the points - $amount += $entry[UserPointsDatabaseWrapper::DB_COLUMN_POINTS]; - - // Now get another criteria - $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); - - // And add our both entries - $updateInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $amount); - - // Add the search criteria for searching for the right entry - $updateInstance->setSearchInstance($searchInstance); - - // Set wrapper class name - $updateInstance->setWrapperConfigEntry('user_points_db_wrapper_class'); - - // Remember the update in database result - $this->getResultInstance()->add2UpdateQueue($updateInstance); - } else { - // Set the amount in class - $this->setAmount($amount); - - // Create the new entry - $wrapperInstance->insertUserPoints($this); - } - } - - /** - * Adds registration elements to a given dataset instance - * - * @param $criteriaInstance An instance of a StoreableCriteria class - * @param $requestInstance An instance of a Requestable class - * @return void - */ - public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { - // Add user id - $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $this->getUserInstance()->getUserId()); - - // Add amount - $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $this->getAmount()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/reader/.htaccess b/inc/classes/main/reader/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/reader/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/reader/class_ConsoleNewsReader.php b/inc/classes/main/reader/class_ConsoleNewsReader.php deleted file mode 100644 index 1aa4b615..00000000 --- a/inc/classes/main/reader/class_ConsoleNewsReader.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this reader by a provided request instance - * - * @param $requestInstance An instance of a Requestable class - * @return $readerInstance An instance of this reader class - */ - public static final function createConsoleNewsReader (Requestable $requestInstance) { - // Get a new instance - $readerInstance = new ConsoleNewsReader(); - - // Set request instance - $readerInstance->setRequestInstance($requestInstance); - - // Return prepared instance - return $readerInstance; - } - - /** - * Initializes this reader class by pre-fetching news depending on 'command' - * (outside or login area), which amount of news and how much to skip - * - * @return void - */ - public function initializeReader () { - // Get 'command' for saving some calls - $command = $this->getRequestInstance()->getRequestElement('command'); - - // First get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class'); - - // Next create a searchable criteria instance - $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add the command as criteria to it at lease - $criteriaInstance->addCriteria('command', $command); - - // Add limitation from config - $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit'); - - // Get a resultInstance back from the database - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); - - // Save that resultInstance in this class - $this->setResultInstance($resultInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/reader/class_DefaultNewsReader.php b/inc/classes/main/reader/class_DefaultNewsReader.php deleted file mode 100644 index 95354828..00000000 --- a/inc/classes/main/reader/class_DefaultNewsReader.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this reader by a provided request instance - * - * @param $requestInstance An instance of a Requestable class - * @return $readerInstance An instance of this reader class - */ - public static final function createDefaultNewsReader (Requestable $requestInstance) { - // Get a new instance - $readerInstance = new DefaultNewsReader(); - - // Set request instance - $readerInstance->setRequestInstance($requestInstance); - - // Return prepared instance - return $readerInstance; - } - - /** - * Initializes this reader class by pre-fetching news depending on 'command' - * (outside or login area), which amount of news and how much to skip - * - * @return void - */ - public function initializeReader () { - // Get 'command' for saving some calls - $command = $this->getRequestInstance()->getRequestElement('command'); - - // First get a wrapper instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class'); - - // Next create a searchable criteria instance - $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add the page as criteria to it at lease - $criteriaInstance->addCriteria('command', $command); - - // Add limitation from config - $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit'); - - // Get a resultInstance back from the database - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); - - // Save that resultInstance in this class - $this->setResultInstance($resultInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/registration/.htaccess b/inc/classes/main/registration/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/registration/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/registration/class_BaseRegistration.php b/inc/classes/main/registration/class_BaseRegistration.php deleted file mode 100644 index 0a516f89..00000000 --- a/inc/classes/main/registration/class_BaseRegistration.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseRegistration extends BaseFrameworkSystem { - /** - * Pre-registration filter chain - */ - private $preRegistrationFilter = NULL; - - /** - * Pre-registration filter chain - */ - private $postRegistrationFilter = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Initialize filters. This must be done before you can use them - * - * @return void - */ - protected function initFilterChains () { - // Pre/post-registration filters - $this->preRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); - $this->postRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); - } - - /** - * Adds a filter to the pre filter chain - * - * @param $filterInstance An instance of a filter - * @return void - */ - public function addPreFilter (Filterable $filterInstance) { - // Add the pre filter - $this->preRegistrationFilter->addFilter($filterInstance); - } - - /** - * Adds a filter to the post filter chain - * - * @param $filterInstance An instance of a filter - * @return void - */ - public function addPostFilter (Filterable $filterInstance) { - // Add the post filter - $this->postRegistrationFilter->addFilter($filterInstance); - } - - /** - * Executes all pre filters - * - * @return void - */ - protected function executePreFilters () { - // Execute all pre filters - $this->preRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance()); - } - - /** - * Executes all post filters - * - * @return void - */ - protected function executePostFilters () { - // Execute all post filters - $this->postRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/registry/.htaccess b/inc/classes/main/registry/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/registry/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/registry/class_ b/inc/classes/main/registry/class_ deleted file mode 100644 index db836926..00000000 --- a/inc/classes/main/registry/class_ +++ /dev/null @@ -1,59 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Registry extends BaseRegistry implements Register { - /** - * Instance of this class - */ - private static $registryInstance = null; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Singleton getter for self instance. This class has no factory pattern - * because here is no need for special parameters. - * - * @return $registryInstance Instance of this class - */ - public final static function getRegistry () { - // Is an instance there? - if (is_null(self::$registryInstance)) { - // Not yet, so create one - self::$registryInstance = new ???Registry(); - } // END - if - - // Return the instance - return self::$registryInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/registry/class_BaseRegistry.php b/inc/classes/main/registry/class_BaseRegistry.php deleted file mode 100644 index 34f4a892..00000000 --- a/inc/classes/main/registry/class_BaseRegistry.php +++ /dev/null @@ -1,224 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseRegistry extends BaseFrameworkSystem implements Registerable { - /** - * Glue for generating a registry key - */ - const REGISTRY_KEY_GLUE = '_'; - - /** - * Instance of this class - */ - private static $registryInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init raw array - $this->initGenericArrayGroup('raw', 'generic'); - } - - /** - * Checks whether an instance key was found - * - * @param $instanceKey The key holding an instance in registry - * @return $exists Whether the key exists in registry - */ - public function instanceExists ($instanceKey) { - // Does this key exists? - $exists = $this->isGenericArrayKeySet('registry', 'instance', $instanceKey); - - // Return the result - return $exists; - } - - /** - * Adds/overwrites a new instance to the registry at the given key - * - * @param $instanceKey The key to identify the instance - * @param $objectInstance An instance we shall store - * @return void - */ - public function addInstance ($instanceKey, Registerable $objectInstance) { - $this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance); - } - - /** - * Getter for whole instance registry - * - * @return $instanceRegistry The whole instance registry array - */ - public final function getInstanceRegistry () { - return $this->getGenericSubArray('registry', 'instance'); - } - - /** - * Adds a new entry to the given list name. If you want to add objects - * please use addInstance() and getInstance() instead. - * - * @param $key The key to identify the whole list - * @param $value The value to be stored - * @return void - */ - public final function addEntry ($key, $value) { - // Key must not be an array - assert(!is_array($key)); - - // Push it - $this->pushValueToGenericArrayKey('raw', 'generic', $key, $value); - } - - /** - * Getter for entries or "sub entries" - * - * @return $entries An array with entries from this registry - */ - public final function getEntries ($key = NULL) { - // Key must not be an array - assert(!is_array($key)); - - // Default is whole array - $entries = $this->getGenericArray('raw'); - - // Is $key set? - if (!is_null($key)) { - // Then use this entry - $entries = $this->getGenericArrayKey('raw', 'generic', $key); - } // END - if - - // Return the array - return $entries; - } - - /** - * "Getter" for an array of all entries for given key - * - * @param $arrayKey The array (key) to look in - * @param $lookFor The key to look for - * @return $entry An array with all keys - */ - public function getArrayFromKey ($arrayKey, $lookFor) { - // Key must not be an array - assert(!is_array($arrayKey)); - - // Init array - $entry = array(); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking arrayKey=' . $arrayKey . ',lookFor=' . $lookFor); - - // "Walk" over all entries - foreach ($this->getEntries($arrayKey) as $key => $value) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor); - - // If $value matches the $lookFor, we need to look for more entries for this! - if ($lookFor == $value) { - // Look for more entries - foreach ($this->getEntries() as $key2 => $value2) { - // Now "walk" through all entries, if an array is returned - if (is_array($value2)) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key2=' . $key2 . ',value2()=' . count($value2) . ',lookFor=' . $lookFor); - - // "Walk" through all of them - foreach ($value2 as $key3 => $value3) { - // $value3 needs to be an array - assert(is_array($value3)); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key=' . $key . ',key3=' . $key3 . ',isset()=' . isset($value3[$key]) . ' ...'); - - // Both keys must match! - if (($key == $key3) || (isset($value3[$key]))) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . $value3[$key] . ' ...'); - - // Then add it - $entry[$key3] = $value3[$key]; - } // END - if - } // END - foreach - } // END - if - } // END - foreach - - // Skip further lookups - break; - } // END - if - } // END - foreach - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Returning entry(' . count($entry) . ')=' . print_r($entry, TRUE)); - - // Return it - return $entry; - } - - /** - * Gets a registered instance or null if not found - * - * @param $instanceKey The key to identify the instance - * @return $objectInstance An instance we shall store - * @throws NullPointerException If the requested key is not found - */ - public function getInstance ($instanceKey) { - // Is the instance there? - if (!$this->instanceExists($instanceKey)) { - // This might happen if a non-registered key was requested - throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); - } // END - if - - // Get the instance - $objectInstance = $this->getGenericArrayKey('registry', 'instance', $instanceKey); - - // Return the result - return $objectInstance; - } - - /** - * "Getter" for a registry key for given prefix and array. This method - * calls implode() to get a suitable key. This method does not care about - * the indexes. - * - * @param $prefix Prefix for the key - * @param $data An array with data - * @return $registryKey A registry key - */ - public static function getRegistryKeyFromArray ($prefix, array $data) { - // "Generate" the key - $registryKey = $prefix . self::REGISTRY_KEY_GLUE . implode(self::REGISTRY_KEY_GLUE, $data); - - // Return it - return $registryKey; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/registry/generic/.htaccess b/inc/classes/main/registry/generic/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/registry/generic/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/registry/generic/class_Registry.php b/inc/classes/main/registry/generic/class_Registry.php deleted file mode 100644 index d998ac83..00000000 --- a/inc/classes/main/registry/generic/class_Registry.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Registry extends BaseRegistry implements Register { - /** - * Instance of this class - */ - private static $registryInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Singleton getter for self instance. This class has no factory pattern - * because here is no need for special parameters. - * - * @return $registryInstance Instance of this class - */ - public static final function getRegistry () { - // Is an instance there? - if (is_null(self::$registryInstance)) { - // Not yet, so create one - self::$registryInstance = new Registry(); - } // END - if - - // Return the instance - return self::$registryInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/registry/sub/.htaccess b/inc/classes/main/registry/sub/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/registry/sub/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/registry/sub/class_SubRegistry.php b/inc/classes/main/registry/sub/class_SubRegistry.php deleted file mode 100644 index 96c9eac3..00000000 --- a/inc/classes/main/registry/sub/class_SubRegistry.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class SubRegistry extends BaseRegistry implements Register { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance (non-singleton, of course) of this registry class - * - * @return $registryInstance An instance of this registry class - */ - public static final function createSubRegistry () { - // Just get a new instance ... - $registryInstance = new SubRegistry(); - - // ... and return it - return $registryInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/request/.htaccess b/inc/classes/main/request/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/request/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/request/class_ b/inc/classes/main/request/class_ deleted file mode 100644 index ac05147e..00000000 --- a/inc/classes/main/request/class_ +++ /dev/null @@ -1,93 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Request extends BaseRequest implements Requestable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class and prepares it a little - * - * @return $httpInstance An instance of this class - */ - public final static function create???Request () { - // Create an instance - $httpInstance = new ???Request(); - - // Prepare the HTTP request data for usage - $httpInstance->prepareRequestData(); - - // Return the prepared instance - return $httpInstance; - } - - /** - * Prepares the request data for usage - * - * @return void - * @todo Needs to be implemented - */ - public function prepareRequestData () { - $this->partialStub("Please implement this method."); - } - - /** - * Getter for a header element or 'null' if header was not found - * - * @param $headerName Name of the header - * @return $headerValue Value of the header or 'null' if not found - */ - public function getHeaderElement ($headerName) { - $this->partialStub("Please implement this method."); - } - - /** - * Getter for request method. This getter might be useful for security filters - * - * @return $requestMethod Used request method - */ - public final function getRequestMethod () { - $this->partialStub("Please implement this method."); - return $_SERVER['REQUEST_METHOD']; - } - - /** - * Reads a cookie and returns it's value or null if not found - * - * @param $cookieName Name of cookie we shall read - * @return $cookieValue Value of cookie or null if not found - */ - public final function readCookie ($cookieName) { - $this->partialStub("Please implement this method."); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/request/class_BaseRequest.php b/inc/classes/main/request/class_BaseRequest.php deleted file mode 100644 index 0069bc47..00000000 --- a/inc/classes/main/request/class_BaseRequest.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseRequest extends BaseFrameworkSystem { - /** - * Array for the request data - */ - private $requestData = array(); - - /** - * Whether this request is valid and can be further processed. The default is - * valid so make sure your intercepting filters sets this attribute to FALSE - * when they need to intercept the data flow. - */ - private $requestIsValid = TRUE; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Checks whether a request element is set - * @param $element Name of the request element we want to check - * @return $isSet Whether the request element is set - */ - public function isRequestElementSet ($element) { - // Is this element found? - $isSet = isset($this->requestData[$element]); - - // Return result - return $isSet; - } - - /** - * Getter for request element or 'null' if element was not found - * - * @param $element Name of the request element we want to check - * @return $value Value of the found request element or 'null' if the - * element was not found - */ - public function getRequestElement ($element) { - // Initialize value - $value = NULL; - - // Is the element set? - if ($this->isRequestElementSet($element)) { - // Get the bare value - $value = $this->requestData[$element]; - - // Secure it against attacks - $value = htmlentities(strip_tags($value), ENT_QUOTES); - } // END - if - - // Return the element's value - return $value; - } - - /** - * Setter for request elements - * - * @param $element Request element to se - * @param $value Value to set - * @return void - */ - public function setRequestElement ($element, $value) { - $this->requestData[$element] = $value; - } - - /** - * Setter for request data array - * - * @param $requestData Request element to se - * @return void - */ - public function setRequestData (array $requestData) { - $this->requestData = $requestData; - } - - /** - * Wrapper method for array_key() function for the request data array - * - * @return $array An array containing all array keys to return - */ - public function getParameterNames () { - return array_keys($this->requestData); - } - - /** - * Sets whether the request was valid (default: TRUE) - * - * @param $isValid Whether the request is valid - * @return void - */ - public final function requestIsValid ($isValid = TRUE) { - $this->requestIsValid = (bool) $isValid; - } - - /** - * Returns whether this request is valid - * - * @return $requestIsValid Whether this request is valid - */ - public final function isRequestValid () { - return $this->requestIsValid; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/request/console/.htaccess b/inc/classes/main/request/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/request/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/request/console/class_ConsoleRequest.php b/inc/classes/main/request/console/class_ConsoleRequest.php deleted file mode 100644 index c5e070ed..00000000 --- a/inc/classes/main/request/console/class_ConsoleRequest.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleRequest extends BaseRequest implements Requestable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class and prepares it a little - * - * @return $httpInstance An instance of this class - */ - public static final function createConsoleRequest () { - // Create an instance - $httpInstance = new ConsoleRequest(); - - // Prepare the console request data for usage - $httpInstance->prepareRequestData(); - - // Return the prepared instance - return $httpInstance; - } - - /** - * Prepares the request data for usage - * - * @return void - */ - public function prepareRequestData () { - // Get the "request data" from the command-line argument list - $args = $_SERVER['argv']; - - // Are there less than two parameters? - if ($_SERVER['argc'] < 2) { - // Skip this - return; - } // END - if - - // Is the first element "index.php" ? - if ($args[0] == 'index.php') { - // Then remove it - array_shift($args); - } // END - if - - // Try to determine next parameters - foreach ($args as $arg) { - // Seperate arguemnt name from value - $argArray = explode('=', $arg); - - // Is the second one set? - if (!isset($argArray[1])) { - // Add it likewise, but empty value - $this->setRequestElement($argArray[0], ''); - } else { - // Set a name=value pair escaped and secured - $this->setRequestElement($argArray[0], escapeshellcmd($argArray[1])); - } - } // END - foreach - } - - /** - * Getter for a header element or 'null' if header was not found - * - * @param $headerName Name of the header - * @return $headerValue Value of the header or 'null' if not found - * @throws UnsupportedOperationException This method should never be called - */ - public function getHeaderElement ($headerName) { - // Console doesn't have any headers - throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for request method. This getter might be useful for security filters - * - * @return $requestMethod Used request method - */ - public final function getRequestMethod () { - // @TODO Can't this be 'CONSOLE' ? - return 'LOCAL'; - } - - /** - * Reads a cookie and returns it's value or null if not found - * - * @param $cookieName Name of cookie we shall read - * @return $cookieValue Value of cookie or null if not found - * @throws UnsupportedOperationException This method should never be called - */ - public final function readCookie ($cookieName) { - // There are no cookies on console - throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks if the request method is GET. - * - * @return $isGet Whether the request method is GET - * @throws UnsupportedOperationException This method should never be called - */ - public function isGetRequestMethod () { - // Not support method - throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks if the request method is HEAD. - * - * @return $isHead Whether the request method is HEAD - * @throws UnsupportedOperationException This method should never be called - */ - public function isHeadRequestMethod () { - // Not support method - throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks if the request method is POST. - * - * @return $isPost Whether the request method is POST - * @throws UnsupportedOperationException This method should never be called - */ - public function isPostRequestMethod () { - // Not support method - throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/request/html/.htaccess b/inc/classes/main/request/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/request/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/request/html/class_HtmlRequest.php b/inc/classes/main/request/html/class_HtmlRequest.php deleted file mode 100644 index edf9c9a4..00000000 --- a/inc/classes/main/request/html/class_HtmlRequest.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Move out the cookie part to a seperate class, e.g. Cookie - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlRequest extends BaseRequest implements Requestable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class and prepares it a little - * - * @return $requestInstance An instance of this class - */ - public static final function createHtmlRequest () { - // Create an instance - $requestInstance = new HtmlRequest(); - - // Prepare the HTML request data for usage - $requestInstance->prepareRequestData(); - - // Return the prepared instance - return $requestInstance; - } - - /** - * Checks if the request method is GET. - * - * @return $isGet Whether the request method is GET - */ - public function isGetRequestMethod () { - // Check it - return ($this->getRequestMethod() == 'GET'); - } - - /** - * Checks if the request method is HEAD. - * - * @return $isHead Whether the request method is HEAD - */ - public function isHeadRequestMethod () { - // Check it - return ($this->getRequestMethod() == 'HEAD'); - } - - /** - * Checks if the request method is POST. - * - * @return $isPost Whether the request method is POST - */ - public function isPostRequestMethod () { - // Check it - return ($this->getRequestMethod() == 'POST'); - } - - /** - * Prepares the HTML request data for usage by currently copying - * $_REQUEST into a private attribute. Later on we can add more - * things for initialization here. - * - * @return void - */ - public function prepareRequestData () { - // Copy GET then POST data - $this->setRequestData(array_merge($_GET, $_POST)); - } - - /** - * Getter for a header element or 'null' if header was not found - * - * @param $headerName Name of the header - * @return $headerValue Value of the header or 'null' if not found - */ - public function getHeaderElement ($headerName) { - // Default return value on error - $headerValue = NULL; - - // Construct the name - $name = 'HTTP_' . strtoupper(self::convertDashesToUnderscores($headerName)); - - // Does this header exist? - if (isset($_SERVER[$name])) { - $headerValue = $_SERVER[$name]; - } // END - if - - // Return the value - return $headerValue; - } - - /** - * Getter for request method. This getter might be useful for security filters - * - * @return $requestMethod Used request method - */ - public final function getRequestMethod () { - return $_SERVER['REQUEST_METHOD']; - } - - /** - * Reads a cookie and returns it's value or null if not found - * - * @param $cookieName Name of cookie we shall read - * @return $cookieValue Value of cookie or null if not found - */ - public final function readCookie ($cookieName) { - // Default is no cookie with that name found - $cookieValue = NULL; - - // Is the cookie set? - if (isset($_COOKIE[$cookieName])) { - // Then get it - $cookieValue = $_COOKIE[$cookieName]; - } // END - if - - // Return the value - return $cookieValue; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/.htaccess b/inc/classes/main/resolver/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/action/.htaccess b/inc/classes/main/resolver/action/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/action/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/action/class_BaseActionResolver.php b/inc/classes/main/resolver/action/class_BaseActionResolver.php deleted file mode 100644 index 44836e9d..00000000 --- a/inc/classes/main/resolver/action/class_BaseActionResolver.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseActionResolver extends BaseResolver { - /** - * Validated action name - */ - private $actionName = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for action name - * - * @param $actionName Last validated action name - * @return void - */ - protected final function setActionName ($actionName) { - $this->actionName = (string) $actionName; - } - - /** - * Getter for action name - * - * @return $actionName Last validated action name - */ - public final function getActionName () { - return $this->actionName; - } - - /** - * Checks whether the given action is valid - * - * @param $actionName The default action we shall execute - * @return $isValid Whether the given action is valid - * @throws EmptyVariableException Thrown if given action is not set - */ - public function isActionValid ($actionName) { - // By default nothing shall be valid - $isValid = FALSE; - - // Is a action set? - if (empty($actionName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($this, 'actionName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - - // Create class name - $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($actionName) . 'Action'; - - // Now, let us create the full name of the action class - $this->setClassName($className); - - // Is this class already loaded? - if (class_exists($this->getClassName())) { - // This class does exist. :-) - $isValid = TRUE; - } // END - if - - // Set action name - $this->setActionName($actionName); - - // Return the result - return $isValid; - } - - /** - * "Loads" current action and instances it if not yet cached - * - * @return $actionInstance A loaded action instance - */ - protected function loadAction () { - // Init action instance - $actionInstance = NULL; - - // Create action class name - $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($this->getActionName()) . 'Action'; - - // ... and set it - $this->setClassName($className); - - // Initiate the action - $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); - - // Return the result - return $actionInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/action/html/.htaccess b/inc/classes/main/resolver/action/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/action/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/action/html/class_HtmlActionResolver.php b/inc/classes/main/resolver/action/html/class_HtmlActionResolver.php deleted file mode 100644 index e6d8bb37..00000000 --- a/inc/classes/main/resolver/action/html/class_HtmlActionResolver.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlActionResolver extends BaseActionResolver implements ActionResolver { - /** - * Last successfull resolved action - */ - private $lastActionInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to 'html' - $this->setClassPrefix('html'); - } - - /** - * Creates an instance of a Html action resolver with a given default action - * - * @param $actionName The default action we shall execute - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if default action is not set - * @throws InvalidActionException Thrown if default action is invalid - */ - public static final function createHtmlActionResolver ($actionName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new HtmlActionResolver(); - - // Is the variable $actionName set and the action is valid? - if (empty($actionName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isActionValid($actionName) === FALSE) { - // Invalid action found - throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an action instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $actionInstance An instance of the resolved action - * @throws InvalidActionException Thrown if $actionName is - * invalid - * @throws InvalidActionInstanceException Thrown if $actionInstance - * is an invalid instance - */ - public function resolveActionByRequest (Requestable $requestInstance) { - // Init variables - $actionName = ''; - $actionInstance = NULL; - - // This goes fine so let's resolve the action - $actionName = $requestInstance->getRequestElement('action'); - - // Is the action empty? Then fall back to default action - if (empty($actionName)) { - $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->isActionValid($actionName) === FALSE) { - // This action is invalid! - throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $actionInstance = $this->loadAction(); - - // And validate it - if ((!is_object($actionInstance)) || (!$actionInstance instanceof Actionable)) { - // This action has an invalid instance! - throw new InvalidActionInstanceException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Set last action - $this->setResolvedInstance($actionInstance); - - // Return the resolved action instance - return $actionInstance; - } - - /** - * Resolves the action by its direct name and returns an instance of its class - * - * @return $actionInstance An instance of the action class - * @throws InvalidActionException Thrown if $actionName is invalid - */ - public function resolveAction () { - // Initiate the instance variable - $actionInstance = NULL; - - // Get action name - $actionName = $this->getActionName(); - - // Is the action empty? Then fall back to default action - if (empty($actionName)) { - $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->isActionValid($actionName) === FALSE) { - // This action is invalid! - throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $actionInstance = $this->loadAction(); - - // Return the instance - return $actionInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/class_ b/inc/classes/main/resolver/class_ deleted file mode 100644 index 5cdfd089..00000000 --- a/inc/classes/main/resolver/class_ +++ /dev/null @@ -1,577 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Resolver extends BaseResolver implements Resolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to '???' - $this->setClassPrefix('???'); - } - - /** - * Creates an instance of a Html action resolver with a given default action - * - * @param $!!!Name The default action we shall execute - * @param $appInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if default action is not set - * @throws Invalid|||Exception Thrown if default action is invalid - */ - public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { - // Create the new instance - $resolverInstance = new ???Resolver(); - - // Is the variable $!!!Name set and the action is valid? - if (empty($!!!Name)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { - // Invalid action found - throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($appInstance); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an action instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $!!!Instance An instance of the resolved action - * @throws Invalid|||Exception Thrown if $!!!Name is - * invalid - * @throws Invalid|||InstanceException Thrown if $!!!Instance - * is an invalid instance - */ - public function resolve|||ByRequest (Requestable $requestInstance) { - // Init variables - $!!!Name = ''; - $!!!Instance = null; - - // This goes fine so let's resolve the action - $!!!Name = $requestInstance->getRequestElement('action'); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // And validate it - if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { - // This action has an invalid instance! - throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Set last action - $this->setResolvedInstance($!!!Instance); - - // Return the resolved action instance - return $!!!Instance; - } - - /** - * Resolves the action by its direct name and returns an instance of its class - * - * @return $!!!Instance An instance of the action class - * @throws Invalid|||Exception Thrown if $!!!Name is invalid - */ - public function resolve||| () { - // Initiate the instance variable - $!!!Instance = null; - - // Get action name - $!!!Name = $this->get|||Name(); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) { - $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // Return the instance - return $!!!Instance; - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Resolver extends BaseResolver implements Resolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to '???' - $this->setClassPrefix('???'); - } - - /** - * Creates an instance of a Html action resolver with a given default action - * - * @param $!!!Name The default action we shall execute - * @param $appInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if default action is not set - * @throws Invalid|||Exception Thrown if default action is invalid - */ - public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { - // Create the new instance - $resolverInstance = new ???Resolver(); - - // Is the variable $!!!Name set and the action is valid? - if (empty($!!!Name)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { - // Invalid action found - throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($appInstance); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an action instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $!!!Instance An instance of the resolved action - * @throws Invalid|||Exception Thrown if $!!!Name is - * invalid - * @throws Invalid|||InstanceException Thrown if $!!!Instance - * is an invalid instance - */ - public function resolve|||ByRequest (Requestable $requestInstance) { - // Init variables - $!!!Name = ''; - $!!!Instance = null; - - // This goes fine so let's resolve the action - $!!!Name = $requestInstance->getRequestElement('action'); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // And validate it - if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { - // This action has an invalid instance! - throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Set last action - $this->setResolvedInstance($!!!Instance); - - // Return the resolved action instance - return $!!!Instance; - } - - /** - * Resolves the action by its direct name and returns an instance of its class - * - * @return $!!!Instance An instance of the action class - * @throws Invalid|||Exception Thrown if $!!!Name is invalid - */ - public function resolve||| () { - // Initiate the instance variable - $!!!Instance = null; - - // Get action name - $!!!Name = $this->get|||Name(); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) { - $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // Return the instance - return $!!!Instance; - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Resolver extends BaseResolver implements Resolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to '???' - $this->setClassPrefix('???'); - } - - /** - * Creates an instance of a Html action resolver with a given default action - * - * @param $!!!Name The default action we shall execute - * @param $appInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if default action is not set - * @throws Invalid|||Exception Thrown if default action is invalid - */ - public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { - // Create the new instance - $resolverInstance = new ???Resolver(); - - // Is the variable $!!!Name set and the action is valid? - if (empty($!!!Name)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { - // Invalid action found - throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($appInstance); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an action instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $!!!Instance An instance of the resolved action - * @throws Invalid|||Exception Thrown if $!!!Name is - * invalid - * @throws Invalid|||InstanceException Thrown if $!!!Instance - * is an invalid instance - */ - public function resolve|||ByRequest (Requestable $requestInstance) { - // Init variables - $!!!Name = ''; - $!!!Instance = null; - - // This goes fine so let's resolve the action - $!!!Name = $requestInstance->getRequestElement('action'); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // And validate it - if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { - // This action has an invalid instance! - throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Set last action - $this->setResolvedInstance($!!!Instance); - - // Return the resolved action instance - return $!!!Instance; - } - - /** - * Resolves the action by its direct name and returns an instance of its class - * - * @return $!!!Instance An instance of the action class - * @throws Invalid|||Exception Thrown if $!!!Name is invalid - */ - public function resolve||| () { - // Initiate the instance variable - $!!!Instance = null; - - // Get action name - $!!!Name = $this->get|||Name(); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) { - $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // Return the instance - return $!!!Instance; - } -} - -// [EOF] -?> - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Resolver extends BaseResolver implements Resolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to '???' - $this->setClassPrefix('???'); - } - - /** - * Creates an instance of a ??? resolver with a given default action - * - * @param $!!!Name The default action we shall execute - * @param $appInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared action resolver instance - * @throws EmptyVariableException Thrown if default action is not set - * @throws Invalid|||Exception Thrown if default action is invalid - */ - public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { - // Create the new instance - $resolverInstance = new ???Resolver(); - - // Is the variable $!!!Name set and the action is valid? - if (empty($!!!Name)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { - // Invalid action found - throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($appInstance); - - // Return the prepared instance - return $resolverInstance; - } - - /** - * Returns an action instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $!!!Instance An instance of the resolved action - * @throws Invalid|||Exception Thrown if $!!!Name is - * invalid - * @throws Invalid|||InstanceException Thrown if $!!!Instance - * is an invalid instance - */ - public function resolve|||ByRequest (Requestable $requestInstance) { - // Init variables - $!!!Name = ''; - $!!!Instance = null; - - // This goes fine so let's resolve the action - $!!!Name = $requestInstance->getRequestElement('action'); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // And validate it - if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { - // This action has an invalid instance! - throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Set last action - $this->setResolvedInstance($!!!Instance); - - // Return the resolved action instance - return $!!!Instance; - } - - /** - * Resolves the action by its direct name and returns an instance of its class - * - * @return $!!!Instance An instance of the action class - * @throws Invalid|||Exception Thrown if $!!!Name is invalid - */ - public function resolve||| () { - // Initiate the instance variable - $!!!Instance = null; - - // Get action name - $!!!Name = $this->get|||Name(); - - // Is the action empty? Then fall back to default action - if (empty($!!!Name)) { - $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); - } // END - if - - // Check if action is valid - if ($this->is|||Valid($!!!Name) === FALSE) { - // This action is invalid! - throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); - } // END - if - - // Get the action - $!!!Instance = $this->load|||(); - - // Return the instance - return $!!!Instance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/class_BaseResolver.php b/inc/classes/main/resolver/class_BaseResolver.php deleted file mode 100644 index e6582f1a..00000000 --- a/inc/classes/main/resolver/class_BaseResolver.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseResolver extends BaseFrameworkSystem { - /** - * Class name - */ - private $className = ''; - - /** - * Prefix for class - */ - private $classPrefix = ''; - - /** - * (Last) resolved instance - */ - private $resolvedInstance = NULL; - - // Exception constants - const EXCEPTION_INVALID_COMMAND = 0x1d0; - const EXCEPTION_INVALID_CONTROLLER = 0x1d1; - const EXCEPTION_INVALID_ACTION = 0x1d2; - const EXCEPTION_INVALID_STATE = 0x1d3; - - /** - * Protected constructor - * - * @param $className Real name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for class name - * - * @return $className Name of the class - */ - public final function getClassName () { - return $this->className; - } - - /** - * "Getter" for class name (useable for an object factory) - * - * @return $className Capitalized class name - */ - protected function getCapitalizedClassPrefix () { - // Get class name - $className = $this->getClassPrefix(); - - // And capitalize it - $className = self::convertToClassName($className); - - // Return it - return $className; - } - - /** - * Setter for class name - * - * @param $className Name of the class - * @return void - */ - protected final function setClassName ($className) { - $this->className = (string) $className; - } - - /** - * Getter for class prefix - * - * @return $classPrefix Last validated classPrefix - */ - protected final function getClassPrefix () { - return $this->classPrefix; - } - - /** - * Setter for class prefix - * - * @param $classPrefix Last validated classPrefix - * @return void - */ - protected final function setClassPrefix ($classPrefix) { - $this->classPrefix = (string) $classPrefix; - } - - /** - * Getter for (last) resolved instance - * - * @return $resolvedInstance Last validated resolvedInstance - */ - protected final function getResolvedInstance () { - return $this->resolvedInstance; - } - - /** - * Setter for (last) resolved instance - * - * @param $resolvedInstance (Last) validated resolved instance - * @return void - */ - protected final function setResolvedInstance (FrameworkInterface $resolvedInstance) { - $this->resolvedInstance = $resolvedInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/command/.htaccess b/inc/classes/main/resolver/command/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/command/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/command/class_BaseCommandResolver.php b/inc/classes/main/resolver/command/class_BaseCommandResolver.php deleted file mode 100644 index ff444fd7..00000000 --- a/inc/classes/main/resolver/command/class_BaseCommandResolver.php +++ /dev/null @@ -1,180 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseCommandResolver extends BaseResolver { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * "Loads" a given command and instances it if not yet cached - * - * @param $commandName A command name we shall look for - * @return $commandInstance A loaded command instance - * @throws InvalidCommandException Thrown if even the default - * command class is missing (bad!) - */ - protected function loadCommand ($commandName) { - // Init command instance - $commandInstance = NULL; - - // Create class name - $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($commandName) . 'Command'; - - // Create command class name - $this->setClassName($className); - - // Is this class loaded? - if (!class_exists($this->getClassName())) { - // Class not found, so throw an exception - throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } // END - if - - // Initiate the command - $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); - - // Return the result - return $commandInstance; - } - - /** - * Returns an command instance for a given request class or null if - * it was not found - * - * @param $requestInstance An instance of a request class - * @return $commandInstance An instance of the resolved command - * @throws InvalidCommandException Thrown if $commandName is - * invalid - * @throws InvalidCommandInstanceException Thrown if $commandInstance - * is an invalid instance - */ - public function resolveCommandByRequest (Requestable $requestInstance) { - // Init variables - $commandName = ''; - $commandInstance = NULL; - - // This goes fine so let's resolve the command - $commandName = $requestInstance->getRequestElement('command'); - - // Is the command empty? Then fall back to default command - if (empty($commandName)) { - $commandName = $this->getConfigInstance()->getConfigEntry('default_' . self::getResponseTypeFromSystem() . '_command'); - } // END - if - - // Check if command is valid - if ($this->isCommandValid($commandName) === FALSE) { - // This command is invalid! - throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } // END - if - - // Get the command - $commandInstance = $this->loadCommand($commandName); - - // And validate it - if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { - // This command has an invalid instance! - throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } // END - if - - // Set last command - $this->setResolvedInstance($commandInstance); - - // Return the resolved command instance - return $commandInstance; - } - - /** - * Resolves the command by its direct name and returns an instance of its class - * - * @param $commandName The direct command name we shall resolve - * @return $commandInstance An instance of the command class - * @throws InvalidCommandException Thrown if $commandName is invalid - */ - public function resolveCommand ($commandName) { - // Initiate the instance variable - $commandInstance = NULL; - - // Is the command empty? Then fall back to default command - if (empty($commandName)) { - $commandName = $this->getConfigInstance()->getConfigEntry('default_' . self::getResponseTypeFromSystem() . '_command'); - } // END - if - - // Check if command is valid - if ($this->isCommandValid($commandName) === FALSE) { - // This command is invalid! - throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); - } // END - if - - // Get the command - $commandInstance = $this->loadCommand($commandName); - - // Return the instance - return $commandInstance; - } - - /** - * Checks whether the given command is valid - * - * @param $commandName The default command we shall execute - * @return $isValid Whether the given command is valid - * @throws EmptyVariableException Thrown if given command is not set - */ - public function isCommandValid ($commandName) { - // By default nothing shall be valid - $isValid = FALSE; - - // Is a command set? - if (empty($commandName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($this, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - - // Create the full class name - $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($commandName) . 'Command'; - - // Now, let us create the full name of the command class - $this->setClassName($className); - - // Is this class already loaded? - if (class_exists($this->getClassName())) { - // This class does exist. :-) - $isValid = TRUE; - } // END - if - - // Set command name - $this->setCommandName($commandName); - - // Return the result - return $isValid; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/command/console/.htaccess b/inc/classes/main/resolver/command/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/command/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/command/console/class_ConsoleCommandResolver.php b/inc/classes/main/resolver/command/console/class_ConsoleCommandResolver.php deleted file mode 100644 index 2b1582c8..00000000 --- a/inc/classes/main/resolver/command/console/class_ConsoleCommandResolver.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleCommandResolver extends BaseCommandResolver implements CommandResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "Console" - $this->setClassPrefix('console'); - } - - /** - * Creates an instance of a Console command resolver with a given default command - * - * @param $commandName The default command we shall execute - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidCommandException Thrown if default command is invalid - */ - public static final function createConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new ConsoleCommandResolver(); - - // Is the variable $commandName set and the command is valid? - if (empty($commandName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { - // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/command/html/.htaccess b/inc/classes/main/resolver/command/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/command/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/command/html/class_Html b/inc/classes/main/resolver/command/html/class_Html deleted file mode 100644 index 42b09af4..00000000 --- a/inc/classes/main/resolver/command/html/class_Html +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Html???CommandResolver extends BaseCommandResolver implements CommandResolver { - /** - * Last successfull resolved command - */ - private $lastCommandInstance = null; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to 'html' - $this->setCommandPrefix('html'); - } - - /** - * Creates an instance of a Html command resolver with a given default command - * - * @param $commandName The default command we shall execute - * @param $appInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if the default command is not set - * @throws InvalidCommandException Thrown if the default command is invalid - */ - public final static function createHtml???CommandResolver ($commandName, ManageableApplication $appInstance) { - // Create the new instance - $resolverInstance = new Html???CommandResolver(); - - // Is the variable $commandName set and the command is valid? - if (empty($commandName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { - // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($appInstance); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/command/html/class_HtmlCommandResolver.php b/inc/classes/main/resolver/command/html/class_HtmlCommandResolver.php deleted file mode 100644 index db1e6ac7..00000000 --- a/inc/classes/main/resolver/command/html/class_HtmlCommandResolver.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlCommandResolver extends BaseCommandResolver implements CommandResolver { - /** - * Last successfull resolved command - */ - private $lastCommandInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "html" - $this->setClassPrefix('html'); - } - - /** - * Creates an instance of a Html command resolver with a given default command - * - * @param $commandName The default command we shall execute - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidCommandException Thrown if default command is invalid - */ - public static final function createHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new HtmlCommandResolver(); - - // Is the variable $commandName set and the command is valid? - if (empty($commandName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { - // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/command/image/.htaccess b/inc/classes/main/resolver/command/image/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/command/image/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php b/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php deleted file mode 100644 index 80a84dc9..00000000 --- a/inc/classes/main/resolver/command/image/class_ImageCommandResolver.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageCommandResolver extends BaseCommandResolver implements CommandResolver { - /** - * Last successfull resolved command - */ - private $lastCommandInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "Image" - $this->setClassPrefix('image'); - } - - /** - * Creates an instance of a Image command resolver with a given default command - * - * @param $commandName The default command we shall execute - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared command resolver instance - * @throws EmptyVariableException Thrown if default command is not set - * @throws InvalidCommandException Thrown if default command is invalid - */ - public static final function createImageCommandResolver ($commandName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new ImageCommandResolver(); - - // Is the variable $commandName set and the command is valid? - if (empty($commandName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { - // Invalid command found - throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/controller/.htaccess b/inc/classes/main/resolver/controller/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/controller/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php b/inc/classes/main/resolver/controller/class_BaseControllerResolver.php deleted file mode 100644 index 5615515a..00000000 --- a/inc/classes/main/resolver/controller/class_BaseControllerResolver.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseControllerResolver extends BaseResolver { - /** - * Protected constructor - * - * @param $className Name of the real class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * "Loads" a given controller and instances it if not yet cached. If the - * controller was not found one of the default controllers will be used - * depending on whether news shall be displayed. - * - * @param $controllerName A controller name we shall look for - * @return $controllerInstance A loaded controller instance - * @throws InvalidControllerException Thrown if even the requested - * controller class is missing (bad!) - */ - protected function loadController ($controllerName) { - // Cache default controller - $defaultController = $this->getConfigInstance()->getConfigEntry('default_' . strtolower($this->getClassPrefix()) . '_controller'); - - // Init controller instance - $controllerInstance = NULL; - - // Default controller - $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); - - // Generate the class name - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BEFORE: controller=' . $controllerName); - if ($controllerName != $defaultController) { - // Create controller class name - $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($controllerName) . 'Controller'; - - // ... and set it - $this->setClassName($className); - } else { - // No news at main controller or non-news controller - $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); - } - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('AFTER: controller=' . $this->getClassName()); - - // Is this class loaded? - if (!class_exists($this->getClassName())) { - // Throw an exception here - throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set default resolver config name - $resolverConfigEntry = ''; - - // Try to read a config entry for our resolver including controller name... ;-) - $resolverConfigEntry = sprintf('%s_cmd_%s_resolver_class', strtolower($this->getClassPrefix()), strtolower($controllerName)); - - // Get the config, this will throw an exception if there is no special controller resolver - $resolverClass = $this->getConfigInstance()->getConfigEntry($resolverConfigEntry); - - // Initiate the resolver and controller - $resolverInstance = ObjectFactory::createObjectByConfiguredName( - $resolverConfigEntry, - array( - $controllerName, - $this->getApplicationInstance() - ) - ); - $controllerInstance = ObjectFactory::createObjectByName( - $this->getClassName(), - array($resolverInstance) - ); - - // Return the result - return $controllerInstance; - } - - /** - * Checks whether the given controller is valid - * - * @param $controllerName The default controller we shall execute - * @return $isValid Whether the given controller is valid - * @throws EmptyVariableException Thrown if given controller is not set - * @throws DefaultControllerException Thrown if default controller was not found - */ - public function isControllerValid ($controllerName) { - // By default nothing shall be valid - $isValid = FALSE; - - // Is a controller set? - if (empty($controllerName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($this, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - - // Create class name - $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($controllerName) . 'Controller'; - - // Now, let us create the full name of the controller class - $this->setClassName($className); - - // Try it hard to get an controller - while ($isValid === FALSE) { - // Is this class already loaded? - if (class_exists($this->getClassName())) { - // This class does exist. :-) - $isValid = TRUE; - } elseif ($this->getClassName() != $this->getCapitalizedClassPrefix() . 'DefaultNewsController') { - // Set default controller - $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); - } else { - // All is tried, give it up here - throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE); - } - } // END - while - - // Return the result - return $isValid; - } - - /** - * Resolves the default controller of the given controller - * - * @return $controllerInstance A controller instance for the default - * controller - * @throws InvalidControllerInstanceException Thrown if $controllerInstance - * is invalid - */ - public function resolveController () { - // Init variables - $controllerName = ''; - $controllerInstance = NULL; - - // Get the controller name - $controllerName = $this->getControllerName(); - - // Get the controller - $controllerInstance = $this->loadController($controllerName); - - // And validate it - if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { - // This controller has an invalid instance! - throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } // END - if - - // Set last controller - $this->setResolvedInstance($controllerInstance); - - // Return the maybe resolved instance - return $controllerInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/controller/console/.htaccess b/inc/classes/main/resolver/controller/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/controller/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/controller/console/class_ConsoleControllerResolver.php b/inc/classes/main/resolver/controller/console/class_ConsoleControllerResolver.php deleted file mode 100644 index d0e5280d..00000000 --- a/inc/classes/main/resolver/controller/console/class_ConsoleControllerResolver.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to "Console" - $this->setClassPrefix('console'); - } - - /** - * Creates an instance of a resolver class with a given controller - * - * @param $controllerName The controller we shall resolve - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default controller is not set - * @throws InvalidControllerException Thrown if default controller is invalid - */ - public static final function createConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new ConsoleControllerResolver(); - - // Is the variable $controllerName set and the controller is valid? - if (empty($controllerName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid controller found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Set controller name - $resolverInstance->setControllerName($controllerName); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/controller/html/.htaccess b/inc/classes/main/resolver/controller/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/controller/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/controller/html/class_HtmlControllerResolver.php b/inc/classes/main/resolver/controller/html/class_HtmlControllerResolver.php deleted file mode 100644 index c50f32a7..00000000 --- a/inc/classes/main/resolver/controller/html/class_HtmlControllerResolver.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlControllerResolver extends BaseControllerResolver implements ControllerResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to 'Html' - $this->setClassPrefix('html'); - } - - /** - * Creates an instance of a resolver class with a given controller - * - * @param $controllerName The controller we shall resolve - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default controller is not set - * @throws InvalidControllerException Thrown if default controller is invalid - */ - public static final function createHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new HtmlControllerResolver(); - - // Is the variable $controllerName set and the controller is valid? - if (empty($controllerName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid controller found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Set controller name - $resolverInstance->setControllerName($controllerName); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/resolver/controller/image/.htaccess b/inc/classes/main/resolver/controller/image/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/resolver/controller/image/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php b/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php deleted file mode 100644 index 8a14a722..00000000 --- a/inc/classes/main/resolver/controller/image/class_ImageControllerResolver.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageControllerResolver extends BaseControllerResolver implements ControllerResolver { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set prefix to 'image' - $this->setClassPrefix('image'); - } - - /** - * Creates an instance of a resolver class with a given controller - * - * @param $controllerName The controller we shall resolve - * @param $applicationInstance An instance of a manageable application helper class - * @return $resolverInstance The prepared controller resolver instance - * @throws EmptyVariableException Thrown if default controller is not set - * @throws InvalidControllerException Thrown if default controller is invalid - */ - public static final function createImageControllerResolver ($controllerName, ManageableApplication $applicationInstance) { - // Create the new instance - $resolverInstance = new ImageControllerResolver(); - - // Is the variable $controllerName set and the controller is valid? - if (empty($controllerName)) { - // Then thrown an exception here - throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { - // Invalid controller found - throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); - } - - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - - // Set controller name - $resolverInstance->setControllerName($controllerName); - - // Return the prepared instance - return $resolverInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/response/.htaccess b/inc/classes/main/response/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/response/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/response/class_BaseResponse.php b/inc/classes/main/response/class_BaseResponse.php deleted file mode 100644 index 0becb582..00000000 --- a/inc/classes/main/response/class_BaseResponse.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * The extended headers are taken from phpMyAdmin setup tool, written by - * Michal Cihar , licensed under GNU GPL 2.0. - */ -class BaseResponse extends BaseFrameworkSystem { - /** - * Response status - */ - private $responseStatus = '200 OK'; - - /** - * Array with all headers - */ - private $responseHeaders = array(); - - /** - * Cookies we shall sent out - */ - private $cookies = array(); - - /** - * Body of the response - */ - private $responseBody = ''; - - /** - * Instance of the template engine - */ - private $templateInstance = NULL; - - /** - * Response type - */ - private $responseType = 'invalid'; - - /** - * Protected constructor - * - * @param $className Name of the concrete response - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for status - * - * @param $status New response status - * @return void - */ - public final function setResponseStatus ($status) { - $this->responseStatus = (string) $status; - } - - /** - * Add header element - * - * @param $name Name of header element - * @param $value Value of header element - * @return void - */ - public final function addHeader ($name, $value) { - $this->responseHeaders[$name] = $value; - } - - /** - * Reset the header array - * - * @return void - */ - public final function resetResponseHeaders () { - $this->responseHeaders = array(); - } - - /** - * "Writes" data to the response body - * - * @param $output Output we shall sent in the HTTP response - * @return void - */ - public final function writeToBody ($output) { - $this->responseBody .= $output; - } - - /** - * Sets the response body to something new - * - * @param $output Output we shall sent in the HTTP response - * @return void - */ - public final function setResponseBody ($output) { - $this->responseBody = $output; - } - - /** - * Setter for response type - * - * @param $responseType Response type - * @return void - */ - protected final function setResponseType ($responseType) { - $this->responseType = $responseType; - } - - /** - * Getter for response type - * - * @param $responseType Response type - * @return void - */ - public final function getResponseType () { - return $this->responseType; - } - - /** - * Adds a fatal message id to the response. The added messages can then be - * processed and outputed to the world - * - * @param $messageId The message id we shall add - * @return void - */ - public final function addFatalMessage ($messageId) { - // Adds the resolved message id to the fatal message list - $this->addFatalMessagePlain($this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId)); - } - - /** - * Adds a plain fatal message id to the response - * - * @param $message The plain message we shall add - * @return void - */ - public final function addFatalMessagePlain ($message) { - // Adds the resolved message id to the fatal message list - $this->pushValueToGenericArrayKey('fatal_messages', 'generic', 'message', $message); - } - - /** - * Flushs the cached HTTP response to the outer world - * - * @param $force Whether we shall force the output or abort if headers are - * already sent with an exception - * @return void - * @throws ResponseHeadersAlreadySentException Thrown if headers are - * already sent - */ - public function flushBuffer ($force = FALSE) { - if ((headers_sent()) && ($force === FALSE)) { - // Headers are already sent! - throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); - } elseif (!headers_sent()) { - // Send headers out - header('HTTP/1.1 ' . $this->responseStatus); - - // Used later - $now = gmdate('D, d M Y H:i:s') . ' GMT'; - - // General header for no caching - $this->addHeader('Expired', $now); // RFC2616 - Section 14.21 - $this->addHeader('Last-Modified', $now); - $this->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 - $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0 - - // Define the charset to be used - //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->getConfigEntry('header_charset'))); - - // Send all headers - foreach ($this->responseHeaders as $name => $value) { - header($name . ': ' . $value); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('name=' . $name . ',value=' . $value); - } // END - foreach - - // Send cookies out? - if (count($this->cookies) > 0) { - // Send all cookies - $cookieString = implode(' ', $this->cookies); - header('Set-Cookie: ' . $cookieString); - - // Remove them all - $this->cookies = array(); - } // END - if - } - - // Are there some error messages? - if ((!$this->isValidGenericArrayKey('fatal_messages', 'generic', 'message')) || ($this->countGenericArrayElements('fatal_messages', 'generic', 'message') == 0)) { - // Flush the output to the world - $this->getWebOutputInstance()->output($this->responseBody); - } else { - // Display all error messages - $this->getApplicationInstance()->handleFatalMessages($this->getGenericArrayKey('fatal_messages', 'generic', 'message')); - - // Send the error messages out to the world - $this->getWebOutputInstance()->output($this->responseBody); - } - - // Clear response header and body - $this->setResponseBody(''); - $this->resetResponseHeaders(); - } - - /** - * "Getter" for default command - * - * @return $defaultCommand Default command for this response - */ - public function determineDefaultCommand () { - // Get application instance - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Generate config key - $configKey = sprintf('default_%s_%s_command', - $applicationInstance->getAppShortName(), - $this->getResponseType() - ); - - // Get default command response - $defaultCommand = $this->getConfigInstance()->getConfigEntry($configKey); - - // Return it - return $defaultCommand; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/response/console/.htaccess b/inc/classes/main/response/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/response/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/response/console/class_ConsoleResponse.php b/inc/classes/main/response/console/class_ConsoleResponse.php deleted file mode 100644 index 000ecfef..00000000 --- a/inc/classes/main/response/console/class_ConsoleResponse.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * The extended headers are taken from phpMyAdmin setup tool, written by - * Michal Cihar , licensed under GNU GPL 2.0. - */ -class ConsoleResponse extends BaseResponse implements Responseable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set response type - $this->setResponseType('console'); - } - - /** - * Creates an object of this class - * - * @param $applicationInstance An instance of a manageable application - * @return $responseInstance A prepared instance of this class - */ - public static final function createConsoleResponse (ManageableApplication $applicationInstance) { - // Get a new instance - $responseInstance = new ConsoleResponse(); - - // Set the application instance - $responseInstance->setApplicationInstance($applicationInstance); - - // Initialize the template engine here - $responseInstance->initTemplateEngine($applicationInstance); - - // Init web output instance - $responseInstance->initWebOutputInstance(); - - // Return the prepared instance - return $responseInstance; - } - - /** - * Initializes the template engine instance - * - * @param $applicationInstance An instance of a manageable application - * @return void - */ - public final function initTemplateEngine (ManageableApplication $applicationInstance) { - $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance)); - } - - /** - * Adds a cookie to the response - * - * @param $cookieName Cookie's name - * @param $cookieValue Value to store in the cookie - * @param $encrypted Do some extra encryption on the value - * @param $expires Timestamp of expiration (default: configured) - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - */ - public function addCookie ($cookieName, $cookieValue, $encrypted = FALSE, $expires = NULL) { - //* DEBUG: */ echo $cookieName.'='.$cookieValue."
\n"; - $this->partialStub('Naturally unimplemented in console response.'); - } - - /** - * Redirect to a configured URL. The URL can be absolute or relative. In - * case of relative URL it will be extended automatically. - * - * @param $configEntry The configuration entry which holds our URL - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - */ - public function redirectToConfiguredUrl ($configEntry) { - $this->partialStub('Naturally unimplemented in console response.'); - } - - /** - * Expires the given cookie if it is set - * - * @param $cookieName Cookie to expire - * @return void - */ - public function expireCookie ($cookieName) { - $this->partialStub('Naturally unimplemented in console response.'); - } - - /** - * Refreshs a given cookie. This will make the cookie live longer - * - * @param $cookieName Cookie to refresh - * @return void - */ - public function refreshCookie ($cookieName) { - $this->partialStub('Naturally unimplemented in console response.'); - } - - /** - * Flushs the cached console response to the console - * - * @param $force Whether we shall force the output or abort if headers are - * already sent with an exception - * @return void - * @throws ResponseHeadersAlreadySentException Thrown if headers are - * already sent - */ - public function flushBuffer ($force = FALSE) { - $this->partialStub('Please implement this class.'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/response/html/.htaccess b/inc/classes/main/response/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/response/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/response/html/class_HtmlResponse.php b/inc/classes/main/response/html/class_HtmlResponse.php deleted file mode 100644 index ec5924b0..00000000 --- a/inc/classes/main/response/html/class_HtmlResponse.php +++ /dev/null @@ -1,211 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * The extended headers are taken from phpMyAdmin setup tool, written by - * Michal Cihar , licensed under GNU GPL 2.0. - */ -class HtmlResponse extends BaseResponse implements Responseable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set response type - $this->setResponseType('html'); - } - - /** - * Creates an object of this class - * - * @param $applicationInstance An instance of a manageable application - * @return $responseInstance A prepared instance of this class - */ - public static final function createHtmlResponse (ManageableApplication $applicationInstance) { - // Get a new instance - $responseInstance = new HtmlResponse(); - - // Set the application instance - $responseInstance->setApplicationInstance($applicationInstance); - - // Initialize the template engine here - $responseInstance->initTemplateEngine($applicationInstance); - - // Init web output instance - $responseInstance->initWebOutputInstance(); - - // Return the prepared instance - return $responseInstance; - } - - /** - * Initializes the template engine instance - * - * @param $applicationInstance An instance of a manageable application - * @return void - */ - public final function initTemplateEngine (ManageableApplication $applicationInstance) { - $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance)); - } - - /** - * Adds a cookie to the response - * - * @param $cookieName Cookie's name - * @param $cookieValue Value to store in the cookie - * @param $encrypted Do some extra encryption on the value - * @param $expires Timestamp of expiration (default: configured) - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - * @todo Encryption of cookie data not yet supported. - * @todo Why are these parameters conflicting? - * @todo If the return statement is removed and setcookie() commented out, - * @todo this will send only one cookie out, the first one. - */ - public function addCookie ($cookieName, $cookieValue, $encrypted = FALSE, $expires = NULL) { - //* DEBUG: */ echo $cookieName.'='.$cookieValue."
\n"; - // Are headers already sent? - if (headers_sent()) { - // Throw an exception here - //* DEBUG: */ return; - throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); - } // END - if - - // Shall we encrypt the cookie? - if ($encrypted === TRUE) { - // Unsupported at the moment - $this->partialStub('Encryption is unsupported at the moment.'); - } // END - if - - // For slow browsers set the cookie array element first - $_COOKIE[$cookieName] = $cookieValue; - - // Get all config entries - if (is_null($expires)) { - $expires = (time() + $this->getConfigInstance()->getConfigEntry('cookie_expire')); - } // END - if - - $path = $this->getConfigInstance()->getConfigEntry('cookie_path'); - $domain = $this->getConfigInstance()->getConfigEntry('cookie_domain'); - - setcookie($cookieName, $cookieValue, $expires); - //, $path, $domain, (isset($_SERVER['HTTPS'])) - return; - - // Now construct the full header - $cookieString = $cookieName . '=' . $cookieValue . '; '; - $cookieString .= 'expires=' . date('D, d-F-Y H:i:s', $expires) . ' GMT'; - // $cookieString .= "; path=".$path."; domain=".$domain; - - // Set the cookie as a header - $this->cookies[$cookieName] = $cookieString; - } - - /** - * Redirect to a configured URL. The URL can be absolute or relative. In - * case of relative URL it will be extended automatically. - * - * @param $configEntry The configuration entry which holds our URL - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - */ - public function redirectToConfiguredUrl ($configEntry) { - // Is the header not yet sent? - if (headers_sent()) { - // Throw an exception here - throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); - } // END - if - - // Assign application data - $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance()); - - // Get the url from config - $url = $this->getConfigInstance()->getConfigEntry($configEntry . '_url'); - - // Compile the URL - $url = $this->getTemplateInstance()->compileRawCode($url); - - // Do we have a 'http' in front of the URL? - if (substr(strtolower($url), 0, 4) != 'http') { - // Is there a / in front of the relative URL? - if (substr($url, 0, 1) == '/') { - $url = substr($url, 1); - } // END - if - - // No, then extend it with our base URL - $url = $this->getConfigInstance()->getConfigEntry('base_url') . '/' . $url; - } // END - if - - // Add redirect header - $this->addHeader('Location', str_replace('&', '&', $url)); - - // Set correct response status - $this->setResponseStatus('301 Moved Permanently'); - - // Clear the body - $this->setResponseBody(''); - - // Flush the result - $this->flushBuffer(); - - // All done here... - exit(); - } - - /** - * Expires the given cookie if it is set - * - * @param $cookieName Cookie to expire - * @return void - */ - public function expireCookie ($cookieName) { - // Is the cookie there? - if (isset($_COOKIE[$cookieName])) { - // Then expire it with 20 minutes past - $this->addCookie($cookieName, '', FALSE, (time() - 1200)); - - // Remove it from array - unset($_COOKIE[$cookieName]); - } // END - if - } - - /** - * Refreshs a given cookie. This will make the cookie live longer - * - * @param $cookieName Cookie to refresh - * @return void - */ - public function refreshCookie ($cookieName) { - // Only update existing cookies - if (isset($_COOKIE[$cookieName])) { - // Update the cookie - $this->addCookie($cookieName, $_COOKIE[$cookieName], FALSE); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/response/image/.htaccess b/inc/classes/main/response/image/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/response/image/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/response/image/class_ImageResponse.php b/inc/classes/main/response/image/class_ImageResponse.php deleted file mode 100644 index e6c5190d..00000000 --- a/inc/classes/main/response/image/class_ImageResponse.php +++ /dev/null @@ -1,243 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * The extended headers are taken from phpMyAdmin setup tool, written by - * Michal Cihar , licensed under GNU GPL 2.0. - */ -class ImageResponse extends BaseResponse implements Responseable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set response type - $this->setResponseType('image'); - } - - /** - * Creates an object of this class - * - * @param $applicationInstance An instance of a manageable application - * @return $responseInstance A prepared instance of this class - */ - public static final function createImageResponse (ManageableApplication $applicationInstance) { - // Get a new instance - $responseInstance = new ImageResponse(); - - // Set the application instance - $responseInstance->setApplicationInstance($applicationInstance); - - // Initialize the template engine here - $responseInstance->initTemplateEngine($applicationInstance); - - // Init web output instance - $responseInstance->initWebOutputInstance(); - - // Return the prepared instance - return $responseInstance; - } - - /** - * Initializes the template engine instance - * - * @param $applicationInstance An instance of a manageable application - * @return void - */ - public final function initTemplateEngine (ManageableApplication $applicationInstance) { - // Get config instance - $cfg = $this->getConfigInstance(); - - // Set new template engine - $cfg->setConfigEntry('html_template_class' , $cfg->getConfigEntry('image_template_class')); - $cfg->setConfigEntry('raw_template_extension' , '.img'); - $cfg->setConfigEntry('code_template_extension', '.xml'); - $cfg->setConfigEntry('tpl_base_path' , 'templates/images/'); - // @TODO Please fix this - $cfg->setConfigEntry('code_template_type' , 'image'); - - // Get a prepared instance - $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance)); - } - - /** - * Adds a cookie to the response - * - * @param $cookieName Cookie's name - * @param $cookieValue Value to store in the cookie - * @param $encrypted Do some extra encryption on the value - * @param $expires Timestamp of expiration (default: configured) - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - * @todo Encryption of cookie data not yet supported. - * @todo Why are these parameters conflicting? - * @todo If the return statement is removed and setcookie() commented out, - * @todo this will send only one cookie out, the first one. - */ - public function addCookie ($cookieName, $cookieValue, $encrypted = FALSE, $expires = NULL) { - // Are headers already sent? - if (headers_sent()) { - // Throw an exception here - throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); - } // END - if - - // Shall we encrypt the cookie? - if ($encrypted === TRUE) { - // Unsupported at the moment - $this->partialStub('Encryption is unsupported at the moment.'); - } // END - if - - // For slow browsers set the cookie array element first - $_COOKIE[$cookieName] = $cookieValue; - - // Get all config entries - if (is_null($expires)) { - $expires = (time() + $this->getConfigInstance()->getConfigEntry('cookie_expire')); - } // END - if - - $path = $this->getConfigInstance()->getConfigEntry('cookie_path'); - $domain = $this->getConfigInstance()->getConfigEntry('cookie_domain'); - - setcookie($cookieName, $cookieValue, $expires); - //, $path, $domain, (isset($_SERVER['HTTPS'])) - return; - - // Now construct the full header - $cookieString = $cookieName . '=' . $cookieValue . '; '; - $cookieString .= 'expires=' . date('D, d-F-Y H:i:s', $expires) . ' GMT'; - // TODO Why is this not always working? $cookieString .= '; path=' . $path . '; domain=' . $domain; - - // Set the cookie as a header - $this->cookies[$cookieName] = $cookieString; - } - - /** - * Redirect to a configured URL. The URL can be absolute or relative. In - * case of relative URL it will be extended automatically. - * - * @param $configEntry The configuration entry which holds our URL - * @return void - * @throws ResponseHeadersAlreadySentException If headers are already sent - */ - public function redirectToConfiguredUrl ($configEntry) { - // Is the header not yet sent? - if (headers_sent()) { - // Throw an exception here - throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); - } // END - if - - // Assign application data - $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance()); - - // Get the url from config - $url = $this->getConfigInstance()->getConfigEntry($configEntry . '_url'); - - // Compile the URL - $url = $this->getTemplateInstance()->compileRawCode($url); - - // Do we have a 'http' in front of the URL? - if (substr(strtolower($url), 0, 4) != 'http') { - // Is there a / in front of the relative URL? - if (substr($url, 0, 1) == '/') $url = substr($url, 1); - - // No, then extend it with our base URL - $url = $this->getConfigInstance()->getConfigEntry('base_url') . '/' . $url; - } // END - if - - // Add redirect header - $this->addHeader('Location', str_replace('&', '&', $url)); - - // Set correct response status - $this->setResponseStatus('301 Moved Permanently'); - - // Clear the body - $this->setResponseBody(''); - - // Flush the result - $this->flushBuffer(); - - // All done here... - exit(); - } - - /** - * Flushs the cached HTTP response to the outer world - * - * @param $force Whether we shall force the output or abort if headers are - * already sent with an exception - * @return void - */ - public function flushBuffer ($force = FALSE) { - // Finish the image - $this->getImageInstance()->finishImage(); - - // Get image content - $content = $this->getImageInstance()->getContent(); - - // Set it as response body - $this->setResponseBody($content); - - // Set content type - $this->addHeader('Content-type', 'image/' . $this->getImageInstance()->getImageType()); - - // Call parent method - parent::flushBuffer($force); - } - - /** - * Expires the given cookie if it is set - * - * @param $cookieName Cookie to expire - * @return void - */ - public function expireCookie ($cookieName) { - // Is the cookie there? - if (isset($_COOKIE[$cookieName])) { - // Then expire it with 20 minutes past - $this->addCookie($cookieName, '', FALSE, (time() - 1200)); - - // Remove it from array - unset($_COOKIE[$cookieName]); - } // END - if - } - - /** - * Refreshs a given cookie. This will make the cookie live longer - * - * @param $cookieName Cookie to refresh - * @return void - */ - public function refreshCookie ($cookieName) { - // Only update existing cookies - if (isset($_COOKIE[$cookieName])) { - // Update the cookie - $this->addCookie($cookieName, $_COOKIE[$cookieName], FALSE); - } // END - if - } -} - -// [EOF] -?> diff --git a/inc/classes/main/rng/.htaccess b/inc/classes/main/rng/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/rng/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/rng/class_RandomNumberGenerator.php b/inc/classes/main/rng/class_RandomNumberGenerator.php deleted file mode 100644 index a30fb0dd..00000000 --- a/inc/classes/main/rng/class_RandomNumberGenerator.php +++ /dev/null @@ -1,219 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class RandomNumberGenerator extends BaseFrameworkSystem { - /** - * Prime number for better pseudo random numbers - */ - private $prime = 0; - - /** - * Add this calculated number to the rng - */ - private $extraNumber = 0; - - /** - * Extra salt for secured hashing - */ - private $extraSalt = ''; - - /** - * Fixed salt for secured hashing - */ - private $fixedSalt = ''; - - /** - * Maximum length for random string - */ - private $rndStrLen = 0; - - /** - * Self instance - */ - private static $selfInstance = NULL; - - /** - * Protected constructor - * - * @param $className Name of this class - * @return void - */ - protected function __construct ($className = __CLASS__) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Creates an instance of this class - * - * @param $extraInstance An extra instance for more salt (default: null) - * @return $rngInstance An instance of this random number generator - */ - public static final function createRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) { - // Is self instance set? - if (is_null(self::$selfInstance)) { - // Get a new instance - $rngInstance = new RandomNumberGenerator(); - - // Initialize the RNG now - $rngInstance->initRng($extraInstance); - - // Set it "self" - self::$selfInstance = $rngInstance; - } else { - // Use from self instance - $rngInstance = self::$selfInstance; - } - - // Return the instance - return $rngInstance; - } - - /** - * Initializes the random number generator - * - * @param $extraInstance An extra instance for more salt (default: null) - * @return void - * @todo Add site key for stronger salt! - */ - protected function initRng ($extraInstance) { - // Get the prime number from config - $this->prime = $this->getConfigInstance()->getConfigEntry('math_prime'); - - // Calculate the extra number which is always the same unless you give - // a better prime number - $this->extraNumber = ($this->prime * $this->prime / pow(pi(), 2)); - - // Seed mt_rand() - mt_srand((double) sqrt(microtime(TRUE) * 100000000 * $this->extraNumber)); - - // Set the server IP to cluster - $serverIp = 'cluster'; - - // Do we have a single server? - if ($this->getConfigInstance()->getConfigEntry('is_single_server') == 'Y') { - // Then use that IP for extra security - $serverIp = $this->getConfigInstance()->detectServerAddress(); - } // END - if - - // Yet-another fixed salt. This is not dependend on server software or date - if ($extraInstance instanceof FrameworkInterface) { - // With extra instance information - $this->fixedSalt = sha1( - $serverIp . ':' . - $extraInstance->__toString() . ':' . - json_encode($this->getDatabaseInstance()->getConnectionData()) - ); - } else { - // Without extra information - $this->fixedSalt = sha1($serverIp . ':' . json_encode($this->getDatabaseInstance()->getConnectionData())); - } - - // One-way data we need for "extra-salting" the random number - $this->extraSalt = sha1( - $this->fixedSalt . ':' . - getenv('SERVER_SOFTWARE') . ':' . - $this->getConfigInstance()->getConfigEntry('date_key') . ':' . - $this->getConfigInstance()->getConfigEntry('base_url') - ); - - // Get config entry for max salt length - $this->rndStrLen = $this->getConfigInstance()->getConfigEntry('rnd_str_length'); - } - - /** - * Makes a pseudo-random string useable for salts - * - * @param $length Length of the string, default: 128 - * @return $randomString The pseudo-random string - */ - public function randomString ($length = -1) { - // Is the number <1, then fix it to default length - if ($length < 1) { - $length = $this->rndStrLen; - } // END - if - - // Initialize the string - $randomString = ''; - - // And generate it - for ($idx = 0; $idx < $length; $idx++) { - // Add a random character and add it to our string - $randomString .= chr($this->randomNumber(0, 255)); - } // END - for - - // Return the random string a little mixed up - return str_shuffle($randomString); - } - - /** - * Generate a pseudo-random integer number in a given range - * - * @param $min Min value to generate - * @param $max Max value to generate - * @return $num Pseudo-random number - * @todo I had a better random number generator here but now it is somewhere lost :( - */ - public function randomNumber ($min, $max) { - return mt_rand($min, $max); - } - - /** - * Getter for extra salt - * - * @return $extraSalt - */ - public final function getExtraSalt () { - return $this->extraSalt; - } - - /** - * Getter for fixed salt - * - * @return $fixedSalt - */ - public final function getFixedSalt () { - return $this->fixedSalt; - } - - /** - * Generates a key based on if we have extra (default) or fixed salt enabled - * - * @return $key The generated key for encryption - */ - public function generateKey () { - // Default is extra salt - $key = md5($this->getExtraSalt()); - - // Get key - if ($this->getConfigInstance()->getConfigEntry('crypt_fixed_salt') == 'Y') { - $key = md5($this->getFixedSalt()); - } // END - if - - // Return it - return $key; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/scrypt/.htaccess b/inc/classes/main/scrypt/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/scrypt/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/scrypt/class_Scrypt.php b/inc/classes/main/scrypt/class_Scrypt.php deleted file mode 100644 index e1c7cb9c..00000000 --- a/inc/classes/main/scrypt/class_Scrypt.php +++ /dev/null @@ -1,235 +0,0 @@ - - * @license http://www.opensource.org/licenses/BSD-2-Clause BSD 2-Clause License - * @link http://github.com/DomBlack/php-scrypt - */ - -/** - * This class abstracts away from scrypt module, allowing for easy use. - * - * You can create a new hash for a password by calling Scrypt:hashScrypt($password) - * - * You can check a password by calling Scrypt:checkScrypt($password, $hash) - * - * @category Security - * @package Scrypt - * @author Dominic Black - * @author Roland Haeder - * @license http://www.opensource.org/licenses/BSD-2-Clause BSD 2-Clause License - * @link http://github.com/DomBlack/php-scrypt - */ -abstract class Scrypt extends BaseFrameworkSystem -{ - - /** - * - * @var int The key length - */ - private static $_keyLength = 32; - - /** - * Get the byte-length of the given string - * - * @param string $str Input string - * - * @return int - */ - protected static function strlen ($str) { - static $isShadowed = null; - - if ($isShadowed === null) { - $isShadowed = extension_loaded('mbstring') && - ini_get('mbstring.func_overload') & 2; - } - - if ($isShadowed) { - return mb_strlen($str, '8bit'); - } else { - return strlen($str); - } - } - - /** - * Generates a random salt - * - * @param int $length The length of the salt - * - * @return string The salt - */ - public static function generateScryptSalt ($length = 8) - { - $buffer = ''; - $buffer_valid = false; - if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { - $buffer = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); - if ($buffer) { - $buffer_valid = true; - } - } - if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { - $cryptoStrong = false; - $buffer = openssl_random_pseudo_bytes($length, $cryptoStrong); - if ($buffer && $cryptoStrong) { - $buffer_valid = true; - } - } - if (!$buffer_valid && BaseFrameworkSystem::isReadableFile('/dev/urandom')) { - $f = fopen('/dev/urandom', 'r'); - $read = static::strlen($buffer); - while ($read < $length) { - $buffer .= fread($f, $length - $read); - $read = static::strlen($buffer); - } - fclose($f); - if ($read >= $length) { - $buffer_valid = true; - } - } - if (!$buffer_valid || static::strlen($buffer) < $length) { - $bl = static::strlen($buffer); - for ($i = 0; $i < $length; $i++) { - if ($i < $bl) { - $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); - } else { - $buffer .= chr(mt_rand(0, 255)); - } - } - } - $salt = str_replace(array('+', '$'), array('.', ''), base64_encode($buffer)); - - return $salt; - } - - /** - * Create a password hash - * - * @param string $password The clear text password - * @param string $salt The salt to use, or null to generate a random one - * @param int $N The CPU difficultly (must be a power of 2, > 1) - * @param int $r The memory difficultly - * @param int $p The parallel difficultly - * - * @return string The hashed password - */ - public static function hashScrypt ($password, $salt = false, $N = 16384, $r = 8, $p = 1) - { - if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { - // Feature has been disabled - throw new \InvalidArgumentException('Feature "scrypt" disabled.'); - } - - if ($N == 0 || ($N & ($N - 1)) != 0) { - throw new \InvalidArgumentException('N must be > 0 and a power of 2'); - } - - if ($N > PHP_INT_MAX / 128 / $r) { - throw new \InvalidArgumentException('Parameter N is too large'); - } - - if ($r > PHP_INT_MAX / 128 / $p) { - throw new \InvalidArgumentException('Parameter r is too large'); - } - - if ($salt === false) { - $salt = self::generateScryptSalt(); - } else { - // Remove dollar signs from the salt, as we use that as a separator. - $salt = str_replace(array('+', '$'), array('.', ''), base64_encode($salt)); - } - - $hash = scrypt($password, $salt, $N, $r, $p, self::$_keyLength); - - return $N . '$' . $r . '$' . $p . '$' . $salt . '$' . $hash; - } - - /** - * Check a clear text password against a hash - * - * @param string $password The clear text password - * @param string $hash The hashed password - * - * @return boolean If the clear text matches - */ - public static function checkScrypt ($password, $hash) - { - // Is there actually a hash? - if (!$hash) { - return false; - } - - if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { - // Feature has been disabled - throw new \InvalidArgumentException('Feature "scrypt" disabled.'); - } - - list ($N, $r, $p, $salt, $hash) = explode('$', $hash); - - // No empty fields? - if (empty($N) or empty($r) or empty($p) or empty($salt) or empty($hash)) { - return false; - } - - // Are numeric values numeric? - if (!is_numeric($N) or !is_numeric($r) or !is_numeric($p)) { - return false; - } - - $calculated = scrypt($password, $salt, $N, $r, $p, self::$_keyLength); - - // Use compareScryptHashes to avoid timeing attacks - return self::compareScryptHashes($hash, $calculated); - } - - /** - * Zend Framework (http://framework.zend.com/) - * - * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * - * Compare two strings to avoid timing attacks - * - * C function memcmp() internally used by PHP, exits as soon as a difference - * is found in the two buffers. That makes possible of leaking - * timing information useful to an attacker attempting to iteratively guess - * the unknown string (e.g. password). - * - * @param string $expected - * @param string $actual - * - * @return boolean If the two strings match. - */ - public static function compareScryptHashes ($expected, $actual) - { - $expected = (string) $expected; - $actual = (string) $actual; - $lenExpected = static::strlen($expected); - $lenActual = static::strlen($actual); - $len = min($lenExpected, $lenActual); - - $result = 0; - for ($i = 0; $i < $len; $i ++) { - $result |= ord($expected[$i]) ^ ord($actual[$i]); - } - $result |= $lenExpected ^ $lenActual; - - return ($result === 0); - } -} diff --git a/inc/classes/main/stacker/.htaccess b/inc/classes/main/stacker/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/stacker/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/stacker/class_ b/inc/classes/main/stacker/class_ deleted file mode 100644 index a72a14fb..00000000 --- a/inc/classes/main/stacker/class_ +++ /dev/null @@ -1,90 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Stacker extends BaseStacker implements Stackable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class Stacker and prepares it for usage - * - * @param $appInstance A manageable application - * @return $stackInstance An instance of ???Stacker - */ - public final static function create???Stacker (ManageableApplication $appInstance) { - // Get a new instance - $stackInstance = new ???Stacker(); - - // Init generic stacker - $stackInstance->initStack('generic'); - - // Return the prepared instance - return $stackInstance; - } - - /** - * Pushs a value on a named stacker - * - * @param $stackerName Name of the stack - * @param $value Value to push on it - * @return void - * @throws StackerFullException If the stack is full - */ - public function pushNamed ($stackerName, $value) { - $this->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value); - } - - /** - * 'Pops' a value from a named stacker - * - * @param $stackerName Name of the stack - * @return void - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function popNamed ($stackerName) { - $this->partialStub('stackerName=' . $stackerName); - } - - /** - * Get value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function getNamed ($stackerName) { - $this->partialStub('stackerName=' . $stackerName); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/stacker/class_BaseStacker.php b/inc/classes/main/stacker/class_BaseStacker.php deleted file mode 100644 index 0deeeda2..00000000 --- a/inc/classes/main/stacker/class_BaseStacker.php +++ /dev/null @@ -1,269 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseStacker extends BaseFrameworkSystem { - // Exception codes - const EXCEPTION_STACKER_ALREADY_INITIALIZED = 0x050; - const EXCEPTION_STACKER_IS_FULL = 0x051; - const EXCEPTION_NO_STACKER_FOUND = 0x052; - const EXCEPTION_STACKER_IS_EMPTY = 0x053; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Initializes given stacker - * - * @param $stackerName Name of the stack - * @param $forceReInit Force re-initialization - * @return void - * @throws AlreadyInitializedStackerException If the stack is already initialized - */ - public function initStack ($stackerName, $forceReInit = FALSE) { - // Is the stack already initialized? - if (($forceReInit === FALSE) && ($this->isStackInitialized($stackerName))) { - // Then throw the exception - throw new AlreadyInitializedStackerException(array($this, $stackerName, $forceReInit), self::EXCEPTION_STACKER_ALREADY_INITIALIZED); - } // END - if - - // Initialize the given stack - $this->initGenericArrayKey('stacks', $stackerName, 'entries', $forceReInit); - } - - /** - * Initializes all stacks - * - * @return void - */ - public function initStacks (array $stacks, $forceReInit = FALSE) { - // "Walk" through all (more will be added as needed - foreach ($stacks as $stackerName) { - // Init this stack - $this->initStack($stackerName, $forceReInit); - } // END - foreach - } - - /** - * Checks whether the given stack is initialized (set in array $stackers) - * - * @param $stackerName Name of the stack - * @return $isInitialized Whether the stack is initialized - */ - public function isStackInitialized ($stackerName) { - // Is is there? - $isInitialized = ($this->isValidGenericArrayKey('stacks', $stackerName, 'entries')); - - // Return result - return $isInitialized; - } - - /** - * Checks whether the given stack is full - * - * @param $stackerName Name of the stack - * @return $isFull Whether the stack is full - * @throws NoStackerException If given stack is missing - */ - protected function isStackFull ($stackerName) { - // Is the stack not yet initialized? - if (!$this->isStackInitialized($stackerName)) { - // Throw an exception - throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); - } // END - if - - // So, is the stack full? - $isFull = (($this->getStackCount($stackerName)) == $this->getConfigInstance()->getConfigEntry('stacker_' . $stackerName . '_max_size')); - - // Return result - return $isFull; - } - - /** - * Checks whether the given stack is empty - * - * @param $stackerName Name of the stack - * @return $isEmpty Whether the stack is empty - * @throws NoStackerException If given stack is missing - */ - public function isStackEmpty ($stackerName) { - // Is the stack not yet initialized? - if (!$this->isStackInitialized($stackerName)) { - // Throw an exception - throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); - } // END - if - - // So, is the stack empty? - $isEmpty = (($this->getStackCount($stackerName)) == 0); - - // Return result - return $isEmpty; - } - - /** - * Getter for size of given stack (array count) - * - * @param $stackerName Name of the stack - * @return $count Size of stack (array count) - * @throws NoStackerException If given stack is missing - */ - public function getStackCount ($stackerName) { - // Is the stack not yet initialized? - if (!$this->isStackInitialized($stackerName)) { - // Throw an exception - throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); - } // END - if - - // Now, count the array of entries - $count = $this->countGenericArrayElements('stacks', $stackerName, 'entries'); - - // Return result - return $count; - } - - /** - * Adds a value to given stack - * - * @param $stackerName Name of the stack - * @param $value Value to add to this stacker - * @return void - * @throws FullStackerException Thrown if the stack is full - */ - protected function addValue ($stackerName, $value) { - // Is the stack not yet initialized or full? - if (!$this->isStackInitialized($stackerName)) { - // Then do it here - $this->initStack($stackerName); - } elseif ($this->isStackFull($stackerName)) { - // Stacker is full - throw new FullStackerException(array($this, $stackerName, $value), self::EXCEPTION_STACKER_IS_FULL); - } - - // Now add the value to the stack - $this->pushValueToGenericArrayKey('stacks', $stackerName, 'entries', $value); - } - - /** - * Get last value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - protected function getLastValue ($stackerName) { - // Is the stack not yet initialized or full? - if (!$this->isStackInitialized($stackerName)) { - // Throw an exception - throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); - } elseif ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } - - // Now get the last value - $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1); - - // Return it - return $value; - } - - /** - * Get first value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - protected function getFirstValue ($stackerName) { - // Is the stack not yet initialized or full? - if (!$this->isStackInitialized($stackerName)) { - // Throw an exception - throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); - } elseif ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } - - // Now get the first value - $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', 0); - - // Return it - return $value; - } - - /** - * "Pops" last entry from stack - * - * @param $stackerName Name of the stack - * @return $value Value "poped" from array - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - protected function popLast ($stackerName) { - // Is the stack not yet initialized or full? - if (!$this->isStackInitialized($stackerName)) { - // Throw an exception - throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); - } elseif ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } - - // Now, remove the last entry, we don't care about the return value here, see elseif() block above - return $this->popGenericArrayElement('stacks', $stackerName, 'entries'); - } - - /** - * "Pops" first entry from stack - * - * @param $stackerName Name of the stack - * @return $value Value "shifted" from array - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - protected function popFirst ($stackerName) { - // Is the stack not yet initialized or full? - if (!$this->isStackInitialized($stackerName)) { - // Throw an exception - throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); - } elseif ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } - - // Now, remove the last entry, we don't care about the return value here, see elseif() block above - return $this->shiftGenericArrayElement('stacks', $stackerName, 'entries'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/stacker/fifo/.htaccess b/inc/classes/main/stacker/fifo/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/stacker/fifo/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/stacker/fifo/class_FiFoStacker.php b/inc/classes/main/stacker/fifo/class_FiFoStacker.php deleted file mode 100644 index e9a64035..00000000 --- a/inc/classes/main/stacker/fifo/class_FiFoStacker.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FiFoStacker extends BaseStacker implements Stackable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class Stacker and prepares it for usage - * - * @return $stackInstance An instance of FiFoStacker - */ - public static final function createFiFoStacker () { - // Get a new instance - $stackInstance = new FiFoStacker(); - - // Init generic stacker - $stackInstance->initStack('generic'); - - // Return the prepared instance - return $stackInstance; - } - - /** - * Pushs a value on a named stacker - * - * @param $stackerName Name of the stack - * @param $value Value to push on it - * @return void - * @throws StackerFullException If the stack is full - */ - public function pushNamed ($stackerName, $value) { - // Call the protected method - parent::addValue($stackerName, $value); - } - - /** - * 'Pops' a value from a named stacker and returns it's value - * - * @param $stackerName Name of the stack - * @return $value Value of the current stack entry - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function popNamed ($stackerName) { - // Get the value - $value = $this->getNamed($stackerName); - - // Call the protected method - parent::popFirst($stackerName); - - // Return the value - return $value; - } - - /** - * Get value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function getNamed ($stackerName) { - // Call the protected method - return parent::getFirstValue($stackerName); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/stacker/file/.htaccess b/inc/classes/main/stacker/file/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/stacker/file/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/stacker/file/class_ b/inc/classes/main/stacker/file/class_ deleted file mode 100644 index 38970b39..00000000 --- a/inc/classes/main/stacker/file/class_ +++ /dev/null @@ -1,109 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???FileStack extends BaseFileStack implements StackableFile, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $fileName Absolute Name of stack file - * @return $stackInstance An instance of a Stackable class - */ - public final static function create???FileStack ($fileName) { - // Get new instance - $stackInstance = new ???FileStack(); - - // Init this stack - $stackInstance->initStack($fileName); - - // Return the prepared instance - return $stackInstance; - } - - /** - * Pushs a value on a named stacker - * - * @param $stackerName Name of the stack - * @param $value Value to push on it - * @return void - * @throws StackerFullException If the stack is full - */ - public function pushNamed ($stackerName, $value) { - $this->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value); - } - - /** - * 'Pops' a value from a named stacker - * - * @param $stackerName Name of the stack - * @return void - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function popNamed ($stackerName) { - $this->partialStub('stackerName=' . $stackerName); - } - - /** - * Get value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function getNamed ($stackerName) { - $this->partialStub('stackerName=' . $stackerName); - } - - /** - * Seeks to given position - * - * @param $seekPosition Seek position in file - * @return void - */ - public function seek ($seekPosition) { - $this->partialStub('seekPosition=' . $seekPosition); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - public function size () { - $this->partialStub(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php deleted file mode 100644 index 03242694..00000000 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ /dev/null @@ -1,616 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseFileStack extends BaseStacker { - /** - * Magic for this stack - */ - const STACK_MAGIC = 'STACKv0.1'; - - /** - * Name of array index for gap position - */ - const ARRAY_INDEX_GAP_POSITION = 'gap'; - - /** - * Name of array index for hash - */ - const ARRAY_INDEX_HASH = 'hash'; - - /** - * Name of array index for length of raw data - */ - const ARRAY_INDEX_DATA_LENGTH = 'length'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Reads the file header - * - * @return void - * @todo To hard assertions here, better rewrite them to exceptions - */ - public function readFileHeader () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // First rewind to beginning as the header sits at the beginning ... - $this->getIteratorInstance()->rewind(); - - // Then read it (see constructor for calculation) - $data = $this->getIteratorInstance()->read($this->getIteratorInstance()->getHeaderSize()); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getIteratorInstance()->getHeaderSize())); - - // Have all requested bytes been read? - assert(strlen($data) == $this->getIteratorInstance()->getHeaderSize()); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Last character must be the separator - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data(-1)=%s', __METHOD__, __LINE__, dechex(ord(substr($data, -1, 1))))); - assert(substr($data, -1, 1) == chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Okay, then remove it - $data = substr($data, 0, -1); - - // And update seek position - $this->getIteratorInstance()->updateSeekPosition(); - - /* - * Now split it: - * - * 0 => magic - * 1 => total entries - * 2 => current seek position - */ - $header = explode(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), $data); - - // Set header here - $this->getIteratorInstance()->setHeader($header); - - // Check if the array has only 3 elements - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, TRUE))); - assert(count($header) == 3); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Check magic - assert($header[0] == self::STACK_MAGIC); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Check length of count and seek position - assert(strlen($header[1]) == BaseBinaryFile::LENGTH_COUNT); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - assert(strlen($header[2]) == BaseBinaryFile::LENGTH_POSITION); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); - - // Decode count and seek position - $header[1] = hex2bin($header[1]); - $header[2] = hex2bin($header[2]); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Flushes the file header - * - * @return void - */ - public function flushFileHeader () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); - - // Put all informations together - $header = sprintf('%s%s%s%s%s%s', - // Magic - self::STACK_MAGIC, - - // Separator magic<->count - chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), - - // Total entries (will be zero) and pad it to 20 chars - str_pad($this->dec2hex($this->getIteratorInstance()->getCounter()), BaseBinaryFile::LENGTH_COUNT, '0', STR_PAD_LEFT), - - // Separator count<->seek position - chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), - - // Position (will be zero) - str_pad($this->dec2hex($this->getIteratorInstance()->getSeekPosition(), 2), BaseBinaryFile::LENGTH_POSITION, '0', STR_PAD_LEFT), - - // Separator position<->entries - chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES) - ); - - // Write it to disk (header is always at seek position 0) - $this->getIteratorInstance()->writeData(0, $header, FALSE); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); - } - - /** - * Initializes this file-based stack. - * - * @param $fileName File name of this stack - * @param $type Type of this stack (e.g. url_source for URL sources) - * @return void - * @todo Currently the stack file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole stack file. - */ - protected function initFileStack ($fileName, $type) { - // Get a stack file instance - $fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileName, $this)); - - // Get iterator instance - $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', array($fileInstance)); - - // Is the instance implementing the right interface? - assert($iteratorInstance instanceof SeekableWritableFileIterator); - - // Set iterator here - $this->setIteratorInstance($iteratorInstance); - - // Calculate header size - $this->getIteratorInstance()->setHeaderSize( - strlen(self::STACK_MAGIC) + - strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) + - BaseBinaryFile::LENGTH_COUNT + - strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) + - BaseBinaryFile::LENGTH_POSITION + - strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)) - ); - - // Init counters and gaps array - $this->getIteratorInstance()->initCountersGapsArray(); - - // Is the file's header initialized? - if (!$this->getIteratorInstance()->isFileHeaderInitialized()) { - // No, then create it (which may pre-allocate the stack) - $this->getIteratorInstance()->createFileHeader(); - - // And pre-allocate a bit - $this->getIteratorInstance()->preAllocateFile('file_stack'); - } // END - if - - // Load the file header - $this->readFileHeader(); - - // Count all entries in file - $this->getIteratorInstance()->analyzeFile(); - - /* - * Get stack index instance. This can be used for faster - * "defragmentation" and startup. - */ - $indexInstance = FileStackIndexFactory::createFileStackIndexInstance($fileName, $type); - - // And set it here - $this->setIndexInstance($indexInstance); - } - - /** - * Adds a value to given stack - * - * @param $stackerName Name of the stack - * @param $value Value to add to this stacker - * @return void - * @throws FullStackerException If the stack is full - */ - protected function addValue ($stackerName, $value) { - // Do some tests - if ($this->isStackFull($stackerName)) { - // Stacker is full - throw new FullStackerException(array($this, $stackerName, $value), self::EXCEPTION_STACKER_IS_FULL); - } // END - if - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); - - // No objects/resources are allowed as their serialization takes to long - assert(!is_object($value)); - assert(!is_resource($value)); - - /* - * Now add the value to the file stack which returns gap position, a - * hash and length of the raw data. - */ - $data = $this->getIteratorInstance()->writeValueToFile($stackerName, $value); - - // Add the hash and gap position to the index - $this->getIndexInstance()->addHashToIndex($stackerName, $data); - } - - /** - * Get last value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws EmptyStackerException If the stack is empty - */ - protected function getLastValue ($stackerName) { - // Is the stack not yet initialized or full? - if ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } // END - if - - // Now get the last value - /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); - $value = NULL; - - // Return it - return $value; - } - - /** - * Get first value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws EmptyStackerException If the stack is empty - */ - protected function getFirstValue ($stackerName) { - // Is the stack not yet initialized or full? - if ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } // END - if - - // Now get the first value - /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); - $value = NULL; - - // Return it - return $value; - } - - /** - * "Pops" last entry from stack - * - * @param $stackerName Name of the stack - * @return $value Value "poped" from array - * @throws EmptyStackerException If the stack is empty - */ - protected function popLast ($stackerName) { - // Is the stack not yet initialized or full? - if ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } // END - if - - // Now, remove the last entry, we don't care about the return value here, see elseif() block above - /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); - return NULL; - } - - /** - * "Pops" first entry from stack - * - * @param $stackerName Name of the stack - * @return $value Value "shifted" from array - * @throws EmptyStackerException If the named stacker is empty - */ - protected function popFirst ($stackerName) { - // Is the stack not yet initialized or full? - if ($this->isStackEmpty($stackerName)) { - // Throw an exception - throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); - } // END - if - - // Now, remove the last entry, we don't care about the return value here, see elseif() block above - /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); - return NULL; - } - - /** - * Checks whether the given stack is full - * - * @param $stackerName Name of the stack - * @return $isFull Whether the stack is full - */ - protected function isStackFull ($stackerName) { - // File-based stacks will only run full if the disk space is low. - // @TODO Please implement this, returning FALSE - $isFull = FALSE; - - // Return result - return $isFull; - } - - /** - * Checks whether the given stack is empty - * - * @param $stackerName Name of the stack - * @return $isEmpty Whether the stack is empty - * @throws NoStackerException If given stack is missing - */ - public function isStackEmpty ($stackerName) { - // So, is the stack empty? - $isEmpty = (($this->getStackCount($stackerName)) == 0); - - // Return result - return $isEmpty; - } - - /** - * Initializes given stacker - * - * @param $stackerName Name of the stack - * @param $forceReInit Force re-initialization - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function initStack ($stackerName, $forceReInit = FALSE) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Initializes all stacks - * - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function initStacks (array $stacks, $forceReInit = FALSE) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks whether the given stack is initialized (set in array $stackers) - * - * @param $stackerName Name of the stack - * @return $isInitialized Whether the stack is initialized - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function isStackInitialized ($stackerName) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Determines whether the EOF has been reached - * - * @return $isEndOfFileReached Whether the EOF has been reached - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function isEndOfFileReached () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for file name - * - * @return $fileName The current file name - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function getFileName () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for size of given stack (array count) - * - * @param $stackerName Name of the stack - * @return $count Size of stack (array count) - */ - public function getStackCount ($stackerName) { - // Now, simply return the found count value, this must be up-to-date then! - return $this->getIteratorInstance()->getCounter(); - } - - /** - * Calculates minimum length for one entry/block - * - * @return $length Minimum length for one entry/block - */ - public function calculateMinimumBlockLength () { - // Calulcate it - $length = - // Length of entry group - BaseBinaryFile::LENGTH_GROUP + strlen(chr(BaseBinaryFile::SEPARATOR_GROUP_HASH)) + - // Hash + value - self::getHashLength() + strlen(chr(BaseBinaryFile::SEPARATOR_HASH_VALUE)) + 1 + - // Final separator - strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES)); - - // Return it - return $length; - } - - /** - * Initializes counter for valid entries, arrays for damaged entries and - * an array for gap seek positions. If you call this method on your own, - * please re-analyze the file structure. So you are better to call - * analyzeFile() instead of this method. - * - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function initCountersGapsArray () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for header size - * - * @return $totalEntries Size of file header - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function getHeaderSize () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Setter for header size - * - * @param $headerSize Size of file header - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function setHeaderSize ($headerSize) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for header array - * - * @return $totalEntries Size of file header - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function getHeader () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Setter for header - * - * @param $header Array for a file header - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function setHeader (array $header) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Updates seekPosition attribute from file to avoid to much access on file. - * - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function updateSeekPosition () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Getter for total entries - * - * @return $totalEntries Total entries in this file - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public final function getCounter () { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Writes data at given position - * - * @param $seekPosition Seek position - * @param $data Data to be written - * @param $flushHeader Whether to flush the header (default: flush) - * @return void - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function writeData ($seekPosition, $data, $flushHeader = TRUE) { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data[]=%s,flushHeader=%d', __METHOD__, __LINE__, $seekPosition, gettype($data), intval($flushHeader))); - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Writes given value to the file and returns a hash and gap position for it - * - * @param $groupId Group identifier - * @param $value Value to be added to the stack - * @return $data Hash and gap position - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function writeValueToFile ($groupId, $value) { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,value[%s]=%s', __METHOD__, __LINE__, $groupId, gettype($value), print_r($value, TRUE))); - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Searches for next suitable gap the given length of data can fit in - * including padding bytes. - * - * @param $length Length of raw data - * @return $seekPosition Found next gap's seek position - * @throws UnsupportedOperationException This method is not (and maybe never will be) supported - */ - public function searchNextGap ($length) { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] length=%s', __METHOD__, __LINE__, $length)); - throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * "Getter" for file size - * - * @return $fileSize Size of currently loaded file - */ - public function getFileSize () { - // Call iterator's method - return $this->getIteratorInstance()->getFileSize(); - } - - /** - * Writes given raw data to the file and returns a gap position and length - * - * @param $groupId Group identifier - * @param $hash Hash from encoded value - * @param $encoded Encoded value to be written to the file - * @return $data Gap position and length of the raw data - */ - public function writeDataToFreeGap ($groupId, $hash, $encoded) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,encoded()=%d - CALLED!', __METHOD__, __LINE__, $groupId, $hash, strlen($encoded))); - - // Raw data been written to the file - $rawData = sprintf('%s%s%s%s%s', - $groupId, - BaseBinaryFile::SEPARATOR_GROUP_HASH, - hex2bin($hash), - BaseBinaryFile::SEPARATOR_HASH_VALUE, - $encoded - ); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d', __METHOD__, __LINE__, $groupId, $hash, strlen($rawData))); - - // Search for next free gap - $gapPosition = $this->getIteratorInstance()->searchNextGap(strlen($rawData)); - - // Gap position cannot be smaller than header length + 1 - assert($gapPosition > $this->getIteratorInstance()->getHeaderSize()); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,gapPosition=%s', __METHOD__, __LINE__, $groupId, $hash, $gapPosition)); - - // Then write the data at that gap - $this->getIteratorInstance()->writeData($gapPosition, $rawData); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d - EXIT!', __METHOD__, __LINE__, $groupId, $hash, strlen($rawData))); - - // Return gap position, hash and length of raw data - return array( - self::ARRAY_INDEX_GAP_POSITION => $gapPosition, - self::ARRAY_INDEX_HASH => $hash, - self::ARRAY_INDEX_DATA_LENGTH => strlen($rawData) - ); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/stacker/file/fifo/.htaccess b/inc/classes/main/stacker/file/fifo/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/stacker/file/fifo/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/stacker/file/fifo/class_FiFoFileStack.php b/inc/classes/main/stacker/file/fifo/class_FiFoFileStack.php deleted file mode 100644 index fc7edf43..00000000 --- a/inc/classes/main/stacker/file/fifo/class_FiFoFileStack.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FiFoFileStack extends BaseFileStack implements StackableFile, CalculatableBlock, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @param $fileName Absolute Name of stack file - * @param $type Type of this stack (e.g. url_source for URL sources) - * @return $stackInstance An instance of a Stackable class - */ - public final static function createFiFoFileStack ($fileName, $type) { - // Get new instance - $stackInstance = new FiFoFileStack(); - - // Init this stack - $stackInstance->initFileStack($fileName, $type); - - // Return the prepared instance - return $stackInstance; - } - - /** - * Pushs a value on a named stacker - * - * @param $stackerName Name of the stack - * @param $value Value to push on it - * @return void - * @throws StackerFullException If the stack is full - */ - public function pushNamed ($stackerName, $value) { - // Call the protected method - parent::addValue($stackerName, $value); - } - - /** - * 'Pops' a value from a named stacker and returns it's value - * - * @param $stackerName Name of the stack - * @return $value Value of the current stack entry - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function popNamed ($stackerName) { - // Get the value - $value = $this->getNamed($stackerName); - - // Call the protected method - parent::popFirst($stackerName); - - // Return the value - return $value; - } - - /** - * Get value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function getNamed ($stackerName) { - // Call the protected method - return parent::getFirstValue($stackerName); - } - - /** - * Seeks to given position - * - * @param $seekPosition Seek position in file - * @return $status Status of this operation - */ - public function seek ($seekPosition) { - $this->partialStub('seekPosition=' . $seekPosition); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - public function size () { - // Call the iterator instance - return $this->getIteratorInstance()->size(); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/stacker/filo/.htaccess b/inc/classes/main/stacker/filo/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/stacker/filo/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/stacker/filo/class_FiLoStacker.php b/inc/classes/main/stacker/filo/class_FiLoStacker.php deleted file mode 100644 index ba7c09c3..00000000 --- a/inc/classes/main/stacker/filo/class_FiLoStacker.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FiLoStacker extends BaseStacker implements Stackable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class Stacker and prepares it for usage - * - * @return $stackInstance An instance of FiLoStacker - */ - public static final function createFiLoStacker () { - // Get a new instance - $stackInstance = new FiLoStacker(); - - // Init the generic stacker - $stackInstance->initStack('generic'); - - // Return the prepared instance - return $stackInstance; - } - - /** - * Pushs a value on a named stacker - * - * @param $stackerName Name of the stack - * @param $value Value to push on it - * @return void - * @throws StackerFullException If the stack is full - */ - public function pushNamed ($stackerName, $value) { - // Call the protected method - parent::addValue($stackerName, $value); - } - - /** - * 'Pops' a value from a named stacker and returns it's value - * - * @param $stackerName Name of the stack - * @return $value Value of the current stack entry - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function popNamed ($stackerName) { - // Get the value - $value = $this->getNamed($stackerName); - - // Call the protected method - parent::popLast($stackerName); - - // Return the value - return $value; - } - - /** - * Get value from named stacker - * - * @param $stackerName Name of the stack - * @return $value Value of last added value - * @throws NoStackerException If the named stacker was not found - * @throws EmptyStackerException If the named stacker is empty - */ - public function getNamed ($stackerName) { - // Call the protected method - return parent::getLastValue($stackerName); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/states/.htaccess b/inc/classes/main/states/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/states/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/states/class_ b/inc/classes/main/states/class_ deleted file mode 100644 index b2505a4e..00000000 --- a/inc/classes/main/states/class_ +++ /dev/null @@ -1,40 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???State extends BaseState implements ??Stateable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set state name - $this->setStateName('!!!'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/states/class_BaseState.php b/inc/classes/main/states/class_BaseState.php deleted file mode 100644 index 73970992..00000000 --- a/inc/classes/main/states/class_BaseState.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseState extends BaseFrameworkSystem implements Stateable { - // Exception code constants - const EXCEPTION_INVALID_STATE = 0xc00; - - /** - * State name for printing out (except debug output where you want to use - * $stateInstance->__toString() instead of this). - */ - private $stateName = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Getter for state name - * - * @return $stateName Name of this state in a printable maner - */ - public final function getStateName () { - return $this->stateName; - } - - /** - * Setter for state name - * - * @param $stateName Name of this state in a printable maner - * @return void - */ - protected final function setStateName ($stateName) { - $this->stateName = $stateName; - } - - /** - * Executes the state with given Executor instance - * - * @param $executorInstance An instance of a Executor class - * @return void - * @throws UnsupportedOperationException This method should be overwritten - */ - public function executeState (Executor $executorInstance) { - throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/streams/.htaccess b/inc/classes/main/streams/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/streams/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/streams/class_ b/inc/classes/main/streams/class_ deleted file mode 100644 index d7e24e2d..00000000 --- a/inc/classes/main/streams/class_ +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Stream extends BaseStream implements Stream { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this node class - * - * @return $streamInstance An instance of this node class - */ - public final static function create???Stream (Requestable $requestInstance) { - // Get a new instance - $streamInstance = new ???Stream(); - - // Return the instance - return $streamInstance; - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/streams/class_BaseStream.php b/inc/classes/main/streams/class_BaseStream.php deleted file mode 100644 index 435479e0..00000000 --- a/inc/classes/main/streams/class_BaseStream.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseStream extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/streams/crypto/.htaccess b/inc/classes/main/streams/crypto/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/streams/crypto/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/streams/crypto/class_McryptStream.php b/inc/classes/main/streams/crypto/class_McryptStream.php deleted file mode 100644 index 2a60fe23..00000000 --- a/inc/classes/main/streams/crypto/class_McryptStream.php +++ /dev/null @@ -1,175 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class McryptStream extends BaseStream implements EncryptableStream { - /** - * Separator on many places - */ - const DATA_PAYLOAD_SEPARATOR = '|'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this node class - * - * @param $rngInstance An RNG instance - * @return $streamInstance An instance of this node class - */ - public static final function createMcryptStream (RandomNumberGenerator $rngInstance) { - // Get a new instance - $streamInstance = new McryptStream(); - - // Set the RNG instance - $streamInstance->setRngInstance($rngInstance); - - // Return the instance - return $streamInstance; - } - - /** - * Encrypt the string with fixed salt - * - * @param $str The unencrypted string - * @param $key Optional key, if none provided, a random key will be generated - * @return $encrypted Encrypted string - */ - public function encryptStream ($str, $key = NULL) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: key[' . gettype($key) . ']=' . $key); - - // Init crypto module - $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); - $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); - - // Generate key, if none provided - if (is_null($key)) { - // None provided - $key = $this->getRngInstance()->generateKey(); - } // END - if - - // Add some "payload" to the string - switch ($this->getRngInstance()->randomNumber(0, 8)) { - case 0: - $payloadString = crc32($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20)); - break; - - case 1: - $payloadString = crc32($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20)); - break; - - case 2: - $payloadString = crc32($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20)); - break; - - case 3: - $payloadString = md5($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20)); - break; - - case 4: - $payloadString = md5($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20)); - break; - - case 5: - $payloadString = md5($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20)); - break; - - case 6: - $payloadString = sha1($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20)); - break; - - case 7: - $payloadString = sha1($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20)); - break; - - case 8: - $payloadString = sha1($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20)); - break; - } - - // Encrypt the string - $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $payloadString, MCRYPT_MODE_ECB, $iv); - - // Return the string - return $encrypted; - } - - /** - * Decrypt the string with fixed salt - * - * @param $encrypted Encrypted string - * @param $key Optional key, if none provided, a random key will be generated - * @return $str The unencrypted string - */ - public function decryptStream ($encrypted, $key = NULL) { - // Init crypto module - $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); - $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); - - // Shall we use a default key or custom? - if (is_null($key)) { - // Generate (default) key - $key = $this->getRngInstance()->generateKey(); - } // END - if - - // Decrypt the string - $payloadString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); - - // Get the real string out - $strArray = explode(self::DATA_PAYLOAD_SEPARATOR, $payloadString); - - // Does the element count match? - assert(count($strArray) == 3); - - // Decode the string - $str = base64_decode($strArray[1]); - - // Trim trailing nulls away - $str = rtrim($str, "\0"); - - // Return the string - return $str; - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called (which is a mistake) - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/streams/crypto/class_NullCryptoStream.php b/inc/classes/main/streams/crypto/class_NullCryptoStream.php deleted file mode 100644 index c42e6d1f..00000000 --- a/inc/classes/main/streams/crypto/class_NullCryptoStream.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NullCryptoStream extends BaseStream implements EncryptableStream { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this node class - * - * @return $streamInstance An instance of this node class - */ - public static final function createNullCryptoStream () { - // Get a new instance - $streamInstance = new NullCryptoStream(); - - // Return the instance - return $streamInstance; - } - - /** - * Encrypt the string with fixed salt - * - * @param $str The unencrypted string - * @param $key Optional key, if none provided, a random key will be generated - * @return $encrypted Encrypted string - */ - public function encryptStream ($str, $key = NULL) { - // Just handle it over - $encrypted = (string) $str; - - // Return it - return $encrypted; - } - - /** - * Decrypt the string with fixed salt - * - * @param $encrypted Encrypted string - * @return $str The unencrypted string - */ - public function decryptStream ($encrypted) { - // Just handle it over - $str = (string) $encrypted; - - // Return it - return $str; - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called (which is a mistake) - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/streams/input/.htaccess b/inc/classes/main/streams/input/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/streams/input/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/streams/input/class_ b/inc/classes/main/streams/input/class_ deleted file mode 100644 index 0bae09ff..00000000 --- a/inc/classes/main/streams/input/class_ +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???InputStream extends BaseStream implements InputStream { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this node class - * - * @return $streamInstance An instance of this node class - */ - public final static function create???InputStream () { - // Get a new instance - $streamInstance = new ???InputStream(); - - // Return the instance - return $streamInstance; - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/streams/output/.htaccess b/inc/classes/main/streams/output/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/streams/output/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/streams/output/class_ b/inc/classes/main/streams/output/class_ deleted file mode 100644 index 10b3c722..00000000 --- a/inc/classes/main/streams/output/class_ +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???OutputStream extends BaseStream implements OutputStream { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this node class - * - * @return $streamInstance An instance of this node class - */ - public final static function create???OutputStream () { - // Get a new instance - $streamInstance = new ???OutputStream(); - - // Return the instance - return $streamInstance; - } - - /** - * Streams the data and maybe does something to it - * - * @param $data The data (string mostly) to "stream" - * @return $data The data (string mostly) to "stream" - * @throws UnsupportedOperationException If this method is called - */ - public function streamData ($data) { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/tasks/.htaccess b/inc/classes/main/tasks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/tasks/class_ b/inc/classes/main/tasks/class_ deleted file mode 100644 index 1bbb87e2..00000000 --- a/inc/classes/main/tasks/class_ +++ /dev/null @@ -1,82 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class !!!???Task extends BaseTask implements Taskable, Visitable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Visitable class - */ - public final static function create!!!???Task () { - // Get new instance - $taskInstance = new !!!???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } - - /** - * Shuts down the task - * - * @return void - * @todo 0% done - */ - public function doShutdown () { - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/tasks/class_BaseTask.php b/inc/classes/main/tasks/class_BaseTask.php deleted file mode 100644 index c7bbe68b..00000000 --- a/inc/classes/main/tasks/class_BaseTask.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseTask extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/tasks/idle/.htaccess b/inc/classes/main/tasks/idle/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/tasks/idle/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/tasks/idle/class_IdleLoopTask.php b/inc/classes/main/tasks/idle/class_IdleLoopTask.php deleted file mode 100644 index 20d394be..00000000 --- a/inc/classes/main/tasks/idle/class_IdleLoopTask.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class IdleLoopTask extends BaseTask implements Taskable, Visitable { - /** - * Idle loop time - */ - private $idleTime = 0; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init idle loop time from config ("cache" it here) - $this->idleTime = $this->getConfigInstance()->getConfigEntry('idle_loop_time'); - } - - /** - * Creates an instance of this class - * - * @return $taskInstance An instance of a Taskable/Visitable class - */ - public static final function createIdleLoopTask () { - // Get new instance - $taskInstance = new IdleLoopTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - */ - public function executeTask () { - // Idle here a little - $this->idle($this->idleTime); - } - - /** - * Shutdown this task, this does nothing here, just supply the method. - * - * @return void - */ - public function doShutdown () { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/template/.htaccess b/inc/classes/main/template/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/template/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/template/class_ b/inc/classes/main/template/class_ deleted file mode 100644 index e27e3215..00000000 --- a/inc/classes/main/template/class_ +++ /dev/null @@ -1,85 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???TemplateEngine extends BaseTemplateEngine implements CompileableTemplate { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @param $applicationInstance A manageable application - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public final static function create???TemplateEngine (ManageableApplication $applicationInstance) { - // Get a new instance - $templateInstance = new ???TemplateEngine(); - - // Determine base path - $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $templateInstance->setTemplateBasePath($templateBasePath); - - // Set template extensions - $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); - $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); - - // Absolute output path for compiled templates - $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); - - // Return the prepared instance - return $templateInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php deleted file mode 100644 index 543bd88f..00000000 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ /dev/null @@ -1,1641 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseTemplateEngine extends BaseFrameworkSystem { - /** - * The local path name where all templates and sub folders for special - * templates are stored. We will internally determine the language plus - * "html" for web templates or "emails" for email templates - */ - private $templateBasePath = ''; - - /** - * Template type - */ - private $templateType = 'html'; - - /** - * The extension for web and email templates (not compiled templates) - */ - private $templateExtension = '.tpl'; - - /** - * The extension for code templates (not compiled templates) - */ - private $codeExtension = '.ctp'; - - /** - * Path relative to $templateBasePath and language code for compiled code-templates - */ - private $compileOutputPath = 'templates/_compiled/'; - - /** - * The path name for all templates - */ - private $genericBasePath = 'templates/'; - - /** - * The raw (maybe uncompiled) template - */ - private $rawTemplateData = ''; - - /** - * Template data with compiled-in variables - */ - private $compiledData = ''; - - /** - * The last loaded template's FQFN for debugging the engine - */ - private $lastTemplate = ''; - - /** - * The variable stack for the templates - */ - private $varStack = array(); - - /** - * Loaded templates for recursive protection and detection - */ - private $loadedTemplates = array(); - - /** - * Compiled templates for recursive protection and detection - */ - private $compiledTemplates = array(); - - /** - * Loaded raw template data - */ - private $loadedRawData = NULL; - - /** - * Raw templates which are linked in code templates - */ - private $rawTemplates = NULL; - - /** - * A regular expression for variable=value pairs - */ - private $regExpVarValue = '/([\w_]+)(="([^"]*)"|=([\w_]+))?/'; - - /** - * A regular expression for filtering out code tags - * - * E.g.: {?template:variable=value;var2=value2;[...]?} - */ - private $regExpCodeTags = '/\{\?([a-z_]+)(:("[^"]+"|[^?}]+)+)?\?\}/'; - - /** - * A regular expression to find template comments like - */ - private $regExpComments = '//'; - - /** - * Loaded helpers - */ - private $helpers = array(); - - /** - * Current variable group - */ - private $currGroup = 'general'; - - /** - * All template groups except "general" - */ - private $variableGroups = array(); - - /** - * Code begin - */ - private $codeBegin = ''; - - /** - * Language support is enabled by default - */ - private $languageSupport = TRUE; - - /** - * XML compacting is disabled by default - */ - private $xmlCompacting = FALSE; - - // Exception codes for the template engine - const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x110; - const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111; - const EXCEPTION_INVALID_VIEW_HELPER = 0x112; - const EXCEPTION_VARIABLE_IS_MISSING = 0x113; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - - // Init file I/O instance - $ioInstance = ObjectFactory::createObjectByConfiguredName('file_io_class'); - - // Set it - $this->setFileIoInstance($ioInstance); - } - - /** - * Search for a variable in the stack - * - * @param $variableName The variable we are looking for - * @param $variableGroup Optional variable group to look in - * @return $index FALSE means not found, >=0 means found on a specific index - */ - private function getVariableIndex ($variableName, $variableGroup = NULL) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // First everything is not found - $found = FALSE; - - // If the stack is NULL, use the current group - if (is_null($variableGroup)) { - // Use current group - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); - $variableGroup = $this->currGroup; - } // END - if - - // Is the group there? - if ($this->isVarStackSet($variableGroup)) { - // Now search for it - foreach ($this->getVarStack($variableGroup) as $index => $currEntry) { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':currGroup=' . $variableGroup . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName); - // Is the entry found? - if ($currEntry['name'] == $variableName) { - // Found! - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':FOUND!'); - $found = $index; - break; - } // END - if - } // END - foreach - } // END - if - - // Return the current position - return $found; - } - - /** - * Checks whether the given variable group is set - * - * @param $variableGroup Variable group to check - * @return $isSet Whether the given variable group is set - */ - protected final function isVarStackSet ($variableGroup) { - // Check it - $isSet = isset($this->varStack[$variableGroup]); - - // Return result - return $isSet; - } - - /** - * Getter for given variable group - * - * @param $variableGroup Variable group to check - * @return $varStack Found variable group - */ - public final function getVarStack ($variableGroup) { - return $this->varStack[$variableGroup]; - } - - /** - * Setter for given variable group - * - * @param $variableGroup Variable group to check - * @param $varStack Variable stack to check - * @return void - */ - protected final function setVarStack ($variableGroup, array $varStack) { - $this->varStack[$variableGroup] = $varStack; - } - - /** - * Return a content of a variable or null if not found - * - * @param $variableName The variable we are looking for - * @param $variableGroup Optional variable group to look in - * @return $content Content of the variable or null if not found - */ - protected function readVariable ($variableName, $variableGroup = NULL) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // First everything is not found - $content = NULL; - - // If the stack is NULL, use the current group - if (is_null($variableGroup)) { - // Use current group - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); - $variableGroup = $this->currGroup; - } // END - if - - // Get variable index - $found = $this->getVariableIndex($variableName, $variableGroup); - - // Is the variable found? - if ($found !== FALSE) { - // Read it - $content = $this->getVariableValue($variableGroup, $found); - } // END - if - - // Return the current position - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': variableGroup=' . $variableGroup . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content); - return $content; - } - - /** - * Add a variable to the stack - * - * @param $variableName Name of variable to add - * @param $value Value we want to store in the variable - * @return void - */ - private function addVariable ($variableName, $value) { - // Set general variable group - $this->setVariableGroup('general'); - - // Add it to the stack - $this->addGroupVariable($variableName, $value); - } - - /** - * Returns all variables of current group or empty array - * - * @return $result Whether array of found variables or empty array - */ - private function readCurrentGroup () { - // Default is not found - $result = array(); - - // Is the group there? - if ($this->isVarStackSet($this->currGroup)) { - // Then use it - $result = $this->getVarStack($this->currGroup); - } // END - if - - // Return result - return $result; - } - - /** - * Settter for variable group - * - * @param $groupName Name of variable group - * @param $add Whether add this group - * @return void - */ - public function setVariableGroup ($groupName, $add = TRUE) { - // Set group name - //* DEBIG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': currGroup=' . $groupName); - $this->currGroup = $groupName; - - // Skip group 'general' - if (($groupName != 'general') && ($add === TRUE)) { - $this->variableGroups[$groupName] = 'OK'; - } // END - if - } - - - /** - * Adds a variable to current group - * - * @param $variableName Variable to set - * @param $value Value to store in variable - * @return void - */ - public function addGroupVariable ($variableName, $value) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value); - - // Get current variables in group - $currVars = $this->readCurrentGroup(); - - // Append our variable - array_push($currVars, $this->generateVariableArray($variableName, $value)); - - // Add it to the stack - $this->setVarStack($this->currGroup, $currVars); - } - - /** - * Getter for variable value, throws a NoVariableException if the variable is not found - * - * @param $variableGroup Variable group to use - * @param $index Index in variable array - * @return $value Value to set - */ - private function getVariableValue ($variableGroup, $index) { - // Return it - return $this->varStack[$variableGroup][$index]['value']; - } - - /** - * Modify an entry on the stack - * - * @param $variableName The variable we are looking for - * @param $value The value we want to store in the variable - * @return void - * @throws NoVariableException If the given variable is not found - */ - private function modifyVariable ($variableName, $value) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // Get index for variable - $index = $this->getVariableIndex($variableName); - - // Is the variable set? - if ($index === FALSE) { - // Unset variables cannot be modified - throw new NoVariableException(array($this, $variableName, $value), self::EXCEPTION_VARIABLE_IS_MISSING); - } // END - if - - // Then modify it - $this->setVariableValue($this->currGroup, $index, $value); - } - - /** - * Sets a variable value for given variable group and index - * - * @param $variableGroup Variable group to use - * @param $index Index in variable array - * @param $value Value to set - * @return void - */ - private function setVariableValue ($variableGroup, $index, $value) { - $this->varStack[$variableGroup][$index]['value'] = $value; - } - - /** - * Sets a variable within given group. This method does detect if the - * variable is already set. If so, the variable got modified, otherwise - * added. - * - * @param $variableGroup Variable group to use - * @param $variableName Variable to set - * @param $value Value to set - * @return void - */ - protected function setVariable ($variableGroup, $variableName, $value) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // Get index for variable - $index = $this->getVariableIndex($variableName); - - // Is the variable set? - if ($index === FALSE) { - // Is the stack there? - if (!isset($this->varStack[$variableGroup])) { - // Then initialize it here - $this->varStack[$variableGroup] = array(); - } // END - if - - // Not found, add it - array_push($this->varStack[$variableGroup], $this->generateVariableArray($variableName, $value)); - } else { - // Then modify it - $this->setVariableValue($this->currGroup, $index, $value); - } - } - - /** - * "Generates" (better returns) an array for all variables for given - * variable/value pay. - * - * @param $variableName Variable to set - * @param $value Value to set - * @return $varData Variable data array - */ - private function generateVariableArray ($variableName, $value) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // Generate the temporary array - $varData = array( - 'name' => $variableName, - 'value' => $value - ); - - // And return it - return $varData; - } - - /** - * Setter for template type. Only 'html', 'emails' and 'compiled' should - * be sent here - * - * @param $templateType The current template's type - * @return void - */ - protected final function setTemplateType ($templateType) { - $this->templateType = (string) $templateType; - } - - /** - * Getter for template type - * - * @return $templateType The current template's type - */ - public final function getTemplateType () { - return $this->templateType; - } - - /** - * Setter for the last loaded template's FQFN - * - * @param $template The last loaded template - * @return void - */ - private final function setLastTemplate ($template) { - $this->lastTemplate = (string) $template; - } - - /** - * Getter for the last loaded template's FQFN - * - * @return $template The last loaded template - */ - private final function getLastTemplate () { - return $this->lastTemplate; - } - - /** - * Setter for base path - * - * @param $templateBasePath The relative base path for all templates - * @return void - */ - protected final function setTemplateBasePath ($templateBasePath) { - // And set it - $this->templateBasePath = (string) $templateBasePath; - } - - /** - * Getter for base path - * - * @return $templateBasePath The relative base path for all templates - */ - public final function getTemplateBasePath () { - // And set it - return $this->templateBasePath; - } - - /** - * Getter for generic base path - * - * @return $templateBasePath The relative base path for all templates - */ - public final function getGenericBasePath () { - // And set it - return $this->genericBasePath; - } - - /** - * Setter for template extension - * - * @param $templateExtension The file extension for all uncompiled - * templates - * @return void - */ - protected final function setRawTemplateExtension ($templateExtension) { - // And set it - $this->templateExtension = (string) $templateExtension; - } - - /** - * Setter for code template extension - * - * @param $codeExtension The file extension for all uncompiled - * templates - * @return void - */ - protected final function setCodeTemplateExtension ($codeExtension) { - // And set it - $this->codeExtension = (string) $codeExtension; - } - - /** - * Getter for template extension - * - * @return $templateExtension The file extension for all uncompiled - * templates - */ - public final function getRawTemplateExtension () { - // And set it - return $this->templateExtension; - } - - /** - * Getter for code-template extension - * - * @return $codeExtension The file extension for all code- - * templates - */ - public final function getCodeTemplateExtension () { - // And set it - return $this->codeExtension; - } - - /** - * Setter for path of compiled templates - * - * @param $compileOutputPath The local base path for all compiled - * templates - * @return void - */ - protected final function setCompileOutputPath ($compileOutputPath) { - // And set it - $this->compileOutputPath = (string) $compileOutputPath; - } - - /** - * Unsets the given offset in the variable group - * - * @param $index Index to unset - * @param $variableGroup Variable group (default: currGroup) - * @return void - */ - protected final function unsetVariableStackOffset ($index, $variableGroup = NULL) { - // Is the variable group not set? - if (is_null($variableGroup)) { - // Then set it to current - $variableGroup = $this->currGroup; - } // END - if - - // Is the entry there? - if (!isset($this->varStack[$variableGroup][$index])) { - // Abort here, we need fixing! - $this->debugInstance(); - } // END - if - - // Remove it - unset($this->varStack[$variableGroup][$index]); - } - - /** - * Private setter for raw template data - * - * @param $rawTemplateData The raw data from the template - * @return void - */ - protected final function setRawTemplateData ($rawTemplateData) { - // And store it in this class - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.'); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack)); - $this->rawTemplateData = (string) $rawTemplateData; - } - - /** - * Getter for raw template data - * - * @return $rawTemplateData The raw data from the template - */ - public final function getRawTemplateData () { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: ' . strlen($this->rawTemplateData) . ' Bytes read.'); - return $this->rawTemplateData; - } - - /** - * Private setter for compiled templates - * - * @return void - */ - private final function setCompiledData ($compiledData) { - // And store it in this class - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: ' . strlen($compiledData) . ' Bytes set.'); - $this->compiledData = (string) $compiledData; - } - - /** - * Getter for compiled templates, must be public for e.g. Mailer classes. - * - * @return $compiledData Compiled template data - */ - public final function getCompiledData () { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: ' . strlen($this->compiledData) . ' Bytes read.'); - return $this->compiledData; - } - - /** - * Private loader for all template types - * - * @param $template The template we shall load - * @param $extOther An other extension to use - * @return void - * @throws FileNotFoundException If the template was not found - */ - protected function loadTemplate ($template, $extOther = '') { - // Get extension for the template if empty - if (empty($extOther)) { - // None provided, so get the raw one - $ext = $this->getRawTemplateExtension(); - } else { - // Then use it! - $ext = (string) $extOther; - } - - // Is language support enabled? - if ($this->isLanguageSupportEnabled()) { - // Construct the FQFN for the template by honoring the current language - $fqfn = sprintf('%s%s%s%s/%s/%s%s', - $this->getConfigInstance()->getConfigEntry('base_path'), - $this->getTemplateBasePath(), - $this->getGenericBasePath(), - $this->getLanguageInstance()->getLanguageCode(), - $this->getTemplateType(), - (string) $template, - $ext - ); - } else { - // Construct the FQFN for the template without language - $fqfn = sprintf('%s%s%s%s/%s%s', - $this->getConfigInstance()->getConfigEntry('base_path'), - $this->getTemplateBasePath(), - $this->getGenericBasePath(), - $this->getTemplateType(), - (string) $template, - $ext - ); - } - - // First try this - try { - // Load the raw template data - $this->loadRawTemplateData($fqfn); - } catch (FileNotFoundException $e) { - // If we shall load a code-template we need to switch the file extension - if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('html_template_type')) && (empty($extOther))) { - // Switch over to the code-template extension and try it again - $ext = $this->getCodeTemplateExtension(); - - // Try it again... - $this->loadTemplate($template, $ext); - } else { - // Throw it again - throw new FileNotFoundException($fqfn, self::EXCEPTION_FILE_NOT_FOUND); - } - } - - } - - /** - * A private loader for raw template names - * - * @param $fqfn The full-qualified file name for a template - * @return void - */ - private function loadRawTemplateData ($fqfn) { - // Some debug code to look on the file which is being loaded - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: FQFN=' . $fqfn); - - // Load the raw template - $rawTemplateData = $this->getFileIoInstance()->loadFileContents($fqfn); - - // Store the template's contents into this class - $this->setRawTemplateData($rawTemplateData); - - // Remember the template's FQFN - $this->setLastTemplate($fqfn); - } - - /** - * Try to assign an extracted template variable as a "content" or 'config' - * variable. - * - * @param $variableName The variable's name (shall be content or config) - * by default - * @param $variableName The variable we want to assign - * @return void - */ - private function assignTemplateVariable ($variableName, $var) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: variableName=' . $variableName . ',variableName=' . $variableName); - - // Is it not a config variable? - if ($variableName != 'config') { - // Regular template variables - $this->assignVariable($variableName, ''); - } else { - // Configuration variables - $this->assignConfigVariable($var); - } - } - - /** - * Extract variables from a given raw data stream - * - * @param $rawData The raw template data we shall analyze - * @return void - */ - private function extractVariablesFromRawData ($rawData) { - // Cast to string - $rawData = (string) $rawData; - - // Search for variables - preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, TRUE)); - - // Did we find some variables? - if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) { - // Initialize all missing variables - foreach ($variableMatches[3] as $key => $var) { - // Variable name - $variableName = $variableMatches[1][$key]; - - // Workarround: Do not assign empty variables - if (!empty($var)) { - // Try to assign it, empty strings are being ignored - $this->assignTemplateVariable($variableName, $var); - } // END - if - } // END - foreach - } // END - if - } - - /** - * Main analysis of the loaded template - * - * @param $templateMatches Found template place-holders, see below - * @return void - * - *--------------------------------- - * Structure of $templateMatches: - *--------------------------------- - * [0] => Array - An array with all full matches - * [1] => Array - An array with left part (before the ':') of a match - * [2] => Array - An array with right part of a match including ':' - * [3] => Array - An array with right part of a match excluding ':' - */ - private function analyzeTemplate (array $templateMatches) { - // Backup raw template data - $backup = $this->getRawTemplateData(); - - // Initialize some arrays - if (is_null($this->loadedRawData)) { - // Initialize both - $this->loadedRawData = array(); - $this->rawTemplates = array(); - } // END - if - - // Load all requested templates - foreach ($templateMatches[1] as $template) { - // Load and compile only templates which we have not yet loaded - // RECURSIVE PROTECTION! BE CAREFUL HERE! - if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:template=' . $template); - - // Template not found, but maybe variable assigned? - if ($this->getVariableIndex($template) !== FALSE) { - // Use that content here - $this->loadedRawData[$template] = $this->readVariable($template); - - // Recursive protection: - array_push($this->loadedTemplates, $template); - } else { - // Then try to search for code-templates - try { - // Load the code template and remember it's contents - $this->loadCodeTemplate($template); - $this->loadedRawData[$template] = $this->getRawTemplateData(); - - // Remember this template for recursion detection - // RECURSIVE PROTECTION! - array_push($this->loadedTemplates, $template); - } catch (FileNotFoundException $e) { - // Even this is not done... :/ - array_push($this->rawTemplates, $template); - } - } - } // END - if - } // END - foreach - - // Restore the raw template data - $this->setRawTemplateData($backup); - } - - /** - * Compile a given raw template code and remember it for later usage - * - * @param $code The raw template code - * @param $template The template's name - * @return void - */ - private function compileCode ($code, $template) { - // Is this template already compiled? - if (in_array($template, $this->compiledTemplates)) { - // Abort here... - return; - } // END - if - - // Remember this template being compiled - array_push($this->compiledTemplates, $template); - - // Compile the loaded code in five steps: - // - // 1. Backup current template data - $backup = $this->getRawTemplateData(); - - // 2. Set the current template's raw data as the new content - $this->setRawTemplateData($code); - - // 3. Compile the template data - $this->compileTemplate(); - - // 4. Remember it's contents - $this->loadedRawData[$template] = $this->getRawTemplateData(); - - // 5. Restore the previous raw content from backup variable - $this->setRawTemplateData($backup); - } - - /** - * Insert all given and loaded templates by running through all loaded - * codes and searching for their place-holder in the main template - * - * @param $templateMatches See method analyzeTemplate() - * @return void - */ - private function insertAllTemplates (array $templateMatches) { - // Run through all loaded codes - foreach ($this->loadedRawData as $template => $code) { - - // Search for the template - $foundIndex = array_search($template, $templateMatches[1]); - - // Lookup the matching template replacement - if (($foundIndex !== FALSE) && (isset($templateMatches[0][$foundIndex]))) { - - // Get the current raw template - $rawData = $this->getRawTemplateData(); - - // Replace the space holder with the template code - $rawData = str_replace($templateMatches[0][$foundIndex], $code, $rawData); - - // Set the new raw data - $this->setRawTemplateData($rawData); - } // END - if - } // END - foreach - } - - /** - * Load all extra raw templates - * - * @return void - */ - private function loadExtraRawTemplates () { - // Are there some raw templates we need to load? - if (count($this->rawTemplates) > 0) { - // Try to load all raw templates - foreach ($this->rawTemplates as $key => $template) { - try { - // Load the template - $this->loadHtmlTemplate($template); - - // Remember it's contents - $this->rawTemplates[$template] = $this->getRawTemplateData(); - - // Remove it from the loader list - unset($this->rawTemplates[$key]); - - // Remember this template for recursion detection - // RECURSIVE PROTECTION! - array_push($this->loadedTemplates, $template); - } catch (FileNotFoundException $e) { - // This template was never found. We silently ignore it - unset($this->rawTemplates[$key]); - } - } // END - foreach - } // END - if - } - - /** - * Assign all found template variables - * - * @param $varMatches An array full of variable/value pairs. - * @return void - * @todo Unfinished work or don't die here. - */ - private function assignAllVariables (array $varMatches) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:varMatches()=' . count($varMatches)); - - // Search for all variables - foreach ($varMatches[1] as $key => $var) { - // Replace all dashes to underscores to match variables with configuration entries - $var = trim(self::convertDashesToUnderscores($var)); - - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:key=' . $key . ',var=' . $var); - - // Detect leading equals - if (substr($varMatches[2][$key], 0, 1) == '=') { - // Remove and cast it - $varMatches[2][$key] = (string) substr($varMatches[2][$key], 1); - } // END - if - - // Do we have some quotes left and right side? Then it is free text - if ((substr($varMatches[2][$key], 0, 1) == '"') && (substr($varMatches[2][$key], -1, 1) == '"')) { - // Free string detected! Which we can assign directly - $this->assignVariable($var, $varMatches[3][$key]); - } elseif (!empty($varMatches[2][$key])) { - // @TODO Non-string found so we need some deeper analysis... - ApplicationEntryPoint::app_exit('Deeper analysis not yet implemented!'); - } - } // END - foreach - } - - /** - * Compiles all loaded raw templates - * - * @param $templateMatches See method analyzeTemplate() for details - * @return void - */ - private function compileRawTemplateData (array $templateMatches) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:loadedRawData()= ' .count($this->loadedRawData)); - - // Are some code-templates found which we need to compile? - if (count($this->loadedRawData) > 0) { - // Then compile all! - foreach ($this->loadedRawData as $template => $code) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:template=' . $template . ',code(' . strlen($code) . ')=' . $code); - - // Is this template already compiled? - if (in_array($template, $this->compiledTemplates)) { - // Then skip it - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: Template ' . $template . ' already compiled. SKIPPED!'); - continue; - } // END - if - - // Search for the template - $foundIndex = array_search($template, $templateMatches[1]); - - // Lookup the matching variable data - if (($foundIndex !== FALSE) && (isset($templateMatches[3][$foundIndex]))) { - // Split it up with another reg. exp. into variable=value pairs - preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:varMatches=' . print_r($varMatches, TRUE)); - - // Assign all variables - $this->assignAllVariables($varMatches); - } // END - if (isset($templateMatches ... - - // Compile the loaded template - $this->compileCode($code, $template); - } // END - foreach ($this->loadedRawData ... - - // Insert all templates - $this->insertAllTemplates($templateMatches); - } // END - if (count($this->loadedRawData) ... - } - - /** - * Inserts all raw templates into their respective variables - * - * @return void - */ - private function insertRawTemplates () { - // Load all templates - foreach ($this->rawTemplates as $template => $content) { - // Set the template as a variable with the content - $this->assignVariable($template, $content); - } - } - - /** - * Finalizes the compilation of all template variables - * - * @return void - */ - private function finalizeVariableCompilation () { - // Get the content - $content = $this->getRawTemplateData(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: content before=' . strlen($content) . ' (' . md5($content) . ')'); - - // Do we have the stack? - if (!$this->isVarStackSet('general')) { - // Abort here silently - // @TODO This silent abort should be logged, maybe. - return; - } // END - if - - // Walk through all variables - foreach ($this->getVarStack('general') as $currEntry) { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: name=' . $currEntry['name'] . ', value=
' . htmlentities($currEntry['value']) . '
'); - // Replace all [$var] or {?$var?} with the content - // @TODO Old behaviour, will become obsolete! - $content = str_replace('$content[' . $currEntry['name'] . ']', $currEntry['value'], $content); - - // @TODO Yet another old way - $content = str_replace('[' . $currEntry['name'] . ']', $currEntry['value'], $content); - - // The new behaviour - $content = str_replace('{?' . $currEntry['name'] . '?}', $currEntry['value'], $content); - } // END - for - - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: content after=' . strlen($content) . ' (' . md5($content) . ')'); - - // Set the content back - $this->setRawTemplateData($content); - } - - /** - * Load a specified HTML template into the engine - * - * @param $template The web template we shall load which is located in - * 'html' by default - * @return void - */ - public function loadHtmlTemplate ($template) { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('html_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - - /** - * Assign (add) a given variable with a value - * - * @param $variableName The variable we are looking for - * @param $value The value we want to store in the variable - * @return void - * @throws EmptyVariableException If the variable name is left empty - */ - public final function assignVariable ($variableName, $value) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // Empty variable found? - if (empty($variableName)) { - // Throw an exception - throw new EmptyVariableException(array($this, 'variableName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - - // First search for the variable if it was already added - $index = $this->getVariableIndex($variableName); - - // Was it found? - if ($index === FALSE) { - // Add it to the stack - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value); - $this->addVariable($variableName, $value); - } elseif (!empty($value)) { - // Modify the stack entry - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value); - $this->modifyVariable($variableName, $value); - } - } - - /** - * Removes a given variable - * - * @param $variableName The variable we are looking for - * @param $variableGroup Name of variable group (default: 'general') - * @return void - */ - public final function removeVariable ($variableName, $variableGroup = 'general') { - // First search for the variable if it was already added - $index = $this->getVariableIndex($variableName, $variableGroup); - - // Was it found? - if ($index !== FALSE) { - // Remove this variable - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:UNSET: variableGroup=' . $variableGroup . ',variableName=' . $variableName . ',index=' . $index); - $this->unsetVariableStackOffset($index, $variableGroup); - } // END - if - } - - /** - * Assigns the last loaded raw template content with a given variable - * - * @param $templateName Name of the template we want to assign - * @param $variableName Name of the variable we want to assign - * @return void - */ - public function assignTemplateWithVariable ($templateName, $variableName) { - // Get the content from last loaded raw template - $content = $this->getRawTemplateData(); - - // Assign the variable - $this->assignVariable($variableName, $content); - - // Purge raw content - $this->setRawTemplateData(''); - } - - /** - * Assign a given congfiguration variable with a value - * - * @param $variableName The configuration variable we want to assign - * @return void - */ - public function assignConfigVariable ($variableName) { - // Replace all dashes to underscores to match variables with configuration entries - $variableName = trim(self::convertDashesToUnderscores($variableName)); - - // Sweet and simple... - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName)); - $this->assignVariable($variableName, $this->getConfigInstance()->getConfigEntry($variableName)); - } - - /** - * Assigns a lot variables into the stack of currently loaded template. - * This method should only be used in very rare circumstances, e.g. when - * you have to copy a whole set of variables into the template engine. - * Before you use this method, please make sure you have considered all - * other possiblities. - * - * @param $variables An array with variables to be assigned - * @return void - */ - public function assignMultipleVariables (array $variables) { - // "Inject" all - foreach ($variables as $name => $value) { - // Set variable with name for 'config' group - $this->assignVariable($name, $value); - } // END - foreach - } - - /** - * Assigns all the application data with template variables - * - * @param $applicationInstance A manageable application instance - * @return void - */ - public function assignApplicationData (ManageableApplication $applicationInstance) { - // Get long name and assign it - $this->assignVariable('app_full_name' , $applicationInstance->getAppName()); - - // Get short name and assign it - $this->assignVariable('app_short_name', $applicationInstance->getAppShortName()); - - // Get version number and assign it - $this->assignVariable('app_version' , $applicationInstance->getAppVersion()); - - // Assign extra application-depending data - $applicationInstance->assignExtraTemplateData($this); - } - - /** - * Load a specified code template into the engine - * - * @param $template The code template we shall load which is - * located in 'code' by default - * @return void - */ - public function loadCodeTemplate ($template) { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('code_' . self::getResponseTypeFromSystem() . '_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - - /** - * Load a specified email template into the engine - * - * @param $template The email template we shall load which is - * located in 'emails' by default - * @return void - */ - public function loadEmailTemplate ($template) { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('email_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - - /** - * Compiles configuration place-holders in all variables. This 'walks' - * through the variable group 'general'. It interprets all values from that - * variables as configuration entries after compiling them. - * - * @return void - */ - public final function compileConfigInVariables () { - // Do we have the stack? - if (!$this->isVarStackSet('general')) { - // Abort here silently - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: Aborted, variable stack general not found!'); - return; - } // END - if - - // Iterate through all general variables - foreach ($this->getVarStack('general') as $index => $currVariable) { - // Compile the value - $value = $this->compileRawCode($this->readVariable($currVariable['name']), TRUE); - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: name=' . $currVariable['name'] . ',value=' . $value); - - // Remove it from stack - $this->removeVariable($currVariable['name'], 'general'); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: value='. $value . ',name=' . $currVariable['name'] . ',index=' . $index); - - // Is it a configuration key? - if ($this->getConfigInstance()->isConfigurationEntrySet($value)) { - // The value itself is a configuration entry - $this->assignConfigVariable($value); - } else { - // Re-assign the value directly - $this->assignVariable($currVariable['name'], $value); - } - } // END - foreach - } - - /** - * Compile all variables by inserting their respective values - * - * @return void - * @todo Make this code some nicer... - */ - public final function compileVariables () { - // Initialize the $content array - $validVar = $this->getConfigInstance()->getConfigEntry('tpl_valid_var'); - $dummy = array(); - - // Iterate through all general variables - foreach ($this->getVarStack('general') as $currVariable) { - // Transfer it's name/value combination to the $content array - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:' . $currVariable['name'] . '=
' . htmlentities($currVariable['value']).'
'); - $dummy[$currVariable['name']] = $currVariable['value']; - }// END - if - - // Set the new variable (don't remove the second dollar!) - $$validVar = $dummy; - - // Remove some variables - unset($index); - unset($currVariable); - - // Run the compilation three times to get content from helper classes in - $cnt = 0; - while ($cnt < 3) { - // Finalize the compilation of template variables - $this->finalizeVariableCompilation(); - - // Prepare the eval() command for comiling the template - $eval = sprintf('$result = "%s";', - addslashes($this->getRawTemplateData()) - ); - - // This loop does remove the backslashes (\) in PHP parameters - while (strpos($eval, $this->codeBegin) !== FALSE) { - // Get left part before "codeBegin)); - - // Get all from right of "codeBegin) + 5)); - - // Cut middle part out and remove escapes - $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, $this->codeEnd))); - $evalMiddle = stripslashes($evalMiddle); - - // Remove the middle part from right one - $evalRight = substr($evalRight, (strpos($evalRight, $this->codeEnd) + 2)); - - // And put all together - $eval = sprintf('%s<%%php %s %%>%s', $evalLeft, $evalMiddle, $evalRight); - } // END - while - - // Prepare PHP code for eval() command - $eval = str_replace( - '<%php', '";', - str_replace( - '%>', - "\n\$result .= \"", - $eval - ) - ); - - // Run the constructed command. This will "compile" all variables in - eval($eval); - - // Goes something wrong? - if ((!isset($result)) || (empty($result))) { - // Output eval command - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('Failed eval() code:
%s
', $this->markupCode($eval, TRUE)), TRUE); - - // Output backtrace here - $this->debugBackTrace(); - } // END - if - - // Set raw template data - $this->setRawTemplateData($result); - $cnt++; - } // END - while - - // Final variable assignment - $this->finalizeVariableCompilation(); - - // Set the new content - $this->setCompiledData($this->getRawTemplateData()); - } - - /** - * Compile all required templates into the current loaded one - * - * @return void - * @throws UnexpectedTemplateTypeException If the template type is - * not "code" - * @throws InvalidArrayCountException If an unexpected array - * count has been found - */ - public function compileTemplate () { - // Get code type to make things shorter - $codeType = $this->getConfigInstance()->getConfigEntry('code_' . self::getResponseTypeFromSystem() . '_template_type'); - - // We will only work with template type "code" from configuration - if (substr($this->getTemplateType(), 0, strlen($codeType)) != $codeType) { - // Abort here - throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->getConfigEntry('code_' . self::getResponseTypeFromSystem() . '_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED); - } // END - if - - // Get the raw data. - $rawData = $this->getRawTemplateData(); - - // Remove double spaces and trim leading/trailing spaces - $rawData = trim(str_replace(' ', ' ', $rawData)); - - // Search for raw variables - $this->extractVariablesFromRawData($rawData); - - // Search for code-tags which are {? ?} - preg_match_all($this->regExpCodeTags, $rawData, $templateMatches); - - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:templateMatches=' . print_r($templateMatches , TRUE)); - - // Analyze the matches array - if ((is_array($templateMatches)) && (count($templateMatches) == 4) && (count($templateMatches[0]) > 0)) { - // Entries are found: - // - // The main analysis - $this->analyzeTemplate($templateMatches); - - // Compile raw template data - $this->compileRawTemplateData($templateMatches); - - // Are there some raw templates left for loading? - $this->loadExtraRawTemplates(); - - // Are some raw templates found and loaded? - if (count($this->rawTemplates) > 0) { - // Insert all raw templates - $this->insertRawTemplates(); - - // Remove the raw template content as well - $this->setRawTemplateData(''); - } // END - if - } // END - if($templateMatches ... - } - - /** - * Loads a given view helper (by name) - * - * @param $helperName The helper's name - * @return void - */ - protected function loadViewHelper ($helperName) { - // Is this view helper loaded? - if (!isset($this->helpers[$helperName])) { - // Create a class name - $className = self::convertToClassName($helperName) . 'ViewHelper'; - - // Generate new instance - $this->helpers[$helperName] = ObjectFactory::createObjectByName($className); - } // END - if - - // Return the requested instance - return $this->helpers[$helperName]; - } - - /** - * Transfers the content of this template engine to a given response instance - * - * @param $responseInstance An instance of a response class - * @return void - */ - public function transferToResponse (Responseable $responseInstance) { - // Get the content and set it in response class - $responseInstance->writeToBody($this->getCompiledData()); - } - - /** - * "Compiles" a variable by replacing {?var?} with it's content - * - * @param $rawCode Raw code to compile - * @param $setMatchAsCode Sets $match if readVariable() returns empty result - * @return $rawCode Compile code with inserted variable value - */ - public function compileRawCode ($rawCode, $setMatchAsCode=FALSE) { - // Find the variables - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:rawCode=
' . htmlentities($rawCode) . '
'); - preg_match_all($this->regExpVarValue, $rawCode, $varMatches); - - // Compile all variables - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:
' . print_r($varMatches, TRUE) . '
'); - foreach ($varMatches[0] as $match) { - // Add variable tags around it - $varCode = '{?' . $match . '?}'; - - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:varCode=' . $varCode); - - // Is the variable found in code? (safes some calls) - if (strpos($rawCode, $varCode) !== FALSE) { - // Debug message - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: match=' . $match . ',rawCode[' . gettype($rawCode) . ']=' . $rawCode); - - // Use $match as new value or $value from read variable? - if ($setMatchAsCode === TRUE) { - // Insert match - $rawCode = str_replace($varCode, $match, $rawCode); - } else { - // Read the variable - $value = $this->readVariable($match); - - // Insert value - $rawCode = str_replace($varCode, $value, $rawCode); - } - } // END - if - } // END - foreach - - // Return the compiled data - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:rawCode=
' . htmlentities($rawCode) . '
'); - return $rawCode; - } - - /** - * Getter for variable group array - * - * @return $variableGroups All variable groups - */ - public final function getVariableGroups () { - return $this->variableGroups; - } - - /** - * Renames a variable in code and in stack - * - * @param $oldName Old name of variable - * @param $newName New name of variable - * @return void - */ - public function renameVariable ($oldName, $newName) { - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: oldName=' . $oldName . ', newName=' . $newName); - // Get raw template code - $rawData = $this->getRawTemplateData(); - - // Replace it - $rawData = str_replace($oldName, $newName, $rawData); - - // Set the code back - $this->setRawTemplateData($rawData); - } - - /** - * Renders the given XML content - * - * @param $content Valid XML content or if not set the current loaded raw content - * @return void - * @throws XmlParserException If an XML error was found - */ - public function renderXmlContent ($content = NULL) { - // Is the content set? - if (is_null($content)) { - // Get current content - $content = $this->getRawTemplateData(); - } // END - if - - // Get a XmlParser instance - $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this)); - - // Check if XML compacting is enabled - if ($this->isXmlCompactingEnabled()) { - // Yes, so get a decorator class for transparent compacting - $parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', array($parserInstance)); - } // END - if - - // Parse the XML document - $parserInstance->parseXmlContent($content); - } - - /** - * Enables or disables language support - * - * @param $languageSupport New language support setting - * @return void - */ - public final function enableLanguageSupport ($languageSupport = TRUE) { - $this->languageSupport = (bool) $languageSupport; - } - - /** - * Checks whether language support is enabled - * - * @return $languageSupport Whether language support is enabled or disabled - */ - public final function isLanguageSupportEnabled () { - return $this->languageSupport; - } - - /** - * Enables or disables XML compacting - * - * @param $xmlCompacting New XML compacting setting - * @return void - */ - public final function enableXmlCompacting ($xmlCompacting = TRUE) { - $this->xmlCompacting = (bool) $xmlCompacting; - } - - /** - * Checks whether XML compacting is enabled - * - * @return $xmlCompacting Whether XML compacting is enabled or disabled - */ - public final function isXmlCompactingEnabled () { - return $this->xmlCompacting; - } - - /** - * Removes all commentd, tabs and new-line characters to compact the content - * - * @param $uncompactedContent The uncompacted content - * @return $compactedContent The compacted content - */ - public function compactContent ($uncompactedContent) { - // First, remove all tab/new-line/revert characters - $compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent))); - - // Then regex all comments like away - preg_match_all($this->regExpComments, $compactedContent, $matches); - - // Do we have entries? - if (isset($matches[0][0])) { - // Remove all - foreach ($matches[0] as $match) { - // Remove the match - $compactedContent = str_replace($match, '', $compactedContent); - } // END - foreach - } // END - if - - // Set the content again - $this->setRawTemplateData($compactedContent); - - // Return compacted content - return $compactedContent; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/template/console/.htaccess b/inc/classes/main/template/console/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/template/console/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/template/console/class_ConsoleTemplateEngine.php b/inc/classes/main/template/console/class_ConsoleTemplateEngine.php deleted file mode 100644 index 4a55c273..00000000 --- a/inc/classes/main/template/console/class_ConsoleTemplateEngine.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createConsoleTemplateEngine () { - // Get a new instance - $templateInstance = new ConsoleTemplateEngine(); - - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Determine base path - $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $templateInstance->setTemplateBasePath($templateBasePath); - - // Set template extensions - $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); - $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); - - // Absolute output path for compiled templates - $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); - - // Return the prepared instance - return $templateInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/template/html/.htaccess b/inc/classes/main/template/html/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/template/html/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/template/html/class_HtmlTemplateEngine.php b/inc/classes/main/template/html/class_HtmlTemplateEngine.php deleted file mode 100644 index f1d758a5..00000000 --- a/inc/classes/main/template/html/class_HtmlTemplateEngine.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HtmlTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createHtmlTemplateEngine () { - // Get a new instance - $templateInstance = new HtmlTemplateEngine(); - - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Determine base path - $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $templateInstance->setTemplateBasePath($templateBasePath); - - // Set template extensions - $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); - $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); - - // Absolute output path for compiled templates - $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); - - // Return the prepared instance - return $templateInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/template/image/.htaccess b/inc/classes/main/template/image/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/template/image/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php deleted file mode 100644 index 3b7b8da0..00000000 --- a/inc/classes/main/template/image/class_ImageTemplateEngine.php +++ /dev/null @@ -1,505 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { - /** - * Main nodes in the XML tree ('image' is ignored) - */ - private $mainNodes = array( - 'base', - 'type', - 'resolution', - 'background-color', - 'foreground-color', - 'image-string' - ); - - /** - * Sub nodes in the XML tree - */ - private $subNodes = array( - 'name', - 'string-name', - 'x', - 'y', - 'font-size', - 'width', - 'height', - 'red', - 'green', - 'blue', - 'text' - ); - - /** - * Current main node - */ - private $currMainNode = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createImageTemplateEngine () { - // Get a new instance - $templateInstance = new ImageTemplateEngine(); - - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Determine base path - $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $templateInstance->setTemplateBasePath($templateBasePath); - - // Set template extensions - $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); - $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); - - // Absolute output path for compiled templates - $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Getter for current main node - * - * @return $currMainNode Current main node - */ - public final function getCurrMainNode () { - return $this->currMainNode; - } - - /** - * Getter for main node array - * - * @return $mainNodes Array with valid main node names - */ - public final function getMainNodes () { - return $this->mainNodes; - } - - /** - * Getter for sub node array - * - * @return $subNodes Array with valid sub node names - */ - public final function getSubNodes () { - return $this->subNodes; - } - - /** - * Handles the start element of an XML resource - * - * @param $resource XML parser resource (currently ignored) - * @param $element The element we shall handle - * @param $attributes All attributes - * @return void - * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found - */ - public function startElement ($resource, $element, array $attributes) { - // Initial method name which will never be called... - $methodName = 'initImage'; - - // Make the element name lower-case - $element = strtolower($element); - - // Is the element a main node? - //* DEBUG: */ echo "START: >".$element."<
\n"; - if (in_array($element, $this->mainNodes)) { - // Okay, main node found! - $methodName = 'setImage' . self::convertToClassName($element); - } elseif (in_array($element, $this->subNodes)) { - // Sub node found - $methodName = 'setImageProperty' . self::convertToClassName($element); - } elseif ($element != 'image') { - // Invalid node name found - throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); - } - - // Call method - //* DEBUG: */ echo "call: ".$methodName."
\n"; - call_user_func_array(array($this, $methodName), $attributes); - } - - /** - * Ends the main or sub node by sending out the gathered data - * - * @param $resource An XML resource pointer (currently ignored) - * @param $nodeName Name of the node we want to finish - * @return void - * @throws XmlNodeMismatchException If current main node mismatches the closing one - */ - public function finishElement ($resource, $nodeName) { - // Make all lower-case - $nodeName = strtolower($nodeName); - - // Does this match with current main node? - //* DEBUG: */ echo "END: >".$nodeName."<
\n"; - if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { - // Did not match! - throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); - } elseif (in_array($nodeName, $this->getSubNodes())) { - // Silently ignore sub nodes - return; - } - - // Construct method name - $methodName = 'finish' . self::convertToClassName($nodeName); - - // Call the corresponding method - call_user_func_array(array($this->getImageInstance(), $methodName), array()); - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something usefull with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Unfinished work! - $this->partialStub('Handling extra characters is not yet supported!'); - } - - /** - * Intializes the image - * - * @return void - * @todo Add cache creation here - */ - private function initImage () { - // Unfinished work! - } - - /** - * Set the image type - * - * @param $imageType Code fragment or direct value holding the image type - * @return void - */ - private function setImageType ($imageType) { - // Set group to general - $this->setVariableGroup('general'); - - // Try to compile it first to get the value from variable stack - $imageType = $this->compileRawCode($imageType); - - // Now make a class name of it - $className = self::convertToClassName($imageType.'_image'); - - // And try to initiate it - $this->setImageInstance(ObjectFactory::createObjectByName($className, array($this))); - - // Set current main node to type - $this->currMainNode = 'type'; - } - - /** - * "Setter" for resolution, we first need to collect the resolution from the - * sub-nodes. So first, this method will prepare an array for it - * - * @return void - */ - private function setImageResolution () { - // Call the image class - $this->getImageInstance()->initResolution(); - - // Current main node is resolution - $this->currMainNode = 'resolution'; - } - - /** - * "Setter" for base information. For more details see above method! - * - * @return void - * @see ImageTemplateEngine::setImageResolution - */ - private function setImageBase () { - // Call the image class - $this->getImageInstance()->initBase(); - - // Current main node is resolution - $this->currMainNode = 'base'; - } - - /** - * "Setter" for background-color. For more details see above method! - * - * @return void - * @see ImageTemplateEngine::setImageResolution - */ - private function setImageBackgroundColor () { - // Call the image class - $this->getImageInstance()->initBackgroundColor(); - - // Current main node is background-color - $this->currMainNode = 'background-color'; - } - - /** - * "Setter" for foreground-color. For more details see above method! - * - * @return void - * @see ImageTemplateEngine::setImageResolution - */ - private function setImageForegroundColor () { - // Call the image class - $this->getImageInstance()->initForegroundColor(); - - // Current main node is foreground-color - $this->currMainNode = 'foreground-color'; - } - - /** - * "Setter" for image-string. For more details see above method! - * - * @param $groupable Whether this image string is groupable - * @return void - * @see ImageTemplateEngine::setImageResolution - */ - private function setImageImageString ($groupable = 'single') { - // Call the image class - $this->getImageInstance()->initImageString($groupable); - - // Current main node is foreground-color - $this->currMainNode = 'image-string'; - } - - /** - * Setter for image name - * - * @param $imageName Name of the image - * @return void - */ - private function setImagePropertyName ($imageName) { - // Call the image class - $this->getImageInstance()->setImageName($imageName); - } - - /** - * Setter for image width - * - * @param $width Width of the image or variable - * @return void - */ - private function setImagePropertyWidth ($width) { - // Call the image class - $this->getImageInstance()->setWidth($width); - } - - /** - * Setter for image height - * - * @param $height Height of the image or variable - * @return void - */ - private function setImagePropertyHeight ($height) { - // Call the image class - $this->getImageInstance()->setHeight($height); - } - - /** - * Setter for image red color - * - * @param $red Red color value - * @return void - */ - private function setImagePropertyRed ($red) { - // Call the image class - $this->getImageInstance()->setRed($red); - } - - /** - * Setter for image green color - * - * @param $green Green color value - * @return void - */ - private function setImagePropertyGreen ($green) { - // Call the image class - $this->getImageInstance()->setGreen($green); - } - - /** - * Setter for image blue color - * - * @param $blue Blue color value - * @return void - */ - private function setImagePropertyBlue ($blue) { - // Call the image class - $this->getImageInstance()->setBlue($blue); - } - - /** - * Setter for string name (identifier) - * - * @param $stringName String name (identifier) - * @return void - */ - private function setImagePropertyStringName ($stringName) { - // Call the image class - $this->getImageInstance()->setStringName($stringName); - } - - /** - * Setter for font size - * - * @param $fontSize Size of the font - * @return void - */ - private function setImagePropertyFontSize ($fontSize) { - // Call the image class - $this->getImageInstance()->setFontSize($fontSize); - } - - /** - * Setter for image string - * - * @param $imageString Image string to set - * @return void - */ - private function setImagePropertyText ($imageString) { - // Call the image class - $this->getImageInstance()->setString($imageString); - } - - /** - * Setter for X coordinate - * - * @param $x X coordinate - * @return void - */ - private function setImagePropertyX ($x) { - // Call the image class - $this->getImageInstance()->setX($x); - } - - /** - * Setter for Y coordinate - * - * @param $y Y coordinate - * @return void - */ - private function setImagePropertyY ($y) { - // Call the image class - $this->getImageInstance()->setY($y); - } - - /** - * Getter for image cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the image cache - */ - public function getImageCacheFqfn () { - // Get the FQFN ready - $fqfn = sprintf('%s%s%s/%s.%s', - $this->getConfigInstance()->getConfigEntry('base_path'), - $this->getGenericBasePath(), - 'images/_cache', - md5( - $this->getImageInstance()->getImageName() . ':' . $this->__toString() . ':' . $this->getImageInstance()->__toString() - ), - $this->getImageInstance()->getImageType() - ); - - // Return it - return $fqfn; - } - - /** - * Outputs the image to the world - * - * @param $responseInstance An instance of a Responseable class - * @return void - */ - public function transferToResponse (Responseable $responseInstance) { - // Set the image instance - $responseInstance->setImageInstance($this->getImageInstance()); - } - - /** - * Load a specified image template into the engine - * - * @param $template The image template we shall load which is - * located in 'image' by default - * @return void - */ - public function loadImageTemplate ($template) { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('image_template_type')); - - // Load the special template - $this->loadTemplate($template); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/template/mail/.htaccess b/inc/classes/main/template/mail/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/template/mail/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/template/mail/class_MailTemplateEngine.php b/inc/classes/main/template/mail/class_MailTemplateEngine.php deleted file mode 100644 index 90ae7ccd..00000000 --- a/inc/classes/main/template/mail/class_MailTemplateEngine.php +++ /dev/null @@ -1,359 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo This template engine does not make use of setTemplateType() - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MailTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { - /** - * Main nodes in the XML tree - */ - private $mainNodes = array( - 'mail-data' - ); - - /** - * Sub nodes in the XML tree - */ - private $subNodes = array( - 'subject-line', - 'sender-address', - 'recipient-address', - 'message' - ); - - /** - * Mailer instance - */ - private $mailerInstance = NULL; - - /** - * Current main node - */ - private $currMainNode = ''; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createMailTemplateEngine () { - // Get a new instance - $templateInstance = new MailTemplateEngine(); - - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Determine base path - $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $templateInstance->setTemplateBasePath($templateBasePath); - - // Set template extensions - $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); - $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); - - // Absolute output path for compiled templates - $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Getter for current main node - * - * @return $currMainNode Current main node - */ - public final function getCurrMainNode () { - return $this->currMainNode; - } - - /** - * Getter for main node array - * - * @return $mainNodes Array with valid main node names - */ - public final function getMainNodes () { - return $this->mainNodes; - } - - /** - * Getter for sub node array - * - * @return $subNodes Array with valid sub node names - */ - public final function getSubNodes () { - return $this->subNodes; - } - - /** - * Handles the start element of an XML resource - * - * @param $resource XML parser resource (currently ignored) - * @param $element The element we shall handle - * @param $attributes All attributes - * @return void - * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found - */ - public function startElement ($resource, $element, array $attributes) { - // Initial method name which will never be called... - $methodName = 'initEmail'; - - // Make the element name lower-case - $element = strtolower($element); - - // Is the element a main node? - //* DEBUG: */ echo "START: >".$element."<
\n"; - if (in_array($element, $this->getMainNodes())) { - // Okay, main node found! - $methodName = 'setEmail' . self::convertToClassName($element); - } elseif (in_array($element, $this->getSubNodes())) { - // Sub node found - $methodName = 'setEmailProperty' . self::convertToClassName($element); - } elseif ($element != 'text-mail') { - // Invalid node name found - throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); - } - - // Call method - //* DEBUG: */ echo "call: ".$methodName."
\n"; - call_user_func_array(array($this, $methodName), $attributes); - } - - /** - * Ends the main or sub node by sending out the gathered data - * - * @param $resource An XML resource pointer (currently ignored) - * @param $nodeName Name of the node we want to finish - * @return void - * @throws XmlNodeMismatchException If current main node mismatches the closing one - */ - public function finishElement ($resource, $nodeName) { - // Make all lower-case - $nodeName = strtolower($nodeName); - - // Does this match with current main node? - //* DEBUG: */ echo "END: >".$nodeName."<
\n"; - if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { - // Did not match! - throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); - } elseif (in_array($nodeName, $this->getSubNodes())) { - // Silently ignore sub nodes - return; - } - - // Construct method name - $methodName = 'finish' . self::convertToClassName($nodeName); - - // Call the corresponding method - call_user_func_array(array($this, $methodName), array()); - } - - /** - * Adds the message text to the template engine - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Add the message now - $this->assignVariable('message', $characters); - } - - /** - * Intializes the mail - * - * @return void - * @todo Add cache creation here - */ - private function initEmail () { - // Unfinished work! - } - - /** - * Setter for mail data node - * - * @return void - * @todo Should we call back the mailer class here? - */ - private function setEmailMailData () { - // Set current main node - $this->currMainNode = 'mail-data'; - } - - /** - * Setter for sender address property - * - * @param $senderAddress Sender address to set in email - * @return void - */ - private function setEmailPropertySenderAddress ($senderAddress) { - // Set the template variable - $this->assignVariable('sender', $senderAddress); - } - - /** - * Setter for recipient address property - * - * @param $recipientAddress Recipient address to set in email - * @return void - */ - private function setEmailPropertyRecipientAddress ($recipientAddress) { - // Set the template variable - $this->assignVariable('recipient', $recipientAddress); - } - - /** - * Setter for subject line property - * - * @return void - */ - private function setEmailPropertySubjectLine () { - // Empty for now - } - - /** - * Method stub to avoid output - * - * @return void - */ - private function setEmailPropertyMessage () { - // Empty for now - } - - /** - * Gets the template variable "message", stores it back as raw template data - * and compiles all variables so the mail message got prepared for output - * - * @return void - */ - private function finishMailData () { - // Get the message and set it as new raw template data back - $message = $this->readVariable('message'); - $this->setRawTemplateData($message); - - // Get some variables to compile - //$sender = $this->compileRawCode($this->readVariable('sender')); - //$this->assignVariable('sender', $sender); - - // Then compile all variables - $this->compileVariables(); - } - - /** - * Invokes the final mail process - * - * @return void - */ - private function finishTextMail () { - $this->getMailerInstance()->invokeMailDelivery(); - } - - /** - * Getter for image cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the image cache - * @todo 0% done - */ - public function getMailCacheFqfn () { - // Initialize FQFN - $fqfn = ''; - $this->debugBackTrace('Unfinished area!'); - - // Return it - return $fqfn; - } - - /** - * Setter for mailer instance - * - * @param $mailerInstance A mailer instance - * @return void - */ - public final function setMailerInstance (DeliverableMail $mailerInstance) { - $this->mailerInstance = $mailerInstance; - } - - /** - * Getter for mailer instance - * - * @return $mailerInstance A mailer instance - */ - protected final function getMailerInstance () { - return $this->mailerInstance; - } - - /** - * Outputs the mail to the world. This should only the mailer debug class do! - * - * @param $responseInstance An instance of a Responseable class - * @return void - */ - public function transferToResponse (Responseable $responseInstance) { - $responseInstance->writeToBody($this->getCompiledData()); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/template/menu/.htaccess b/inc/classes/main/template/menu/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/template/menu/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/template/menu/class_MenuTemplateEngine.php b/inc/classes/main/template/menu/class_MenuTemplateEngine.php deleted file mode 100644 index f0237b1e..00000000 --- a/inc/classes/main/template/menu/class_MenuTemplateEngine.php +++ /dev/null @@ -1,877 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { - /** - * Main nodes in the XML tree ('menu' is ignored) - */ - private $mainNodes = array( - 'block-list', - ); - - /** - * Sub nodes in the XML tree - */ - private $subNodes = array( - 'entry-list', - 'entry', - 'entry-id', - 'entries-content', - 'block-header', - 'block-footer', - 'footer-id', - 'footer-class', - 'footer-text', - 'block', - 'title', - 'title-id', - 'title-class', - 'title-text', - 'design', - 'text', - 'advert', - 'anchor', - 'anchor-id', - 'anchor-text', - 'anchor-title', - 'anchor-href', - ); - - /** - * Variables for a menu entry - */ - private $menuEntryVariables = array( - // List entry - 'entry_id', - // Anchor - 'anchor-id', - 'anchor-text', - 'anchor-title', - 'anchor-href', - ); - - /** - * Variables for a menu block - */ - private $menuBlockVariables = array( - // Title - 'title_id', - 'title_class', - 'title_text', - // Content is taken from menuEntries - // Footer - 'footer_id', - 'footer_class', - 'footer_text', - ); - - /** - * Rendered menu entries - */ - private $menuEntries = array(); - - /** - * Rendered menu blocks - */ - private $menuBlocks = array(); - - /** - * Menu instance - */ - private $menuInstance = NULL; - - /** - * Current main node - */ - private $curr = array(); - - /** - * Content from dependency - */ - private $dependencyContent = array(); - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of the class TemplateEngine and prepares it for usage - * - * @param $menuInstance A RenderableMenu instance - * @return $templateInstance An instance of TemplateEngine - * @throws BasePathIsEmptyException If the provided $templateBasePath is empty - * @throws InvalidBasePathStringException If $templateBasePath is no string - * @throws BasePathIsNoDirectoryException If $templateBasePath is no - * directory or not found - * @throws BasePathReadProtectedException If $templateBasePath is - * read-protected - */ - public static final function createMenuTemplateEngine (RenderableMenu $menuInstance) { - // Get a new instance - $templateInstance = new MenuTemplateEngine(); - - // Get the application instance from registry - $applicationInstance = Registry::getRegistry()->getInstance('app'); - - // Determine base path - $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; - - // Is the base path valid? - if (empty($templateBasePath)) { - // Base path is empty - throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } elseif (!is_string($templateBasePath)) { - // Is not a string - throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); - } elseif (!is_dir($templateBasePath)) { - // Is not a path - throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); - } elseif (!is_readable($templateBasePath)) { - // Is not readable - throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); - } - - // Set the base path - $templateInstance->setTemplateBasePath($templateBasePath); - - // Set template extensions - $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); - $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('menu_template_extension')); - - // Absolute output path for compiled templates - $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); - - // Set the menu instance - $templateInstance->setMenuInstance($menuInstance); - - // Init a variable stacker - $stackInstance = ObjectFactory::createObjectByConfiguredName('menu_stacker_class'); - - // Set it - $templateInstance->setStackInstance($stackInstance); - - // Return the prepared instance - return $templateInstance; - } - - /** - * Load a specified menu template into the engine - * - * @param $template The menu template we shall load which is - * located in 'menu' by default - * @return void - */ - public function loadMenuTemplate ($template) { - // Set template type - $this->setTemplateType($this->getConfigInstance()->getConfigEntry('menu_template_type')); - - // Load the special template - $this->loadTemplate($template); - } - - /** - * Getter for current main node - * - * @return $currMainNode Current main node - */ - public final function getCurrMainNode () { - return $this->curr['main_node']; - } - - /** - * Setter for current main node - * - * @param $element Element name to set as current main node - * @return $currMainNode Current main node - */ - private final function setCurrMainNode ($element) { - $this->curr['main_node'] = (string) $element; - } - - /** - * Getter for main node array - * - * @return $mainNodes Array with valid main node names - */ - public final function getMainNodes () { - return $this->mainNodes; - } - - /** - * Getter for sub node array - * - * @return $subNodes Array with valid sub node names - */ - public final function getSubNodes () { - return $this->subNodes; - } - - /** - * Handles the start element of an XML resource - * - * @param $resource XML parser resource (currently ignored) - * @param $element The element we shall handle - * @param $attributes All attributes - * @return void - * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found - */ - public function startElement ($resource, $element, array $attributes) { - // Initial method name which will never be called... - $methodName = 'initMenu'; - - // Make the element name lower-case - $element = strtolower($element); - - // Is the element a main node? - //* DEBUG: */ echo "START: >".$element."<
\n"; - if (in_array($element, $this->getMainNodes())) { - // Okay, main node found! - $methodName = 'start' . self::convertToClassName($element); - - // Set it - $this->setCurrMainNode($element); - } elseif (in_array($element, $this->getSubNodes())) { - // Sub node found - $methodName = 'start' . self::convertToClassName($element); - } elseif ($element != 'menu') { - // Invalid node name found - throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); - } - - // Call method - //* DEBUG: */ echo "call: ".$methodName."
\n"; - call_user_func_array(array($this, $methodName), $attributes); - } - - /** - * Ends the main or sub node by sending out the gathered data - * - * @param $resource An XML resource pointer (currently ignored) - * @param $nodeName Name of the node we want to finish - * @return void - * @throws XmlNodeMismatchException If current main node mismatches the closing one - */ - public function finishElement ($resource, $nodeName) { - // Make all lower-case - $nodeName = strtolower($nodeName); - - // Does this match with current main node? - //* DEBUG: */ echo "END: >".$nodeName."<
\n"; - if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { - // Did not match! - throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); - } // END - if - - // Construct method name - $methodName = 'finish' . self::convertToClassName($nodeName); - - // Call the corresponding method - //* DEBUG: */ echo "call: ".$methodName."
\n"; - call_user_func_array(array($this, $methodName), array()); - } - - /** - * Currently not used - * - * @param $resource XML parser resource (currently ignored) - * @param $characters Characters to handle - * @return void - * @todo Find something useful with this! - */ - public function characterHandler ($resource, $characters) { - // Trim all spaces away - $characters = trim($characters); - - // Is this string empty? - if (empty($characters)) { - // Then skip it silently - return; - } // END - if - - // Assign the found characters to variable and use the last entry from - // stack as the name - parent::assignVariable($this->getStackInstance()->getNamed('current_node'), $characters); - } - - /** - * Handles the template dependency for given node - * - * @param $node The node we should load a dependency template - * @param $templateDependency A template to load to satisfy dependencies - * @return void - */ - private function handleTemplateDependency ($node, $templateDependency) { - // Is the template dependency set? - if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { - // Get a temporay menu template instance - $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this->getMenuInstance())); - - // Then load it - $templateInstance->loadMenuTemplate($templateDependency); - - // Parse the XML content - $templateInstance->renderXmlContent(); - - // Save the parsed raw content in our dependency array - $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); - } // END - if - } - - /** - * Intializes the menu - * - * @param $templateDependency A template to load to satisfy dependencies - * @return void - * @todo Add cache creation here - */ - private function initMenu ($templateDependency = '') { - // Get web template engine - $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array($this->getApplicationInstance()))); - - // Handle the dependency template - $this->handleTemplateDependency('menu', $templateDependency); - - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'menu'); - } - - /** - * Starts the menu entries - * - * @param $templateDependency A template to load to satisfy dependencies - * @return void - */ - private function startEntryList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'entry-list'); - } - - /** - * Starts the menu block header - * - * @return void - */ - private function startBlockHeader () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'block-header'); - } - - /** - * Starts the menu block footer - * - * @return void - */ - private function startBlockFooter () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'block-footer'); - } - - /** - * Starts the menu property 'block-list' - * - * @return void - */ - private function startBlockList () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'block-list'); - } - - /** - * Starts the menu property 'block' - * - * @return void - */ - private function startBlock () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'block'); - } - - /** - * Starts the menu property 'title' - * - * @return void - */ - private function startTitle () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'title'); - } - - /** - * Starts the menu property 'title-id' - * - * @return void - */ - private function startTitleId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'title-id'); - } - - /** - * Starts the menu property 'title-class' - * - * @return void - */ - private function startTitleClass () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'title-class'); - } - - /** - * Starts the menu property 'title-text' - * - * @return void - */ - private function startTitleText () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'title-text'); - } - - /** - * Starts the menu property 'entry' - * - * @return void - */ - private function startEntry () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'entry'); - } - - /** - * Starts the menu property 'entry-id' - * - * @return void - */ - private function startEntryId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'entry-id'); - } - - /** - * Starts the menu property 'anchor' - * - * @return void - */ - private function startAnchor () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'anchor'); - } - - /** - * Starts the menu property 'anchor-id' - * - * @return void - */ - private function startAnchorId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'anchor-id'); - } - - /** - * Starts the menu property 'anchor-text' - * - * @return void - */ - private function startAnchorText () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'anchor-text'); - } - - /** - * Starts the menu property 'anchor-title' - * - * @return void - */ - private function startAnchorTitle () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'anchor-title'); - } - - /** - * Starts the menu property 'anchor-href' - * - * @return void - */ - private function startAnchorHref () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'anchor-href'); - } - - /** - * Starts the menu property 'footer-id' - * - * @return void - */ - private function startFooterId () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'footer-id'); - } - - /** - * Starts the menu property 'footer-class' - * - * @return void - */ - private function startFooterClass () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'footer-class'); - } - - /** - * Starts the menu property 'footer-text' - * - * @return void - */ - private function startFooterText () { - // Push the node name on the stacker - $this->getStackInstance()->pushNamed('current_node', 'footer-text'); - } - - /** - * Finishes the title node by added another template to the menu - * - * @return void - */ - private function finishTitle () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the title-id node by - * - * @return void - */ - private function finishTitleId () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the title-class node - * - * @return void - */ - private function finishTitleClass () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the title-class node - * - * @return void - */ - private function finishTitleText () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the footer-text node - * - * @return void - */ - private function finishFooterText () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the footer-class node - * - * @return void - */ - private function finishFooterClass () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the footer-id node - * - * @return void - */ - private function finishFooterId () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the anchor-href node - * - * @return void - */ - private function finishAnchorHref () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the anchor-title node - * - * @return void - */ - private function finishAnchorTitle () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the anchor-text node - * - * @return void - */ - private function finishAnchorText () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the anchor-id node - * - * @return void - */ - private function finishAnchorId () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the anchor node - * - * @return void - */ - private function finishAnchor () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the entry-id node - * - * @return void - */ - private function finishEntryId () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the entry node - * - * @return void - */ - private function finishEntry () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - - // Render this menu entry - $this->renderMenuEntry(); - } - - /** - * Finishes the block node - * - * @return void - */ - private function finishBlock () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - - // Render this menu block - $this->renderMenuBlock(); - } - - /** - * Finishes the block-list node - * - * @return void - */ - private function finishBlockList () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the menu entries - * - * @return void - */ - private function finishEntryList () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the menu block header - * - * @return void - */ - private function finishBlockHeader () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the menu block footer - * - * @return void - */ - private function finishBlockFooter () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Finishes the menu - * - * @return void - */ - private function finishMenu () { - // Pop the last entry - $this->getStackInstance()->popNamed('current_node'); - } - - /** - * Renders this menu entry, as every block all variables got overwritten - * with data from next entry. - * - * @return void - */ - private function renderMenuEntry () { - // Prepare template engine - $templateInstance = $this->prepareTemplateInstance(); - - // Load menu entry template - $templateInstance->loadCodeTemplate('menu_entry'); - - // Copy all variables over to it - foreach ($this->menuEntryVariables as $variableName) { - // Copy variable - $variableValue = $this->readVariable($variableName); - - // Is the key 'anchor-href'? - if ($variableName == 'anchor-href') { - // Expand variable with URL then - $variableValue = '{?base_url?}/' . $variableValue; - } // END - if - - // ... into the instance - $templateInstance->assignVariable($variableName, $variableValue); - } // END - foreach - - // Compile template + variables - $templateInstance->compileTemplate(); - $templateInstance->compileVariables(); - - // Remember it here - $this->menuEntries[$this->readVariable('entry_id')] = $templateInstance->getRawTemplateData(); - } - - /** - * Renders this menu block, as next block all data is overwritten with - * next block. - * - * @return void - */ - private function renderMenuBlock () { - // Init block content - $blockContent = implode('', $this->menuEntries); - - // Prepare template engine - $templateInstance = $this->prepareTemplateInstance(); - - // Load menu entry template - $templateInstance->loadCodeTemplate('menu_block'); - - // Copy all variables over to it - foreach ($this->menuBlockVariables as $variableName) { - // Copy variable - $variableValue = $this->readVariable($variableName); - - // ... into the instance - $templateInstance->assignVariable($variableName, $variableValue); - } // END - foreach - - // Assign block content - $templateInstance->assignVariable('block_content', $blockContent); - - // Compile template + variables - $templateInstance->compileTemplate(); - $templateInstance->compileVariables(); - - // Remember it here - array_push($this->menuBlocks, $templateInstance->getRawTemplateData()); - - // Reset rendered menu entries array - $this->menuEntries = array(); - } - - /** - * "Getter" for menu content - * - * @return $menuContent Returned menu content - */ - public function getMenuContent () { - // Implode menuBlocks - $menuContent = implode('', $this->menuBlocks); - - // Clean variable - $this->menuBlocks = array(); - - // And return it - return $menuContent; - } - - /** - * Getter for menu cache file (FQFN) - * - * @return $fqfn Full-qualified file name of the menu cache - */ - public function getMenuCacheFqfn () { - // Get the FQFN ready - $fqfn = sprintf('%s%s%s/%s.%s', - $this->getConfigInstance()->getConfigEntry('base_path'), - $this->getGenericBasePath(), - 'menus/_cache', - md5( - $this->getMenuInstance()->getMenuName() . ':' . - $this->__toString() . ':' . - $this->getMenuInstance()->__toString() - ), - $this->getMenuInstance()->getMenuType() - ); - - // Return it - return $fqfn; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/user/.htaccess b/inc/classes/main/user/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/user/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/user/class_BaseUser.php b/inc/classes/main/user/class_BaseUser.php deleted file mode 100644 index bc7988a4..00000000 --- a/inc/classes/main/user/class_BaseUser.php +++ /dev/null @@ -1,363 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseUser extends BaseFrameworkSystem implements Updateable { - // Exception constances - const EXCEPTION_USERNAME_NOT_FOUND = 0x150; - const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151; - const EXCEPTION_USER_PASS_MISMATCH = 0x152; - const EXCEPTION_USER_IS_GUEST = 0x153; - - /** - * Username of current user - */ - private $userName = ''; - - /** - * User id of current user - */ - private $userId = 0; - - /** - * Email of current user - */ - private $email = ''; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for username - * - * @param $userName The username to set - * @return void - */ - public final function setUserName ($userName) { - $this->userName = (string) $userName; - } - - /** - * Getter for username - * - * @return $userName The username to get - */ - public final function getUserName () { - return $this->userName; - } - - /** - * Setter for user id - * - * @param $userId The user id to set - * @return void - * @todo Find a way of casting here. "(int)" might destroy the user id > 32766 - */ - public final function setUserId ($userId) { - $this->userId = $userId; - } - - /** - * Getter for user id - * - * @return $userId The user id to get - */ - public final function getUserId () { - return $this->userId; - } - - /** - * Setter for email - * - * @param $email The email to set - * @return void - */ - protected final function setEmail ($email) { - $this->email = (string) $email; - } - - /** - * Getter for email - * - * @return $email The email to get - */ - public final function getEmail () { - return $this->email; - } - - /** - * Determines whether the username exists or not - * - * @return $exists Whether the username exists - */ - public function ifUsernameExists () { - // By default the username does not exist - $exists = FALSE; - - // Is a previous result there? - if (!$this->getResultInstance() instanceof SearchableResult) { - // Get a UserDatabaseWrapper instance - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); - - // Create a search criteria - $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add the username as a criteria and set limit to one entry - $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); - $criteriaInstance->setLimit(1); - - // Get a search result - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); - - // Set the index "solver" - $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); - - // And finally set it - $this->setResultInstance($resultInstance); - } // END - if - - // Rewind it - $this->getResultInstance()->rewind(); - - // Search for it - if ($this->getResultInstance()->next()) { - // Entry found - $exists = TRUE; - } // END - if - - // Return the status - return $exists; - } - - /** - * Determines whether the email exists or not - * - * @return $exists Whether the email exists - */ - public function ifEmailAddressExists () { - // By default the email does not exist - $exists = FALSE; - - // Is a previous result there? - if (!$this->getResultInstance() instanceof SearchableResult) { - // Get a UserDatabaseWrapper instance - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); - - // Create a search criteria - $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add the username as a criteria and set limit to one entry - $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail()); - $criteriaInstance->setLimit(1); - - // Get a search result - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); - - // Set the index "solver" - $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); - - // And finally set it - $this->setResultInstance($resultInstance); - } // END - if - - // Rewind it - $this->getResultInstance()->rewind(); - - // Search for it - if ($this->getResultInstance()->next()) { - // Entry found - $exists = TRUE; - - // Is the username set? - if ($this->getUserName() == '') { - // Get current entry - $currEntry = $this->getResultInstance()->current(); - - // Set the username - $this->setUserName($currEntry['username']); - } // END - if - } // END - if - - // Return the status - return $exists; - } - - /** - * Checks if supplied password hash in request matches with the stored in - * database. - * - * @param $requestInstance A requestable class instance - * @return $matches Whether the supplied password hash matches - */ - public function ifPasswordHashMatches (Requestable $requestInstance) { - // By default nothing matches... ;) - $matches = FALSE; - - // Is a previous result there? - if ((!$this->getResultInstance() instanceof SearchableResult) || ($this->getResultInstance()->count() == 0)) { - // Get a UserDatabaseWrapper instance - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); - - // Create a search criteria - $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add the username as a criteria and set limit to one entry - $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); - $criteriaInstance->setLimit(1); - - // Get a search result - $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); - - // Set the index "solver" - $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); - - // And finally set it - $this->setResultInstance($resultInstance); - } // END - if - - // Rewind it and advance to first entry - $this->getResultInstance()->rewind(); - - // This call set the result instance to a clean state - $this->getResultInstance()->next(); - - // Search for it - if ($this->getResultInstance()->find('pass_hash')) { - // So does the hashes match? - //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash') . '
' . $this->getResultInstance()->getFoundValue() . '
'; - $matches = ($requestInstance->getRequestElement('pass_hash') === $this->getResultInstance()->getFoundValue()); - } // END - if - - // Return the status - return $matches; - } - - /** - * "Getter" for user's password hash - * - * @return $passHash User's password hash from database result - */ - public final function getPasswordHash () { - // Default is missing password hash - $passHash = NULL; - - // Get a database entry - $entry = $this->getDatabaseEntry(); - - // Is the password hash there? - if (isset($entry['pass_hash'])) { - // Get it - $passHash = $entry['pass_hash']; - } // END - if - - // And return the hash - return $passHash; - } - - /** - * Getter for primary key value - * - * @return $primaryValue Value of the primary key based on database type - */ - public final function getPrimaryKey () { - // Get a user database wrapper - $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); - - // Get the primary key back from the wrapper - $primaryKey = $wrapperInstance->getPrimaryKeyValue(); - - // Get that field - $primaryValue = $this->getField($primaryKey); - - // Return the value - return $primaryValue; - } - - /** - * Updates a given field with new value - * - * @param $fieldName Field to update - * @param $fieldValue New value to store - * @return void - * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem - */ - public function updateDatabaseField ($fieldName, $fieldValue) { - // Get a critieria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add search criteria - $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); - $searchInstance->setLimit(1); - - // Now get another criteria - $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); - - // Add criteria entry which we shall update - $updateInstance->addCriteria($fieldName, $fieldValue); - - // Add the search criteria for searching for the right entry - $updateInstance->setSearchInstance($searchInstance); - - // Set wrapper class name - $updateInstance->setWrapperConfigEntry('user_db_wrapper_class'); - - // Remember the update in database result - $this->getResultInstance()->add2UpdateQueue($updateInstance); - } - - /** - * Checks whether the user status is 'confirmed' - * - * @return $isConfirmed Whether the user status is 'confirmed' - */ - public function isConfirmed () { - // Determine it - $isConfirmed = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == $this->getConfigInstance()->getConfigEntry('user_status_confirmed')); - - // Return it - return $isConfirmed; - } - - /** - * Checks whether the user status is 'guest' - * - * @return $isGuest Whether the user status is 'guest' - */ - public function isGuest () { - // Determine it - $isGuest = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == $this->getConfigInstance()->getConfigEntry('user_status_guest')); - - // Return it - return $isGuest; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/user/guest/.htaccess b/inc/classes/main/user/guest/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/user/guest/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/user/guest/class_Guest.php b/inc/classes/main/user/guest/class_Guest.php deleted file mode 100644 index 6fdefc7f..00000000 --- a/inc/classes/main/user/guest/class_Guest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Guest extends BaseUser implements ManageableGuest, Registerable { - // Exceptions - const EXCEPTION_USERNAME_NOT_FOUND = 0x170; - const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171; - const EXCEPTION_USER_PASS_MISMATCH = 0x172; - const EXCEPTION_USER_NOT_GUEST = 0x173; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates a user by a given request instance - * - * @param $requestInstance An instance of a Requestable class - * @return $userInstance An instance of this user class - * @todo Add more ways over creating user classes - */ - public static final function createGuestByRequest (Requestable $requestInstance) { - // Determine if by email or username - if (!is_null($requestInstance->getRequestElement('username'))) { - // Username supplied - $userInstance = self::createGuestByUserName($requestInstance->getRequestElement('username')); - } elseif (!is_null($requestInstance->getRequestElement('email'))) { - // Email supplied - $userInstance = self::createGuestByEmail($requestInstance->getRequestElement('email')); - } else { - // Unsupported mode - $userInstance = new Guest(); - $userInstance->debugBackTrace('More ways of creating user classes are needed here.'); - exit(); - } - - // Return the prepared instance - return $userInstance; - } - - /** - * Creates an instance of this user class by a provided username. This - * factory method will check if username is already taken and if not so it - * will throw an exception. - * - * @param $userName Username we need a class instance for - * @return $userInstance An instance of this user class - * @throws UsernameMissingException If the username does not exist - * @throws UserNoGuestException If the user is no guest account - */ - public static final function createGuestByUsername ($userName) { - // Get a new instance - $userInstance = new Guest(); - - // Set the username - $userInstance->setUserName($userName); - - // Check if username exists - if ($userInstance->ifUsernameExists() === FALSE) { - // Throw an exception here - throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); - } elseif ($userInstance->isGuest() === FALSE) { - // Sanity check on 'guest' status failed - throw new UserNoGuestException(array($userInstance, $userName), self::EXCEPTION_USER_NOT_GUEST_STATUS); - } - - // Return the instance - return $userInstance; - } - - /** - * Creates an instance of this user class by a provided email address. This - * factory method will not check if email address is there. - * - * @param $email Email address of the user - * @return $userInstance An instance of this user class - */ - public static final function createGuestByEmail ($email) { - // Get a new instance - $userInstance = new Guest(); - - // Set the username - $userInstance->setEmail($email); - - // Return the instance - return $userInstance; - } - - /** - * Updates the last activity timestamp and last performed action in the - * database result. You should call flushPendingUpdates() to flush these updates - * to the database layer. - * - * @param $requestInstance A requestable class instance - * @return void - */ - public function updateLastActivity (Requestable $requestInstance) { - // No activity will be logged for guest accounts - } - - /** - * Flushs all pending updates to the database layer - * - * @return void - */ - public function flushPendingUpdates () { - // No updates will be flushed to database! - } -} - -// [EOF] -?> diff --git a/inc/classes/main/user/member/.htaccess b/inc/classes/main/user/member/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/user/member/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/user/member/class_Member.php b/inc/classes/main/user/member/class_Member.php deleted file mode 100644 index 1e4a9696..00000000 --- a/inc/classes/main/user/member/class_Member.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Member extends BaseUser implements ManageableMember, Registerable { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this user class by a provided username. This - * factory method will check if username is already taken and if not so it - * will throw an exception. - * - * @param $userName Username we need a class instance for - * @return $userInstance An instance of this user class - * @throws UsernameMissingException If the username does not exist - * @throws UnexpectedGuestAccountException If the user status is 'guest' - */ - public static final function createMemberByUsername ($userName) { - // Get a new instance - $userInstance = new Member(); - - // Set the username - $userInstance->setUserName($userName); - - // Check if username exists - if ($userInstance->ifUsernameExists() === FALSE) { - // Throw an exception here - throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); - } elseif ($userInstance->isGuest() === TRUE) { - // User should not be a guest here - throw new UnexpectedGuestAccountException(array($userInstance, $userName), self::EXCEPTION_USER_IS_GUEST); - } - - // Return the instance - return $userInstance; - } - - /** - * Creates an instance of this user class by a provided email address. This - * factory method will not check if email address is there. - * - * @param $email Email address of the user - * @return $userInstance An instance of this user class - */ - public static final function createMemberByEmail ($email) { - // Get a new instance - $userInstance = new Member(); - - // Set the username - $userInstance->setEmail($email); - - // Return the instance - return $userInstance; - } - - /** - * Creates a user by a given request instance - * - * @param $requestInstance An instance of a Requestable class - * @return $userInstance An instance of this user class - * @todo Add more ways over creating user classes - */ - public static final function createMemberByRequest (Requestable $requestInstance) { - // Determine if by email or username - if (!is_null($requestInstance->getRequestElement('username'))) { - // Username supplied - $userInstance = self::createMemberByUserName($requestInstance->getRequestElement('username')); - } elseif (!is_null($requestInstance->getRequestElement('email'))) { - // Email supplied - $userInstance = self::createMemberByEmail($requestInstance->getRequestElement('email')); - } else { - // Unsupported mode - $userInstance = new Member(); - $userInstance->debugBackTrace('More ways of creating user classes are needed here.'); - exit(); - } - - // Return the prepared instance - return $userInstance; - } - - /** - * Updates the last activity timestamp and last performed action in the - * database result. You should call flushPendingUpdates() to flush these updates - * to the database layer. - * - * @param $requestInstance A requestable class instance - * @return void - */ - public function updateLastActivity (Requestable $requestInstance) { - // Set last action - $lastAction = $requestInstance->getRequestElement('action'); - - // If there is no action use the default on - if (is_null($lastAction)) { - $lastAction = $this->getConfigInstance()->getConfigEntry('login_default_action'); - } // END - if - - // Get a critieria instance - $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); - - // Add search criteria - $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); - $searchInstance->setLimit(1); - - // Now get another criteria - $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); - - // And add our both entries - $updateInstance->addCriteria('last_activity', date('Y-m-d H:i:s', time())); - $updateInstance->addCriteria('last_action', $lastAction); - - // Add the search criteria for searching for the right entry - $updateInstance->setSearchInstance($searchInstance); - - // Set wrapper class name - $updateInstance->setWrapperConfigEntry('user_db_wrapper_class'); - - // Remember the update in database result - $this->getResultInstance()->add2UpdateQueue($updateInstance); - } -} - -// [EOF] -?> diff --git a/inc/classes/main/visitor/.htaccess b/inc/classes/main/visitor/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/visitor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/visitor/class_ b/inc/classes/main/visitor/class_ deleted file mode 100644 index e1ccf277..00000000 --- a/inc/classes/main/visitor/class_ +++ /dev/null @@ -1,53 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ???Visitor extends BaseVisitor implements Visitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('!!!'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public final static function create???Visitor () { - // Get new instance - $visitorInstance = new ???Visitor(); - - // Return the prepared instance - return $visitorInstance; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/visitor/class_BaseVisitor.php b/inc/classes/main/visitor/class_BaseVisitor.php deleted file mode 100644 index 185588fd..00000000 --- a/inc/classes/main/visitor/class_BaseVisitor.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseVisitor extends BaseFrameworkSystem { - /** - * Mode of the visitor (the first word of the concrete class' name) - */ - private $visitorMode = 'invalid'; - - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for visitor mode - * - * @param $visitorMode New visitor mode to set - * @return void - */ - protected final function setVisitorMode ($visitorMode) { - $this->visitorMode = (string) $visitorMode; - } - - /** - * Getter for visitor mode - * - * @return $visitorMode New visitor mode to set - */ - public final function getVisitorMode () { - return $this->visitorMode; - } -} - -// [EOF] -?> diff --git a/inc/classes/main/visitor/tasks/.htaccess b/inc/classes/main/visitor/tasks/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/main/visitor/tasks/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/main/visitor/tasks/class_ActiveTaskVisitor.php b/inc/classes/main/visitor/tasks/class_ActiveTaskVisitor.php deleted file mode 100644 index ec348674..00000000 --- a/inc/classes/main/visitor/tasks/class_ActiveTaskVisitor.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('task'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public static final function createActiveTaskVisitor () { - // Get new instance - $visitorInstance = new ActiveTaskVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given task instance - * - * @param $taskInstance A Taskable instance - * @return void - */ - public function visitTask (Taskable $taskInstance) { - // Execute the task from this visitor - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting task ' . $taskInstance->__toString() . ' - CALLED!'); - $taskInstance->executeTask(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting task ' . $taskInstance->__toString() . ' - EXIT!'); - } - - /** - * Pool visitor method for active tasks - * - * @param $poolInstance A Poolable instance - * @return void - */ - public function visitPool (Poolable $poolInstance) { - /** - * We don't need to visit a pool as an active task because a pool can - * never become a task. Instead e.g. by a listener pool we should visit - * all listeners one by one - */ - } - - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - public function visitListener (Listenable $listenerInstance) { - // Do "listen" here - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - CALLED!'); - $listenerInstance->doListen(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - FINISH'); - } - - /** - * Visits the given decorator instance - * - * @param $decoratorInstance A decorator instance - * @return void - */ - public function visitDecorator (BaseDecorator $decoratorInstance) { - // A decorator itself can never become an active task so this method - // remains empty. - } -} - -// [EOF] -?> diff --git a/inc/classes/main/visitor/tasks/class_ShutdownTaskVisitor.php b/inc/classes/main/visitor/tasks/class_ShutdownTaskVisitor.php deleted file mode 100644 index 4fc037e3..00000000 --- a/inc/classes/main/visitor/tasks/class_ShutdownTaskVisitor.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class ShutdownTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set visitor mode - $this->setVisitorMode('task'); - } - - /** - * Creates an instance of this class - * - * @return $visitorInstance An instance a Visitorable class - */ - public static final function createShutdownTaskVisitor () { - // Get new instance - $visitorInstance = new ShutdownTaskVisitor(); - - // Return the prepared instance - return $visitorInstance; - } - - /** - * Visits the given task instance - * - * @param $taskInstance A Taskable instance - * @return void - */ - public function visitTask (Taskable $taskInstance) { - // Shutdown the task instance - $taskInstance->doShutdown(); - } - - /** - * Pool visitor method for active tasks - * - * @param $poolInstance A Poolable instance - * @return void - */ - public function visitPool (Poolable $poolInstance) { - // Shutdown the pool instance - $poolInstance->doShutdown(); - } - - /** - * Visits the given listener instance - * - * @param $listenerInstance A Listenable instance - * @return void - */ - public function visitListener (Listenable $listenerInstance) { - // Shutdown the listener instance - $listenerInstance->doShutdown(); - } - - /** - * Visits the given decorator instance - * - * @param $decoratorInstance A decorator instance - * @return void - */ - public function visitDecorator (BaseDecorator $decoratorInstance) { - // Shutdown the decorator instance - $decoratorInstance->doShutdown(); - } -} - -// [EOF] -?> diff --git a/inc/classes/middleware/.htaccess b/inc/classes/middleware/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/middleware/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/middleware/class_BaseMiddleware.php b/inc/classes/middleware/class_BaseMiddleware.php deleted file mode 100644 index 5764f554..00000000 --- a/inc/classes/middleware/class_BaseMiddleware.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseMiddleware extends BaseFrameworkSystem { - /** - * Protected constructor - * - * @param $className Name of the class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } -} - -// [EOF] -?> diff --git a/inc/classes/middleware/compressor/.htaccess b/inc/classes/middleware/compressor/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/middleware/compressor/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/middleware/compressor/class_CompressorChannel.php b/inc/classes/middleware/compressor/class_CompressorChannel.php deleted file mode 100644 index f1189c5f..00000000 --- a/inc/classes/middleware/compressor/class_CompressorChannel.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class CompressorChannel extends BaseMiddleware implements Registerable { - /** - * Real compressor instance - */ - private $compressor = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor! - parent::__construct(__CLASS__); - } - - /** - * Create a new compressor channel. - * - * @return $compressorInstance A prepared instance of this class - */ - public static final function createCompressorChannel () { - // Get new instance - $compressorInstance = new CompressorChannel(); - - // Is the compressor handler set? - if ( - (is_null($compressorInstance->getCompressor())) - || (!$compressorInstance->getCompressor() instanceof Compressor) - ) { - // Init base directory - $baseDir = - $compressorInstance->getConfigInstance()->getConfigEntry('base_path') . - $compressorInstance->getConfigInstance()->getConfigEntry('compressor_base_path'); - - // Get a directory pointer - $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($baseDir)); - - // Read all directories but no sub directories, .htaccess files and NullCompressor class - while ($directoryEntry = $directoryInstance->readDirectoryExcept(array('.htaccess', 'class_NullCompressor.php'))) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMPRESSOR[' . __METHOD__ . ':' . __LINE__ . ']: directoryEntry=' . $directoryEntry); - - // Is this a class file? - if ((substr($directoryEntry, 0, 6) == 'class_') && (substr($directoryEntry, -4, 4) == '.php')) { - /* Get the compressor's name. That's why you must name - * your files like your classes and also that's why you - * must keep on class in one file. - */ - $className = substr($directoryEntry, 6, -4); - - // Get an instance from our object factory - $tempInstance = ObjectFactory::createObjectByName($className); - - // Is it null? - if (is_null($tempInstance)) { - // Then skip to the next one - continue; - } // END - if - - // Set the compressor - $compressorInstance->setCompressor($tempInstance); - - // No more searches required because we have found a valid compressor stream - break; - } // END - if - } // END - while - - // Close the directory - $directoryInstance->closeDirectory(); - } // END - if - - // Check again if there is a compressor - if ( - (is_null($compressorInstance->getCompressor())) - || (!is_object($compressorInstance->getCompressor())) - || (!$compressorInstance instanceof Compressor) - ) { - // Set the null compressor handler. This should not be configureable! - // @TODO Is there a configurable fall-back compressor needed, or is NullCompressor okay? - $compressorInstance->setCompressor(ObjectFactory::createObjectByName('NullCompressor')); - } // END - if - - // Return the compressor instance - return $compressorInstance; - } - - /** - * Getter for compressor instance - * - * @return $compressor The compressor instance - */ - public final function getCompressor () { - return $this->compressor; - } - - /** - * Setter for compressor - * - * @param $compressorInstance The compressor instance we shall use - * @return void - */ - public final function setCompressor (Compressor $compressorInstance = NULL) { - $this->compressor = $compressorInstance; - } - - /** - * Getter for the file extension of the current compressor - */ - public final function getCompressorExtension () { - // Get compressor extension from current compressor - return $this->getCompressor()->getCompressorExtension(); - } -} - -// [EOF] -?> diff --git a/inc/classes/middleware/database/.htaccess b/inc/classes/middleware/database/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/middleware/database/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/middleware/database/class_DatabaseConnection.php b/inc/classes/middleware/database/class_DatabaseConnection.php deleted file mode 100644 index d3225c41..00000000 --- a/inc/classes/middleware/database/class_DatabaseConnection.php +++ /dev/null @@ -1,218 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Registerable { - /** - * Array for connection data - */ - private $connectData = array( - 'login' => '', - 'pass' => '', - 'dbase' => '', - 'host' => '' - ); - - // The real database layer - private $dbLayer = NULL; - - // An instance of this class - private static $selfInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - // Create new database connection layer - public static final function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseBackend $dbLayer) { - // Get instance - $databaseInstance = new DatabaseConnection(); - - // Set database layer - $databaseInstance->setDatabaseLayer($dbLayer); - - // Set db instance - self::$selfInstance = $databaseInstance; - - // Return instance - return $databaseInstance; - } - - // Get an instance of this class - public static final function getSelfInstance () { - return self::$selfInstance; - } - - // Public setter for database connection - public final function setConnectionData ($login, $pass, $dbase, $host='localhost') { - // Transfer connection data - $this->connectData['login'] = (string) $login; - $this->connectData['pass'] = (string) $pass; - $this->connectData['dbase'] = (string) $dbase; - $this->connectData['host'] = (string) $host; - } - - /** - * Getter for connection data - * - * @return $connectData Connection data stored with this clas - */ - public final function getConnectionData () { - return $this->connectData; - } - - /** - * Setter for the real database layer - * @param $dbLayer An instance of the real database layer - * @return void - */ - public final function setDatabaseLayer (DatabaseBackend $dbLayer) { - $this->dbLayer = $dbLayer; - } - - /** - * Getter for index key - * - * @return $indexKey Index key - */ - public final function getIndexKey () { - return $this->dbLayer->getIndexKey(); - } - - /** - * Runs a 'select' statement on the database layer with given table name - * and criteria. If this doesn't fail the result will be returned - * - * @param $tableName Name of the 'table' we shall query - * @param $criteriaInstance An instance of a Criteria class - * @return $result The result as an array - */ - public function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance) { - // Connect to the database - $this->dbLayer->connectToDatabase(); - - // Get result from query - $result = $this->dbLayer->querySelect($tableName, $criteriaInstance); - - // Return the result - return $result; - } - - /** - * Getter for last exception - * - * @return $exceptionInstance Last thrown exception - */ - public final function getLastException () { - $exceptionInstance = $this->dbLayer->getLastException(); - return $exceptionInstance; - } - - /** - * 'Inserts' a data set instance into a local file database folder - * - * @param $dataSetInstance A storeable data set - * @return void - */ - public function queryInsertDataSet (StoreableCriteria $dataSetInstance) { - // Connect to the database - $this->dbLayer->connectToDatabase(); - - // Ask the database layer - $this->dbLayer->queryInsertDataSet($dataSetInstance); - } - - /** - * 'Updates' a data set instance with a database layer - * - * @param $dataSetInstance A storeable data set - * @return void - */ - public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) { - // Connect to the database - $this->dbLayer->connectToDatabase(); - - // Ask the database layer - $this->dbLayer->queryUpdateDataSet($dataSetInstance); - } - - /** - * Getter for primary key column of specified table name - * - * @param $tableName Name of table we need the primary key column from - * @return $primaryKey Primary key column of requested table - */ - public function getPrimaryKeyOfTable ($tableName) { - // Connect to the database - $this->dbLayer->connectToDatabase(); - - // Ask the database layer - $primaryKey = $this->dbLayer->getPrimaryKeyOfTable($tableName); - - // Return the value - return $primaryKey; - } - - /** - * Removes non-public data from given array. - * - * @param $data An array with possible non-public data that needs to be removed. - * @return $data A cleaned up array with only public data. - */ - public function removeNonPublicDataFromArray (array $data) { - // Connect to the database - $this->dbLayer->connectToDatabase(); - - // Call database backend - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: Calling this->dbLayer->removeNonPublicDataFromArray(data) ...'); - $data = $this->dbLayer->removeNonPublicDataFromArray($data); - - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: data[]=' . gettype($data)); - return $data; - } - - /** - * Count total table rows - * - * @param $tableName Table name - * @return $count Total row count - */ - public function countTotalRows ($tableName) { - // Connect to the database - $this->dbLayer->connectToDatabase(); - - // Ask the database layer - $count = $this->dbLayer->countTotalRows($tableName); - - // Return the value - return $count; - } -} - -// [EOF] -?> diff --git a/inc/classes/middleware/debug/.htaccess b/inc/classes/middleware/debug/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/middleware/debug/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/middleware/debug/class_DebugMiddleware.php b/inc/classes/middleware/debug/class_DebugMiddleware.php deleted file mode 100644 index 045a3308..00000000 --- a/inc/classes/middleware/debug/class_DebugMiddleware.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @deprecated See LoggerFactory for a more flexible approach - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class DebugMiddleware extends BaseMiddleware implements Registerable { - /** - * An instance of this class - */ - private static $selfInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set own instance - self::$selfInstance = $this; - - // Set it so all can use it - $this->setDebugInstance($this); - } - - /** - * Create a new debug output system. - * If no output is given this class is currently being used for back-fall. - * This fall-back mechanism will become deprecated very soon. - * - * @param $outputClass The class name which we shall use for - * registering the *real* debug output - * @param $className Class where a output should be created and - * configured for - * @return $debugInstance An instance of this middleware class - */ - public static final function createDebugMiddleware ($outputClass, $className) { - //* DEBUG-DIE: */ die(__METHOD__.': outputClass=' . $outputClass . ',className=' . $className); - - // Create an instance if this middleware - $debugInstance = new DebugMiddleware(); - - // Default is that $outputClass may be invalid - $isInitialized = FALSE; - - // Is there a valid output instance provided? - if ((!is_null($outputClass)) && (is_object($outputClass)) && ($outputClass instanceof OutputStreamer)) { - // Use the given output instance - $debugInstance->setOutputInstance($outputClass); - - // All fine - $isInitialized = TRUE; - } elseif ((!is_null($outputClass)) && (is_string($outputClass)) && (class_exists($outputClass))) { - // A name for a debug output class has been provided so we try to get it - $outputInstance = ObjectFactory::createObjectByName($outputClass); - - // Set this as output class - $debugInstance->setOutputInstance($outputInstance); - - // All fine - $isInitialized = TRUE; - } - - // Is the output class initialized? - if ($isInitialized === TRUE) { - // Then set class name - $debugInstance->getOutputInstance()->setLoggerClassName($className); - } // END - if - - // Return instance - return $debugInstance; - } - - /** - * Getter for an instance of this class - * - * @return $selfInstance An instance of this class - */ - public static final function getSelfInstance() { - return self::$selfInstance; - } - - /** - * This method shall send debug output which can be HTML code for the - * browser or debug lines for a log file, etc. to the registered debug - * output instance. - * - * @param $outStream Data we shall 'stream' out to the world - * @param $stripTags Whether HTML tags shall be stripped out - * @return void - */ - public final function output ($outStream, $stripTags = FALSE) { - // Is the output stream set - if (empty($outStream)) { - // @TODO Initialization phase - return; - } // END - if - - // Use the output instance - $this->getOutputInstance()->outputStream($outStream, $stripTags); - } -} - -// [EOF] -?> diff --git a/inc/classes/middleware/io/.htaccess b/inc/classes/middleware/io/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/middleware/io/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/middleware/io/class_FileIoHandler.php b/inc/classes/middleware/io/class_FileIoHandler.php deleted file mode 100644 index 3480a31d..00000000 --- a/inc/classes/middleware/io/class_FileIoHandler.php +++ /dev/null @@ -1,202 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class FileIoHandler extends BaseMiddleware implements IoHandler { - /** - * The *real* file input class we shall use for reading data - */ - private $inputStream = NULL; - - /** - * The *real* file output class we shall use for reading data - */ - private $outputStream = NULL; - - /** - * An instance of this class - */ - private static $selfInstance = NULL; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set own instance - self::$selfInstance = $this; - } - - /** - * Creates an instance of this class and prepares the IO system. This is - * being done by setting the default file IO class - * - * @return $ioInstance A prepared instance of FilIOHandler - */ - public static final function createFileIoHandler () { - // Get instance - $ioHandler = new FileIoHandler(); - - // Set the *real* file IO instances (both the same) - $ioHandler->setInputStream(ObjectFactory::createObjectByConfiguredName('file_input_class')); - $ioHandler->setOutputStream(ObjectFactory::createObjectByConfiguredName('file_output_class')); - - // Return instance - return $ioHandler; - } - - /** - * Getter for an instance of this class - * - * @return $selfInstance An instance of this class - */ - public static final function getSelfInstance () { - return self::$selfInstance; - } - - /** - * Setter for the *real* file input instance - * - * @param $inputStream The *real* file-input class - * @return void - */ - public final function setInputStream (FileInputStreamer $inputStream) { - $this->inputStream = $inputStream; - } - - /** - * Getter for the *real* file input instance - * - * @return $inputStream The *real* file-input class - */ - public final function getInputStream () { - return $this->inputStream; - } - - /** - * Setter for the *real* file output instance - * - * @param $outputStream The *real* file-output class - * @return void - */ - public final function setOutputStream (FileOutputStreamer $outputStream) { - $this->outputStream = $outputStream; - } - - /** - * Getter for the *real* file output instance - * - * @return $outputStream The *real* file-output class - */ - public final function getOutputStream () { - return $this->outputStream; - } - /** - * Saves streamed (that are mostly serialized objects) data to files or - * external servers. - * - * @param $fileName The local file's name including full path - * @param $dataArray Array containing the compressor's extension and streamed data - * @return void - * @throws UnsupportedOperationException If this method is called - */ - public function saveFile ($fileName, array $dataArray) { - self::createDebugInstance(__CLASS__)->debugOutput('fileName=' . $fileName . ',dataArray()=' . count($dataArray)); - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Saves a file with data by using the current output stream - * - * @param $fileName Name of the file - * @param $dataStream File data stream - * @param $objectInstance An instance of a FrameworkInterface class (default: NULL) - * @return void - */ - public function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL) { - // Default is this array - $className = $this->__toString(); - - // Is the object instance set? - if ($objectInstance instanceof FrameworkInterface) { - // Then use this - $className = $objectInstance->__toString(); - } // END - if - - // Prepare output array - $dataArray = array( - 0 => $className, - 1 => $dataStream - ); - - // Send the fileName and dataArray to the output handler - $this->getOutputStream()->saveFile($fileName, $dataArray); - } - - /** Loads data from a file over the input handler - * - * @param $fqfn Given full-qualified file name (FQFN) to load - * @return $array Array with the file contents - */ - public function loadFileContents ($fqfn) { - // Read from the input handler - return $this->getInputStream()->loadFileContents($fqfn); - } - - /** - * Determines seek position - * - * @return $seekPosition Current seek position - * @todo 0% done - */ - public function determineSeekPosition () { - $this->partialStub(); - } - - /** - * Seek to given offset (default) or other possibilities as fseek() gives. - * - * @param $offset Offset to seek to (or used as "base" for other seeks) - * @param $whence Added to offset (default: only use offset to seek to) - * @return $status Status of file seek: 0 = success, -1 = failed - */ - public function seek ($offset, $whence = SEEK_SET) { - $this->partialStub('offset=' . $offset . ',whence=' . $whence); - } - - /** - * Size of file stack - * - * @return $size Size (in bytes) of file - */ - public function size () { - $this->partialStub(); - } -} - -// [EOF] -?> diff --git a/inc/classes/third_party/.htaccess b/inc/classes/third_party/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/third_party/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/third_party/akismet/.htaccess b/inc/classes/third_party/akismet/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/third_party/akismet/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/third_party/akismet/akismet.class.php b/inc/classes/third_party/akismet/akismet.class.php deleted file mode 100644 index 021447ec..00000000 --- a/inc/classes/third_party/akismet/akismet.class.php +++ /dev/null @@ -1,388 +0,0 @@ -Usage - * - * $comment = array( - * 'author' => 'viagra-test-123', - * 'email' => 'test@example.com', - * 'website' => 'http://www.example.com/', - * 'body' => 'This is a test comment', - * 'permalink' => 'http://yourdomain.com/yourblogpost.url', - * ); - * - * $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment); - * - * if($akismet->errorsExist()) { - * echo"Couldn't connected to Akismet server!"; - * } else { - * if($akismet->isSpam()) { - * echo"Spam detected"; - * } else { - * echo"yay, no spam!"; - * } - * } - * - * - * @author Bret Kuhns {@link www.miphp.net} - * @link http://www.miphp.net/blog/view/new_akismet_class/ - * @version 0.3.4 - * @license http://www.opensource.org/licenses/mit-license.php MIT License - */ - - - -// Error constants -define("AKISMET_SERVER_NOT_FOUND", 0); -define("AKISMET_RESPONSE_FAILED", 1); -define("AKISMET_INVALID_KEY", 2); - - - -// Base class to assist in error handling between Akismet classes -class AkismetObject { - var $errors = array(); - - - /** - * Add a new error to the errors array in the object - * - * @param String $name A name (array key) for the error - * @param String $string The error message - * @return void - */ - // Set an error in the object - function setError($name, $message) { - $this->errors[$name] = $message; - } - - - /** - * Return a specific error message from the errors array - * - * @param String $name The name of the error you want - * @return mixed Returns a String if the error exists, a false boolean if it does not exist - */ - function getError($name) { - if($this->isError($name)) { - return $this->errors[$name]; - } else { - return false; - } - } - - - /** - * Return all errors in the object - * - * @return String[] - */ - function getErrors() { - return (array)$this->errors; - } - - - /** - * Check if a certain error exists - * - * @param String $name The name of the error you want - * @return boolean - */ - function isError($name) { - return isset($this->errors[$name]); - } - - - /** - * Check if any errors exist - * - * @return boolean - */ - function errorsExist() { - return (count($this->errors) > 0); - } - - -} - - - - - -// Used by the Akismet class to communicate with the Akismet service -class AkismetHttpClient extends AkismetObject { - var $akismetVersion = '1.1'; - var $con; - var $host; - var $port; - var $apiKey; - var $blogUrl; - var $errors = array(); - - - // Constructor - function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) { - $this->host = $host; - $this->port = $port; - $this->blogUrl = $blogUrl; - $this->apiKey = $apiKey; - } - - - // Use the connection active in $con to get a response from the server and return that response - function getResponse($request, $path, $type = "post", $responseLength = 1160) { - $this->_connect(); - - if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) { - $request = - strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" . - "Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" . - "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" . - "Content-Length: ".strlen($request)."\r\n" . - "User-Agent: Akismet PHP4 Class\r\n" . - "\r\n" . - $request - ; - $response = ""; - - @fwrite($this->con, $request); - - while(!feof($this->con)) { - $response .= @fgets($this->con, $responseLength); - } - - $response = explode("\r\n\r\n", $response, 2); - return $response[1]; - } else { - $this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved."); - } - - $this->_disconnect(); - } - - - // Connect to the Akismet server and store that connection in the instance variable $con - function _connect() { - if(!($this->con = @fsockopen($this->host, $this->port))) { - $this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server."); - } - } - - - // Close the connection to the Akismet server - function _disconnect() { - @fclose($this->con); - } - - -} - - - - - -// The controlling class. This is the ONLY class the user should instantiate in -// order to use the Akismet service! -class Akismet extends AkismetObject { - var $apiPort = 80; - var $akismetServer = 'rest.akismet.com'; - var $akismetVersion = '1.1'; - var $http; - - var $ignore = array( - 'HTTP_COOKIE', - 'HTTP_X_FORWARDED_FOR', - 'HTTP_X_FORWARDED_HOST', - 'HTTP_MAX_FORWARDS', - 'HTTP_X_FORWARDED_SERVER', - 'REDIRECT_STATUS', - 'SERVER_PORT', - 'PATH', - 'DOCUMENT_ROOT', - 'SERVER_ADMIN', - 'QUERY_STRING', - 'PHP_SELF', - 'argv' - ); - - var $blogUrl = ""; - var $apiKey = ""; - var $comment = array(); - - - /** - * Constructor - * - * Set instance variables, connect to Akismet, and check API key - * - * @param String $blogUrl The URL to your own blog - * @param String $apiKey Your wordpress API key - * @param String[] $comment A formatted comment array to be examined by the Akismet service - * @return Akismet - */ - function Akismet($blogUrl, $apiKey, $comment = array()) { - $this->blogUrl = $blogUrl; - $this->apiKey = $apiKey; - $this->setComment($comment); - - // Connect to the Akismet server and populate errors if they exist - $this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey); - if($this->http->errorsExist()) { - $this->errors = array_merge($this->errors, $this->http->getErrors()); - } - - // Check if the API key is valid - if(!$this->_isValidApiKey($apiKey)) { - $this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid."); - } - } - - - /** - * Query the Akismet and determine if the comment is spam or not - * - * @return boolean - */ - function isSpam() { - $response = $this->http->getResponse($this->_getQueryString(), 'comment-check'); - - return ($response == "true"); - } - - - /** - * Submit this comment as an unchecked spam to the Akismet server - * - * @return void - */ - function submitSpam() { - $this->http->getResponse($this->_getQueryString(), 'submit-spam'); - } - - - /** - * Submit a false-positive comment as "ham" to the Akismet server - * - * @return void - */ - function submitHam() { - $this->http->getResponse($this->_getQueryString(), 'submit-ham'); - } - - - /** - * Manually set the comment value of the instantiated object. - * - * @param Array $comment - * @return void - */ - function setComment($comment) { - $this->comment = $comment; - if(!empty($comment)) { - $this->_formatCommentArray(); - $this->_fillCommentValues(); - } - } - - - /** - * Returns the current value of the object's comment array. - * - * @return Array - */ - function getComment() { - return $this->comment; - } - - - /** - * Check with the Akismet server to determine if the API key is valid - * - * @access Protected - * @param String $key The Wordpress API key passed from the constructor argument - * @return boolean - */ - function _isValidApiKey($key) { - $keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key'); - - return ($keyCheck == "valid"); - } - - - /** - * Format the comment array in accordance to the Akismet API - * - * @access Protected - * @return void - */ - function _formatCommentArray() { - $format = array( - 'type' => 'comment_type', - 'author' => 'comment_author', - 'email' => 'comment_author_email', - 'website' => 'comment_author_url', - 'body' => 'comment_content' - ); - - foreach($format as $short => $long) { - if(isset($this->comment[$short])) { - $this->comment[$long] = $this->comment[$short]; - unset($this->comment[$short]); - } - } - } - - - /** - * Fill any values not provided by the developer with available values. - * - * @return void - */ - function _fillCommentValues() { - if(!isset($this->comment['user_ip'])) { - $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR'); - } - if(!isset($this->comment['user_agent'])) { - $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; - } - if(!isset($this->comment['referrer'])) { - $this->comment['referrer'] = $_SERVER['HTTP_REFERER']; - } - if(!isset($this->comment['blog'])) { - $this->comment['blog'] = $this->blogUrl; - } - } - - - /** - * Build a query string for use with HTTP requests - * - * @access Protected - * @return String - */ - function _getQueryString() { - foreach($_SERVER as $key => $value) { - if(!in_array($key, $this->ignore)) { - if($key == 'REMOTE_ADDR') { - $this->comment[$key] = $this->comment['user_ip']; - } else { - $this->comment[$key] = $value; - } - } - } - - $query_string = ''; - - foreach($this->comment as $key => $data) { - $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&'; - } - - return $query_string; - } - - -} -?> \ No newline at end of file diff --git a/inc/classes/third_party/api/.htaccess b/inc/classes/third_party/api/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/third_party/api/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/third_party/api/primusportal/.htaccess b/inc/classes/third_party/api/primusportal/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/third_party/api/primusportal/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/third_party/api/primusportal/class_PrimeraApi.php b/inc/classes/third_party/api/primusportal/class_PrimeraApi.php deleted file mode 100644 index b78bf55d..00000000 --- a/inc/classes/third_party/api/primusportal/class_PrimeraApi.php +++ /dev/null @@ -1,263 +0,0 @@ -payPrimera($PayReceiver, $PayAmount, $PayDescription); - * - * Wobei $PayReicer der Username des Empf�ngers bei - * Primusportal.de ist. $PayAmount ist der gerundete( !! ) Betrag an Primera, - * die der Empf�nger erhalten soll. $PayDescription ist eine von Ihnen - * festgelegte kurze Beschreibung. Die L�nge dieses Textes darf 100 Zeichen - * nicht �berschreiten. Beispiel: - * $status = $apiInstance->payPrimera('garbage', 10000, 'Auszahlung IhreSeite.de - ID: 12345'); - * 3. �berpr�fung des Status (R�ckgabecode): - * CODE: - * if ($status === FALSE) { - * // Ein Fehler ist aufgetreten - * // Fehlerbehandlung hier einf�gen... - * } else { - * // Auszahlung erfolgreich durchgef�hrt - * // F�hren Sie hier Ihre Datenbankabfragen durch, um die Auszahlung zu - * // best�tigen... - * } - * - * Die komplette R�ckgabe des Interfaces wird als assoziatives Array in der Klassen- - * variable $data gespeichert: - * $data = array( - * 'status' => R�ckgabecode (PI_DONE, PI_SENDER_ERROR, ...), - * 'statustext' => Status in Worten (z.B.: 'Transaktion erfolgreich durchgef�hrt'), - * ); - * - * - * @author Andreas Schmidt - * @author Roland Haeder - * @version 1.0 - beta - * @copyright (c) 2007 by Primusportal.de - * @copyright (c) 2008, 2011 by Roland Haeder - */ -class PrimeraApi extends BaseFrameworkSystem { - /** - * Fehler - Interfacebenutzer - */ - const PI_ERROR = -1; - - /** - * Statuscode f�r erfolgreich ausgef�hrte Transaktion - */ - const PI_DONE = 200; - - /** - * Fehler - User existiert nicht oder ist gesperrt - */ - const PI_RECEIVER_ERROR = 301; - - /** - * Sender-Account Fehler (User nicht existent, gesperrt, ...) - */ - const PI_SENDER_ERROR = 401; - - /** - * Betrag fehler - */ - const PI_AMOUNT_ERROR = 501; - - /** - * Zu wenig Primera - */ - const PI_TOO_LESS_PRIMERA = 502; - - /** - * User nicht aktiv oder existiert nicht - */ - const PI_USER_CHECK_ERROR = 601; - - /** - * User aktiv - */ - const PI_USER_CHECK_OK = 602; - - /** - * Primerastand erfolgreich geholt - */ - const PI_GET_PRIMERA_DONE = 701; - - /** - * HTTP-EOL - */ - const HTTP_EOL = "\r\n"; - - /** - * URL f�r das Interface auf dem Primusserver: - */ - private $host = 'www.primusportal.de'; - private $path = '/transfer.interface.2.0.php'; - - private $errno = 0; - private $err = ''; - - private $separator = ':'; - - private $username = ''; - private $password = ''; - - private $data = array(); - - /** - * Konstruktor - */ - public function __construct ($primusUsername, $primusPassword) { - // Call parent constructor - parent::__construct(); - - // Set data - $this->username = $primusUsername; - $this->password = $primusPassword; - } - - /** - * Anfrage senden und Rueckgabecode in Variable speichern - */ - private function queryApi ( $data = array() ) { - $fp = fsockopen($this->host, 80, $this->errno, $this->_err); - if (!$fp) return false; - - $data['PrimusInterface_Username'] = base64_encode($this->username); - $data['PrimusInterface_Password'] = base64_encode(md5($this->password)); - - // POST-Daten uebermitteln: - $queryData = http_build_query($data, '', '&'); - - $request .= 'POST ' . $this->path . 'HTTP/1.1' . self::HTTP_EOL; - $request .= 'Host: ' . $this->host . self::HTTP_EOL; - $request .= 'Content-type: application/x-www-form-urlencoded' . self::HTTP_EOL; - $request .= 'Content-length: '. strlen($queryData) . self::HTTP_EOL; - $request .= 'Connection: close' . self::HTTP_EOL; - $request .= self::HTTP_EOL; - $request .= $queryData; - - fputs($fp, $request); - - $return = ''; - while (!feof($fp)) { - $return .= fgets($fp, 128); - } // END - while - - $content = explode('', $return); - return $content[1]; - } - - /** - * Funktion parst die R�ckgabe vom Transferskript: - */ - private function parseContent ( $content ) { - $x = explode("\n", $content); - $return = array(); - foreach($x as $currentLine) { - $line_exploded = explode($this->separator, $currentLine,2); - if (count($line_exploded) > 1) { - $return[$line_exploded[0]] = $line_exploded[1]; - } // END - if - } // END - foreach - return $return; - } - - /** - * @param int/string $Receiver UserID / Username des Empf�ngers - * @param int$Amount Betrag in ganzzahligen Primera - * @param string $Description Beschreibung (Sichtbar in Einzelauflistung) - */ - public function payPrimera ($Receiver, $Amount, $Description = '') { - $valid = FALSE; - $postData = array( - 'PrimusInterface_Action' => 'Pay', - 'PrimusInterface_Receiver' => base64_encode($Receiver), - 'PrimusInterface_Amount' => base64_encode($Amount), - 'PrimusInterface_Description' => base64_encode($Description) - ); - - $postReturn = $this->parseContent( $this->queryApi($postData) ); - - $this->data = $postReturn; - if ($postReturn['status'] == '200') { - $valid = TRUE; - } // END - if - return $valid; - } - - /** - * �berpr�ft den Status eines Primus-Users - * - existiert der User - * - ist er aktiv - * @param string/int $User Userid / Username - */ - public function checkPrimusUser ($userName) { - $valid = FALSE; - $postData = array( - 'PrimusInterface_Action' => 'CheckPrimusUser', - 'PrimusInterface_CheckPrimusUser' => $userName - ); - - $postReturn = $this->parseContent( $this->queryApi($postData) ); - - $this->data = $postReturn; - - if ($postReturn['status'] == self::PI_USER_CHECK_OK) { - $valid = TRUE; - } // END - if - return $valid; - } - - /** - * Die Funktion liefer den aktuellen Primerastand - */ - public function getPrimera() { - $primera = FALSE; - $postData = array( - 'PrimusInterface_Action' => 'GetPrimera' - ); - $postReturn = $this->parseContent( $this->queryApi($postData) ); - - $this->data = $postReturn; - if ($postReturn['status'] == self::PI_GET_PRIMERA_DONE) { - $primera = $postReturn['primera']; - } // END - if - return $primera; - } -} - -// [EOF] -?> diff --git a/inc/classes/third_party/api/wernisportal/.htaccess b/inc/classes/third_party/api/wernisportal/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/third_party/api/wernisportal/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/third_party/api/wernisportal/class_WernisApi.php b/inc/classes/third_party/api/wernisportal/class_WernisApi.php deleted file mode 100644 index 3c5a1a4c..00000000 --- a/inc/classes/third_party/api/wernisportal/class_WernisApi.php +++ /dev/null @@ -1,424 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org - * @todo Out-dated since 0.6-BETA - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class WernisApi extends BaseFrameworkSystem { - /** - * Static base API URL - */ - private static $apiUrl = 'http://www.wds66.com/api/'; - - /** - * API Wernis amount - */ - private $wernis_amount = 0; - - /** - * API username - */ - private $w_id = 0; - - /** - * API Wernis password (not account password!) - */ - private $w_md5 = ''; - - /** - * Nickname of the user - */ - private $w_nick = ''; - - /** - * Wernis amount of the user - */ - private $w_amount = 0; - - /** - * Array with status informations - */ - private $statusArray = array(); - - /** - * Status for 'okay' - */ - private $statusOkay = 'OK'; - - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this API class - * - * @param $cfg Configuration array - * @return $apiInstance An instance of this API class - */ - public static final function createWernisApi (array $cfg) { - // Create a new instance - $apiInstance = new WernisApi(); - - // Fix missing - if (!isset($cfg['api_url'])) $cfg['api_url'] = self::$apiUrl; - - // Konfiguration uebertragen - $apiInstance->setCoonfigArray($cfg); - - // Return the instance - return $apiInstance; - } - - /** - * Setter for gamer data - * - * @param $w_id Username (id) of the gamer - * @param $w_pwd Clear password of the gamer - * @return void - */ - public function setUser ($w_id, $w_pwd) { - // Set username (id) - $this->w_id = $w_id; - - // Hash clear password and set it - $this->w_md5 = md5($w_pwd); - } - - /************************************************ - * The following methods are not yet rewritten! * - ************************************************/ - - public function einziehen ($amount) { - // amount auf Gueltigkeit pruefen - $amount = isset($amount) ? $amount+0 : 0; - - if ($amount < $this->config['mineinsatz']) { - $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); - return false; - } - - // Abfrage senden - return $this->executeWithdraw($amount); - } - - public function verschicken ($amount) { - // amount auf Gueltigkeit pruefen - $amount = isset($amount) ? $amount+0 : 0; - - if ($amount < $this->config['mineinsatz']) { - $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); - return false; - } - - // Abfrage senden - return $this->executePayout($amount); - } - - // Script abbrechen mit Zurueck-Buttom - public function ende () { - global $_CONFIG; - include 'templates/zurueck.html'; - include 'templates/fuss.html'; - exit(); - } - - // Fehlermeldung ausgeben und beenden - public function error () { - print "
Fehler im Spiel: ".$this->getErrorMessage()."

\n"; - $this->ende(); - } - - // Sets a status message and code - public function setStatusMessage ($msg, $status) { - $this->statusArray['message'] = $msg; - $this->statusArray['status'] = $status; - } - - // Get the status message - public function getErrorMessage () { - if (isset($this->statusArray['message'])) { - // Use raw message - return $this->statusArray['message']; - } else { - // Fall-back to status - return sprintf('Fehler-Code %s ist keiner Nachricht zugewiesen.', $this->getErrorCode()); - } - } - - // Get the status code - public function getErrorCode () { - if (isset($this->statusArray['status'])) { - // Use raw message - return $this->statusArray['status']; - } else { - // Something bad happend - return 'unknown'; - } - } - - // Sends out a request to the API and returns it's result - private function sendRequest ($scriptName, array $requestData = array()) { - // Is the requestData an array? - if (!is_array($requestData)) { - // Then abort here! - return array( - 'status' => 'failed_general', - 'message' => 'API-Daten in config sind ungültig!' - ); - } - - // Is the API id and MD5 hash there? - if ((empty($this->config['wernis_api_id'])) || (empty($this->config['wernis_api_key']))) { - // Abort here... - return array( - 'status' => 'failed_general', - 'message' => 'API-Daten in config.php sind leer!' - ); - } - - // Construct the request string - $requestString = $this->config['api_url'] . $scriptName . '?api_id=' . $this->config['wernis_api_id'] . '&api_key='.$this->config['wernis_api_key']; - foreach ($requestData as $key => $value) { - $requestString .= '&' . $key . '=' . $value; - } - - // Get the raw response from the lower function - $response = $this->sendRawRequest($requestString); - - // Check the response header if all is fine - if (strpos($response[0], '200') === FALSE) { - // Something bad happend... :( - return array( - 'status' => 'request_error', - 'message' => sprintf('Servermeldung %s von WDS66-API erhalten.', $response[0]) - ); - } - - // All (maybe) fine so remove the response header from server - for ($idx = (count($response) - 1); $idx > 1; $idx--) { - $line = trim($response[$idx]); - if (!empty($line)) { - $response = $line; - break; - } - } - - // Prepare the returning result for higher functions - if (substr($response, 0, 1) == '&') { - // Remove the leading & (which can be used in Flash) - $response = substr($response, 1); - } - - // Bring back the response - $data = explode('=', $response); - - // Default return array (should not stay empty) - $return = array(); - - // We use only the first two entries (which shall be fine) - if ($data[0] === 'error') { - // The request has failed... :( - switch ($data[1]) { - case '404': // Invalid API ID - case 'AUTH': // Authorization has failed - $return = array( - 'status' => 'auth_failed', - 'message' => 'API-Daten scheinen nicht zu stimmen! (Access Denied)' - ); - break; - - case 'LOCKED': // User account is locked! - case 'PASS': // Bad passphrase entered - case 'USER': // Missing account or invalid password - $return = array( - 'status' => 'user_failed', - 'message' => 'Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben.' - ); - break; - - case 'OWN': // Transfer to own account - $return = array( - 'status' => 'own_failed', - 'message' => 'Du darfst dein eigenes Spiel leider nicht spielen.' - ); - break; - - case 'AMOUNT': // Amount is depleted - $return = array( - 'status' => 'amount_failed', - 'message' => 'Dein Guthaben reicht nicht aus, um das Spiel zu spielen.' - ); - break; - - case 'AMOUNT-SEND': // API amount is depleted - $return = array( - 'status' => 'api_amount_failed', - 'message' => 'Nicht genügend Guthaben auf dem API-Account.' - ); - break; - - default: // Unknown error (maybe new?) - $return = array( - 'status' => 'request_failed', - 'message' => sprintf('Unbekannter Fehler %s von API erhalten.', $data[1]) - ); - break; - } - } else { - // All fine here - $return = array( - 'status' => $this->statusOkay, - 'response' => $response - ); - } - - // Return the result - return $return; - } - - // Widthdraw this amount - private function executeWithdraw ($amount) { - // First all fails... - $result = FALSE; - - // Prepare the purpose - $purpose = "\"Bube oder Dame\"-Einsatz gesetzt."; - - // Prepare the request data - $requestData = array( - 'sub_request' => 'receive', - 't_uid' => $this->w_id, - 't_md5' => $this->w_md5, - 'r_uid' => (int) $this->config['wernis_refid'], - 'amount' => (int) $amount, - 'purpose' => urlencode(base64_encode($purpose)) - ); - - // Return the result from the lower functions - $return = $this->sendRequest('book.php', $requestData); - - if ($return['status'] == $this->statusOkay) { - // All fine! - $result = TRUE; - } else { - // Status failture text - $this->setStatusMessage($return['message'], $return['status']); - } - - // Return result - return $result; - } - - // Payout this amount - private function executePayout ($amount) { - // First all fails... - $result = FALSE; - - // Prepare the purpose - $purpose = "\"Bube oder Dame\"-Gewinn erhalten."; - - // Prepare the request data - $requestData = array( - 'sub_request' => 'send', - 't_uid' => $this->w_id, - 't_md5' => $this->w_md5, - 'r_uid' => (int) $this->config['wernis_refid'], - 'amount' => (int) $amount, - 'purpose' => urlencode(base64_encode($purpose)) - ); - - // Return the result from the lower functions - $return = $this->sendRequest("book.php", $requestData); - - if ($return['status'] == $this->statusOkay) { - // All fine! - $result = TRUE; - } else { - // Status failture text - $this->setStatusMessage($return['message'], $return['status']); - } - - // Return result - return $result; - } - - // Send raw GET request - private function sendRawRequest ($script) { - // Use the hostname from script URL as new hostname - $url = substr($script, 7); - $extract = explode('/', $url); - - // Done extracting the URL :) - $url = $extract[0]; - - // Extract host name - $host = str_replace('http://', '', $url); - if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/')); - - // Generate relative URL - $script = substr($script, (strlen($url) + 7)); - if (substr($script, 0, 1) == '/') $script = substr($script, 1); - - // Open connection - $fp = @fsockopen($host, 80, $errno, $errdesc, 30); - if (!$fp) { - // Failed! - return array('', '', ''); - } - - // Generate request header - $request = "GET /" . trim($script) . " HTTP/1.0\r\n"; - $request .= "Host: " . $host . "\r\n"; - $request .= sprintf("User-Agent: WernisApi/1.0 by Quix0r [Spieler: %d]\r\n\r\n", $this->w_id); - - // Initialize array - $response = array(); - - // Write request - fputs($fp, $request); - - // Read response - while(!feof($fp)) { - array_push($response, trim(fgets($fp, 1024))); - } // END - while - - // Close socket - fclose($fp); - - // Was the request successfull? - if ((!ereg('200 OK', $response[0])) && (empty($response[0]))) { - // Not found / access forbidden - $response = array('', '', ''); - } // END - if - - // Return response - return $response; - } -} - -// [EOF] -?> diff --git a/inc/classes/third_party/php_mailer/.htaccess b/inc/classes/third_party/php_mailer/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/third_party/php_mailer/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/third_party/php_mailer/ChangeLog.txt b/inc/classes/third_party/php_mailer/ChangeLog.txt deleted file mode 100644 index 5de251ee..00000000 --- a/inc/classes/third_party/php_mailer/ChangeLog.txt +++ /dev/null @@ -1,330 +0,0 @@ -ChangeLog - -NOTE: THIS VERSION OF PHPMAILER IS DESIGNED FOR PHP5/PHP6. IT WILL NOT WORK WITH PHP4. - -Version 2.3 (November 06, 2008) - -* added Arabic language (many thanks to Bahjat Al Mostafa) -* removed English language from language files and made it a default within - class.phpmailer.php - if no language is found, it will default to use - the english language translation -* fixed public/private declarations -* corrected line 1728, $basedir to $directory -* added $sign_cert_file to avoid improper duplicate use of $sign_key_file -* corrected $this->Hello on line 612 to $this->Helo -* changed default of $LE to "\r\n" to comply with RFC 2822. Can be set by the user - if default is not acceptable -* removed trim() from return results in EncodeQP -* /test and three files it contained are removed from version 2.3 -* fixed phpunit.php for compliance with PHP5 -* changed $this->AltBody = $textMsg; to $this->AltBody = html_entity_decode($textMsg); -* We have removed the /phpdoc from the downloads. All documentation is now on - the http://phpmailer.codeworxtech.com website. - -Version 2.2.1 () July 19 2008 - -* fixed line 1092 in class.smtp.php (my apologies, error on my part) - -Version 2.2 () July 15 2008 - -* Fixed redirect issue (display of UTF-8 in thank you redirect) -* fixed error in getResponse function declaration (class.pop3.php) -* PHPMailer now PHP6 compliant -* fixed line 1092 in class.smtp.php (endless loop from missing = sign) - -Version 2.1 (Wed, June 04 2008) - -** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. - IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE - APPRECIATED. - -* added S/MIME functionality (ability to digitally sign emails) - BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. - The "Signed Emails" functionality adds the Sign method to pass the private key - filename and the password to read it, and then email will be sent with - content-type multipart/signed and with the digital signature attached. -* fully compatible with E_STRICT error level - - Please note: - In about half the test environments this development version was subjected - to, an error was thrown for the date() functions used (line 1565 and 1569). - This is NOT a PHPMailer error, it is the result of an incorrectly configured - PHP5 installation. The fix is to modify your 'php.ini' file and include the - date.timezone = America/New York - directive, to your own server timezone - - If you do get this error, and are unable to access your php.ini file: - In your PHP script, add - date_default_timezone_set('America/Toronto'); - - do not try to use - $myVar = date_default_timezone_get(); - as a test, it will throw an error. -* added ability to define path (mainly for embedded images) - function MsgHTML($message,$basedir='') ... where: - $basedir is the fully qualified path -* fixed MsgHTML() function: - - Embedded Images where images are specified by :// will not be altered or embedded -* fixed the return value of SMTP exit code ( pclose ) -* addressed issue of multibyte characters in subject line and truncating -* added ability to have user specified Message ID - (default is still that PHPMailer create a unique Message ID) -* corrected unidentified message type to 'application/octet-stream' -* fixed chunk_split() multibyte issue (thanks to Colin Brown, et al). -* added check for added attachments -* enhanced conversion of HTML to text in MsgHTML (thanks to "brunny") - -Version 2.1.0beta2 (Sun, Dec 02 2007) -* implemented updated EncodeQP (thanks to coolbru, aka Marcus Bointon) -* finished all testing, all known bugs corrected, enhancements tested -- note: will NOT work with PHP4. - -please note, this is BETA software -** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS -INTENDED STRICTLY FOR TESTING - -Version 2.1.0beta1 -please note, this is BETA software -** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS -INTENDED STRICTLY FOR TESTING - -Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release -* implements new property to control VERP in class.smtp.php - example (requires instantiating class.smtp.php): - $mail->do_verp = true; -* POP-before-SMTP functionality included, thanks to Richard Davey - (see class.pop3.php & pop3_before_smtp_test.php for examples) -* included example showing how to use PHPMailer with GMAIL -* fixed the missing Cc in SendMail() and Mail() - -****************** -A note on sending bulk emails: - -If the email you are sending is not personalized, consider using the -"undisclosed-recipient:;" strategy. That is, put all of your recipients -in the Bcc field and set the To field to "undisclosed-recipients:;". -It's a lot faster (only one send) and saves quite a bit on resources. -Contrary to some opinions, this will not get you listed in spam engines - -it's a legitimate way for you to send emails. - -A partial example for use with PHPMailer: - -$mail->AddAddress("undisclosed-recipients:;"); -$mail->AddBCC("email1@anydomain.com,email2@anyotherdomain.com,email3@anyalternatedomain.com"); - -Many email service providers restrict the number of emails that can be sent -in any given time period. Often that is between 50 - 60 emails maximum -per hour or per send session. - -If that's the case, then break up your Bcc lists into chunks that are one -less than your limit, and put a pause in your script. -******************* - -Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release -* dramatically simplified using inline graphics ... it's fully automated and requires no user input -* added automatic document type detection for attachments and pictures -* added MsgHTML() function to replace Body tag for HTML emails -* fixed the SendMail security issues (input validation vulnerability) -* enhanced the AddAddresses functionality so that the "Name" portion is used in the email address -* removed the need to use the AltBody method (set from the HTML, or default text used) -* set the PHP Mail() function as the default (still support SendMail, SMTP Mail) -* removed the need to set the IsHTML property (set automatically) -* added Estonian language file by Indrek Päri -* added header injection patch -* added "set" method to permit users to create their own pseudo-properties like 'X-Headers', etc. - example of use: - $mail->set('X-Priority', '3'); - $mail->set('X-MSMail-Priority', 'Normal'); -* fixed warning message in SMTP get_lines method -* added TLS/SSL SMTP support - example of use: - $mail = new PHPMailer(); - $mail->Mailer = "smtp"; - $mail->Host = "smtp.example.com"; - $mail->SMTPSecure = "tls"; // option - //$mail->SMTPSecure = "ssl"; // option - ... - $mail->Send(); -* PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7) -* Works with PHP installed as a module or as CGI-PHP -- NOTE: will NOT work with PHP5 in E_STRICT error mode - -Version 1.73 (Sun, Jun 10 2005) -* Fixed denial of service bug: http://www.cybsec.com/vuln/PHPMailer-DOS.pdf -* Now has a total of 20 translations -* Fixed alt attachments bug: http://tinyurl.com/98u9k - -Version 1.72 (Wed, May 25 2004) -* Added Dutch, Swedish, Czech, Norwegian, and Turkish translations. -* Received: Removed this method because spam filter programs like -SpamAssassin reject this header. -* Fixed error count bug. -* SetLanguage default is now "language/". -* Fixed magic_quotes_runtime bug. - -Version 1.71 (Tue, Jul 28 2003) -* Made several speed enhancements -* Added German and Italian translation files -* Fixed HELO/AUTH bugs on keep-alive connects -* Now provides an error message if language file does not load -* Fixed attachment EOL bug -* Updated some unclear documentation -* Added additional tests and improved others - -Version 1.70 (Mon, Jun 20 2003) -* Added SMTP keep-alive support -* Added IsError method for error detection -* Added error message translation support (SetLanguage) -* Refactored many methods to increase library performance -* Hello now sends the newer EHLO message before HELO as per RFC 2821 -* Removed the boundary class and replaced it with GetBoundary -* Removed queue support methods -* New $Hostname variable -* New Message-ID header -* Received header reformat -* Helo variable default changed to $Hostname -* Removed extra spaces in Content-Type definition (#667182) -* Return-Path should be set to Sender when set -* Adds Q or B encoding to headers when necessary -* quoted-encoding should now encode NULs \000 -* Fixed encoding of body/AltBody (#553370) -* Adds "To: undisclosed-recipients:;" when all recipients are hidden (BCC) -* Multiple bug fixes - -Version 1.65 (Fri, Aug 09 2002) -* Fixed non-visible attachment bug (#585097) for Outlook -* SMTP connections are now closed after each transaction -* Fixed SMTP::Expand return value -* Converted SMTP class documentation to phpDocumentor format - -Version 1.62 (Wed, Jun 26 2002) -* Fixed multi-attach bug -* Set proper word wrapping -* Reduced memory use with attachments -* Added more debugging -* Changed documentation to phpDocumentor format - -Version 1.60 (Sat, Mar 30 2002) -* Sendmail pipe and address patch (Christian Holtje) -* Added embedded image and read confirmation support (A. Ognio) -* Added unit tests -* Added SMTP timeout support (*nix only) -* Added possibly temporary PluginDir variable for SMTP class -* Added LE message line ending variable -* Refactored boundary and attachment code -* Eliminated SMTP class warnings -* Added SendToQueue method for future queuing support - -Version 1.54 (Wed, Dec 19 2001) -* Add some queuing support code -* Fixed a pesky multi/alt bug -* Messages are no longer forced to have "To" addresses - -Version 1.50 (Thu, Nov 08 2001) -* Fix extra lines when not using SMTP mailer -* Set WordWrap variable to int with a zero default - -Version 1.47 (Tue, Oct 16 2001) -* Fixed Received header code format -* Fixed AltBody order error -* Fixed alternate port warning - -Version 1.45 (Tue, Sep 25 2001) -* Added enhanced SMTP debug support -* Added support for multiple ports on SMTP -* Added Received header for tracing -* Fixed AddStringAttachment encoding -* Fixed possible header name quote bug -* Fixed wordwrap() trim bug -* Couple other small bug fixes - -Version 1.41 (Wed, Aug 22 2001) -* Fixed AltBody bug w/o attachments -* Fixed rfc_date() for certain mail servers - -Version 1.40 (Sun, Aug 12 2001) -* Added multipart/alternative support (AltBody) -* Documentation update -* Fixed bug in Mercury MTA - -Version 1.29 (Fri, Aug 03 2001) -* Added AddStringAttachment() method -* Added SMTP authentication support - -Version 1.28 (Mon, Jul 30 2001) -* Fixed a typo in SMTP class -* Fixed header issue with Imail (win32) SMTP server -* Made fopen() calls for attachments use "rb" to fix win32 error - -Version 1.25 (Mon, Jul 02 2001) -* Added RFC 822 date fix (Patrice) -* Added improved error handling by adding a $ErrorInfo variable -* Removed MailerDebug variable (obsolete with new error handler) - -Version 1.20 (Mon, Jun 25 2001) -* Added quoted-printable encoding (Patrice) -* Set Version as public and removed PrintVersion() -* Changed phpdoc to only display public variables and methods - -Version 1.19 (Thu, Jun 21 2001) -* Fixed MS Mail header bug -* Added fix for Bcc problem with mail(). *Does not work on Win32* - (See PHP bug report: http://www.php.net/bugs.php?id=11616) -* mail() no longer passes a fifth parameter when not needed - -Version 1.15 (Fri, Jun 15 2001) -[Note: these changes contributed by Patrice Fournier] -* Changed all remaining \n to \r\n -* Bcc: header no longer writen to message except -when sent directly to sendmail -* Added a small message to non-MIME compliant mail reader -* Added Sender variable to change the Sender email -used in -f for sendmail/mail and in 'MAIL FROM' for smtp mode -* Changed boundary setting to a place it will be set only once -* Removed transfer encoding for whole message when using multipart -* Message body now uses Encoding in multipart messages -* Can set encoding and type to attachments 7bit, 8bit -and binary attachment are sent as is, base64 are encoded -* Can set Encoding to base64 to send 8 bits body -through 7 bits servers - -Version 1.10 (Tue, Jun 12 2001) -* Fixed win32 mail header bug (printed out headers in message body) - -Version 1.09 (Fri, Jun 08 2001) -* Changed date header to work with Netscape mail programs -* Altered phpdoc documentation - -Version 1.08 (Tue, Jun 05 2001) -* Added enhanced error-checking -* Added phpdoc documentation to source - -Version 1.06 (Fri, Jun 01 2001) -* Added optional name for file attachments - -Version 1.05 (Tue, May 29 2001) -* Code cleanup -* Eliminated sendmail header warning message -* Fixed possible SMTP error - -Version 1.03 (Thu, May 24 2001) -* Fixed problem where qmail sends out duplicate messages - -Version 1.02 (Wed, May 23 2001) -* Added multiple recipient and attachment Clear* methods -* Added Sendmail public variable -* Fixed problem with loading SMTP library multiple times - -Version 0.98 (Tue, May 22 2001) -* Fixed problem with redundant mail hosts sending out multiple messages -* Added additional error handler code -* Added AddCustomHeader() function -* Added support for Microsoft mail client headers (affects priority) -* Fixed small bug with Mailer variable -* Added PrintVersion() function - -Version 0.92 (Tue, May 15 2001) -* Changed file names to class.phpmailer.php and class.smtp.php to match - current PHP class trend. -* Fixed problem where body not being printed when a message is attached -* Several small bug fixes - -Version 0.90 (Tue, April 17 2001) -* Intial public release diff --git a/inc/classes/third_party/php_mailer/LICENSE b/inc/classes/third_party/php_mailer/LICENSE deleted file mode 100644 index f3f1b3b6..00000000 --- a/inc/classes/third_party/php_mailer/LICENSE +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/inc/classes/third_party/php_mailer/README b/inc/classes/third_party/php_mailer/README deleted file mode 100644 index 3f0ee3fa..00000000 --- a/inc/classes/third_party/php_mailer/README +++ /dev/null @@ -1,193 +0,0 @@ -/******************************************************************* -* The http://phpmailer.codeworxtech.com/ website now carries a few * -* advertisements through the Google Adsense network. Please visit * -* the advertiser sites and help us offset some of our costs. * -* Thanks .... * -********************************************************************/ - -PHPMailer -Full Featured Email Transfer Class for PHP -========================================== - -Version 2.3 (November 08, 2008) - -We have removed the /phpdoc from the downloads. All documentation is now on -the http://phpmailer.codeworxtech.com website. - -The phpunit.php has been updated to support PHP5. - -For all other changes and notes, please see the changelog. - -Donations are accepted at PayPal with our id "paypal@worxteam.com". - -Version 2.2 (July 15 2008) - -- see the changelog. - -Version 2.1 (June 04 2008) - -With this release, we are announcing that the development of PHPMailer for PHP5 -will be our focus from this date on. We have implemented all the enhancements -and fixes from the latest release of PHPMailer for PHP4. - -Far more important, though, is that this release of PHPMailer (v2.1) is -fully tested with E_STRICT error checking enabled. - -** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. - IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE - APPRECIATED. - -We have now added S/MIME functionality (ability to digitally sign emails). -BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. -The "Signed Emails" functionality adds the Sign method to pass the private key -filename and the password to read it, and then email will be sent with -content-type multipart/signed and with the digital signature attached. - -A quick note on E_STRICT: - -- In about half the test environments the development version was subjected - to, an error was thrown for the date() functions (used at line 1565 and 1569). - This is NOT a PHPMailer error, it is the result of an incorrectly configured - PHP5 installation. The fix is to modify your 'php.ini' file and include the - date.timezone = America/New York - directive, (for your own server timezone) -- If you do get this error, and are unable to access your php.ini file, there is - a workaround. In your PHP script, add - date_default_timezone_set('America/Toronto'); - - * do NOT try to use - $myVar = date_default_timezone_get(); - as a test, it will throw an error. - -We have also included more example files to show the use of "sendmail", "mail()", -"smtp", and "gmail". - -We are also looking for more programmers to join the volunteer development team. -If you have an interest in this, please let us know. - -Enjoy! - - -Version 2.1.0beta1 & beta2 - -please note, this is BETA software -** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS -INTENDED STRICTLY FOR TESTING - -** NOTE: - -As of November 2007, PHPMailer has a new project team headed by industry -veteran Andy Prevost (codeworxtech). The first release in more than two -years will focus on fixes, adding ease-of-use enhancements, provide -basic compatibility with PHP4 and PHP5 using PHP5 backwards compatibility -features. A new release is planned before year-end 2007 that will provide -full compatiblity with PHP4 and PHP5, as well as more bug fixes. - -We are looking for project developers to assist in restoring PHPMailer to -its leadership position. Our goals are to simplify use of PHPMailer, provide -good documentation and examples, and retain backward compatibility to level -1.7.3 standards. - -If you are interested in helping out, visit http://sourceforge.net/projects/phpmailer -and indicate your interest. - -** - -http://phpmailer.sourceforge.net/ - -This software is licenced under the LGPL. Please read LICENSE for information on the -software availability and distribution. - -Class Features: -- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs -- Redundant SMTP servers -- Multipart/alternative emails for mail clients that do not read HTML email -- Support for 8bit, base64, binary, and quoted-printable encoding -- Uses the same methods as the very popular AspEmail active server (COM) component -- SMTP authentication -- Native language support -- Word wrap, and more! - -Why you might need it: - -Many PHP developers utilize email in their code. The only PHP function -that supports this is the mail() function. However, it does not expose -any of the popular features that many email clients use nowadays like -HTML-based emails and attachments. There are two proprietary -development tools out there that have all the functionality built into -easy to use classes: AspEmail(tm) and AspMail. Both of these -programs are COM components only available on Windows. They are also a -little pricey for smaller projects. - -Since I do Linux development I’ve missed these tools for my PHP coding. -So I built a version myself that implements the same methods (object -calls) that the Windows-based components do. It is open source and the -LGPL license allows you to place the class in your proprietary PHP -projects. - - -Installation: - -Copy class.phpmailer.php into your php.ini include_path. If you are -using the SMTP mailer then place class.smtp.php in your path as well. -In the language directory you will find several files like -phpmailer.lang-en.php. If you look right before the .php extension -that there are two letters. These represent the language type of the -translation file. For instance "en" is the English file and "br" is -the Portuguese file. Chose the file that best fits with your language -and place it in the PHP include path. If your language is English -then you have nothing more to do. If it is a different language then -you must point PHPMailer to the correct translation. To do this, call -the PHPMailer SetLanguage method like so: - -// To load the Portuguese version -$mail->SetLanguage("br", "/optional/path/to/language/directory/"); - -That's it. You should now be ready to use PHPMailer! - - -A Simple Example: - -IsSMTP(); // set mailer to use SMTP -$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server -$mail->SMTPAuth = true; // turn on SMTP authentication -$mail->Username = "jswan"; // SMTP username -$mail->Password = "secret"; // SMTP password - -$mail->From = "from@example.com"; -$mail->FromName = "Mailer"; -$mail->AddAddress("josh@example.net", "Josh Adams"); -$mail->AddAddress("ellen@example.com"); // name is optional -$mail->AddReplyTo("info@example.com", "Information"); - -$mail->WordWrap = 50; // set word wrap to 50 characters -$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments -$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name -$mail->IsHTML(true); // set email format to HTML - -$mail->Subject = "Here is the subject"; -$mail->Body = "This is the HTML message body in bold!"; -$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; - -if(!$mail->Send()) -{ - echo "Message could not be sent.

"; - echo "Mailer Error: " . $mail->ErrorInfo; - exit; -} - -echo "Message has been sent"; -?> - -CHANGELOG - -See ChangeLog.txt - -Download: http://sourceforge.net/project/showfiles.php?group_id=26031 - -Andy Prevost diff --git a/inc/classes/third_party/php_mailer/class.phpmailer.php b/inc/classes/third_party/php_mailer/class.phpmailer.php deleted file mode 100644 index 419b26b6..00000000 --- a/inc/classes/third_party/php_mailer/class.phpmailer.php +++ /dev/null @@ -1,1910 +0,0 @@ -ContentType = 'text/html'; - } else { - $this->ContentType = 'text/plain'; - } - } - - /** - * Sets Mailer to send message using SMTP. - * @return void - */ - public function IsSMTP() { - $this->Mailer = 'smtp'; - } - - /** - * Sets Mailer to send message using PHP mail() function. - * @return void - */ - public function IsMail() { - $this->Mailer = 'mail'; - } - - /** - * Sets Mailer to send message using the $Sendmail program. - * @return void - */ - public function IsSendmail() { - $this->Mailer = 'sendmail'; - } - - /** - * Sets Mailer to send message using the qmail MTA. - * @return void - */ - public function IsQmail() { - $this->Sendmail = '/var/qmail/bin/sendmail'; - $this->Mailer = 'sendmail'; - } - - ///////////////////////////////////////////////// - // METHODS, RECIPIENTS - ///////////////////////////////////////////////// - - /** - * Adds a "To" address. - * @param string $address - * @param string $name - * @return void - */ - public function AddAddress($address, $name = '') { - $cur = count($this->to); - $this->to[$cur][0] = trim($address); - $this->to[$cur][1] = $name; - } - - /** - * Adds a "Cc" address. Note: this function works - * with the SMTP mailer on win32, not with the "mail" - * mailer. - * @param string $address - * @param string $name - * @return void - */ - public function AddCC($address, $name = '') { - $cur = count($this->cc); - $this->cc[$cur][0] = trim($address); - $this->cc[$cur][1] = $name; - } - - /** - * Adds a "Bcc" address. Note: this function works - * with the SMTP mailer on win32, not with the "mail" - * mailer. - * @param string $address - * @param string $name - * @return void - */ - public function AddBCC($address, $name = '') { - $cur = count($this->bcc); - $this->bcc[$cur][0] = trim($address); - $this->bcc[$cur][1] = $name; - } - - /** - * Adds a "Reply-to" address. - * @param string $address - * @param string $name - * @return void - */ - public function AddReplyTo($address, $name = '') { - $cur = count($this->ReplyTo); - $this->ReplyTo[$cur][0] = trim($address); - $this->ReplyTo[$cur][1] = $name; - } - - ///////////////////////////////////////////////// - // METHODS, MAIL SENDING - ///////////////////////////////////////////////// - - /** - * Creates message and assigns Mailer. If the message is - * not sent successfully then it returns false. Use the ErrorInfo - * variable to view description of the error. - * @return bool - */ - public function Send() { - $header = ''; - $body = ''; - $result = true; - - if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - $this->SetError($this->Lang('provide_address')); - return false; - } - - /* Set whether the message is multipart/alternative */ - if(!empty($this->AltBody)) { - $this->ContentType = 'multipart/alternative'; - } - - $this->error_count = 0; // reset errors - $this->SetMessageType(); - $header .= $this->CreateHeader(); - $body = $this->CreateBody(); - - if($body == '') { - return false; - } - - /* Choose the mailer */ - switch($this->Mailer) { - case 'sendmail': - $result = $this->SendmailSend($header, $body); - break; - case 'smtp': - $result = $this->SmtpSend($header, $body); - break; - case 'mail': - $result = $this->MailSend($header, $body); - break; - default: - $result = $this->MailSend($header, $body); - break; - //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); - //$result = false; - //break; - } - - return $result; - } - - /** - * Sends mail using the $Sendmail program. - * @access public - * @return bool - */ - public function SendmailSend($header, $body) { - if ($this->Sender != '') { - $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); - } else { - $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); - } - - if(!@$mail = popen($sendmail, 'w')) { - $this->SetError($this->Lang('execute') . $this->Sendmail); - return false; - } - - fputs($mail, $header); - fputs($mail, $body); - - $result = pclose($mail); - if (version_compare(phpversion(), '4.2.3') == -1) { - $result = $result >> 8 & 0xFF; - } - if($result != 0) { - $this->SetError($this->Lang('execute') . $this->Sendmail); - return false; - } - - return true; - } - - /** - * Sends mail using the PHP mail() function. - * @access public - * @return bool - */ - public function MailSend($header, $body) { - - $to = ''; - for($i = 0; $i < count($this->to); $i++) { - if($i != 0) { $to .= ', '; } - $to .= $this->AddrFormat($this->to[$i]); - } - - $toArr = split(',', $to); - - $params = sprintf("-oi -f %s", $this->Sender); - if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { - $old_from = ini_get('sendmail_from'); - ini_set('sendmail_from', $this->Sender); - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); - } - } - - if (isset($old_from)) { - ini_set('sendmail_from', $old_from); - } - - if(!$rt) { - $this->SetError($this->Lang('instantiate')); - return false; - } - - return true; - } - - /** - * Sends mail via SMTP using PhpSMTP (Author: - * Chris Ryan). Returns bool. Returns false if there is a - * bad MAIL FROM, RCPT, or DATA input. - * @access public - * @return bool - */ - public function SmtpSend($header, $body) { - include_once($this->PluginDir . 'class.smtp.php'); - $error = ''; - $bad_rcpt = array(); - - if(!$this->SmtpConnect()) { - return false; - } - - $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; - if(!$this->smtp->Mail($smtp_from)) { - $error = $this->Lang('from_failed') . $smtp_from; - $this->SetError($error); - $this->smtp->Reset(); - return false; - } - - /* Attempt to send attach all recipients */ - for($i = 0; $i < count($this->to); $i++) { - if(!$this->smtp->Recipient($this->to[$i][0])) { - $bad_rcpt[] = $this->to[$i][0]; - } - } - for($i = 0; $i < count($this->cc); $i++) { - if(!$this->smtp->Recipient($this->cc[$i][0])) { - $bad_rcpt[] = $this->cc[$i][0]; - } - } - for($i = 0; $i < count($this->bcc); $i++) { - if(!$this->smtp->Recipient($this->bcc[$i][0])) { - $bad_rcpt[] = $this->bcc[$i][0]; - } - } - - if(count($bad_rcpt) > 0) { // Create error message - for($i = 0; $i < count($bad_rcpt); $i++) { - if($i != 0) { - $error .= ', '; - } - $error .= $bad_rcpt[$i]; - } - $error = $this->Lang('recipients_failed') . $error; - $this->SetError($error); - $this->smtp->Reset(); - return false; - } - - if(!$this->smtp->Data($header . $body)) { - $this->SetError($this->Lang('data_not_accepted')); - $this->smtp->Reset(); - return false; - } - if($this->SMTPKeepAlive == true) { - $this->smtp->Reset(); - } else { - $this->SmtpClose(); - } - - return true; - } - - /** - * Initiates a connection to an SMTP server. Returns false if the - * operation failed. - * @access public - * @return bool - */ - public function SmtpConnect() { - if($this->smtp == NULL) { - $this->smtp = new SMTP(); - } - - $this->smtp->do_debug = $this->SMTPDebug; - $hosts = explode(';', $this->Host); - $index = 0; - $connection = ($this->smtp->Connected()); - - /* Retry while there is no connection */ - while($index < count($hosts) && $connection == false) { - $hostinfo = array(); - if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { - $host = $hostinfo[1]; - $port = $hostinfo[2]; - } else { - $host = $hosts[$index]; - $port = $this->Port; - } - - $tls = ($this->SMTPSecure == 'tls'); - $ssl = ($this->SMTPSecure == 'ssl'); - - if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { - - $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname()); - $this->smtp->Hello($hello); - - if($tls) { - if(!$this->smtp->StartTLS()) { - $this->SetError($this->Lang("tls")); - $this->smtp->Reset(); - $connection = false; - } - - //We must resend HELLO after tls negociation - $this->smtp->Hello($hello); - } - - $connection = true; - if($this->SMTPAuth) { - if(!$this->smtp->Authenticate($this->Username, $this->Password)) { - $this->SetError($this->Lang('authenticate')); - $this->smtp->Reset(); - $connection = false; - } - } - } - $index++; - } - if(!$connection) { - $this->SetError($this->Lang('connect_host')); - } - - return $connection; - } - - /** - * Closes the active SMTP session if one exists. - * @return void - */ - public function SmtpClose() { - if($this->smtp != NULL) { - if($this->smtp->Connected()) { - $this->smtp->Quit(); - $this->smtp->Close(); - } - } - } - - /** - * Sets the language for all class error messages. Returns false - * if it cannot load the language file. The default language type - * is English. - * @param string $lang_type Type of language (e.g. Portuguese: "br") - * @param string $lang_path Path to the language file directory - * @access public - * @return bool - */ - function SetLanguage($lang_type = 'en', $lang_path = 'language/') { - if( !(@include $lang_path.'phpmailer.lang-'.$lang_type.'.php') ) { - $PHPMAILER_LANG = array(); - $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' . - $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.'; - $PHPMAILER_LANG["execute"] = 'Could not execute: '; - $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.'; - $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.'; - $PHPMAILER_LANG["from_failed"] = 'The following From address failed: '; - $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' . - $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.'; - $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.'; - $PHPMAILER_LANG["file_access"] = 'Could not access file: '; - $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: '; - $PHPMAILER_LANG["encoding"] = 'Unknown encoding: '; - $PHPMAILER_LANG["signing"] = 'Signing Error: '; - } - $this->language = $PHPMAILER_LANG; - return true; - } - - ///////////////////////////////////////////////// - // METHODS, MESSAGE CREATION - ///////////////////////////////////////////////// - - /** - * Creates recipient headers. - * @access public - * @return string - */ - public function AddrAppend($type, $addr) { - $addr_str = $type . ': '; - $addr_str .= $this->AddrFormat($addr[0]); - if(count($addr) > 1) { - for($i = 1; $i < count($addr); $i++) { - $addr_str .= ', ' . $this->AddrFormat($addr[$i]); - } - } - $addr_str .= $this->LE; - - return $addr_str; - } - - /** - * Formats an address correctly. - * @access public - * @return string - */ - public function AddrFormat($addr) { - if(empty($addr[1])) { - $formatted = $this->SecureHeader($addr[0]); - } else { - $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; - } - - return $formatted; - } - - /** - * Wraps message for use with mailers that do not - * automatically perform wrapping and for quoted-printable. - * Original written by philippe. - * @access public - * @return string - */ - public function WrapText($message, $length, $qp_mode = false) { - $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; - // If utf-8 encoding is used, we will need to make sure we don't - // split multibyte characters when we wrap - $is_utf8 = (strtolower($this->CharSet) == "utf-8"); - - $message = $this->FixEOL($message); - if (substr($message, -1) == $this->LE) { - $message = substr($message, 0, -1); - } - - $line = explode($this->LE, $message); - $message = ''; - for ($i=0 ;$i < count($line); $i++) { - $line_part = explode(' ', $line[$i]); - $buf = ''; - for ($e = 0; $e $length)) { - $space_left = $length - strlen($buf) - 1; - if ($e != 0) { - if ($space_left > 20) { - $len = $space_left; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - $buf .= ' ' . $part; - $message .= $buf . sprintf("=%s", $this->LE); - } else { - $message .= $buf . $soft_break; - } - $buf = ''; - } - while (strlen($word) > 0) { - $len = $length; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - - if (strlen($word) > 0) { - $message .= $part . sprintf("=%s", $this->LE); - } else { - $buf = $part; - } - } - } else { - $buf_o = $buf; - $buf .= ($e == 0) ? $word : (' ' . $word); - - if (strlen($buf) > $length and $buf_o != '') { - $message .= $buf_o . $soft_break; - $buf = $word; - } - } - } - $message .= $buf . $this->LE; - } - - return $message; - } - - /** - * Finds last character boundary prior to maxLength in a utf-8 - * quoted (printable) encoded string. - * Original written by Colin Brown. - * @access public - * @param string $encodedText utf-8 QP text - * @param int $maxLength find last character boundary prior to this length - * @return int - */ - public function UTF8CharBoundary($encodedText, $maxLength) { - $foundSplitPos = false; - $lookBack = 3; - while (!$foundSplitPos) { - $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); - $encodedCharPos = strpos($lastChunk, "="); - if ($encodedCharPos !== false) { - // Found start of encoded character byte within $lookBack block. - // Check the encoded byte value (the 2 chars after the '=') - $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); - $dec = hexdec($hex); - if ($dec < 128) { // Single byte character. - // If the encoded char was found at pos 0, it will fit - // otherwise reduce maxLength to start of the encoded char - $maxLength = ($encodedCharPos == 0) ? $maxLength : - $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec >= 192) { // First byte of a multi byte character - // Reduce maxLength to split at start of character - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back - $lookBack += 3; - } - } else { - // No encoded character found - $foundSplitPos = true; - } - } - return $maxLength; - } - - - /** - * Set the body wrapping. - * @access public - * @return void - */ - public function SetWordWrap() { - if($this->WordWrap < 1) { - return; - } - - switch($this->message_type) { - case 'alt': - /* fall through */ - case 'alt_attachments': - $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); - break; - default: - $this->Body = $this->WrapText($this->Body, $this->WordWrap); - break; - } - } - - /** - * Assembles message header. - * @access public - * @return string - */ - public function CreateHeader() { - $result = ''; - - /* Set the boundaries */ - $uniq_id = md5(uniqid(time())); - $this->boundary[1] = 'b1_' . $uniq_id; - $this->boundary[2] = 'b2_' . $uniq_id; - - $result .= $this->HeaderLine('Date', $this->RFCDate()); - if($this->Sender == '') { - $result .= $this->HeaderLine('Return-Path', trim($this->From)); - } else { - $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); - } - - /* To be created automatically by mail() */ - if($this->Mailer != 'mail') { - if(count($this->to) > 0) { - $result .= $this->AddrAppend('To', $this->to); - } elseif (count($this->cc) == 0) { - $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); - } - } - - $from = array(); - $from[0][0] = trim($this->From); - $from[0][1] = $this->FromName; - $result .= $this->AddrAppend('From', $from); - - /* sendmail and mail() extract Cc from the header before sending */ - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) { - $result .= $this->AddrAppend('Cc', $this->cc); - } - - /* sendmail and mail() extract Bcc from the header before sending */ - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { - $result .= $this->AddrAppend('Bcc', $this->bcc); - } - - if(count($this->ReplyTo) > 0) { - $result .= $this->AddrAppend('Reply-to', $this->ReplyTo); - } - - /* mail() sets the subject itself */ - if($this->Mailer != 'mail') { - $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); - } - - if($this->MessageID != '') { - $result .= $this->HeaderLine('Message-ID',$this->MessageID); - } else { - $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); - } - $result .= $this->HeaderLine('X-Priority', $this->Priority); - $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.codeworxtech.com) [version ' . $this->Version . ']'); - - if($this->ConfirmReadingTo != '') { - $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); - } - - // Add custom headers - for($index = 0; $index < count($this->CustomHeader); $index++) { - $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); - } - if (!$this->sign_key_file) { - $result .= $this->HeaderLine('MIME-Version', '1.0'); - $result .= $this->GetMailMIME(); - } - - return $result; - } - - /** - * Returns the message MIME. - * @access public - * @return string - */ - public function GetMailMIME() { - $result = ''; - switch($this->message_type) { - case 'plain': - $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); - $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); - break; - case 'attachments': - /* fall through */ - case 'alt_attachments': - if($this->InlineImageExists()){ - $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); - } else { - $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - } - break; - case 'alt': - $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - break; - } - - if($this->Mailer != 'mail') { - $result .= $this->LE.$this->LE; - } - - return $result; - } - - /** - * Assembles the message body. Returns an empty string on failure. - * @access public - * @return string - */ - public function CreateBody() { - $result = ''; - - if ($this->sign_key_file) { - $result .= $this->GetMailMIME(); - } - - $this->SetWordWrap(); - - switch($this->message_type) { - case 'alt': - $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); - $result .= $this->EncodeString($this->AltBody, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->EndBoundary($this->boundary[1]); - break; - case 'plain': - $result .= $this->EncodeString($this->Body, $this->Encoding); - break; - case 'attachments': - $result .= $this->GetBoundary($this->boundary[1], '', '', ''); - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE; - $result .= $this->AttachAll(); - break; - case 'alt_attachments': - $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); - $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); - $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body - $result .= $this->EncodeString($this->AltBody, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->EndBoundary($this->boundary[2]); - $result .= $this->AttachAll(); - break; - } - - if($this->IsError()) { - $result = ''; - } else if ($this->sign_key_file) { - $file = tempnam("", "mail"); - $fp = fopen($file, "w"); - fwrite($fp, $result); - fclose($fp); - $signed = tempnam("", "signed"); - - if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { - $fp = fopen($signed, "r"); - $result = ''; - while(!feof($fp)){ - $result = $result . fread($fp, 1024); - } - fclose($fp); - } else { - $this->SetError($this->Lang("signing").openssl_error_string()); - $result = ''; - } - - unlink($file); - unlink($signed); - } - - return $result; - } - - /** - * Returns the start of a message boundary. - * @access public - */ - public function GetBoundary($boundary, $charSet, $contentType, $encoding) { - $result = ''; - if($charSet == '') { - $charSet = $this->CharSet; - } - if($contentType == '') { - $contentType = $this->ContentType; - } - if($encoding == '') { - $encoding = $this->Encoding; - } - $result .= $this->TextLine('--' . $boundary); - $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); - $result .= $this->LE; - $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); - $result .= $this->LE; - - return $result; - } - - /** - * Returns the end of a message boundary. - * @access public - */ - public function EndBoundary($boundary) { - return $this->LE . '--' . $boundary . '--' . $this->LE; - } - - /** - * Sets the message type. - * @access public - * @return void - */ - public function SetMessageType() { - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { - $this->message_type = 'plain'; - } else { - if(count($this->attachment) > 0) { - $this->message_type = 'attachments'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { - $this->message_type = 'alt'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { - $this->message_type = 'alt_attachments'; - } - } - } - - /* Returns a formatted header line. - * @access public - * @return string - */ - public function HeaderLine($name, $value) { - return $name . ': ' . $value . $this->LE; - } - - /** - * Returns a formatted mail line. - * @access public - * @return string - */ - public function TextLine($value) { - return $value . $this->LE; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, ATTACHMENTS - ///////////////////////////////////////////////// - - /** - * Adds an attachment from a path on the filesystem. - * Returns false if the file could not be found - * or accessed. - * @param string $path Path to the attachment. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - if(!@is_file($path)) { - $this->SetError($this->Lang('file_access') . $path); - return false; - } - - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - $cur = count($this->attachment); - $this->attachment[$cur][0] = $path; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $name; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = false; // isStringAttachment - $this->attachment[$cur][6] = 'attachment'; - $this->attachment[$cur][7] = 0; - - return true; - } - - /** - * Attaches all fs, string, and binary attachments to the message. - * Returns an empty string on failure. - * @access public - * @return string - */ - public function AttachAll() { - /* Return text of body */ - $mime = array(); - - /* Add all attachments */ - for($i = 0; $i < count($this->attachment); $i++) { - /* Check for string attachment */ - $bString = $this->attachment[$i][5]; - if ($bString) { - $string = $this->attachment[$i][0]; - } else { - $path = $this->attachment[$i][0]; - } - - $filename = $this->attachment[$i][1]; - $name = $this->attachment[$i][2]; - $encoding = $this->attachment[$i][3]; - $type = $this->attachment[$i][4]; - $disposition = $this->attachment[$i][6]; - $cid = $this->attachment[$i][7]; - - $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); - //$mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE); - $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); - $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); - - if($disposition == 'inline') { - $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); - } - - //$mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE); - $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); - - /* Encode as string attachment */ - if($bString) { - $mime[] = $this->EncodeString($string, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } else { - $mime[] = $this->EncodeFile($path, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } - } - - $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); - - return join('', $mime); - } - - /** - * Encodes attachment in requested format. Returns an - * empty string on failure. - * @access public - * @return string - */ - public function EncodeFile ($path, $encoding = 'base64') { - if(!@$fd = fopen($path, 'rb')) { - $this->SetError($this->Lang('file_open') . $path); - return ''; - } - if (function_exists('get_magic_quotes')) { - function get_magic_quotes() { - return false; - } -} - if (PHP_VERSION < 6) { - $magic_quotes = get_magic_quotes_runtime(); - set_magic_quotes_runtime(0); - } - $file_buffer = file_get_contents($path); - $file_buffer = $this->EncodeString($file_buffer, $encoding); - fclose($fd); - if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } - return $file_buffer; - } - - /** - * Encodes string to requested format. Returns an - * empty string on failure. - * @access public - * @return string - */ - public function EncodeString ($str, $encoding = 'base64') { - $encoded = ''; - switch(strtolower($encoding)) { - case 'base64': - $encoded = chunk_split(base64_encode($str), 76, $this->LE); - break; - case '7bit': - case '8bit': - $encoded = $this->FixEOL($str); - if (substr($encoded, -(strlen($this->LE))) != $this->LE) - $encoded .= $this->LE; - break; - case 'binary': - $encoded = $str; - break; - case 'quoted-printable': - $encoded = $this->EncodeQP($str); - break; - default: - $this->SetError($this->Lang('encoding') . $encoding); - break; - } - return $encoded; - } - - /** - * Encode a header string to best of Q, B, quoted or none. - * @access public - * @return string - */ - public function EncodeHeader ($str, $position = 'text') { - $x = 0; - - switch (strtolower($position)) { - case 'phrase': - if (!preg_match('/[\200-\377]/', $str)) { - /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */ - $encoded = addcslashes($str, "\0..\37\177\\\""); - if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { - return ($encoded); - } else { - return ("\"$encoded\""); - } - } - $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); - break; - case 'comment': - $x = preg_match_all('/[()"]/', $str, $matches); - /* Fall-through */ - case 'text': - default: - $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); - break; - } - - if ($x == 0) { - return ($str); - } - - $maxlen = 75 - 7 - strlen($this->CharSet); - /* Try to select the encoding which should produce the shortest output */ - if (strlen($str)/3 < $x) { - $encoding = 'B'; - if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { - // Use a custom function which correctly encodes and wraps long - // multibyte strings without breaking lines within a character - $encoded = $this->Base64EncodeWrapMB($str); - } else { - $encoded = base64_encode($str); - $maxlen -= $maxlen % 4; - $encoded = trim(chunk_split($encoded, $maxlen, "\n")); - } - } else { - $encoding = 'Q'; - $encoded = $this->EncodeQ($str, $position); - $encoded = $this->WrapText($encoded, $maxlen, true); - $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); - } - - $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); - $encoded = trim(str_replace("\n", $this->LE, $encoded)); - - return $encoded; - } - - /** - * Checks if a string contains multibyte characters. - * @access public - * @param string $str multi-byte text to wrap encode - * @return bool - */ - public function HasMultiBytes($str) { - if (function_exists('mb_strlen')) { - return (strlen($str) > mb_strlen($str, $this->CharSet)); - } else { // Assume no multibytes (we can't handle without mbstring functions anyway) - return False; - } - } - - /** - * Correctly encodes and wraps long multibyte strings for mail headers - * without breaking lines within a character. - * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php - * @access public - * @param string $str multi-byte text to wrap encode - * @return string - */ - public function Base64EncodeWrapMB($str) { - $start = "=?".$this->CharSet."?B?"; - $end = "?="; - $encoded = ""; - - $mb_length = mb_strlen($str, $this->CharSet); - // Each line must have length <= 75, including $start and $end - $length = 75 - strlen($start) - strlen($end); - // Average multi-byte ratio - $ratio = $mb_length / strlen($str); - // Base64 has a 4:3 ratio - $offset = $avgLength = floor($length * $ratio * .75); - - for ($i = 0; $i < $mb_length; $i += $offset) { - $lookBack = 0; - - do { - $offset = $avgLength - $lookBack; - $chunk = mb_substr($str, $i, $offset, $this->CharSet); - $chunk = base64_encode($chunk); - $lookBack++; - } - while (strlen($chunk) > $length); - - $encoded .= $chunk . $this->LE; - } - - // Chomp the last linefeed - $encoded = substr($encoded, 0, -strlen($this->LE)); - return $encoded; - } - - /** - * Encode string to quoted-printable. - * @access public - * @param string $string the text to encode - * @param integer $line_max Number of chars allowed on a line before wrapping - * @return string - */ - public function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) { - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); - $lines = preg_split('/(?:\r\n|\r|\n)/', $input); - $eol = "\r\n"; - $escape = '='; - $output = ''; - while( list(, $line) = each($lines) ) { - $linlen = strlen($line); - $newline = ''; - for($i = 0; $i < $linlen; $i++) { - $c = substr( $line, $i, 1 ); - $dec = ord( $c ); - if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E - $c = '=2E'; - } - if ( $dec == 32 ) { - if ( $i == ( $linlen - 1 ) ) { // convert space at eol only - $c = '=20'; - } else if ( $space_conv ) { - $c = '=20'; - } - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required - $h2 = floor($dec/16); - $h1 = floor($dec%16); - $c = $escape.$hex[$h2].$hex[$h1]; - } - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted - $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay - $newline = ''; - // check if newline first character will be point or not - if ( $dec == 46 ) { - $c = '=2E'; - } - } - $newline .= $c; - } // end of for - $output .= $newline.$eol; - } // end of while - return $output; - } - - /** - * Encode string to q encoding. - * @access public - * @return string - */ - public function EncodeQ ($str, $position = 'text') { - /* There should not be any EOL in the string */ - $encoded = preg_replace("[\r\n]", '', $str); - - switch (strtolower($position)) { - case 'phrase': - $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); - break; - case 'comment': - $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); - case 'text': - default: - /* Replace every high ascii, control =, ? and _ characters */ - $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', - "'='.sprintf('%02X', ord('\\1'))", $encoded); - break; - } - - /* Replace every spaces to _ (more readable than =20) */ - $encoded = str_replace(' ', '_', $encoded); - - return $encoded; - } - - /** - * Adds a string or binary attachment (non-filesystem) to the list. - * This method can be used to attach ascii or binary data, - * such as a BLOB record from a database. - * @param string $string String attachment data. - * @param string $filename Name of the attachment. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return void - */ - public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { - /* Append to $attachment array */ - $cur = count($this->attachment); - $this->attachment[$cur][0] = $string; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $filename; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = true; // isString - $this->attachment[$cur][6] = 'attachment'; - $this->attachment[$cur][7] = 0; - } - - /** - * Adds an embedded attachment. This can include images, sounds, and - * just about any other document. Make sure to set the $type to an - * image type. For JPEG images use "image/jpeg" and for GIF images - * use "image/gif". - * @param string $path Path to the attachment. - * @param string $cid Content ID of the attachment. Use this to identify - * the Id for accessing the image in an HTML form. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - - if(!@is_file($path)) { - $this->SetError($this->Lang('file_access') . $path); - return false; - } - - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - /* Append to $attachment array */ - $cur = count($this->attachment); - $this->attachment[$cur][0] = $path; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $name; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = false; - $this->attachment[$cur][6] = 'inline'; - $this->attachment[$cur][7] = $cid; - - return true; - } - - /** - * Returns true if an inline attachment is present. - * @access public - * @return bool - */ - public function InlineImageExists() { - $result = false; - for($i = 0; $i < count($this->attachment); $i++) { - if($this->attachment[$i][6] == 'inline') { - $result = true; - break; - } - } - - return $result; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MESSAGE RESET - ///////////////////////////////////////////////// - - /** - * Clears all recipients assigned in the TO array. Returns void. - * @return void - */ - public function ClearAddresses() { - $this->to = array(); - } - - /** - * Clears all recipients assigned in the CC array. Returns void. - * @return void - */ - public function ClearCCs() { - $this->cc = array(); - } - - /** - * Clears all recipients assigned in the BCC array. Returns void. - * @return void - */ - public function ClearBCCs() { - $this->bcc = array(); - } - - /** - * Clears all recipients assigned in the ReplyTo array. Returns void. - * @return void - */ - public function ClearReplyTos() { - $this->ReplyTo = array(); - } - - /** - * Clears all recipients assigned in the TO, CC and BCC - * array. Returns void. - * @return void - */ - public function ClearAllRecipients() { - $this->to = array(); - $this->cc = array(); - $this->bcc = array(); - } - - /** - * Clears all previously set filesystem, string, and binary - * attachments. Returns void. - * @return void - */ - public function ClearAttachments() { - $this->attachment = array(); - } - - /** - * Clears all custom headers. Returns void. - * @return void - */ - public function ClearCustomHeaders() { - $this->CustomHeader = array(); - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MISCELLANEOUS - ///////////////////////////////////////////////// - - /** - * Adds the error message to the error container. - * Returns void. - * @access private - * @return void - */ - private function SetError($msg) { - $this->error_count++; - $this->ErrorInfo = $msg; - } - - /** - * Returns the proper RFC 822 formatted date. - * @access private - * @return string - */ - private static function RFCDate() { - $tz = date('Z'); - $tzs = ($tz < 0) ? '-' : '+'; - $tz = abs($tz); - $tz = (int)($tz/3600)*100 + ($tz%3600)/60; - $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); - - return $result; - } - - /** - * Returns the server hostname or 'localhost.localdomain' if unknown. - * @access private - * @return string - */ - private function ServerHostname() { - if (!empty($this->Hostname)) { - $result = $this->Hostname; - } elseif (isset($_SERVER['SERVER_NAME'])) { - $result = $_SERVER['SERVER_NAME']; - } else { - $result = "localhost.localdomain"; - } - - return $result; - } - - /** - * Returns a message in the appropriate language. - * @access private - * @return string - */ - private function Lang($key) { - if(count($this->language) < 1) { - $this->SetLanguage('en'); // set the default language - } - - if(isset($this->language[$key])) { - return $this->language[$key]; - } else { - return 'Language string failed to load: ' . $key; - } - } - - /** - * Returns true if an error occurred. - * @access public - * @return bool - */ - public function IsError() { - return ($this->error_count > 0); - } - - /** - * Changes every end of line from CR or LF to CRLF. - * @access private - * @return string - */ - private function FixEOL($str) { - $str = str_replace("\r\n", "\n", $str); - $str = str_replace("\r", "\n", $str); - $str = str_replace("\n", $this->LE, $str); - return $str; - } - - /** - * Adds a custom header. - * @access public - * @return void - */ - public function AddCustomHeader($custom_header) { - $this->CustomHeader[] = explode(':', $custom_header, 2); - } - - /** - * Evaluates the message and returns modifications for inline images and backgrounds - * @access public - * @return $message - */ - public function MsgHTML($message,$basedir='') { - preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); - if(isset($images[2])) { - foreach($images[2] as $i => $url) { - // do not change urls for absolute images (thanks to corvuscorax) - if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) { - $filename = basename($url); - $directory = dirname($url); - ($directory == '.')?$directory='':''; - $cid = 'cid:' . md5($filename); - $fileParts = split("\.", $filename); - $ext = $fileParts[1]; - $mimeType = $this->_mime_types($ext); - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } - if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { - $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); - } - } - } - } - $this->IsHTML(true); - $this->Body = $message; - $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); - if ( !empty($textMsg) && empty($this->AltBody) ) { - $this->AltBody = html_entity_decode($textMsg); - } - if ( empty($this->AltBody) ) { - $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; - } - } - - /** - * Gets the mime type of the embedded or inline image - * @access public - * @return mime type of ext - */ - public function _mime_types($ext = '') { - $mimes = array( - 'hqx' => 'application/mac-binhex40', - 'cpt' => 'application/mac-compactpro', - 'doc' => 'application/msword', - 'bin' => 'application/macbinary', - 'dms' => 'application/octet-stream', - 'lha' => 'application/octet-stream', - 'lzh' => 'application/octet-stream', - 'exe' => 'application/octet-stream', - 'class' => 'application/octet-stream', - 'psd' => 'application/octet-stream', - 'so' => 'application/octet-stream', - 'sea' => 'application/octet-stream', - 'dll' => 'application/octet-stream', - 'oda' => 'application/oda', - 'pdf' => 'application/pdf', - 'ai' => 'application/postscript', - 'eps' => 'application/postscript', - 'ps' => 'application/postscript', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'mif' => 'application/vnd.mif', - 'xls' => 'application/vnd.ms-excel', - 'ppt' => 'application/vnd.ms-powerpoint', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dxr' => 'application/x-director', - 'dvi' => 'application/x-dvi', - 'gtar' => 'application/x-gtar', - 'php' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'phtml' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'js' => 'application/x-javascript', - 'swf' => 'application/x-shockwave-flash', - 'sit' => 'application/x-stuffit', - 'tar' => 'application/x-tar', - 'tgz' => 'application/x-tar', - 'xhtml' => 'application/xhtml+xml', - 'xht' => 'application/xhtml+xml', - 'zip' => 'application/zip', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mpga' => 'audio/mpeg', - 'mp2' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'aif' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'ra' => 'audio/x-realaudio', - 'rv' => 'video/vnd.rn-realvideo', - 'wav' => 'audio/x-wav', - 'bmp' => 'image/bmp', - 'gif' => 'image/gif', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'jpe' => 'image/jpeg', - 'png' => 'image/png', - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'css' => 'text/css', - 'html' => 'text/html', - 'htm' => 'text/html', - 'shtml' => 'text/html', - 'txt' => 'text/plain', - 'text' => 'text/plain', - 'log' => 'text/plain', - 'rtx' => 'text/richtext', - 'rtf' => 'text/rtf', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpe' => 'video/mpeg', - 'qt' => 'video/quicktime', - 'mov' => 'video/quicktime', - 'avi' => 'video/x-msvideo', - 'movie' => 'video/x-sgi-movie', - 'doc' => 'application/msword', - 'word' => 'application/msword', - 'xl' => 'application/excel', - 'eml' => 'message/rfc822' - ); - return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; - } - - /** - * Set (or reset) Class Objects (variables) - * - * Usage Example: - * $page->set('X-Priority', '3'); - * - * @access public - * @param string $name Parameter Name - * @param mixed $value Parameter Value - * NOTE: will not work with arrays, there are no arrays to set/reset - */ - public function set ( $name, $value = '' ) { - if ( isset($this->$name) ) { - $this->$name = $value; - } else { - $this->SetError('Cannot set or reset variable ' . $name); - return false; - } - } - - /** - * Read a file from a supplied filename and return it. - * - * @access public - * @param string $filename Parameter File Name - */ - public function getFile($filename) { - $return = ''; - if ($fp = fopen($filename, 'rb')) { - while (!feof($fp)) { - $return .= fread($fp, 1024); - } - fclose($fp); - return $return; - } else { - return false; - } - } - - /** - * Strips newlines to prevent header injection. - * @access public - * @param string $str String - * @return string - */ - public function SecureHeader($str) { - $str = trim($str); - $str = str_replace("\r", "", $str); - $str = str_replace("\n", "", $str); - return $str; - } - - /** - * Set the private key file and password to sign the message. - * - * @access public - * @param string $key_filename Parameter File Name - * @param string $key_pass Password for private key - */ - public function Sign($cert_filename, $key_filename, $key_pass) { - $this->sign_cert_file = $cert_filename; - $this->sign_key_file = $key_filename; - $this->sign_key_pass = $key_pass; - } -} - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/class.pop3.php b/inc/classes/third_party/php_mailer/class.pop3.php deleted file mode 100644 index 0884a825..00000000 --- a/inc/classes/third_party/php_mailer/class.pop3.php +++ /dev/null @@ -1,393 +0,0 @@ -pop_conn = 0; - $this->connected = false; - $this->error = null; - } - - /** - * Combination of public events - connect, login, disconnect - * @access public - * @param string $host - * @param integer $port - * @param integer $tval - * @param string $username - * @param string $password - */ - public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { - $this->host = $host; - - // If no port value is passed, retrieve it - if ($port == false) { - $this->port = $this->POP3_PORT; - } else { - $this->port = $port; - } - - // If no port value is passed, retrieve it - if ($tval == false) { - $this->tval = $this->POP3_TIMEOUT; - } else { - $this->tval = $tval; - } - - $this->do_debug = $debug_level; - $this->username = $username; - $this->password = $password; - - // Refresh the error log - $this->error = null; - - // Connect - $result = $this->Connect($this->host, $this->port, $this->tval); - - if ($result) { - $login_result = $this->Login($this->username, $this->password); - - if ($login_result) { - $this->Disconnect(); - - return true; - } - - } - - // We need to disconnect regardless if the login succeeded - $this->Disconnect(); - - return false; - } - - /** - * Connect to the POP3 server - * @access public - * @param string $host - * @param integer $port - * @param integer $tval - * @return boolean - */ - public function Connect ($host, $port = false, $tval = 30) { - // Are we already connected? - if ($this->connected) { - return true; - } - - /* - On Windows this will raise a PHP Warning error if the hostname doesn't exist. - Rather than supress it with @fsockopen, let's capture it cleanly instead - */ - - set_error_handler(array(&$this, 'catchWarning')); - - // Connect to the POP3 server - $this->pop_conn = fsockopen($host, // POP3 Host - $port, // Port # - $errno, // Error Number - $errstr, // Error Message - $tval); // Timeout (seconds) - - // Restore the error handler - restore_error_handler(); - - // Does the Error Log now contain anything? - if ($this->error && $this->do_debug >= 1) { - $this->displayErrors(); - } - - // Did we connect? - if ($this->pop_conn == false) { - // It would appear not... - $this->error = array( - 'error' => "Failed to connect to server $host on port $port", - 'errno' => $errno, - 'errstr' => $errstr - ); - - if ($this->do_debug >= 1) { - $this->displayErrors(); - } - - return false; - } - - // Increase the stream time-out - - // Check for PHP 4.3.0 or later - if (version_compare(phpversion(), '5.0.0', 'ge')) { - stream_set_timeout($this->pop_conn, $tval, 0); - } else { - // Does not work on Windows - if (substr(PHP_OS, 0, 3) !== 'WIN') { - socket_set_timeout($this->pop_conn, $tval, 0); - } - } - - // Get the POP3 server response - $pop3_response = $this->getResponse(); - - // Check for the +OK - if ($this->checkResponse($pop3_response)) { - // The connection is established and the POP3 server is talking - $this->connected = true; - return true; - } - - } - - /** - * Login to the POP3 server (does not support APOP yet) - * @access public - * @param string $username - * @param string $password - * @return boolean - */ - public function Login ($username = '', $password = '') { - if ($this->connected == false) { - $this->error = 'Not connected to POP3 server'; - - if ($this->do_debug >= 1) { - $this->displayErrors(); - } - } - - if (empty($username)) { - $username = $this->username; - } - - if (empty($password)) { - $password = $this->password; - } - - $pop_username = "USER $username" . $this->CRLF; - $pop_password = "PASS $password" . $this->CRLF; - - // Send the Username - $this->sendString($pop_username); - $pop3_response = $this->getResponse(); - - if ($this->checkResponse($pop3_response)) { - // Send the Password - $this->sendString($pop_password); - $pop3_response = $this->getResponse(); - - if ($this->checkResponse($pop3_response)) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - /** - * Disconnect from the POP3 server - * @access public - */ - public function Disconnect () { - $this->sendString('QUIT'); - - fclose($this->pop_conn); - } - - ///////////////////////////////////////////////// - // Private Methods - ///////////////////////////////////////////////// - - /** - * Get the socket response back. - * $size is the maximum number of bytes to retrieve - * @access private - * @param integer $size - * @return string - */ - private function getResponse ($size = 128) { - $pop3_response = fgets($this->pop_conn, $size); - - return $pop3_response; - } - - /** - * Send a string down the open socket connection to the POP3 server - * @access private - * @param string $string - * @return integer - */ - private function sendString ($string) { - $bytes_sent = fwrite($this->pop_conn, $string, strlen($string)); - - return $bytes_sent; - } - - /** - * Checks the POP3 server response for +OK or -ERR - * @access private - * @param string $string - * @return boolean - */ - private function checkResponse ($string) { - if (substr($string, 0, 3) !== '+OK') { - $this->error = array( - 'error' => "Server reported an error: $string", - 'errno' => 0, - 'errstr' => '' - ); - - if ($this->do_debug >= 1) { - $this->displayErrors(); - } - - return false; - } else { - return true; - } - - } - - /** - * If debug is enabled, display the error message array - * @access private - */ - private function displayErrors () { - echo '

';
-
-    foreach ($this->error as $single_error) {
-      print_r($single_error);
-    }
-
-    echo '
'; - } - - /** - * Takes over from PHP for the socket warning handler - * @access private - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline - */ - private function catchWarning ($errno, $errstr, $errfile, $errline) { - $this->error[] = array( - 'error' => "Connecting to the POP3 server raised a PHP warning: ", - 'errno' => $errno, - 'errstr' => $errstr - ); - } - - // End of class -} -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/class.smtp.php b/inc/classes/third_party/php_mailer/class.smtp.php deleted file mode 100644 index 360d6afd..00000000 --- a/inc/classes/third_party/php_mailer/class.smtp.php +++ /dev/null @@ -1,1112 +0,0 @@ -smtp_conn = 0; - $this->error = null; - $this->helo_rply = null; - - $this->do_debug = 0; - } - - /************************************************************* - * CONNECTION FUNCTIONS * - ***********************************************************/ - - /** - * Connect to the server specified on the port specified. - * If the port is not specified use the default SMTP_PORT. - * If tval is specified then a connection will try and be - * established with the server for that number of seconds. - * If tval is not specified the default is 30 seconds to - * try on the connection. - * - * SMTP CODE SUCCESS: 220 - * SMTP CODE FAILURE: 421 - * @access public - * @return bool - */ - public function Connect($host,$port=0,$tval=30) { - /* set the error val to null so there is no confusion */ - $this->error = null; - - /* make sure we are __not__ connected */ - if($this->connected()) { - /* ok we are connected! what should we do? - * for now we will just give an error saying we - * are already connected - */ - $this->error = array("error" => "Already connected to a server"); - return false; - } - - if(empty($port)) { - $port = $this->SMTP_PORT; - } - - /* connect to the smtp server */ - $this->smtp_conn = fsockopen($host, // the host of the server - $port, // the port to use - $errno, // error number if any - $errstr, // error message if any - $tval); // give up after ? secs - /* verify we connected properly */ - if(empty($this->smtp_conn)) { - $this->error = array("error" => "Failed to connect to server", - "errno" => $errno, - "errstr" => $errstr); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": $errstr ($errno)" . $this->CRLF; - } - return false; - } - - /* sometimes the SMTP server takes a little longer to respond - * so we will give it a longer timeout for the first read - * - Windows still does not have support for this timeout function - */ - if(substr(PHP_OS, 0, 3) != "WIN") - socket_set_timeout($this->smtp_conn, $tval, 0); - - /* get any announcement stuff */ - $announce = $this->get_lines(); - - /* set the timeout of any socket functions at 1/10 of a second */ - //if(function_exists("socket_set_timeout")) - // socket_set_timeout($this->smtp_conn, 0, 100000); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; - } - - return true; - } - - /** - * Initiate a TSL communication with the server. - * - * SMTP CODE 220 Ready to start TLS - * SMTP CODE 501 Syntax error (no parameters allowed) - * SMTP CODE 454 TLS not available due to temporary reason - * @access public - * @return bool success - */ - public function StartTLS() { - $this->error = null; # to avoid confusion - - if(!$this->connected()) { - $this->error = array("error" => "Called StartTLS() without being connected"); - return false; - } - - fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 220) { - $this->error = - array("error" => "STARTTLS not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; - } - return false; - } - - //Begin encrypted connection - if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { - return false; - } - - return true; - } - - /** - * Performs SMTP authentication. Must be run after running the - * Hello() method. Returns true if successfully authenticated. - * @access public - * @return bool - */ - public function Authenticate($username, $password) { - // Start authentication - fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "AUTH not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - // Send encoded username - fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 334) { - $this->error = - array("error" => "Username not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - // Send encoded password - fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($code != 235) { - $this->error = - array("error" => "Password not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return true; - } - - /** - * Returns true if connected to a server otherwise false - * @access public - * @return bool - */ - public function Connected() { - if(!empty($this->smtp_conn)) { - $sock_status = socket_get_status($this->smtp_conn); - if($sock_status["eof"]) { - // hmm this is an odd situation... the socket is - // valid but we are not connected anymore - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE:" . $this->CRLF . - "EOF caught while checking if connected"; - } - $this->Close(); - return false; - } - return true; // everything looks good - } - return false; - } - - /** - * Closes the socket and cleans up the state of the class. - * It is not considered good to use this function without - * first trying to use QUIT. - * @access public - * @return void - */ - public function Close() { - $this->error = null; // so there is no confusion - $this->helo_rply = null; - if(!empty($this->smtp_conn)) { - // close the connection and cleanup - fclose($this->smtp_conn); - $this->smtp_conn = 0; - } - } - - /*************************************************************** - * SMTP COMMANDS * - *************************************************************/ - - /** - * Issues a data command and sends the msg_data to the server - * finializing the mail transaction. $msg_data is the message - * that is to be send with the headers. Each header needs to be - * on a single line followed by a with the message headers - * and the message body being seperated by and additional . - * - * Implements rfc 821: DATA - * - * SMTP CODE INTERMEDIATE: 354 - * [data] - * . - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 552,554,451,452 - * SMTP CODE FAILURE: 451,554 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - public function Data($msg_data) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Data() without being connected"); - return false; - } - - fputs($this->smtp_conn,"DATA" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 354) { - $this->error = - array("error" => "DATA command not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - /* the server is ready to accept data! - * according to rfc 821 we should not send more than 1000 - * including the CRLF - * characters on a single line so we will break the data up - * into lines by \r and/or \n then if needed we will break - * each of those into smaller lines to fit within the limit. - * in addition we will be looking for lines that start with - * a period '.' and append and additional period '.' to that - * line. NOTE: this does not count towards are limit. - */ - - // normalize the line breaks so we know the explode works - $msg_data = str_replace("\r\n","\n",$msg_data); - $msg_data = str_replace("\r","\n",$msg_data); - $lines = explode("\n",$msg_data); - - /* we need to find a good way to determine is headers are - * in the msg_data or if it is a straight msg body - * currently I am assuming rfc 822 definitions of msg headers - * and if the first field of the first line (':' sperated) - * does not contain a space then it _should_ be a header - * and we can process all lines before a blank "" line as - * headers. - */ - $field = substr($lines[0],0,strpos($lines[0],":")); - $in_headers = false; - if(!empty($field) && !strstr($field," ")) { - $in_headers = true; - } - - $max_line_length = 998; // used below; set here for ease in change - - while(list(,$line) = @each($lines)) { - $lines_out = null; - if($line == "" && $in_headers) { - $in_headers = false; - } - // ok we need to break this line up into several smaller lines - while(strlen($line) > $max_line_length) { - $pos = strrpos(substr($line,0,$max_line_length)," "); - - // Patch to fix DOS attack - if(!$pos) { - $pos = $max_line_length - 1; - $lines_out[] = substr($line,0,$pos); - $line = substr($line,$pos); - } else { - $lines_out[] = substr($line,0,$pos); - $line = substr($line,$pos + 1); - } - - /* if we are processing headers we need to - * add a LWSP-char to the front of the new line - * rfc 822 on long msg headers - */ - if($in_headers) { - $line = "\t" . $line; - } - } - $lines_out[] = $line; - - // now send the lines to the server - while(list(,$line_out) = @each($lines_out)) { - if(strlen($line_out) > 0) - { - if(substr($line_out, 0, 1) == ".") { - $line_out = "." . $line_out; - } - } - fputs($this->smtp_conn,$line_out . $this->CRLF); - } - } - - // ok all the message data has been sent so lets get this - // over with aleady - fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "DATA not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Expand takes the name and asks the server to list all the - * people who are members of the _list_. Expand will return - * back and array of the result or false if an error occurs. - * Each value in the array returned has the format of: - * [ ] - * The definition of is defined in rfc 821 - * - * Implements rfc 821: EXPN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 550 - * SMTP CODE ERROR : 500,501,502,504,421 - * @access public - * @return string array - */ - public function Expand($name) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Expand() without being connected"); - return false; - } - - fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "EXPN not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - // parse the reply and place in our array to return to user - $entries = explode($this->CRLF,$rply); - while(list(,$l) = @each($entries)) { - $list[] = substr($l,4); - } - - return $list; - } - - /** - * Sends the HELO command to the smtp server. - * This makes sure that we and the server are in - * the same known state. - * - * Implements from rfc 821: HELO - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 501, 504, 421 - * @access public - * @return bool - */ - public function Hello($host="") { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Hello() without being connected"); - return false; - } - - // if a hostname for the HELO was not specified determine - //a suitable one to send - if(empty($host)) { - // we need to determine some sort of appopiate default - // to send to the server - $host = "localhost"; - } - - // Send extended hello first (RFC 2821) - if(!$this->SendHello("EHLO", $host)) - { - if(!$this->SendHello("HELO", $host)) - return false; - } - - return true; - } - - /** - * Sends a HELO/EHLO command. - * @access private - * @return bool - */ - private function SendHello($hello, $host) { - fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => $hello . " not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - $this->helo_rply = $rply; - - return true; - } - - /** - * Gets help information on the keyword specified. If the keyword - * is not specified then returns generic help, ussually contianing - * A list of keywords that help is available on. This function - * returns the results back to the user. It is up to the user to - * handle the returned data. If an error occurs then false is - * returned with $this->error set appropiately. - * - * Implements rfc 821: HELP [ ] - * - * SMTP CODE SUCCESS: 211,214 - * SMTP CODE ERROR : 500,501,502,504,421 - * @access public - * @return string - */ - public function Help($keyword="") { - $this->error = null; // to avoid confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Help() without being connected"); - return false; - } - - $extra = ""; - if(!empty($keyword)) { - $extra = " " . $keyword; - } - - fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 211 && $code != 214) { - $this->error = - array("error" => "HELP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return $rply; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. - * - * Implements rfc 821: MAIL FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,421 - * @access public - * @return bool - */ - public function Mail($from) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Mail() without being connected"); - return false; - } - - $useVerp = ($this->do_verp ? "XVERP" : ""); - fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "MAIL not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the command NOOP to the SMTP server. - * - * Implements from rfc 821: NOOP - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 421 - * @access public - * @return bool - */ - public function Noop() { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Noop() without being connected"); - return false; - } - - fputs($this->smtp_conn,"NOOP" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "NOOP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the quit command to the server and then closes the socket - * if there is no error or the $close_on_error argument is true. - * - * Implements from rfc 821: QUIT - * - * SMTP CODE SUCCESS: 221 - * SMTP CODE ERROR : 500 - * @access public - * @return bool - */ - public function Quit($close_on_error=true) { - $this->error = null; // so there is no confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Quit() without being connected"); - return false; - } - - // send the quit command to the server - fputs($this->smtp_conn,"quit" . $this->CRLF); - - // get any good-bye messages - $byemsg = $this->get_lines(); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; - } - - $rval = true; - $e = null; - - $code = substr($byemsg,0,3); - if($code != 221) { - // use e as a tmp var cause Close will overwrite $this->error - $e = array("error" => "SMTP server rejected quit command", - "smtp_code" => $code, - "smtp_rply" => substr($byemsg,4)); - $rval = false; - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $e["error"] . ": " . - $byemsg . $this->CRLF; - } - } - - if(empty($e) || $close_on_error) { - $this->Close(); - } - - return $rval; - } - - /** - * Sends the command RCPT to the SMTP server with the TO: argument of $to. - * Returns true if the recipient was accepted false if it was rejected. - * - * Implements from rfc 821: RCPT TO: - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,552,553,450,451,452 - * SMTP CODE ERROR : 500,501,503,421 - * @access public - * @return bool - */ - public function Recipient($to) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Recipient() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250 && $code != 251) { - $this->error = - array("error" => "RCPT not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Sends the RSET command to abort and transaction that is - * currently in progress. Returns true if successful false - * otherwise. - * - * Implements rfc 821: RSET - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500,501,504,421 - * @access public - * @return bool - */ - public function Reset() { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Reset() without being connected"); - return false; - } - - fputs($this->smtp_conn,"RSET" . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "RSET failed", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in. - * - * Implements rfc 821: SEND FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - public function Send($from) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Send() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SEND not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in and send them an email. - * - * Implements rfc 821: SAML FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - public function SendAndMail($from) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendAndMail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SAML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more Recipient - * commands may be called followed by a Data command. This command - * will send the message to the users terminal if they are logged - * in or mail it to them if they are not. - * - * Implements rfc 821: SOML FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - * @access public - * @return bool - */ - public function SendOrMail($from) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendOrMail() without being connected"); - return false; - } - - fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250) { - $this->error = - array("error" => "SOML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /** - * This is an optional command for SMTP that this class does not - * support. This method is here to make the RFC821 Definition - * complete for this class and __may__ be implimented in the future - * - * Implements from rfc 821: TURN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 502 - * SMTP CODE ERROR : 500, 503 - * @access public - * @return bool - */ - public function Turn() { - $this->error = array("error" => "This method, TURN, of the SMTP ". - "is not implemented"); - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; - } - return false; - } - - /** - * Verifies that the name is recognized by the server. - * Returns false if the name could not be verified otherwise - * the response from the server is returned. - * - * Implements rfc 821: VRFY - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,553 - * SMTP CODE ERROR : 500,501,502,421 - * @access public - * @return int - */ - public function Verify($name) { - $this->error = null; // so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Verify() without being connected"); - return false; - } - - fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); - - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } - - if($code != 250 && $code != 251) { - $this->error = - array("error" => "VRFY failed on name '$name'", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return $rply; - } - - /******************************************************************* - * INTERNAL FUNCTIONS * - ******************************************************************/ - - /** - * Read in as many lines as possible - * either before eof or socket timeout occurs on the operation. - * With SMTP we can tell if we have more lines to read if the - * 4th character is '-' symbol. If it is a space then we don't - * need to read anything else. - * @access private - * @return string - */ - private function get_lines() { - $data = ""; - while($str = @fgets($this->smtp_conn,515)) { - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data was \"$data\"" . - $this->CRLF; - echo "SMTP -> get_lines(): \$str is \"$str\"" . - $this->CRLF; - } - $data .= $str; - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; - } - // if the 4th character is a space then we are done reading - // so just break the loop - if(substr($str,3,1) == " ") { break; } - } - return $data; - } - -} - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/docs/extending.html b/inc/classes/third_party/php_mailer/docs/extending.html deleted file mode 100644 index 310f97a3..00000000 --- a/inc/classes/third_party/php_mailer/docs/extending.html +++ /dev/null @@ -1,148 +0,0 @@ - - -Examples using phpmailer - - - - -

Examples using phpmailer

- -

1. Advanced Example

-

- -This demonstrates sending out multiple email messages with binary attachments -from a MySQL database with multipart/alternative support.

- - - - -
-
-require("class.phpmailer.php");
-
-$mail = new phpmailer();
-
-$mail->From     = "list@example.com";
-$mail->FromName = "List manager";
-$mail->Host     = "smtp1.example.com;smtp2.example.com";
-$mail->Mailer   = "smtp";
-
-@MYSQL_CONNECT("localhost","root","password");
-@mysql_select_db("my_company");
-$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";
-$result = @MYSQL_QUERY($query);
-
-while ($row = mysql_fetch_array ($result))
-{
-    // HTML body
-    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
-    $body .= "<i>Your</i> personal photograph to this message.<p>";
-    $body .= "Sincerely, <br>";
-    $body .= "phpmailer List manager";
-
-    // Plain text body (for mail clients that cannot read HTML)
-    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
-    $text_body .= "Your personal photograph to this message.\n\n";
-    $text_body .= "Sincerely, \n";
-    $text_body .= "phpmailer List manager";
-
-    $mail->Body    = $body;
-    $mail->AltBody = $text_body;
-    $mail->AddAddress($row["email"], $row["full_name"]);
-    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
-
-    if(!$mail->Send())
-        echo "There has been a mail error sending to " . $row["email"] . "<br>";
-
-    // Clear all addresses and attachments for next loop
-    $mail->ClearAddresses();
-    $mail->ClearAttachments();
-}
-
-
-

- -

2. Extending phpmailer

-

- -Extending classes with inheritance is one of the most -powerful features of object-oriented -programming. It allows you to make changes to the -original class for your -own personal use without hacking the original -classes. Plus, it is very -easy to do. I've provided an example: - -

-Here's a class that extends the phpmailer class and sets the defaults -for the particular site:
-PHP include file: mail.inc.php -

- - - - - -
-
-require("class.phpmailer.php");
-
-class my_phpmailer extends phpmailer {
-    // Set default variables for all new objects
-    var $From     = "from@example.com";
-    var $FromName = "Mailer";
-    var $Host     = "smtp1.example.com;smtp2.example.com";
-    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
-    var $WordWrap = 75;
-
-    // Replace the default error_handler
-    function error_handler($msg) {
-        print("My Site Error");
-        print("Description:");
-        printf("%s", $msg);
-        exit;
-    }
-
-    // Create an additional function
-    function do_something($something) {
-        // Place your new code here
-    }
-}
-
-
- -Now here's a normal PHP page in the site, which will have all the defaults set -above:
-Normal PHP file: mail_test.php -

- - - - - -
-
-require("mail.inc.php");
-
-// Instantiate your new class
-$mail = new my_phpmailer;
-
-// Now you only need to add the necessary stuff
-$mail->AddAddress("josh@example.com", "Josh Adams");
-$mail->Subject = "Here is the subject";
-$mail->Body    = "This is the message body";
-$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
-
-if(!$mail->Send())
-{
-   echo "There was an error sending the message";
-   exit;
-}
-
-echo "Message was sent successfully";
-
-
-

- - - diff --git a/inc/classes/third_party/php_mailer/docs/faq.html b/inc/classes/third_party/php_mailer/docs/faq.html deleted file mode 100644 index f71c6c89..00000000 --- a/inc/classes/third_party/php_mailer/docs/faq.html +++ /dev/null @@ -1,67 +0,0 @@ - - -PHPMailer FAQ - - - -
-
-

PHPMailer FAQ

-
    - -
  • Q: I'm using the SMTP mailer and I keep on getting a timeout message - well before the X seconds I set it for. What gives?
    - A: PHP versions 4.0.4pl1 and earlier have a bug in which sockets timeout - early. You can fix this by re-compiling PHP 4.0.4pl1 with this fix: - timeoutfix.diff. Otherwise you can wait for the new PHP release.

  • - -
  • Q: I am concerned that using include files will take up too much - processing time on my computer. How can I make it run faster?
    - A: PHP by itself is very fast. Much faster than ASP or JSP running on - the same type of server. This is because it has very little overhead compared - to its competitors and it pre-compiles all of - its code before it runs each script (in PHP4). However, all of - this compiling and re-compiling can take up a lot of valuable - computer resources. However, there are programs out there that compile - PHP code and store it in memory (or on mmaped files) to reduce the - processing immensely. Two of these: APC - (Alternative PHP Cache) and Afterburner - (Win32 download) - are excellent free tools that do just this. If you have the money - you might also try Zend Cache, it is - even faster than the open source varieties. All of these tools make your - scripts run faster while also reducing the load on your server. I have tried - them myself and they are quite stable too.

  • - -
  • Q: What mailer gives me the best performance?
    - A: On a single machine the sendmail (or Qmail) is fastest overall. - Next fastest is mail() to give you the best performance. Both do not have the overhead of SMTP. - If you have you have your mail server on a another machine then - SMTP is your only option, but you do get the benefit of redundant mail servers.
    - If you are running a mailing list with thousands of names, the fastest mailers in order are: SMTP, sendmail (or Qmail), mail().

  • - -
  • Q: When I try to attach a file with on my server I get a - "Could not find {file} on filesystem error". Why is this?
    - A: If you are using a Unix machine this is probably because the user - running your web server does not have read access to the directory in question. If you are using Windows, - then the problem probably is that you have used single backslashes to denote directories (\). - A single backslash has a special meaning to PHP so these are not - valid. Instead use double backslashes ("\\") or a single forward - slash ("/").

  • - -
- -
-
- - - diff --git a/inc/classes/third_party/php_mailer/docs/pop3_article.txt b/inc/classes/third_party/php_mailer/docs/pop3_article.txt deleted file mode 100644 index cc54f7c0..00000000 --- a/inc/classes/third_party/php_mailer/docs/pop3_article.txt +++ /dev/null @@ -1,39 +0,0 @@ -This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. - -With that noted, here is how to implement it: -Install the class file - -I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory: -[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi] -When you need it, create your POP3 object - -Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: -[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi] - -The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. -The Parameters - -The Authorise parameters are as follows: -[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi] - - 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) - 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) - 3. 30 - A connection time-out value (in seconds) - 4. mailer - The POP3 Username required to logon - 5. password - The POP3 Password required to logon - 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) - -Final Comments + the Download - -1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. - -2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. - -3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. - -4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. -Download - -Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself. - -My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) diff --git a/inc/classes/third_party/php_mailer/docs/use_gmail.txt b/inc/classes/third_party/php_mailer/docs/use_gmail.txt deleted file mode 100644 index 7519d7d2..00000000 --- a/inc/classes/third_party/php_mailer/docs/use_gmail.txt +++ /dev/null @@ -1,45 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSMTP(); -$mail->SMTPAuth = true; // enable SMTP authentication -$mail->SMTPSecure = "ssl"; // sets the prefix to the servier -$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server -$mail->Port = 465; // set the SMTP port - -$mail->Username = "yourname@gmail.com"; // GMAIL username -$mail->Password = "password"; // GMAIL password - -$mail->From = "replyto@yourdomain.com"; -$mail->FromName = "Webmaster"; -$mail->Subject = "This is the subject"; -$mail->AltBody = "This is the body when user views in plain text format"; //Text Body -$mail->WordWrap = 50; // set word wrap - -$mail->MsgHTML($body); - -$mail->AddReplyTo("replyto@yourdomain.com","Webmaster"); - -$mail->AddAttachment("/path/to/file.zip"); // attachment -$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment - -$mail->AddAddress("username@domain.com","First Last"); - -$mail->IsHTML(true); // send as HTML - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message has been sent"; -} - -?> diff --git a/inc/classes/third_party/php_mailer/examples/contents.html b/inc/classes/third_party/php_mailer/examples/contents.html deleted file mode 100644 index 3efbda27..00000000 --- a/inc/classes/third_party/php_mailer/examples/contents.html +++ /dev/null @@ -1,12 +0,0 @@ - -
-

-
- This is a test of PHPMailer v2.0.0 rc1.
-
-This particular example uses HTML, with a <div> tag and inline
-styles.
-
-Also note the use of the PHPMailer at the top with no specific code to handle -including it in the body of the email.
- diff --git a/inc/classes/third_party/php_mailer/examples/images/bkgrnd.gif b/inc/classes/third_party/php_mailer/examples/images/bkgrnd.gif deleted file mode 100644 index bc89624c..00000000 Binary files a/inc/classes/third_party/php_mailer/examples/images/bkgrnd.gif and /dev/null differ diff --git a/inc/classes/third_party/php_mailer/examples/images/phpmailer.gif b/inc/classes/third_party/php_mailer/examples/images/phpmailer.gif deleted file mode 100644 index 5e269714..00000000 Binary files a/inc/classes/third_party/php_mailer/examples/images/phpmailer.gif and /dev/null differ diff --git a/inc/classes/third_party/php_mailer/examples/images/phpmailer.png b/inc/classes/third_party/php_mailer/examples/images/phpmailer.png deleted file mode 100644 index abe0101f..00000000 Binary files a/inc/classes/third_party/php_mailer/examples/images/phpmailer.png and /dev/null differ diff --git a/inc/classes/third_party/php_mailer/examples/images/phpmailer_mini.gif b/inc/classes/third_party/php_mailer/examples/images/phpmailer_mini.gif deleted file mode 100644 index dc7d7827..00000000 Binary files a/inc/classes/third_party/php_mailer/examples/images/phpmailer_mini.gif and /dev/null differ diff --git a/inc/classes/third_party/php_mailer/examples/index.html b/inc/classes/third_party/php_mailer/examples/index.html deleted file mode 100644 index 3ac45d3b..00000000 --- a/inc/classes/third_party/php_mailer/examples/index.html +++ /dev/null @@ -1,73 +0,0 @@ -

The example file "test_mail.php" contents include:

-
- -<?php
-
-include_once('../class.phpmailer.php');
-
-$mail = new PHPMailer();
-
-$body = $mail->getFile('contents.html');
-
-$body = eregi_replace("[\]",'',$body);
-$subject = eregi_replace("[\]",'',$subject);
-
-$mail->From = "name@yourdomain.com";
-$mail->FromName = "First Last";
-
-$mail->Subject = "PHPMailer Test Subject";
-
-$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
-
-$mail->MsgHTML($body);
-
-$mail->AddAddress("whoto@otherdomain.com", "John Doe");
-
-if(!$mail->Send()) {
- echo 'Failed to send mail';
-} else {
- echo 'Mail sent';
-}
-
-?> -
-
-
-Although you could use full compabitility with PHPMailer 1.7.3, this example -shows how to use the new features. If you view 'contents.html', you will note -that there is a background image used in the <body tag as well as an image used -with a regular <img tag. Here's what the HTML file looks like:
-
-
- -<body background="images/bkgrnd.gif" style="margin: 0px;">
-<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
-<div align="center"><img src="images/phpmailer.gif" style="height: 90px; width: 340px"></div><br>
-<br>
- This is a test of PHPMailer v2.0.0 rc1.<br>
-<br>
-This particular example uses <strong>HTML</strong>, with a <div> tag and inline<br>
-styles.<br>
-<br>
-Also note the use of the PHPMailer at the top with no specific code to handle
-including it in the body of the email.</div>
-</body>
-
-
-
-A few things to notice in the PHP script that generates the email: -
    -
  • the use of $mail->AltBody is completely optional. If not used, PHPMailer - will use the HTML text with htmlentities().
  • -
  • the background= and <img src= images were processed without any directives - or methods from the PHP script
  • -
  • there is no specific code to define the image type ... that is handled - automatically by PHPMailer when it parses the images
  • -
  • we are using a new class method '$mail->MsgHTML($body)' ... that is what will handle the parsing of the images and creating the AltBody text
  • -
-

Of course, you can still use PHPMailer the same way you have in the past. -That provides full compatibility with all existing scripts, while new scripts -can take advantage of the new features.

-

Modify test_mail.php now with your own email address and try it out.

-To see what the email SHOULD look like in your HTML compatible email viewer: click here
- diff --git a/inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php b/inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php deleted file mode 100644 index b10b5e15..00000000 --- a/inc/classes/third_party/php_mailer/examples/pop3_before_smtp_test.php +++ /dev/null @@ -1,39 +0,0 @@ - - -POP before SMTP Test - - - - -
-Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
-
-  $mail = new PHPMailer();
-
-  $mail->IsSMTP();
-  $mail->SMTPDebug = 2;
-  $mail->IsHTML(false);
-
-  $mail->Host     = 'relay.example.com';
-
-  $mail->From     = 'mailer@example.com';
-  $mail->FromName = 'Example Mailer';
-
-  $mail->Subject  =  'My subject';
-  $mail->Body     =  'Hello world';
-  $mail->AddAddress('name@anydomain.com', 'First Last');
-
-  if (!$mail->Send())
-  {
-    echo $mail->ErrorInfo;
-  }
-?>
-
- - - diff --git a/inc/classes/third_party/php_mailer/examples/test_gmail.php b/inc/classes/third_party/php_mailer/examples/test_gmail.php deleted file mode 100644 index 1fc2c5e8..00000000 --- a/inc/classes/third_party/php_mailer/examples/test_gmail.php +++ /dev/null @@ -1,50 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSMTP(); -$mail->SMTPAuth = true; // enable SMTP authentication -$mail->SMTPSecure = "ssl"; // sets the prefix to the servier -$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server -$mail->Port = 465; // set the SMTP port for the GMAIL server - -$mail->Username = "yourusername@gmail.com"; // GMAIL username -$mail->Password = "yourpassword"; // GMAIL password - -$mail->AddReplyTo("yourusername@gmail.com","First Last"); - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via gmail"; - -//$mail->Body = "Hi,
This is the HTML BODY
"; //HTML Body -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test -$mail->WordWrap = 50; // set word wrap - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -$mail->IsHTML(true); // send as HTML - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/inc/classes/third_party/php_mailer/examples/test_mail.php b/inc/classes/third_party/php_mailer/examples/test_mail.php deleted file mode 100644 index 6e0ac2fd..00000000 --- a/inc/classes/third_party/php_mailer/examples/test_mail.php +++ /dev/null @@ -1,29 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via mail()"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/inc/classes/third_party/php_mailer/examples/test_sendmail.php b/inc/classes/third_party/php_mailer/examples/test_sendmail.php deleted file mode 100644 index 3b9cc266..00000000 --- a/inc/classes/third_party/php_mailer/examples/test_sendmail.php +++ /dev/null @@ -1,37 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSendmail(); // telling the class to use SendMail transport - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via smtp"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/inc/classes/third_party/php_mailer/examples/test_smtp.php b/inc/classes/third_party/php_mailer/examples/test_smtp.php deleted file mode 100644 index d8da32b0..00000000 --- a/inc/classes/third_party/php_mailer/examples/test_smtp.php +++ /dev/null @@ -1,39 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSMTP(); // telling the class to use SMTP -$mail->Host = "mail.worxteam.com"; // SMTP server - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via smtp"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ar.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ar.php deleted file mode 100644 index 61ac12c6..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ar.php +++ /dev/null @@ -1,25 +0,0 @@ - */ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG["provide_address"] = ' íÌÈ Ãä ÊÖÚ Úáì ÇáÃÞá ' . - 'ÚäæÇä ÈÑíÏ ÅáßÊÑæäí ãÓÊÞÈá æÇÍÏ'; -$PHPMAILER_LANG["mailer_not_supported"] = ' ãÑÓá ÇáÈÑíÏ ÛíÑ ãÏÚæã :'; -$PHPMAILER_LANG["execute"] = 'áÇ íãßä ÊäÝíÐ : '; -$PHPMAILER_LANG["instantiate"] = 'áã íÓÊØÚ ÊåíÆÉ ÊÇÈÚ ÇáÈÑíÏ'; -$PHPMAILER_LANG["authenticate"] = 'ÎØà STMP : áã íãáß ÇáÕáÇÍíÉ'; -$PHPMAILER_LANG["from_failed"] = 'ÇáÚäæÇä ÇáãÑÓá ÇáÊÇáí ÝÔá : '; -$PHPMAILER_LANG["recipients_failed"] = 'ÎØà STMP : ' . - 'åÄáÇÁ ÇáãÓÊÞÈáæä ÝÔáæÇ : '; -$PHPMAILER_LANG["data_not_accepted"] = 'ÎØà STMP : ÇáãÚØíÇÊ áã ÊÞÈá .'; -$PHPMAILER_LANG["connect_host"] = 'ÎØà STMP : ÇáÇÊÕÇá ÈãÓÊÖíÝ STMP áã íÊã'; -$PHPMAILER_LANG["file_access"] = 'áÇ íãßä ÇáæÕæá áãáÝ : '; -$PHPMAILER_LANG["file_open"] = 'ÎØà ãáÝ : áã íãßä ÝÊÍ ãáÝ :'; -$PHPMAILER_LANG["encoding"] = 'ÊÔÝíÑ ÛíÑ ãÚÑæÝ : '; -$PHPMAILER_LANG["signing"] = 'ÎØà ÊÓÌíá : '; - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php deleted file mode 100644 index abb2fed0..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-br.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php deleted file mode 100644 index c5ca72b9..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ca.php +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php deleted file mode 100644 index 48e4669e..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-cz.php +++ /dev/null @@ -1,26 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php deleted file mode 100644 index 843971b9..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-de.php +++ /dev/null @@ -1,26 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php deleted file mode 100644 index 1580da69..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-dk.php +++ /dev/null @@ -1,25 +0,0 @@ - */ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG["provide_address"] = 'Du skal indtaste mindst en ' . - 'modtagers emailadresse.'; -$PHPMAILER_LANG["mailer_not_supported"] = ' mailer understøttes ikke.'; -$PHPMAILER_LANG["execute"] = 'Kunne ikke køre: '; -$PHPMAILER_LANG["instantiate"] = 'Kunne ikke initialisere email funktionen.'; -$PHPMAILER_LANG["authenticate"] = 'SMTP fejl: Kunne ikke logge pÃ¥.'; -$PHPMAILER_LANG["from_failed"] = 'Følgende afsenderadresse er forkert: '; -$PHPMAILER_LANG["recipients_failed"] = 'SMTP fejl: Følgende' . - 'modtagere er forkerte: '; -$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fejl: Data kunne ikke accepteres.'; -$PHPMAILER_LANG["connect_host"] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.'; -$PHPMAILER_LANG["file_access"] = 'Ingen adgang til fil: '; -$PHPMAILER_LANG["file_open"] = 'Fil fejl: Kunne ikke Ã¥bne filen: '; -$PHPMAILER_LANG["encoding"] = 'Ukendt encode-format: '; -$PHPMAILER_LANG["signing"] = 'Signing Error: '; - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php deleted file mode 100644 index f7d4286d..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-en.php +++ /dev/null @@ -1,25 +0,0 @@ - diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php deleted file mode 100644 index 493e9b41..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-es.php +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php deleted file mode 100644 index 40cfc622..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-et.php +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php deleted file mode 100644 index 1c4feace..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fi.php +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php deleted file mode 100644 index 5cb24ced..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fo.php +++ /dev/null @@ -1,27 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php deleted file mode 100644 index e00dac70..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-fr.php +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php deleted file mode 100644 index f97e0d9e..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-hu.php +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php deleted file mode 100644 index 9bb3a558..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-it.php +++ /dev/null @@ -1,29 +0,0 @@ -*/ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG["provide_address"] = 'Deve essere fornito almeno un'. - ' indirizzo ricevente'; -$PHPMAILER_LANG["mailer_not_supported"] = 'Mailer non supportato'; -$PHPMAILER_LANG["execute"] = "Impossibile eseguire l'operazione: "; -$PHPMAILER_LANG["instantiate"] = 'Impossibile istanziare la funzione mail'; -$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Impossibile autenticarsi.'; -$PHPMAILER_LANG["from_failed"] = 'I seguenti indirizzi mittenti hanno'. - ' generato errore: '; -$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: I seguenti indirizzi'. - 'destinatari hanno generato errore: '; -$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data non accettati dal'. - 'server.'; -$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Impossibile connettersi'. - ' all\'host SMTP.'; -$PHPMAILER_LANG["file_access"] = 'Impossibile accedere al file: '; -$PHPMAILER_LANG["file_open"] = 'File Error: Impossibile aprire il file: '; -$PHPMAILER_LANG["encoding"] = 'Encoding set dei caratteri sconosciuto: '; -$PHPMAILER_LANG["signing"] = 'Signing Error: '; - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ja.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ja.php deleted file mode 100644 index 92e2b666..00000000 Binary files a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ja.php and /dev/null differ diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php deleted file mode 100644 index 459de614..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-nl.php +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php deleted file mode 100644 index 06d93107..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-no.php +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php deleted file mode 100644 index 2b342a3a..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-pl.php +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php deleted file mode 100644 index 3c8bc117..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ro.php +++ /dev/null @@ -1,24 +0,0 @@ - */ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG["provide_address"] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).'; -$PHPMAILER_LANG["mailer_not_supported"] = ' mailer nu este suportat.'; -$PHPMAILER_LANG["execute"] = 'Nu pot executa: '; -$PHPMAILER_LANG["instantiate"] = 'Nu am putut instantia functia mail.'; -$PHPMAILER_LANG["authenticate"] = 'Eroare SMTP: Nu a functionat autentificarea.'; -$PHPMAILER_LANG["from_failed"] = 'Urmatoarele adrese From au dat eroare: '; -$PHPMAILER_LANG["recipients_failed"] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: '; -$PHPMAILER_LANG["data_not_accepted"] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.'; -$PHPMAILER_LANG["connect_host"] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.'; -$PHPMAILER_LANG["file_access"] = 'Nu pot accesa fisierul: '; -$PHPMAILER_LANG["file_open"] = 'Eroare de fisier: Nu pot deschide fisierul: '; -$PHPMAILER_LANG["encoding"] = 'Encodare necunoscuta: '; -$PHPMAILER_LANG["signing"] = 'Signing Error: '; - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php deleted file mode 100644 index e456c493..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-ru.php +++ /dev/null @@ -1,24 +0,0 @@ - */ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG["provide_address"] = 'Ïîæàëóéñòà, ââåäèòå õîòÿ áû îäèí àäðåñ e-mail ' . - 'ïîëó÷àòåëÿ.'; -$PHPMAILER_LANG["mailer_not_supported"] = ' - ïî÷òîâûé ñåðâåð íå ïîääåðæèâàåòñÿ.'; -$PHPMAILER_LANG["execute"] = 'Íåâîçìîæíî âûïîëíèòü êîìàíäó: '; -$PHPMAILER_LANG["instantiate"] = 'Íåâîçìîæíî çàïóñòèòü ôóíêöèþ mail.'; -$PHPMAILER_LANG["authenticate"] = 'Îøèáêà SMTP: îøèáêà àâòîðèçàöèè.'; -$PHPMAILER_LANG["from_failed"] = 'Íåâåðíûé àäðåñ îòïðàâèòåëÿ: '; -$PHPMAILER_LANG["recipients_failed"] = 'Îøèáêà SMTP: îòïðàâêà ïî ñëåäóþùèì ' . - 'àäðåñàì ïîëó÷àòåëåé íå óäàëàñü: '; -$PHPMAILER_LANG["data_not_accepted"] = 'Îøèáêà SMTP: äàííûå íå ïðèíÿòû.'; -$PHPMAILER_LANG["connect_host"] = 'Îøèáêà SMTP: íå óäàåòñÿ ïîäêëþ÷èòüñÿ ê ñåðâåðó SMTP.'; -$PHPMAILER_LANG["file_access"] = 'Íåò äîñòóïà ê ôàéëó: '; -$PHPMAILER_LANG["file_open"] = 'Ôàéëîâàÿ îøèáêà: íå óäàåòñÿ îòêðûòü ôàéë: '; -$PHPMAILER_LANG["encoding"] = 'Íåèçâåñòíûé âèä êîäèðîâêè: '; -$PHPMAILER_LANG["signing"] = 'Signing Error: '; - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php deleted file mode 100644 index 0670afc0..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-se.php +++ /dev/null @@ -1,25 +0,0 @@ - */ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG["provide_address"] = 'Du måste ange minst en ' . - 'mottagares e-postadress.'; -$PHPMAILER_LANG["mailer_not_supported"] = ' mailer stöds inte.'; -$PHPMAILER_LANG["execute"] = 'Kunde inte köra: '; -$PHPMAILER_LANG["instantiate"] = 'Kunde inte initiera e-postfunktion.'; -$PHPMAILER_LANG["authenticate"] = 'SMTP fel: Kunde inte autentisera.'; -$PHPMAILER_LANG["from_failed"] = 'Följande avsändaradress är felaktig: '; -$PHPMAILER_LANG["recipients_failed"] = 'SMTP fel: Följande ' . - 'mottagare är felaktig: '; -$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fel: Data accepterades inte.'; -$PHPMAILER_LANG["connect_host"] = 'SMTP fel: Kunde inte ansluta till SMTP-server.'; -$PHPMAILER_LANG["file_access"] = 'Ingen åtkomst till fil: '; -$PHPMAILER_LANG["file_open"] = 'Fil fel: Kunde inte öppna fil: '; -$PHPMAILER_LANG["encoding"] = 'Okänt encode-format: '; -$PHPMAILER_LANG["signing"] = 'Signing Error: '; - -?> \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php b/inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php deleted file mode 100644 index 4e3e675c..00000000 --- a/inc/classes/third_party/php_mailer/language/phpmailer.lang-tr.php +++ /dev/null @@ -1,26 +0,0 @@ - \ No newline at end of file diff --git a/inc/classes/third_party/php_mailer/test/phpmailer_test.php b/inc/classes/third_party/php_mailer/test/phpmailer_test.php deleted file mode 100644 index ffbe4bd4..00000000 --- a/inc/classes/third_party/php_mailer/test/phpmailer_test.php +++ /dev/null @@ -1,572 +0,0 @@ -TestCase( $name ); - } - - /** - * Run before each test is started. - */ - function setUp() { - global $global_vars; - global $INCLUDE_DIR; - - $this->Mail = new PHPMailer(); - - $this->Mail->Priority = 3; - $this->Mail->Encoding = "8bit"; - $this->Mail->CharSet = "iso-8859-1"; - $this->Mail->From = "unit_test@phpmailer.sf.net"; - $this->Mail->FromName = "Unit Tester"; - $this->Mail->Sender = ""; - $this->Mail->Subject = "Unit Test"; - $this->Mail->Body = ""; - $this->Mail->AltBody = ""; - $this->Mail->WordWrap = 0; - $this->Mail->Host = $global_vars["mail_host"]; - $this->Mail->Port = 25; - $this->Mail->Helo = "localhost.localdomain"; - $this->Mail->SMTPAuth = false; - $this->Mail->Username = ""; - $this->Mail->Password = ""; - $this->Mail->PluginDir = $INCLUDE_DIR; - $this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy"); - $this->Mail->Sender = "unit_test@phpmailer.sf.net"; - - if(strlen($this->Mail->Host) > 0) - $this->Mail->Mailer = "smtp"; - else - { - $this->Mail->Mailer = "mail"; - $this->Sender = "unit_test@phpmailer.sf.net"; - } - - global $global_vars; - $this->SetAddress($global_vars["mail_to"], "Test User"); - if(strlen($global_vars["mail_cc"]) > 0) - $this->SetAddress($global_vars["mail_cc"], "Carbon User", "cc"); - } - - /** - * Run after each test is completed. - */ - function tearDown() { - // Clean global variables - $this->Mail = NULL; - $this->ChangeLog = array(); - $this->NoteLog = array(); - } - - - /** - * Build the body of the message in the appropriate format. - * @private - * @returns void - */ - function BuildBody() { - $this->CheckChanges(); - - // Determine line endings for message - if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) - { - $eol = "
"; - $bullet = "
  • "; - $bullet_start = "
      "; - $bullet_end = "
    "; - } - else - { - $eol = "\n"; - $bullet = " - "; - $bullet_start = ""; - $bullet_end = ""; - } - - $ReportBody = ""; - - $ReportBody .= "---------------------" . $eol; - $ReportBody .= "Unit Test Information" . $eol; - $ReportBody .= "---------------------" . $eol; - $ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol; - $ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol; - - if(strlen($this->Mail->Host) > 0) - $ReportBody .= "Host: " . $this->Mail->Host . $eol; - - // If attachments then create an attachment list - if(count($this->Mail->attachment) > 0) - { - $ReportBody .= "Attachments:" . $eol; - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->Mail->attachment); $i++) - { - $ReportBody .= $bullet . "Name: " . $this->Mail->attachment[$i][1] . ", "; - $ReportBody .= "Encoding: " . $this->Mail->attachment[$i][3] . ", "; - $ReportBody .= "Type: " . $this->Mail->attachment[$i][4] . $eol; - } - $ReportBody .= $bullet_end . $eol; - } - - // If there are changes then list them - if(count($this->ChangeLog) > 0) - { - $ReportBody .= "Changes" . $eol; - $ReportBody .= "-------" . $eol; - - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->ChangeLog); $i++) - { - $ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" . - $this->ChangeLog[$i][1] . "]" . $eol; - } - $ReportBody .= $bullet_end . $eol . $eol; - } - - // If there are notes then list them - if(count($this->NoteLog) > 0) - { - $ReportBody .= "Notes" . $eol; - $ReportBody .= "-----" . $eol; - - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->NoteLog); $i++) - { - $ReportBody .= $bullet . $this->NoteLog[$i] . $eol; - } - $ReportBody .= $bullet_end; - } - - // Re-attach the original body - $this->Mail->Body .= $eol . $eol . $ReportBody; - } - - /** - * Check which default settings have been changed for the report. - * @private - * @returns void - */ - function CheckChanges() { - if($this->Mail->Priority != 3) - $this->AddChange("Priority", $this->Mail->Priority); - if($this->Mail->Encoding != "8bit") - $this->AddChange("Encoding", $this->Mail->Encoding); - if($this->Mail->CharSet != "iso-8859-1") - $this->AddChange("CharSet", $this->Mail->CharSet); - if($this->Mail->Sender != "") - $this->AddChange("Sender", $this->Mail->Sender); - if($this->Mail->WordWrap != 0) - $this->AddChange("WordWrap", $this->Mail->WordWrap); - if($this->Mail->Mailer != "mail") - $this->AddChange("Mailer", $this->Mail->Mailer); - if($this->Mail->Port != 25) - $this->AddChange("Port", $this->Mail->Port); - if($this->Mail->Helo != "localhost.localdomain") - $this->AddChange("Helo", $this->Mail->Helo); - if($this->Mail->SMTPAuth) - $this->AddChange("SMTPAuth", "true"); - } - - /** - * Adds a change entry. - * @private - * @returns void - */ - function AddChange($sName, $sNewValue) { - $cur = count($this->ChangeLog); - $this->ChangeLog[$cur][0] = $sName; - $this->ChangeLog[$cur][1] = $sNewValue; - } - - /** - * Adds a simple note to the message. - * @public - * @returns void - */ - function AddNote($sValue) { - $this->NoteLog[] = $sValue; - } - - /** - * Adds all of the addresses - * @public - * @returns void - */ - function SetAddress($sAddress, $sName = "", $sType = "to") { - switch($sType) - { - case "to": - $this->Mail->AddAddress($sAddress, $sName); - break; - case "cc": - $this->Mail->AddCC($sAddress, $sName); - break; - case "bcc": - $this->Mail->AddBCC($sAddress, $sName); - break; - } - } - - ///////////////////////////////////////////////// - // UNIT TESTS - ///////////////////////////////////////////////// - - /** - * Try a plain message. - */ - function test_WordWrap() { - - $this->Mail->WordWrap = 40; - $my_body = "Here is the main body of this message. It should " . - "be quite a few lines. It should be wrapped at the " . - "40 characters. Make sure that it is."; - $nBodyLen = strlen($my_body); - $my_body .= "\n\nThis is the above body length: " . $nBodyLen; - - $this->Mail->Body = $my_body; - $this->Mail->Subject .= ": Wordwrap"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Try a plain message. - */ - function test_Low_Priority() { - - $this->Mail->Priority = 5; - $this->Mail->Body = "Here is the main body. There should be " . - "a reply to address in this message."; - $this->Mail->Subject .= ": Low Priority"; - $this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)"); - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple plain file attachment test. - */ - function test_Multiple_Plain_FileAttachment() { - - $this->Mail->Body = "Here is the text body"; - $this->Mail->Subject .= ": Plain + Multiple FileAttachments"; - - if(!$this->Mail->AddAttachment("test.png")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple plain string attachment test. - */ - function test_Plain_StringAttachment() { - - $this->Mail->Body = "Here is the text body"; - $this->Mail->Subject .= ": Plain + StringAttachment"; - - $sAttachment = "These characters are the content of the " . - "string attachment.\nThis might be taken from a ". - "database or some other such thing. "; - - $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Plain quoted-printable message. - */ - function test_Quoted_Printable() { - - $this->Mail->Body = "Here is the main body"; - $this->Mail->Subject .= ": Plain + Quoted-printable"; - $this->Mail->Encoding = "quoted-printable"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Try a plain message. - */ - function test_Html() { - - $this->Mail->IsHTML(true); - $this->Mail->Subject .= ": HTML only"; - - $this->Mail->Body = "This is a test message written in HTML.
    " . - "Go to " . - "http://phpmailer.sourceforge.net/ for new versions of " . - "phpmailer.

    Thank you!"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple HTML and attachment test - */ - function test_HTML_Attachment() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->Subject .= ": HTML + Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * An embedded attachment test. - */ - function test_Embedded_Image() { - - $this->Mail->Body = "Embedded Image: \"phpmailer\"" . - "Here is an image!"; - $this->Mail->Subject .= ": Embedded Image"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", - "base64", "image/png")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * An embedded attachment test. - */ - function test_Multi_Embedded_Image() { - - $this->Mail->Body = "Embedded Image: \"phpmailer\"" . - "Here is an image!"; - $this->Mail->Subject .= ": Embedded Image + Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", - "base64", "image/png")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple multipart/alternative test. - */ - function test_AltBody() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->AltBody = "Here is the text body of this message. " . - "It should be quite a few lines. It should be wrapped at the " . - "40 characters. Make sure that it is."; - $this->Mail->WordWrap = 40; - $this->AddNote("This is a mulipart alternative email"); - $this->Mail->Subject .= ": AltBody + Word Wrap"; - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - /** - * Simple HTML and attachment test - */ - function test_AltBody_Attachment() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->AltBody = "This is the text part of the email."; - $this->Mail->Subject .= ": AltBody + Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - - $fp = fopen("message.txt", "w"); - fwrite($fp, $this->Mail->CreateHeader() . $this->Mail->CreateBody()); - fclose($fp); - } - - function test_MultipleSend() { - $this->Mail->Body = "Sending two messages without keepalive"; - $this->BuildBody(); - $subject = $this->Mail->Subject; - - $this->Mail->Subject = $subject . ": SMTP 1"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - - $this->Mail->Subject = $subject . ": SMTP 2"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - function test_SmtpKeepAlive() { - $this->Mail->Body = "This was done using the SMTP keep-alive."; - $this->BuildBody(); - $subject = $this->Mail->Subject; - - $this->Mail->SMTPKeepAlive = true; - $this->Mail->Subject = $subject . ": SMTP keep-alive 1"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - - $this->Mail->Subject = $subject . ": SMTP keep-alive 2"; - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - $this->Mail->SmtpClose(); - } - - /** - * Tests this denial of service attack: - * http://www.cybsec.com/vuln/PHPMailer-DOS.pdf - */ - function test_DenialOfServiceAttack() { - $this->Mail->Body = "This should no longer cause a denial of service."; - $this->BuildBody(); - - $this->Mail->Subject = str_repeat("A", 998); - $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); - } - - function test_Error() { - $this->Mail->Subject .= ": This should be sent"; - $this->BuildBody(); - $this->Mail->ClearAllRecipients(); // no addresses should cause an error - $this->assert($this->Mail->IsError() == false, "Error found"); - $this->assert($this->Mail->Send() == false, "Send succeeded"); - $this->assert($this->Mail->IsError(), "No error found"); - $this->assertEquals('You must provide at least one ' . - 'recipient email address.', $this->Mail->ErrorInfo); - $this->Mail->AddAddress(get("mail_to")); - $this->assert($this->Mail->Send(), "Send failed"); - } -} - -/** - * Create and run test instance. - */ - -if(isset($HTTP_GET_VARS)) - $global_vars = $HTTP_GET_VARS; -else - $global_vars = $_REQUEST; - -if(isset($global_vars["submitted"])) -{ - echo "Test results:
    "; - $suite = new TestSuite( "phpmailerTest" ); - - $testRunner = new TestRunner; - $testRunner->run($suite); - echo "


    "; -} - -function get($sName) { - global $global_vars; - if(isset($global_vars[$sName])) - return $global_vars[$sName]; - else - return ""; -} - -?> - - - -

    phpmailer Unit Test

    -By entering a SMTP hostname it will automatically perform tests with SMTP. - - - -To Address: "/> -
    -Cc Address: "/> -
    -SMTP Hostname: "/> -

    - - -

  • - - diff --git a/inc/classes/third_party/php_mailer/test/phpunit.php b/inc/classes/third_party/php_mailer/test/phpunit.php deleted file mode 100644 index 8c7256e3..00000000 --- a/inc/classes/third_party/php_mailer/test/phpunit.php +++ /dev/null @@ -1,378 +0,0 @@ - -// OntoSys, Inc -// -// $Id$ - -// Copyright (c) 2000 Fred Yankowski - -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE | - E_CORE_ERROR | E_CORE_WARNING); - -/* -interface Test { - function run(&$aTestResult); - function countTestCases(); -} -*/ - -function trace($msg) { - return; - print($msg); - flush(); -} - - -class phpUnitException { - /* Emulate a Java exception, sort of... */ - var $message; - var $type; - function phpUnitException($message, $type = 'FAILURE') { - $this->message = $message; - $this->type = $type; - } - function getMessage() { - return $this->message; - } -} - -class Assert { - function assert($boolean, $message=0) { - if (! $boolean) - $this->fail($message); - } - - function assertEquals($expected, $actual, $message=0) { - if ($expected != $actual) { - $this->failNotEquals($expected, $actual, "expected", $message); - } - } - - function assertRegexp($regexp, $actual, $message=false) { - if (! preg_match($regexp, $actual)) { - $this->failNotEquals($regexp, $actual, "pattern", $message); - } - } - - function failNotEquals($expected, $actual, $expected_label, $message=0) { - // Private function for reporting failure to match. - $str = $message ? ($message . ' ') : ''; - $str .= "($expected_label/actual)
    "; - $htmlExpected = htmlspecialchars($expected); - $htmlActual = htmlspecialchars($actual); - $str .= sprintf("
    %s\n--------\n%s
    ", - $htmlExpected, $htmlActual); - $this->fail($str); - } -} - -class TestCase extends Assert /* implements Test */ { - /* Defines context for running tests. Specific context -- such as - instance variables, global variables, global state -- is defined - by creating a subclass that specializes the setUp() and - tearDown() methods. A specific test is defined by a subclass - that specializes the runTest() method. */ - var $fName; - var $fResult; - var $fExceptions = array(); - - function TestCase($name) { - $this->fName = $name; - } - - function run($testResult=0) { - /* Run this single test, by calling the run() method of the - TestResult object which will in turn call the runBare() method - of this object. That complication allows the TestResult object - to do various kinds of progress reporting as it invokes each - test. Create/obtain a TestResult object if none was passed in. - Note that if a TestResult object was passed in, it must be by - reference. */ - if (! $testResult) - $testResult = $this->_createResult(); - $this->fResult = $testResult; - $testResult->run(&$this); - $this->fResult = 0; - return $testResult; - } - - function countTestCases() { - return 1; - } - - function runTest() { - $name = $this->name(); - // Since isset($this->$name) is false, no way to run defensive checks - $this->$name(); - } - - function setUp() /* expect override */ { - //print("TestCase::setUp()
    \n"); - } - - function tearDown() /* possible override */ { - //print("TestCase::tearDown()
    \n"); - } - - //////////////////////////////////////////////////////////////// - - - function _createResult() /* protected */ { - /* override this to use specialized subclass of TestResult */ - return new TestResult; - } - - function fail($message=0) { - //printf("TestCase::fail(%s)
    \n", ($message) ? $message : ''); - /* JUnit throws AssertionFailedError here. We just record the - failure and carry on */ - $this->fExceptions[] = new Exception(&$message); - } - - function error($message) { - /* report error that requires correction in the test script - itself, or (heaven forbid) in this testing infrastructure */ - printf('ERROR: ' . $message . '
    '); - $this->fResult->stop(); - } - - function failed() { - return count($this->fExceptions); - } - - function getExceptions() { - return $this->fExceptions; - } - - function name() { - return $this->fName; - } - - function runBare() { - $this->setup(); - $this->runTest(); - $this->tearDown(); - } -} - - -class TestSuite /* implements Test */ { - /* Compose a set of Tests (instances of TestCase or TestSuite), and - run them all. */ - var $fTests = array(); - - function TestSuite($classname=false) { - if ($classname) { - // Find all methods of the given class whose name starts with - // "test" and add them to the test suite. We are just _barely_ - // able to do this with PHP's limited introspection... Note - // that PHP seems to store method names in lower case, and we - // have to avoid the constructor function for the TestCase class - // superclass. This will fail when $classname starts with - // "Test" since that will have a constructor method that will - // get matched below and then treated (incorrectly) as a test - // method. So don't name any TestCase subclasses as "Test..."! - if (floor(phpversion()) >= 4) { - // PHP4 introspection, submitted by Dylan Kuhn - $names = get_class_methods($classname); - while (list($key, $method) = each($names)) { - if (preg_match('/^test/', $method) && $method != "testcase") { - $this->addTest(new $classname($method)); - } - } - } - else { - $dummy = new $classname("dummy"); - $names = (array) $dummy; - while (list($key, $value) = each($names)) { - $type = gettype($value); - if ($type == "user function" && preg_match('/^test/', $key) - && $key != "testcase") { - $this->addTest(new $classname($key)); - } - } - } - } - } - - function addTest($test) { - /* Add TestCase or TestSuite to this TestSuite */ - $this->fTests[] = $test; - } - - function run(&$testResult) { - /* Run all TestCases and TestSuites comprising this TestSuite, - accumulating results in the given TestResult object. */ - reset($this->fTests); - while (list($na, $test) = each($this->fTests)) { - if ($testResult->shouldStop()) - break; - $test->run(&$testResult); - } - } - - function countTestCases() { - /* Number of TestCases comprising this TestSuite (including those - in any constituent TestSuites) */ - $count = 0; - reset($fTests); - while (list($na, $test_case) = each($this->fTests)) { - $count += $test_case->countTestCases(); - } - return $count; - } -} - - -class TestFailure { - /* Record failure of a single TestCase, associating it with the - exception(s) that occurred */ - var $fFailedTestName; - var $fExceptions; - - function TestFailure(&$test, &$exceptions) { - $this->fFailedTestName = $test->name(); - $this->fExceptions = $exceptions; - } - - function getExceptions() { - return $this->fExceptions; - } - function getTestName() { - return $this->fFailedTestName; - } -} - - -class TestResult { - /* Collect the results of running a set of TestCases. */ - var $fFailures = array(); - var $fRunTests = 0; - var $fStop = false; - - function TestResult() { } - - function _endTest($test) /* protected */ { - /* specialize this for end-of-test action, such as progress - reports */ - } - - function getFailures() { - return $this->fFailures; - } - - function run($test) { - /* Run a single TestCase in the context of this TestResult */ - $this->_startTest($test); - $this->fRunTests++; - - $test->runBare(); - - /* this is where JUnit would catch AssertionFailedError */ - $exceptions = $test->getExceptions(); - if ($exceptions) - $this->fFailures[] = new TestFailure(&$test, &$exceptions); - $this->_endTest($test); - } - - function countTests() { - return $this->fRunTests; - } - - function shouldStop() { - return $this->fStop; - } - - function _startTest($test) /* protected */ { - /* specialize this for start-of-test actions */ - } - - function stop() { - /* set indication that the test sequence should halt */ - $fStop = true; - } - - function countFailures() { - return count($this->fFailures); - } -} - - -class TextTestResult extends TestResult { - /* Specialize TestResult to produce text/html report */ - function TextTestResult() { - $this->TestResult(); // call superclass constructor - } - - function report() { - /* report result of test run */ - $nRun = $this->countTests(); - $nFailures = $this->countFailures(); - printf("

    %s test%s run
    ", $nRun, ($nRun == 1) ? '' : 's'); - printf("%s failure%s.
    \n", $nFailures, ($nFailures == 1) ? '' : 's'); - if ($nFailures == 0) - return; - - print("

      \n"); - $failures = $this->getFailures(); - while (list($i, $failure) = each($failures)) { - $failedTestName = $failure->getTestName(); - printf("
    1. %s\n", $failedTestName); - - $exceptions = $failure->getExceptions(); - print("
        "); - while (list($na, $exception) = each($exceptions)) - printf("
      • %s\n", $exception->getMessage()); - print("
      "); - } - print("
    \n"); - } - - function _startTest($test) { - printf("%s ", $test->name()); - flush(); - } - - function _endTest($test) { - $outcome = $test->failed() - ? "FAIL" - : "ok"; - printf("$outcome
    \n"); - flush(); - } -} - - -class TestRunner { - /* Run a suite of tests and report results. */ - function run($suite) { - $result = new TextTestResult; - $suite->run($result); - $result->report(); - } -} - -?> diff --git a/inc/classes/third_party/php_mailer/test/test.png b/inc/classes/third_party/php_mailer/test/test.png deleted file mode 100644 index 02de5a7a..00000000 Binary files a/inc/classes/third_party/php_mailer/test/test.png and /dev/null differ diff --git a/inc/classes/third_party/scrypt/.htaccess b/inc/classes/third_party/scrypt/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/inc/classes/third_party/scrypt/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/inc/classes/third_party/scrypt/CREDITS b/inc/classes/third_party/scrypt/CREDITS deleted file mode 100644 index 79c72e5a..00000000 --- a/inc/classes/third_party/scrypt/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -scrypt -Dominic Black \ No newline at end of file diff --git a/inc/classes/third_party/scrypt/LICENSE b/inc/classes/third_party/scrypt/LICENSE deleted file mode 100644 index 381d3aff..00000000 --- a/inc/classes/third_party/scrypt/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -Original Scrypt Implementation; - Copyright (c) 2009 Colin Percival - -PHP Module; - Copyright (c) 2012, Dominic Black - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/inc/classes/third_party/scrypt/README.md b/inc/classes/third_party/scrypt/README.md deleted file mode 100644 index fef282bd..00000000 --- a/inc/classes/third_party/scrypt/README.md +++ /dev/null @@ -1,90 +0,0 @@ -PHP scrypt module -================= - -[![Build Status](https://travis-ci.org/DomBlack/php-scrypt.svg?branch=master)](https://travis-ci.org/DomBlack/php-scrypt) - -This is a PHP library providing a wrapper to [Colin Percival's scrypt implementation](http://www.tarsnap.com/scrypt.html). Scrypt is a key derivation function designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt. - -Details of the scrypt key derivation function are given in a paper by Colin Percival, Stronger Key Derivation via Sequential Memory-Hard Functions: [PDF](http://www.tarsnap.com/scrypt/scrypt-slides.pdf). - -An example class using this module can be found in; scrypt.php - -Join in! --------- - -We are happy to receive bug reports, fixes, documentation enhancements, and other improvements. - -Please report bugs via the [github issue tracker](http://github.com/DomBlack/php-scrypt/issues). - -Master [git repository](https://github.com/DomBlack/php-scrypt): - - git clone git://github.com/DomBlack/php-scrypt.git - -Authors -------- - -This library is written and maintained by Dominic Black, . - ----- - -PECL Install -============ - -This extension is now avaible through PECL. - -``` -pecl install scrypt -``` - -Build From Source -================= - -Unix/OSX --------- - -1. `phpize` -2. If on OSX; `export CFLAGS='-arch i386 -arch x86_64'` -3. `./configure --enable-scrypt` -4. `make` -5. `make install` -6. Add the extension to your php.ini - -```` - ; Enable scrypt extension module - extension=scrypt.so -```` - -Windows -------- - -Using Visual Studio 2008 (or Visual C++ Express 2008) open up the attached project -inside the VS2008 folder. This project assumes you have the PHP thread safe source at; -`C:\phpsrcts\`, a PHP install at `C:\php\` and this source code extracted to -`C:\php-scrypt\`. - -1. Build the project. -2. Copy the resultant `scrypt.dll` to your ext directory in PHP. -3. Add the extension to your php.ini - -```` - ; Enable scrypt extension module - extension=scrypt.dll -```` - -Legal Stuff -=========== -This works is licensed under the BSD 2-Clause license. - -Original Scrypt Implementation; - Copyright (c) 2009 Colin Percival - -PHP Module; - Copyright (c) 2012, Dominic Black - -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/inc/config.php b/inc/config.php index f42bd1a3..4545f461 100644 --- a/inc/config.php +++ b/inc/config.php @@ -25,8 +25,8 @@ */ // Load very basic classes, required to bootstrap -require(ApplicationEntryPoint::detectCorePath() . '/inc/classes/interfaces/class_FrameworkInterface.php'); -require(ApplicationEntryPoint::detectCorePath() . '/inc/classes/interfaces/registry/class_Registerable.php'); +require(ApplicationEntryPoint::detectCorePath() . '/inc/main/interfaces/class_FrameworkInterface.php'); +require(ApplicationEntryPoint::detectCorePath() . '/inc/main/interfaces/registry/class_Registerable.php'); require(ApplicationEntryPoint::detectCorePath() . '/inc/config/class_FrameworkConfiguration.php'); // Get a new configuration instance @@ -78,7 +78,7 @@ $cfg->setConfigEntry('tpl_base_path', 'templates/'); $cfg->setConfigEntry('lang_base_path', 'inc/language/'); // CFG: COMPRESSOR-BASE-PATH -$cfg->setConfigEntry('compressor_base_path', 'inc/classes/main/compressor/'); +$cfg->setConfigEntry('compressor_base_path', 'inc/main/classes/compressor/'); // CFG: APPLICATION-BASE-PATH $cfg->setConfigEntry('application_base_path', 'application/'); diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 5a206d5c..a3bcb84a 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -2,7 +2,7 @@ /** * A class for the configuration stuff implemented in a singleton design paddern * - * NOTE: We cannot put this in inc/classes/ because it would be loaded (again) in + * NOTE: We cannot put this in inc/main/ because it would be loaded (again) in * class loader. See inc/loader/class_ClassLoader.php for instance * * @see ClassLoader diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php index 11683c49..7b6bb2dd 100644 --- a/inc/loader/class_ClassLoader.php +++ b/inc/loader/class_ClassLoader.php @@ -104,7 +104,7 @@ class ClassLoader { private static $frameworkPaths = array( 'exceptions', // Exceptions 'interfaces', // Interfaces - 'main', // General main classes + 'classes', // Classes 'middleware' // The middleware ); @@ -178,9 +178,9 @@ class ClassLoader { $loaderInstance = self::getSelfInstance(); // Load all classes - foreach (self::$frameworkPaths as $className) { + foreach (self::$frameworkPaths as $pathName) { // Try to load the framework classes - $loaderInstance->scanClassPath('inc/classes/' . $className . '/'); + $loaderInstance->scanClassPath('inc/main/' . $pathName . '/'); } // END - foreach } @@ -462,7 +462,7 @@ class ClassLoader { } /** - * Getter for a printable list of included classes/interfaces/exceptions + * Getter for a printable list of included main/interfaces/exceptions * * @param $includeList A printable include list */ diff --git a/inc/main/.htaccess b/inc/main/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/.htaccess b/inc/main/classes/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/actions/.htaccess b/inc/main/classes/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/actions/class_ b/inc/main/classes/actions/class_ new file mode 100644 index 00000000..c654e18b --- /dev/null +++ b/inc/main/classes/actions/class_ @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Action extends BaseAction implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @return $actionInstance An instance of this action class + */ + public final static function create???Action () { + // Get a new instance + $actionInstance = new ???Action(); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub("You have to implement me."); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/actions/class_BaseAction.php b/inc/main/classes/actions/class_BaseAction.php new file mode 100644 index 00000000..59d76686 --- /dev/null +++ b/inc/main/classes/actions/class_BaseAction.php @@ -0,0 +1,40 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseAction extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/actions/html/.htaccess b/inc/main/classes/actions/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/actions/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/actions/html/class_HtmlLoginProfileAction.php b/inc/main/classes/actions/html/class_HtmlLoginProfileAction.php new file mode 100644 index 00000000..55ff8cee --- /dev/null +++ b/inc/main/classes/actions/html/class_HtmlLoginProfileAction.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginProfileAction extends BaseAction implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @param $resolverInstance An instance of an action resolver + * @return $actionInstance An instance of this action class + */ + public static final function createHtmlLoginProfileAction (ActionResolver $resolverInstance) { + // Get a new instance + $actionInstance = new HtmlLoginProfileAction(); + + // Set the resolver instance + $actionInstance->setResolverInstance($resolverInstance); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Dummy method + } + + /** + * 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) { + // Add user status filter here + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/actions/post_registration/.htaccess b/inc/main/classes/actions/post_registration/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/actions/post_registration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/actions/post_registration/class_LoginAfterRegistrationAction.php b/inc/main/classes/actions/post_registration/class_LoginAfterRegistrationAction.php new file mode 100644 index 00000000..2ee90844 --- /dev/null +++ b/inc/main/classes/actions/post_registration/class_LoginAfterRegistrationAction.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LoginAfterRegistrationAction extends BaseAction implements PerformableAction { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this action + * + * @return $actionInstance An instance of this action class + */ + public static final function createLoginAfterRegistrationAction () { + // Get a new instance + $actionInstance = new LoginAfterRegistrationAction(); + + // Return the instance + return $actionInstance; + } + + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a login class from factory + $loginInstance = LoginFactory::createLoginObjectByRequest($requestInstance); + + // Login the user by the request instance + $loginInstance->doLogin($requestInstance, $responseInstance); + + // Was the login fine? Then redirect here + if ($loginInstance->ifLoginWasSuccessfull()) { + // Try to redirect here + try { + // Redirect... + $responseInstance->redirectToConfiguredUrl('app_login'); + + // Stop here + exit(); + } catch (FrameworkException $e) { + // Something went wrong here! + $responseInstance->addFatalMessage($e->getMessage()); + } + } else { + // Attach error message to the response + $responseInstance->addFatalMessage('failed_login_after_registration'); + } + } +} + +// [EOF] +?> diff --git a/inc/main/classes/application/.htaccess b/inc/main/classes/application/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/application/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/application/class_BaseApplication.php b/inc/main/classes/application/class_BaseApplication.php new file mode 100644 index 00000000..7f14fe24 --- /dev/null +++ b/inc/main/classes/application/class_BaseApplication.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseApplication extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Get registry instance + $registryInstance = Registry::getRegistry(); + + // Add this instance + $registryInstance->addInstance('application', $this); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/auth/.htaccess b/inc/main/classes/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/auth/class_CookieAuth.php b/inc/main/classes/auth/class_CookieAuth.php new file mode 100644 index 00000000..1e195271 --- /dev/null +++ b/inc/main/classes/auth/class_CookieAuth.php @@ -0,0 +1,122 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CookieAuth extends BaseFrameworkSystem implements Authorizeable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class by the given response instance + * + * @param $responseInstance An instance of a Responseable class + * @return $loginInstance An instance of this login class + */ + public static final function createCookieAuth (Responseable $responseInstance) { + // Get a new instance + $loginInstance = new CookieAuth(); + + // Set the response instance + $loginInstance->setResponseInstance($responseInstance); + + // Return the prepared instance + return $loginInstance; + } + + /** + * "Setter" for username auth data + * + * @param $userName The username from request we shall set + * @return void + */ + public function setUserAuth ($userName) { + $this->getResponseInstance()->addCookie('username', $userName); + } + + /** + * "Setter" for password hash auth data + * + * @param $passHash The hashed password from request we shall set + * @return void + */ + public function setPasswordAuth ($passHash) { + $this->getResponseInstance()->addCookie('u_hash', $passHash); + } + + /** + * Getter for user auth cookie + * + * @return $userName Username to get from cookie + */ + public function getUserAuth () { + // Get the username from cookie + $userName = $this->getRequestInstance()->readCookie('username'); + + // Return the username + return $userName; + } + + /** + * Getter for password hash auth cookie + * + * @return $passHash Password hash to get from cookie + */ + public function getPasswordAuth () { + // Get the username from cookie + $passHash = $this->getRequestInstance()->readCookie('u_hash'); + + // Return the username + return $passHash; + } + + /** + * Destroy the authorization data + * + * @return void + */ + public function destroyAuthData () { + // Expire both cookies + $this->getResponseInstance()->expireCookie('username'); + $this->getResponseInstance()->expireCookie('u_hash'); + } + + /** + * Updates the authorization data and/or sets additional tracking data + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function updateAuthData () { + $this->getResponseInstance()->refreshCookie('username'); + $this->getResponseInstance()->refreshCookie('u_hash'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/cache/.htaccess b/inc/main/classes/cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/cache/class_MemoryCache.php b/inc/main/classes/cache/class_MemoryCache.php new file mode 100644 index 00000000..9b827ba9 --- /dev/null +++ b/inc/main/classes/cache/class_MemoryCache.php @@ -0,0 +1,145 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MemoryCache extends BaseFrameworkSystem implements Cacheable { + /** + * The "memory cache" is simply a wrapped object array + */ + private $dataCache = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $cacheInstance An instance of this cache class + */ + public static final function createMemoryCache () { + // Get a new instance + $cacheInstance = new MemoryCache(); + + // Initialize the cache + $cacheInstance->initCache(); + + // Return the prepared instance + return $cacheInstance; + } + + /** + * Initialize this cache by creating an object array + * + * @return void + */ + protected function initCache () { + // Now create the "data cache" + $this->dataCache = new FrameworkArrayObject('FakedDataCache'); + } + + /** + * Does the specified offset exist in cache? + * + * @param $offset The offset we are looking for + * @param $arrayElement If type is array, then this element must be found + * @param $minimumCount If array element is found then this count must at least match + * @return $exists Whether the offset exists + */ + public function offsetExists ($offset, $arrayElement = NULL, $minimumCount = 0) { + // Is it there? + $exists = $this->dataCache->offsetExists($offset); + + // So look for array element? + if (($exists === TRUE) && (!is_null($arrayElement))) { + // Get it + $array = $this->offsetGet($offset); + + // Is it an array and element is found? + if ((is_array($array)) && (isset($array[$arrayElement]))) { + // Is an array and element is found, so check count + $exists = (count($array[$arrayElement]) >= $minimumCount); + } else { + // Not found + $exists = FALSE; + } + } // END - if + + // Return status + return $exists; + } + + /** + * Setter for cache offset + * + * @param $offset The offset we shall set + * @param $data Data to store in cache + * @return void + */ + public function offsetSet ($offset, $data) { + $this->dataCache->offsetSet($offset, $data); + } + + /** + * Getter for cache offset or "null" if not found + * + * @param $offset The offset we shall set + * @return $data Data to store in cache + */ + public function offsetGet ($offset) { + // Default is offset not found + $data = NULL; + + // Is the offset there? + if ($this->offsetExists($offset)) { + // Then get the data from it + $data = $this->dataCache->offsetGet($offset); + } // END - if + + // Return data + return $data; + } + + /** + * Purges the given cache entry + * + * @param $offset The offset we shall set + * @return void + */ + public function purgeOffset ($offset) { + // Is the offset there? + if ($this->offsetExists($offset)) { + // Purge only existing keys + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CACHE: Unsetting cache ' . $offset); + $this->dataCache->offsetUnset($offset); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/class_ b/inc/main/classes/class_ new file mode 100644 index 00000000..48f2751a --- /dev/null +++ b/inc/main/classes/class_ @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???!!! extends Base!!! implements CompileableTemplate { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this !!! class and prepares it for usage + * + * @param $appInstance A manageable application + * @return $///Instance An instance of this !!! class + */ + public final static function create???!!! (ManageableApplication $appInstance) { + // Get a new instance + $///Instance = new ???!!!(); + + // Return the prepared instance + return $///Instance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/class_Base b/inc/main/classes/class_Base new file mode 100644 index 00000000..fce73ca5 --- /dev/null +++ b/inc/main/classes/class_Base @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Base??? extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/class_BaseFrameworkSystem.php b/inc/main/classes/class_BaseFrameworkSystem.php new file mode 100644 index 00000000..7bee5eca --- /dev/null +++ b/inc/main/classes/class_BaseFrameworkSystem.php @@ -0,0 +1,3380 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFrameworkSystem extends stdClass implements FrameworkInterface { + /** + * Length of output from hash() + */ + private static $hashLength = NULL; + + /** + * The real class name + */ + private $realClass = 'BaseFrameworkSystem'; + + /** + * Instance of a request class + */ + private $requestInstance = NULL; + + /** + * Instance of a response class + */ + private $responseInstance = NULL; + + /** + * Search criteria instance + */ + private $searchInstance = NULL; + + /** + * Update criteria instance + */ + private $updateInstance = NULL; + + /** + * The file I/O instance for the template loader + */ + private $fileIoInstance = NULL; + + /** + * Resolver instance + */ + private $resolverInstance = NULL; + + /** + * Template engine instance + */ + private $templateInstance = NULL; + + /** + * Database result instance + */ + private $resultInstance = NULL; + + /** + * Instance for user class + */ + private $userInstance = NULL; + + /** + * A controller instance + */ + private $controllerInstance = NULL; + + /** + * Instance of a RNG + */ + private $rngInstance = NULL; + + /** + * Instance of a crypto helper + */ + private $cryptoInstance = NULL; + + /** + * Instance of an Iterator class + */ + private $iteratorInstance = NULL; + + /** + * Instance of the list + */ + private $listInstance = NULL; + + /** + * Instance of a menu + */ + private $menuInstance = NULL; + + /** + * Instance of the image + */ + private $imageInstance = NULL; + + /** + * Instance of the stacker + */ + private $stackInstance = NULL; + + /** + * A Compressor instance + */ + private $compressorInstance = NULL; + + /** + * A Parseable instance + */ + private $parserInstance = NULL; + + /** + * A HandleableProtocol instance + */ + private $protocolInstance = NULL; + + /** + * A database wrapper instance + */ + private $databaseInstance = NULL; + + /** + * A helper instance for the form + */ + private $helperInstance = NULL; + + /** + * An instance of a Source class + */ + private $sourceInstance = NULL; + + /** + * An instance of a UrlSource class + */ + private $urlSourceInstance = NULL; + + /** + * An instance of a InputStream class + */ + private $inputStreamInstance = NULL; + + /** + * An instance of a OutputStream class + */ + private $outputStreamInstance = NULL; + + /** + * Networkable handler instance + */ + private $handlerInstance = NULL; + + /** + * Visitor handler instance + */ + private $visitorInstance = NULL; + + /** + * DHT instance + */ + private $dhtInstance = NULL; + + /** + * An instance of a database wrapper class + */ + private $wrapperInstance = NULL; + + /** + * An instance of a file I/O pointer class (not handler) + */ + private $pointerInstance = NULL; + + /** + * An instance of an Indexable class + */ + private $indexInstance = NULL; + + /** + * An instance of a Block class + */ + private $blockInstance = NULL; + + /** + * A Minable instance + */ + private $minableInstance = NULL; + + /** + * A FrameworkDirectory instance + */ + private $directoryInstance = NULL; + + /** + * Listener instance + */ + private $listenerInstance = NULL; + + /** + * An instance of a communicator + */ + private $communicatorInstance = NULL; + + /** + * The concrete output instance + */ + private $outputInstance = NULL; + + /** + * State instance + */ + private $stateInstance = NULL; + + /** + * Thousands separator + */ + private $thousands = '.'; // German + + /** + * Decimal separator + */ + private $decimals = ','; // German + + /** + * Socket resource + */ + private $socketResource = FALSE; + + /** + * Regular expression to use for validation + */ + private $regularExpression = ''; + + /** + * Package data + */ + private $packageData = array(); + + /** + * Generic array + */ + private $genericArray = array(); + + /** + * Command name + */ + private $commandName = ''; + + /** + * Controller name + */ + private $controllerName = ''; + + /** + * Name of used protocol + */ + private $protocolName = 'invalid'; + + /** + * Array with bitmasks and such for pack/unpack methods to support both + * 32-bit and 64-bit systems + */ + private $packingData = array( + 32 => array( + 'step' => 3, + 'left' => 0xffff0000, + 'right' => 0x0000ffff, + 'factor' => 16, + 'format' => 'II', + ), + 64 => array( + 'step' => 7, + 'left' => 0xffffffff00000000, + 'right' => 0x00000000ffffffff, + 'factor' => 32, + 'format' => 'NN' + ) + ); + + /** + * Simple 64-bit check, thanks to "Salman A" from stackoverflow.com: + * + * The integer size is 4 bytes on 32-bit and 8 bytes on a 64-bit system. + */ + private $archArrayElement = FALSE; + + /*********************** + * Exception codes.... * + ***********************/ + + // @todo Try to clean these constants up + const EXCEPTION_IS_NULL_POINTER = 0x001; + const EXCEPTION_IS_NO_OBJECT = 0x002; + const EXCEPTION_IS_NO_ARRAY = 0x003; + const EXCEPTION_MISSING_METHOD = 0x004; + const EXCEPTION_CLASSES_NOT_MATCHING = 0x005; + const EXCEPTION_INDEX_OUT_OF_BOUNDS = 0x006; + const EXCEPTION_DIMENSION_ARRAY_INVALID = 0x007; + const EXCEPTION_ITEM_NOT_TRADEABLE = 0x008; + const EXCEPTION_ITEM_NOT_IN_PRICE_LIST = 0x009; + const EXCEPTION_GENDER_IS_WRONG = 0x00a; + const EXCEPTION_BIRTH_DATE_IS_INVALID = 0x00b; + const EXCEPTION_EMPTY_STRUCTURES_ARRAY = 0x00c; + const EXCEPTION_HAS_ALREADY_PERSONELL_LIST = 0x00d; + const EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES = 0x00e; + const EXCEPTION_TOTAL_PRICE_NOT_CALCULATED = 0x00f; + const EXCEPTION_HARBOR_HAS_NO_SHIPYARDS = 0x010; + const EXCEPTION_CONTRACT_PARTNER_INVALID = 0x011; + const EXCEPTION_CONTRACT_PARTNER_MISMATCH = 0x012; + const EXCEPTION_CONTRACT_ALREADY_SIGNED = 0x013; + const EXCEPTION_UNEXPECTED_EMPTY_STRING = 0x014; + const EXCEPTION_PATH_NOT_FOUND = 0x015; + const EXCEPTION_INVALID_PATH_NAME = 0x016; + const EXCEPTION_READ_PROTECED_PATH = 0x017; + const EXCEPTION_WRITE_PROTECED_PATH = 0x018; + const EXCEPTION_DIR_POINTER_INVALID = 0x019; + const EXCEPTION_FILE_POINTER_INVALID = 0x01a; + const EXCEPTION_INVALID_RESOURCE = 0x01b; + const EXCEPTION_UNEXPECTED_OBJECT = 0x01c; + const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d; + const EXCEPTION_GETTER_IS_MISSING = 0x01e; + const EXCEPTION_ARRAY_EXPECTED = 0x01f; + const EXCEPTION_ARRAY_HAS_INVALID_COUNT = 0x020; + const EXCEPTION_ID_IS_INVALID_FORMAT = 0x021; + const EXCEPTION_MD5_CHECKSUMS_MISMATCH = 0x022; + const EXCEPTION_UNEXPECTED_STRING_SIZE = 0x023; + const EXCEPTION_SIMULATOR_ID_INVALID = 0x024; + const EXCEPTION_MISMATCHING_COMPRESSORS = 0x025; + const EXCEPTION_CONTAINER_ITEM_IS_NULL = 0x026; + const EXCEPTION_ITEM_IS_NO_ARRAY = 0x027; + const EXCEPTION_CONTAINER_MAYBE_DAMAGED = 0x028; + const EXCEPTION_INVALID_STRING = 0x029; + const EXCEPTION_VARIABLE_NOT_SET = 0x02a; + const EXCEPTION_ATTRIBUTES_ARE_MISSING = 0x02b; + const EXCEPTION_ARRAY_ELEMENTS_MISSING = 0x02c; + const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED = 0x02d; + const EXCEPTION_UNSPPORTED_OPERATION = 0x02e; + const EXCEPTION_FACTORY_REQUIRE_PARAMETER = 0x02f; + const EXCEPTION_MISSING_ELEMENT = 0x030; + const EXCEPTION_HEADERS_ALREADY_SENT = 0x031; + const EXCEPTION_DEFAULT_CONTROLLER_GONE = 0x032; + const EXCEPTION_CLASS_NOT_FOUND = 0x033; + const EXCEPTION_REQUIRED_INTERFACE_MISSING = 0x034; + const EXCEPTION_FATAL_ERROR = 0x035; + const EXCEPTION_FILE_NOT_FOUND = 0x036; + const EXCEPTION_ASSERTION_FAILED = 0x037; + const EXCEPTION_FILE_NOT_REACHABLE = 0x038; + const EXCEPTION_FILE_CANNOT_BE_READ = 0x039; + const EXCEPTION_FILE_CANNOT_BE_WRITTEN = 0x03a; + const EXCEPTION_PATH_CANNOT_BE_WRITTEN = 0x03b; + const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x03c; + const EXCEPTION_FILTER_CHAIN_INTERCEPTED = 0x03d; + + /** + * Hexadecimal->Decimal translation array + */ + private static $hexdec = array( + '0' => 0, + '1' => 1, + '2' => 2, + '3' => 3, + '4' => 4, + '5' => 5, + '6' => 6, + '7' => 7, + '8' => 8, + '9' => 9, + 'a' => 10, + 'b' => 11, + 'c' => 12, + 'd' => 13, + 'e' => 14, + 'f' => 15 + ); + + /** + * Decimal->hexadecimal translation array + */ + private static $dechex = array( + 0 => '0', + 1 => '1', + 2 => '2', + 3 => '3', + 4 => '4', + 5 => '5', + 6 => '6', + 7 => '7', + 8 => '8', + 9 => '9', + 10 => 'a', + 11 => 'b', + 12 => 'c', + 13 => 'd', + 14 => 'e', + 15 => 'f' + ); + + /** + * Startup time in miliseconds + */ + private static $startupTime = 0; + + /** + * Protected super constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Set real class + $this->setRealClass($className); + + // Set configuration instance if no registry ... + if (!$this instanceof Register) { + // ... because registries doesn't need to be configured + $this->setConfigInstance(FrameworkConfiguration::getSelfInstance()); + } // END - if + + // Is the startup time set? (0 cannot be TRUE anymore) + if (self::$startupTime == 0) { + // Then set it + self::$startupTime = microtime(TRUE); + } // END - if + + // Set array element + $this->archArrayElement = (PHP_INT_SIZE === 8 ? 64 : 32); + } + + /** + * Destructor for all classes. You should not call this method on your own. + * + * @return void + */ + public function __destruct () { + // Flush any updated entries to the database + $this->flushPendingUpdates(); + + // Is this object already destroyed? + if ($this->__toString() != 'DestructedObject') { + // Destroy all informations about this class but keep some text about it alive + $this->setRealClass('DestructedObject'); + } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { + // Already destructed object + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] The object %s is already destroyed.', + __CLASS__, + $this->__toString() + )); + } else { + // Do not call this twice + trigger_error(__METHOD__ . ': Called twice.'); + exit; + } + } + + /** + * The __call() method where all non-implemented methods end up + * + * @param $methodName Name of the missing method + * @args $args Arguments passed to the method + * @return void + */ + public final function __call ($methodName, $args) { + return self::__callStatic($methodName, $args); + } + + /** + * The __callStatic() method where all non-implemented static methods end up + * + * @param $methodName Name of the missing method + * @args $args Arguments passed to the method + * @return void + */ + public static final function __callStatic ($methodName, $args) { + // Init argument string + $argsString = ''; + + // Is it NULL, empty or an array? + if (is_null($args)) { + // No arguments + $argsString = 'NULL'; + } elseif (empty($args)) { + // Empty arguments + $argsString = '(empty)'; + } elseif (is_array($args)) { + // Some arguments are there + foreach ($args as $arg) { + // Add the value itself if not array. This prevents 'array to string conversion' message + if (is_array($arg)) { + $argsString .= 'Array'; + } else { + $argsString .= $arg; + } + + // Add data about the argument + $argsString .= ' (' . gettype($arg); + + if (is_string($arg)) { + // Add length for strings + $argsString .= ', ' . strlen($arg); + } elseif (is_array($arg)) { + // .. or size if array + $argsString .= ', ' . count($arg); + } elseif ($arg === TRUE) { + // ... is boolean 'TRUE' + $argsString .= ', TRUE'; + } elseif ($arg === FALSE) { + // ... is boolean 'FALSE' + $argsString .= ', FALSE'; + } + + // Closing bracket + $argsString .= '), '; + } // END - foreach + + // Remove last comma + if (substr($argsString, -2, 1) == ',') { + $argsString = substr($argsString, 0, -2); + } // END - if + } else { + // Invalid arguments! + $argsString = '!INVALID:' . gettype($args) . '!'; + } + + // Output stub message + // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s', + $methodName, + $argsString + )); + + // Return nothing + return NULL; + } + + /** + * Getter for $realClass + * + * @return $realClass The name of the real class (not BaseFrameworkSystem) + */ + public function __toString () { + return $this->realClass; + } + + /** + * Magic method to catch setting of missing but set class fields/attributes + * + * @param $name Name of the field/attribute + * @param $value Value to store + * @return void + */ + public final function __set ($name, $value) { + $this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s', + $name, + gettype($value), + print_r($value, TRUE) + )); + } + + /** + * Magic method to catch getting of missing fields/attributes + * + * @param $name Name of the field/attribute + * @return void + */ + public final function __get ($name) { + $this->debugBackTrace(sprintf('Tried to get a missing field. name=%s', + $name + )); + } + + /** + * Magic method to catch unsetting of missing fields/attributes + * + * @param $name Name of the field/attribute + * @return void + */ + public final function __unset ($name) { + $this->debugBackTrace(sprintf('Tried to unset a missing field. name=%s', + $name + )); + } + + /** + * Magic method to catch object serialization + * + * @return $unsupported Unsupported method + * @throws UnsupportedOperationException Objects of this framework cannot be serialized + */ + public final function __sleep () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Magic method to catch object deserialization + * + * @return $unsupported Unsupported method + * @throws UnsupportedOperationException Objects of this framework cannot be serialized + */ + public final function __wakeup () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Magic method to catch calls when an object instance is called + * + * @return $unsupported Unsupported method + * @throws UnsupportedOperationException Objects of this framework cannot be serialized + */ + public final function __invoke () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for the real class name + * + * @param $realClass Class name (string) + * @return void + */ + public final function setRealClass ($realClass) { + // Set real class + $this->realClass = (string) $realClass; + } + + /** + * Setter for database result instance + * + * @param $resultInstance An instance of a database result class + * @return void + * @todo SearchableResult and UpdateableResult shall have a super interface to use here + */ + protected final function setResultInstance (SearchableResult $resultInstance) { + $this->resultInstance = $resultInstance; + } + + /** + * Getter for database result instance + * + * @return $resultInstance An instance of a database result class + */ + public final function getResultInstance () { + return $this->resultInstance; + } + + /** + * Setter for template engine instances + * + * @param $templateInstance An instance of a template engine class + * @return void + */ + protected final function setTemplateInstance (CompileableTemplate $templateInstance) { + $this->templateInstance = $templateInstance; + } + + /** + * Getter for template engine instances + * + * @return $templateInstance An instance of a template engine class + */ + protected final function getTemplateInstance () { + return $this->templateInstance; + } + + /** + * Setter for search instance + * + * @param $searchInstance Searchable criteria instance + * @return void + */ + public final function setSearchInstance (LocalSearchCriteria $searchInstance) { + $this->searchInstance = $searchInstance; + } + + /** + * Getter for search instance + * + * @return $searchInstance Searchable criteria instance + */ + public final function getSearchInstance () { + return $this->searchInstance; + } + + /** + * Setter for update instance + * + * @param $updateInstance Searchable criteria instance + * @return void + */ + public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) { + $this->updateInstance = $updateInstance; + } + + /** + * Getter for update instance + * + * @return $updateInstance Updateable criteria instance + */ + public final function getUpdateInstance () { + return $this->updateInstance; + } + + /** + * Setter for resolver instance + * + * @param $resolverInstance Instance of a command resolver class + * @return void + */ + public final function setResolverInstance (Resolver $resolverInstance) { + $this->resolverInstance = $resolverInstance; + } + + /** + * Getter for resolver instance + * + * @return $resolverInstance Instance of a command resolver class + */ + public final function getResolverInstance () { + return $this->resolverInstance; + } + + /** + * Setter for language instance + * + * @param $configInstance The configuration instance which shall + * be FrameworkConfiguration + * @return void + */ + public final function setConfigInstance (FrameworkConfiguration $configInstance) { + Registry::getRegistry()->addInstance('config', $configInstance); + } + + /** + * Getter for configuration instance + * + * @return $configInstance Configuration instance + */ + public final function getConfigInstance () { + $configInstance = Registry::getRegistry()->getInstance('config'); + return $configInstance; + } + + /** + * Setter for debug instance + * + * @param $debugInstance The instance for debug output class + * @return void + */ + public final function setDebugInstance (DebugMiddleware $debugInstance) { + Registry::getRegistry()->addInstance('debug', $debugInstance); + } + + /** + * Getter for debug instance + * + * @return $debugInstance Instance to class DebugConsoleOutput or DebugWebOutput + */ + public final function getDebugInstance () { + // Get debug instance + $debugInstance = Registry::getRegistry()->getInstance('debug'); + + // Return it + return $debugInstance; + } + + /** + * Setter for web output instance + * + * @param $webInstance The instance for web output class + * @return void + */ + public final function setWebOutputInstance (OutputStreamer $webInstance) { + Registry::getRegistry()->addInstance('web_output', $webInstance); + } + + /** + * Getter for web output instance + * + * @return $webOutputInstance - Instance to class WebOutput + */ + public final function getWebOutputInstance () { + $webOutputInstance = Registry::getRegistry()->getInstance('web_output'); + return $webOutputInstance; + } + + /** + * Setter for database instance + * + * @param $databaseInstance The instance for the database connection (forced DatabaseConnection) + * @return void + */ + public final function setDatabaseInstance (DatabaseConnection $databaseInstance) { + Registry::getRegistry()->addInstance('db_instance', $databaseInstance); + } + + /** + * Getter for database layer + * + * @return $databaseInstance The database layer instance + */ + public final function getDatabaseInstance () { + // Get instance + $databaseInstance = Registry::getRegistry()->getInstance('db_instance'); + + // Return instance + return $databaseInstance; + } + + /** + * Setter for compressor channel + * + * @param $compressorInstance An instance of CompressorChannel + * @return void + */ + public final function setCompressorChannel (CompressorChannel $compressorInstance) { + Registry::getRegistry()->addInstance('compressor', $compressorInstance); + } + + /** + * Getter for compressor channel + * + * @return $compressorInstance The compressor channel + */ + public final function getCompressorChannel () { + $compressorInstance = Registry::getRegistry()->getInstance('compressor'); + return $compressorInstance; + } + + /** + * Protected getter for a manageable application helper class + * + * @return $applicationInstance An instance of a manageable application helper class + */ + protected final function getApplicationInstance () { + $applicationInstance = Registry::getRegistry()->getInstance('application'); + return $applicationInstance; + } + + /** + * Setter for a manageable application helper class + * + * @param $applicationInstance An instance of a manageable application helper class + * @return void + */ + public final function setApplicationInstance (ManageableApplication $applicationInstance) { + Registry::getRegistry()->addInstance('application', $applicationInstance); + } + + /** + * Setter for request instance + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public final function setRequestInstance (Requestable $requestInstance) { + $this->requestInstance = $requestInstance; + } + + /** + * Getter for request instance + * + * @return $requestInstance An instance of a Requestable class + */ + public final function getRequestInstance () { + return $this->requestInstance; + } + + /** + * Setter for response instance + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public final function setResponseInstance (Responseable $responseInstance) { + $this->responseInstance = $responseInstance; + } + + /** + * Getter for response instance + * + * @return $responseInstance An instance of a Responseable class + */ + public final function getResponseInstance () { + return $this->responseInstance; + } + + /** + * Private getter for language instance + * + * @return $langInstance An instance to the language sub-system + */ + protected final function getLanguageInstance () { + $langInstance = Registry::getRegistry()->getInstance('language'); + return $langInstance; + } + + /** + * Setter for language instance + * + * @param $langInstance An instance to the language sub-system + * @return void + * @see LanguageSystem + */ + public final function setLanguageInstance (ManageableLanguage $langInstance) { + Registry::getRegistry()->addInstance('language', $langInstance); + } + + /** + * Private getter for file IO instance + * + * @return $fileIoInstance An instance to the file I/O sub-system + */ + protected final function getFileIoInstance () { + return $this->fileIoInstance; + } + + /** + * Setter for file I/O instance + * + * @param $fileIoInstance An instance to the file I/O sub-system + * @return void + */ + public final function setFileIoInstance (IoHandler $fileIoInstance) { + $this->fileIoInstance = $fileIoInstance; + } + + /** + * Protected setter for user instance + * + * @param $userInstance An instance of a user class + * @return void + */ + protected final function setUserInstance (ManageableAccount $userInstance) { + $this->userInstance = $userInstance; + } + + /** + * Getter for user instance + * + * @return $userInstance An instance of a user class + */ + public final function getUserInstance () { + return $this->userInstance; + } + + /** + * Setter for controller instance (this surely breaks a bit the MVC patterm) + * + * @param $controllerInstance An instance of the controller + * @return void + */ + public final function setControllerInstance (Controller $controllerInstance) { + $this->controllerInstance = $controllerInstance; + } + + /** + * Getter for controller instance (this surely breaks a bit the MVC patterm) + * + * @return $controllerInstance An instance of the controller + */ + public final function getControllerInstance () { + return $this->controllerInstance; + } + + /** + * Setter for RNG instance + * + * @param $rngInstance An instance of a random number generator (RNG) + * @return void + */ + protected final function setRngInstance (RandomNumberGenerator $rngInstance) { + $this->rngInstance = $rngInstance; + } + + /** + * Getter for RNG instance + * + * @return $rngInstance An instance of a random number generator (RNG) + */ + public final function getRngInstance () { + return $this->rngInstance; + } + + /** + * Setter for Cryptable instance + * + * @param $cryptoInstance An instance of a Cryptable class + * @return void + */ + protected final function setCryptoInstance (Cryptable $cryptoInstance) { + $this->cryptoInstance = $cryptoInstance; + } + + /** + * Getter for Cryptable instance + * + * @return $cryptoInstance An instance of a Cryptable class + */ + public final function getCryptoInstance () { + return $this->cryptoInstance; + } + + /** + * Setter for the list instance + * + * @param $listInstance A list of Listable + * @return void + */ + protected final function setListInstance (Listable $listInstance) { + $this->listInstance = $listInstance; + } + + /** + * Getter for the list instance + * + * @return $listInstance A list of Listable + */ + protected final function getListInstance () { + return $this->listInstance; + } + + /** + * Setter for the menu instance + * + * @param $menuInstance A RenderableMenu instance + * @return void + */ + protected final function setMenuInstance (RenderableMenu $menuInstance) { + $this->menuInstance = $menuInstance; + } + + /** + * Getter for the menu instance + * + * @return $menuInstance A RenderableMenu instance + */ + protected final function getMenuInstance () { + return $this->menuInstance; + } + + /** + * Setter for image instance + * + * @param $imageInstance An instance of an image + * @return void + */ + public final function setImageInstance (BaseImage $imageInstance) { + $this->imageInstance = $imageInstance; + } + + /** + * Getter for image instance + * + * @return $imageInstance An instance of an image + */ + public final function getImageInstance () { + return $this->imageInstance; + } + + /** + * Setter for stacker instance + * + * @param $stackInstance An instance of an stacker + * @return void + */ + public final function setStackInstance (Stackable $stackInstance) { + $this->stackInstance = $stackInstance; + } + + /** + * Getter for stacker instance + * + * @return $stackInstance An instance of an stacker + */ + public final function getStackInstance () { + return $this->stackInstance; + } + + /** + * Setter for compressor instance + * + * @param $compressorInstance An instance of an compressor + * @return void + */ + public final function setCompressorInstance (Compressor $compressorInstance) { + $this->compressorInstance = $compressorInstance; + } + + /** + * Getter for compressor instance + * + * @return $compressorInstance An instance of an compressor + */ + public final function getCompressorInstance () { + return $this->compressorInstance; + } + + /** + * Setter for Parseable instance + * + * @param $parserInstance An instance of an Parseable + * @return void + */ + public final function setParserInstance (Parseable $parserInstance) { + $this->parserInstance = $parserInstance; + } + + /** + * Getter for Parseable instance + * + * @return $parserInstance An instance of an Parseable + */ + public final function getParserInstance () { + return $this->parserInstance; + } + + /** + * Setter for HandleableProtocol instance + * + * @param $protocolInstance An instance of an HandleableProtocol + * @return void + */ + public final function setProtocolInstance (HandleableProtocol $protocolInstance) { + $this->protocolInstance = $protocolInstance; + } + + /** + * Getter for HandleableProtocol instance + * + * @return $protocolInstance An instance of an HandleableProtocol + */ + public final function getProtocolInstance () { + return $this->protocolInstance; + } + + /** + * Setter for DatabaseWrapper instance + * + * @param $wrapperInstance An instance of an DatabaseWrapper + * @return void + */ + public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) { + $this->wrapperInstance = $wrapperInstance; + } + + /** + * Getter for DatabaseWrapper instance + * + * @return $wrapperInstance An instance of an DatabaseWrapper + */ + public final function getWrapperInstance () { + return $this->wrapperInstance; + } + + /** + * Setter for socket resource + * + * @param $socketResource A valid socket resource + * @return void + */ + public final function setSocketResource ($socketResource) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource); + $this->socketResource = $socketResource; + } + + /** + * Getter for socket resource + * + * @return $socketResource A valid socket resource + */ + public final function getSocketResource () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource); + return $this->socketResource; + } + + /** + * Setter for regular expression + * + * @param $regularExpression A valid regular expression + * @return void + */ + public final function setRegularExpression ($regularExpression) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); + $this->regularExpression = $regularExpression; + } + + /** + * Getter for regular expression + * + * @return $regularExpression A valid regular expression + */ + public final function getRegularExpression () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); + return $this->regularExpression; + } + + /** + * Setter for helper instance + * + * @param $helperInstance An instance of a helper class + * @return void + */ + protected final function setHelperInstance (Helper $helperInstance) { + $this->helperInstance = $helperInstance; + } + + /** + * Getter for helper instance + * + * @return $helperInstance An instance of a helper class + */ + public final function getHelperInstance () { + return $this->helperInstance; + } + + /** + * Setter for a Source instance + * + * @param $sourceInstance An instance of a Source class + * @return void + */ + protected final function setSourceInstance (Source $sourceInstance) { + $this->sourceInstance = $sourceInstance; + } + + /** + * Getter for a Source instance + * + * @return $sourceInstance An instance of a Source class + */ + protected final function getSourceInstance () { + return $this->sourceInstance; + } + + /** + * Setter for a UrlSource instance + * + * @param $sourceInstance An instance of a UrlSource class + * @return void + */ + protected final function setUrlSourceInstance (UrlSource $urlSourceInstance) { + $this->urlSourceInstance = $urlSourceInstance; + } + + /** + * Getter for a UrlSource instance + * + * @return $urlSourceInstance An instance of a UrlSource class + */ + protected final function getUrlSourceInstance () { + return $this->urlSourceInstance; + } + + /** + * Getter for a InputStream instance + * + * @param $inputStreamInstance The InputStream instance + */ + protected final function getInputStreamInstance () { + return $this->inputStreamInstance; + } + + /** + * Setter for a InputStream instance + * + * @param $inputStreamInstance The InputStream instance + * @return void + */ + protected final function setInputStreamInstance (InputStream $inputStreamInstance) { + $this->inputStreamInstance = $inputStreamInstance; + } + + /** + * Getter for a OutputStream instance + * + * @param $outputStreamInstance The OutputStream instance + */ + protected final function getOutputStreamInstance () { + return $this->outputStreamInstance; + } + + /** + * Setter for a OutputStream instance + * + * @param $outputStreamInstance The OutputStream instance + * @return void + */ + protected final function setOutputStreamInstance (OutputStream $outputStreamInstance) { + $this->outputStreamInstance = $outputStreamInstance; + } + + /** + * Setter for handler instance + * + * @param $handlerInstance An instance of a Handleable class + * @return void + */ + protected final function setHandlerInstance (Handleable $handlerInstance) { + $this->handlerInstance = $handlerInstance; + } + + /** + * Getter for handler instance + * + * @return $handlerInstance A Networkable instance + */ + protected final function getHandlerInstance () { + return $this->handlerInstance; + } + + /** + * Setter for visitor instance + * + * @param $visitorInstance A Visitor instance + * @return void + */ + protected final function setVisitorInstance (Visitor $visitorInstance) { + $this->visitorInstance = $visitorInstance; + } + + /** + * Getter for visitor instance + * + * @return $visitorInstance A Visitor instance + */ + protected final function getVisitorInstance () { + return $this->visitorInstance; + } + + /** + * Setter for DHT instance + * + * @param $dhtInstance A Distributable instance + * @return void + */ + protected final function setDhtInstance (Distributable $dhtInstance) { + $this->dhtInstance = $dhtInstance; + } + + /** + * Getter for DHT instance + * + * @return $dhtInstance A Distributable instance + */ + protected final function getDhtInstance () { + return $this->dhtInstance; + } + + /** + * Setter for raw package Data + * + * @param $packageData Raw package Data + * @return void + */ + public final function setPackageData (array $packageData) { + $this->packageData = $packageData; + } + + /** + * Getter for raw package Data + * + * @return $packageData Raw package Data + */ + public function getPackageData () { + return $this->packageData; + } + + + /** + * Setter for Iterator instance + * + * @param $iteratorInstance An instance of an Iterator + * @return void + */ + protected final function setIteratorInstance (Iterator $iteratorInstance) { + $this->iteratorInstance = $iteratorInstance; + } + + /** + * Getter for Iterator instance + * + * @return $iteratorInstance An instance of an Iterator + */ + public final function getIteratorInstance () { + return $this->iteratorInstance; + } + + /** + * Setter for FilePointer instance + * + * @param $pointerInstance An instance of an FilePointer class + * @return void + */ + protected final function setPointerInstance (FilePointer $pointerInstance) { + $this->pointerInstance = $pointerInstance; + } + + /** + * Getter for FilePointer instance + * + * @return $pointerInstance An instance of an FilePointer class + */ + public final function getPointerInstance () { + return $this->pointerInstance; + } + + /** + * Unsets pointer instance which triggers a call of __destruct() if the + * instance is still there. This is surely not fatal on already "closed" + * file pointer instances. + * + * I don't want to mess around with above setter by giving it a default + * value NULL as setter should always explicitly only set (existing) object + * instances and NULL is NULL. + * + * @return void + */ + protected final function unsetPointerInstance () { + // Simply it to NULL + $this->pointerInstance = NULL; + } + + /** + * Setter for Indexable instance + * + * @param $indexInstance An instance of an Indexable class + * @return void + */ + protected final function setIndexInstance (Indexable $indexInstance) { + $this->indexInstance = $indexInstance; + } + + /** + * Getter for Indexable instance + * + * @return $indexInstance An instance of an Indexable class + */ + public final function getIndexInstance () { + return $this->indexInstance; + } + + /** + * Setter for Block instance + * + * @param $blockInstance An instance of an Block class + * @return void + */ + protected final function setBlockInstance (Block $blockInstance) { + $this->blockInstance = $blockInstance; + } + + /** + * Getter for Block instance + * + * @return $blockInstance An instance of an Block class + */ + public final function getBlockInstance () { + return $this->blockInstance; + } + + /** + * Setter for Minable instance + * + * @param $minableInstance A Minable instance + * @return void + */ + protected final function setMinableInstance (Minable $minableInstance) { + $this->minableInstance = $minableInstance; + } + + /** + * Getter for minable instance + * + * @return $minableInstance A Minable instance + */ + protected final function getMinableInstance () { + return $this->minableInstance; + } + + /** + * Setter for FrameworkDirectory instance + * + * @param $directoryInstance A FrameworkDirectoryPointer instance + * @return void + */ + protected final function setDirectoryInstance (FrameworkDirectory $directoryInstance) { + $this->directoryInstance = $directoryInstance; + } + + /** + * Getter for FrameworkDirectory instance + * + * @return $directoryInstance A FrameworkDirectory instance + */ + protected final function getDirectoryInstance () { + return $this->directoryInstance; + } + + /** + * Setter for listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + protected final function setListenerInstance (Listenable $listenerInstance) { + $this->listenerInstance = $listenerInstance; + } + + /** + * Getter for listener instance + * + * @return $listenerInstance A Listenable instance + */ + protected final function getListenerInstance () { + return $this->listenerInstance; + } + + /** + * Getter for communicator instance + * + * @return $communicatorInstance An instance of a Communicator class + */ + public final function getCommunicatorInstance () { + return $this->communicatorInstance; + } + + /** + * Setter for communicator instance + * + * @param $communicatorInstance An instance of a Communicator class + * @return void + */ + protected final function setCommunicatorInstance (Communicator $communicatorInstance) { + $this->communicatorInstance = $communicatorInstance; + } + + /** + * Setter for state instance + * + * @param $stateInstance A Stateable instance + * @return void + */ + public final function setStateInstance (Stateable $stateInstance) { + $this->stateInstance = $stateInstance; + } + + /** + * Getter for state instance + * + * @return $stateInstance A Stateable instance + */ + public final function getStateInstance () { + return $this->stateInstance; + } + + /** + * Setter for output instance + * + * @param $outputInstance The debug output instance + * @return void + */ + public final function setOutputInstance (OutputStreamer $outputInstance) { + $this->outputInstance = $outputInstance; + } + + /** + * Getter for output instance + * + * @return $outputInstance The debug output instance + */ + public final function getOutputInstance () { + return $this->outputInstance; + } + + /** + * Setter for command name + * + * @param $commandName Last validated command name + * @return void + */ + protected final function setCommandName ($commandName) { + $this->commandName = $commandName; + } + + /** + * Getter for command name + * + * @return $commandName Last validated command name + */ + protected final function getCommandName () { + return $this->commandName; + } + + /** + * Setter for controller name + * + * @param $controllerName Last validated controller name + * @return void + */ + protected final function setControllerName ($controllerName) { + $this->controllerName = $controllerName; + } + + /** + * Getter for controller name + * + * @return $controllerName Last validated controller name + */ + protected final function getControllerName () { + return $this->controllerName; + } + + /** + * Getter for protocol name + * + * @return $protocolName Name of used protocol + */ + public final function getProtocolName () { + return $this->protocolName; + } + + /** + * Setter for protocol name + * + * @param $protocolName Name of used protocol + * @return void + */ + protected final function setProtocolName ($protocolName) { + $this->protocolName = $protocolName; + } + + /** + * Checks whether an object equals this object. You should overwrite this + * method to implement own equality checks + * + * @param $objectInstance An instance of a FrameworkInterface object + * @return $equals Whether both objects equals + */ + public function equals (FrameworkInterface $objectInstance) { + // Now test it + $equals = (( + $this->__toString() == $objectInstance->__toString() + ) && ( + $this->hashCode() == $objectInstance->hashCode() + )); + + // Return the result + return $equals; + } + + /** + * Generates a generic hash code of this class. You should really overwrite + * this method with your own hash code generator code. But keep KISS in mind. + * + * @return $hashCode A generic hash code respresenting this whole class + */ + public function hashCode () { + // Simple hash code + return crc32($this->__toString()); + } + + /** + * Formats computer generated price values into human-understandable formats + * with thousand and decimal separators. + * + * @param $value The in computer format value for a price + * @param $currency The currency symbol (use HTML-valid characters!) + * @param $decNum Number of decimals after commata + * @return $price The for the current language formated price string + * @throws MissingDecimalsThousandsSeparatorException If decimals or + * thousands separator + * is missing + */ + public function formatCurrency ($value, $currency = '€', $decNum = 2) { + // Are all required attriutes set? + if ((!isset($this->decimals)) || (!isset($this->thousands))) { + // Throw an exception + throw new MissingDecimalsThousandsSeparatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING); + } // END - if + + // Cast the number + $value = (float) $value; + + // Reformat the US number + $price = number_format($value, $decNum, $this->decimals, $this->thousands) . $currency; + + // Return as string... + return $price; + } + + /** + * Appends a trailing slash to a string + * + * @param $str A string (maybe) without trailing slash + * @return $str A string with an auto-appended trailing slash + */ + public final function addMissingTrailingSlash ($str) { + // Is there a trailing slash? + if (substr($str, -1, 1) != '/') { + $str .= '/'; + } // END - if + + // Return string with trailing slash + return $str; + } + + /** + * Prepare the template engine (HtmlTemplateEngine by default) for a given + * application helper instance (ApplicationHelper by default). + * + * @param $applicationInstance An application helper instance or + * null if we shall use the default + * @return $templateInstance The template engine instance + * @throws NullPointerException If the discovered application + * instance is still null + */ + protected function prepareTemplateInstance (ManageableApplication $applicationInstance = NULL) { + // Is the application instance set? + if (is_null($applicationInstance)) { + // Get the current instance + $applicationInstance = $this->getApplicationInstance(); + + // Still null? + if (is_null($applicationInstance)) { + // Thrown an exception + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + } // END - if + + // Initialize the template engine + $templateInstance = ObjectFactory::createObjectByConfiguredName('html_template_class'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Debugs this instance by putting out it's full content + * + * @param $message Optional message to show in debug output + * @return void + */ + public final function debugInstance ($message = '') { + // Restore the error handler to avoid trouble with missing array elements or undeclared variables + restore_error_handler(); + + // Init content + $content = ''; + + // Is a message set? + if (!empty($message)) { + // Construct message + $content = sprintf('
    Message: %s
    ' . PHP_EOL, $message); + } // END - if + + // Generate the output + $content .= sprintf('
    %s
    ', + trim( + htmlentities( + print_r($this, TRUE) + ) + ) + ); + + // Output it + ApplicationEntryPoint::app_exit(sprintf('
    %s debug output:
    %s
    Loaded includes:
    %s
    ', + $this->__toString(), + $content, + ClassLoader::getSelfInstance()->getPrintableIncludeList() + )); + } + + /** + * Replaces control characters with printable output + * + * @param $str String with control characters + * @return $str Replaced string + */ + protected function replaceControlCharacters ($str) { + // Replace them + $str = str_replace( + chr(13), '[r]', str_replace( + chr(10), '[n]', str_replace( + chr(9) , '[t]', + $str + ))); + + // Return it + return $str; + } + + /** + * Output a partial stub message for the caller method + * + * @param $message An optional message to display + * @return void + */ + protected function partialStub ($message = '') { + // Get the backtrace + $backtrace = debug_backtrace(); + + // Generate the class::method string + $methodName = 'UnknownClass->unknownMethod'; + if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) { + $methodName = $backtrace[1]['class'] . '->' . $backtrace[1]['function']; + } // END - if + + // Construct the full message + $stubMessage = sprintf('[%s:] Partial stub!', + $methodName + ); + + // Is the extra message given? + if (!empty($message)) { + // Then add it as well + $stubMessage .= ' Message: ' . $message; + } // END - if + + // Debug instance is there? + if (!is_null($this->getDebugInstance())) { + // Output stub message + self::createDebugInstance(__CLASS__)->debugOutput($stubMessage); + } else { + // Trigger an error + trigger_error($stubMessage); + exit; + } + } + + /** + * Outputs a debug backtrace and stops further script execution + * + * @param $message An optional message to output + * @param $doExit Whether exit the program (TRUE is default) + * @return void + */ + public function debugBackTrace ($message = '', $doExit = TRUE) { + // Sorry, there is no other way getting this nice backtrace + if (!empty($message)) { + // Output message + printf('Message: %s
    ' . chr(10), $message); + } // END - if + + print('
    ');
    +		debug_print_backtrace();
    +		print('
    '); + + // Exit program? + if ($doExit === TRUE) { + exit(); + } // END - if + } + + /** + * Creates an instance of a debugger instance + * + * @param $className Name of the class (currently unsupported) + * @return $debugInstance An instance of a debugger class + * @deprecated Not fully, as the new Logger facilities are not finished yet. + */ + public final static function createDebugInstance ($className) { + // Is the instance set? + if (!Registry::getRegistry()->instanceExists('debug')) { + // Init debug instance + $debugInstance = NULL; + + // Try it + try { + // Get a debugger instance + $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'), $className); + } catch (NullPointerException $e) { + // Didn't work, no instance there + exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage()); + } + + // Empty string should be ignored and used for testing the middleware + DebugMiddleware::getSelfInstance()->output(''); + + // Set it in its own class. This will set it in the registry + $debugInstance->setDebugInstance($debugInstance); + } else { + // Get instance from registry + $debugInstance = Registry::getRegistry()->getDebugInstance(); + } + + // Return it + return $debugInstance; + } + + /** + * Simple output of a message with line-break + * + * @param $message Message to output + * @return void + */ + public function outputLine ($message) { + // Simply output it + print($message . PHP_EOL); + } + + /** + * Outputs a debug message whether to debug instance (should be set!) or + * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to + * ApplicationEntryPoint::app_exit(), this would cause an endless loop. + * + * @param $message Message we shall send out... + * @param $doPrint Whether print or die here (default: print) + * @paran $stripTags Whether to strip tags (default: FALSE) + * @return void + */ + public function debugOutput ($message, $doPrint = TRUE, $stripTags = FALSE) { + // Set debug instance to NULL + $debugInstance = NULL; + + // Try it: + try { + // Get debug instance + $debugInstance = $this->getDebugInstance(); + } catch (NullPointerException $e) { + // The debug instance is not set (yet) + } + + // Is the debug instance there? + if (is_object($debugInstance)) { + // Use debug output handler + $debugInstance->output($message, $stripTags); + + if ($doPrint === FALSE) { + // Die here if not printed + exit(); + } // END - if + } else { + // Are debug times enabled? + if ($this->getConfigInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_output_timings') == 'Y') { + // Prepent it + $message = $this->getPrintableExecutionTime() . $message; + } // END - if + + // Put directly out + if ($doPrint === TRUE) { + // Print message + $this->outputLine($message); + } else { + // Die here + exit($message); + } + } + } + + /** + * Converts e.g. a command from URL to a valid class by keeping out bad characters + * + * @param $str The string, what ever it is needs to be converted + * @return $className Generated class name + */ + public static final function convertToClassName ($str) { + // Init class name + $className = ''; + + // Convert all dashes in underscores + $str = self::convertDashesToUnderscores($str); + + // Now use that underscores to get classname parts for hungarian style + foreach (explode('_', $str) as $strPart) { + // Make the class name part lower case and first upper case + $className .= ucfirst(strtolower($strPart)); + } // END - foreach + + // Return class name + return $className; + } + + /** + * Converts dashes to underscores, e.g. useable for configuration entries + * + * @param $str The string with maybe dashes inside + * @return $str The converted string with no dashed, but underscores + */ + public static final function convertDashesToUnderscores ($str) { + // Convert them all + $str = str_replace('-', '_', $str); + + // Return converted string + return $str; + } + + /** + * Marks up the code by adding e.g. line numbers + * + * @param $phpCode Unmarked PHP code + * @return $markedCode Marked PHP code + */ + public function markupCode ($phpCode) { + // Init marked code + $markedCode = ''; + + // Get last error + $errorArray = error_get_last(); + + // Init the code with error message + if (is_array($errorArray)) { + // Get error infos + $markedCode = sprintf('
    File: %s, Line: %s, Message: %s, Type: %s
    ', + basename($errorArray['file']), + $errorArray['line'], + $errorArray['message'], + $errorArray['type'] + ); + } // END - if + + // Add line number to the code + foreach (explode(chr(10), $phpCode) as $lineNo => $code) { + // Add line numbers + $markedCode .= sprintf('%s: %s' . chr(10), + ($lineNo + 1), + htmlentities($code, ENT_QUOTES) + ); + } // END - foreach + + // Return the code + return $markedCode; + } + + /** + * Filter a given GMT timestamp (non Uni* stamp!) to make it look more + * beatiful for web-based front-ends. If null is given a message id + * null_timestamp will be resolved and returned. + * + * @param $timestamp Timestamp to prepare (filter) for display + * @return $readable A readable timestamp + */ + public function doFilterFormatTimestamp ($timestamp) { + // Default value to return + $readable = '???'; + + // Is the timestamp null? + if (is_null($timestamp)) { + // Get a message string + $readable = $this->getLanguageInstance()->getMessage('null_timestamp'); + } else { + switch ($this->getLanguageInstance()->getLanguageCode()) { + case 'de': // German format is a bit different to default + // Split the GMT stamp up + $dateTime = explode(' ', $timestamp ); + $dateArray = explode('-', $dateTime[0]); + $timeArray = explode(':', $dateTime[1]); + + // Construct the timestamp + $readable = sprintf($this->getConfigInstance()->getConfigEntry('german_date_time'), + $dateArray[0], + $dateArray[1], + $dateArray[2], + $timeArray[0], + $timeArray[1], + $timeArray[2] + ); + break; + + default: // Default is pass-through + $readable = $timestamp; + break; + } // END - switch + } + + // Return the stamp + return $readable; + } + + /** + * Filter a given number into a localized number + * + * @param $value The raw value from e.g. database + * @return $localized Localized value + */ + public function doFilterFormatNumber ($value) { + // Generate it from config and localize dependencies + switch ($this->getLanguageInstance()->getLanguageCode()) { + case 'de': // German format is a bit different to default + $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), ',', '.'); + break; + + default: // US, etc. + $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), '.', ','); + break; + } // END - switch + + // Return it + return $localized; + } + + /** + * "Getter" for databse entry + * + * @return $entry An array with database entries + * @throws NullPointerException If the database result is not found + * @throws InvalidDatabaseResultException If the database result is invalid + */ + protected final function getDatabaseEntry () { + // Is there an instance? + if (!$this->getResultInstance() instanceof SearchableResult) { + // Throw an exception here + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Rewind it + $this->getResultInstance()->rewind(); + + // Do we have an entry? + if ($this->getResultInstance()->valid() === FALSE) { + // @TODO Move the constant to e.g. BaseDatabaseResult when there is a non-cached database result available + throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), CachedDatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT); + } // END - if + + // Get next entry + $this->getResultInstance()->next(); + + // Fetch it + $entry = $this->getResultInstance()->current(); + + // And return it + return $entry; + } + + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + * @throws NullPointerException If the result instance is null + */ + public final function getField ($fieldName) { + // Default field value + $fieldValue = NULL; + + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is this instance null? + if (is_null($resultInstance)) { + // Then the user instance is no longer valid (expired cookies?) + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get current array + $fieldArray = $resultInstance->current(); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':
    '.print_r($fieldArray, TRUE).'
    '); + + // Convert dashes to underscore + $fieldName2 = self::convertDashesToUnderscores($fieldName); + + // Does the field exist? + if ($this->isFieldSet($fieldName)) { + // Get it + $fieldValue = $fieldArray[$fieldName2]; + } elseif (defined('DEVELOPER')) { + // Missing field entry, may require debugging + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray
    =' . print_r($fieldArray, TRUE) . '
    ,fieldName=' . $fieldName . ' not found!'); + } else { + // Missing field entry, may require debugging + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldName=' . $fieldName . ' not found!'); + } + + // Return it + return $fieldValue; + } + + /** + * Checks if given field is set + * + * @param $fieldName Field name to check + * @return $isSet Whether the given field name is set + * @throws NullPointerException If the result instance is null + */ + public function isFieldSet ($fieldName) { + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Is this instance null? + if (is_null($resultInstance)) { + // Then the user instance is no longer valid (expired cookies?) + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get current array + $fieldArray = $resultInstance->current(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=
    '.print_r($fieldArray, TRUE).'
    '); + + // Convert dashes to underscore + $fieldName = self::convertDashesToUnderscores($fieldName); + + // Determine it + $isSet = isset($fieldArray[$fieldName]); + + // Return result + return $isSet; + } + + /** + * Flushs all pending updates to the database layer + * + * @return void + */ + public function flushPendingUpdates () { + // Get result instance + $resultInstance = $this->getResultInstance(); + + // Do we have data to update? + if ((is_object($resultInstance)) && ($resultInstance->ifDataNeedsFlush())) { + // Get wrapper class name config entry + $configEntry = $resultInstance->getUpdateInstance()->getWrapperConfigEntry(); + + // Create object instance + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName($configEntry); + + // Yes, then send the whole result to the database layer + $wrapperInstance->doUpdateByResult($this->getResultInstance()); + } // END - if + } + + /** + * Outputs a deprecation warning to the developer. + * + * @param $message The message we shall output to the developer + * @return void + * @todo Write a logging mechanism for productive mode + */ + public function deprecationWarning ($message) { + // Is developer mode active? + if (defined('DEVELOPER')) { + // Debug instance is there? + if (!is_null($this->getDebugInstance())) { + // Output stub message + self::createDebugInstance(__CLASS__)->debugOutput($message); + } else { + // Trigger an error + trigger_error($message . "
    \n"); + exit; + } + } else { + // @TODO Finish this part! + $this->partialStub('Developer mode inactive. Message:' . $message); + } + } + + /** + * Checks whether the given PHP extension is loaded + * + * @param $phpExtension The PHP extension we shall check + * @return $isLoaded Whether the PHP extension is loaded + */ + public final function isPhpExtensionLoaded ($phpExtension) { + // Is it loaded? + $isLoaded = in_array($phpExtension, get_loaded_extensions()); + + // Return result + return $isLoaded; + } + + /** + * "Getter" as a time() replacement but with milliseconds. You should use this + * method instead of the encapsulated getimeofday() function. + * + * @return $milliTime Timestamp with milliseconds + */ + public function getMilliTime () { + // Get the time of day as float + $milliTime = gettimeofday(TRUE); + + // Return it + return $milliTime; + } + + /** + * Idles (sleeps) for given milliseconds + * + * @return $hasSlept Whether it goes fine + */ + public function idle ($milliSeconds) { + // Sleep is fine by default + $hasSlept = TRUE; + + // Idle so long with found function + if (function_exists('time_sleep_until')) { + // Get current time and add idle time + $sleepUntil = $this->getMilliTime() + abs($milliSeconds) / 1000; + + // New PHP 5.1.0 function found, ignore errors + $hasSlept = @time_sleep_until($sleepUntil); + } else { + /* + * My Sun station doesn't have that function even with latest PHP + * package. :( + */ + usleep($milliSeconds * 1000); + } + + // Return result + return $hasSlept; + } + /** + * Converts a hexadecimal string, even with negative sign as first string to + * a decimal number using BC functions. + * + * This work is based on comment #86673 on php.net documentation page at: + * + * + * @param $hex Hexadecimal string + * @return $dec Decimal number + */ + protected function hex2dec ($hex) { + // Convert to all lower-case + $hex = strtolower($hex); + + // Detect sign (negative/positive numbers) + $sign = ''; + if (substr($hex, 0, 1) == '-') { + $sign = '-'; + $hex = substr($hex, 1); + } // END - if + + // Decode the hexadecimal string into a decimal number + $dec = 0; + for ($i = strlen($hex) - 1, $e = 1; $i >= 0; $i--, $e = bcmul($e, 16)) { + $factor = self::$hexdec[substr($hex, $i, 1)]; + $dec = bcadd($dec, bcmul($factor, $e)); + } // END - for + + // Return the decimal number + return $sign . $dec; + } + + /** + * Converts even very large decimal numbers, also signed, to a hexadecimal + * string. + * + * This work is based on comment #97756 on php.net documentation page at: + * + * + * @param $dec Decimal number, even with negative sign + * @param $maxLength Optional maximum length of the string + * @return $hex Hexadecimal string + */ + protected function dec2hex ($dec, $maxLength = 0) { + // maxLength can be zero or devideable by 2 + assert(($maxLength == 0) || (($maxLength % 2) == 0)); + + // Detect sign (negative/positive numbers) + $sign = ''; + if ($dec < 0) { + $sign = '-'; + $dec = abs($dec); + } // END - if + + // Encode the decimal number into a hexadecimal string + $hex = ''; + do { + $hex = self::$dechex[($dec % (2 ^ 4))] . $hex; + $dec /= (2 ^ 4); + } while ($dec >= 1); + + /* + * Leading zeros are required for hex-decimal "numbers". In some + * situations more leading zeros are wanted, so check for both + * conditions. + */ + if ($maxLength > 0) { + // Prepend more zeros + $hex = str_pad($hex, $maxLength, '0', STR_PAD_LEFT); + } elseif ((strlen($hex) % 2) != 0) { + // Only make string's length dividable by 2 + $hex = '0' . $hex; + } + + // Return the hexadecimal string + return $sign . $hex; + } + + /** + * Converts a ASCII string (0 to 255) into a decimal number. + * + * @param $asc The ASCII string to be converted + * @return $dec Decimal number + */ + protected function asc2dec ($asc) { + // Convert it into a hexadecimal number + $hex = bin2hex($asc); + + // And back into a decimal number + $dec = $this->hex2dec($hex); + + // Return it + return $dec; + } + + /** + * Converts a decimal number into an ASCII string. + * + * @param $dec Decimal number + * @return $asc An ASCII string + */ + protected function dec2asc ($dec) { + // First convert the number into a hexadecimal string + $hex = $this->dec2hex($dec); + + // Then convert it into the ASCII string + $asc = $this->hex2asc($hex); + + // Return it + return $asc; + } + + /** + * Converts a hexadecimal number into an ASCII string. Negative numbers + * are not allowed. + * + * @param $hex Hexadecimal string + * @return $asc An ASCII string + */ + protected function hex2asc ($hex) { + // Check for length, it must be devideable by 2 + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex); + assert((strlen($hex) % 2) == 0); + + // Walk the string + $asc = ''; + for ($idx = 0; $idx < strlen($hex); $idx+=2) { + // Get the decimal number of the chunk + $part = hexdec(substr($hex, $idx, 2)); + + // Add it to the final string + $asc .= chr($part); + } // END - for + + // Return the final string + return $asc; + } + + /** + * Checks whether the given encoded data was encoded with Base64 + * + * @param $encodedData Encoded data we shall check + * @return $isBase64 Whether the encoded data is Base64 + */ + protected function isBase64Encoded ($encodedData) { + // Determine it + $isBase64 = (@base64_decode($encodedData, TRUE) !== FALSE); + + // Return it + return $isBase64; + } + + /** + * "Getter" to get response/request type from analysis of the system. + * + * @return $responseType Analyzed response type + */ + protected static function getResponseTypeFromSystem () { + // Default is console + $responseType = 'console'; + + // Is 'HTTP_HOST' set? + if (isset($_SERVER['HTTP_HOST'])) { + /* + * Then it is a HTML response/request as RSS and so on may be + * transfered over HTTP as well. + */ + $responseType = 'html'; + } // END - if + + // Return it + return $responseType; + } + + /** + * Gets a cache key from Criteria instance + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $cacheKey A cache key suitable for lookup/storage purposes + */ + protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) { + // Generate it + $cacheKey = sprintf('%s@%s', + $this->__toString(), + $criteriaInstance->getCacheKey($onlyKeys) + ); + + // And return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey); + return $cacheKey; + } + + /** + * Getter for startup time in miliseconds + * + * @return $startupTime Startup time in miliseconds + */ + protected function getStartupTime () { + return self::$startupTime; + } + + /** + * "Getter" for a printable currently execution time in nice braces + * + * @return $executionTime Current execution time in nice braces + */ + protected function getPrintableExecutionTime () { + // Caculate the execution time + $executionTime = microtime(TRUE) - $this->getStartupTime(); + + // Pack it in nice braces + $executionTime = sprintf('[ %01.5f ] ', $executionTime); + + // And return it + return $executionTime; + } + + /** + * Hashes a given string with a simple but stronger hash function (no salt) + * and hex-encode it. + * + * @param $str The string to be hashed + * @return $hash The hash from string $str + */ + public static final function hash ($str) { + // Hash given string with (better secure) hasher + $hash = bin2hex(mhash(MHASH_SHA256, $str)); + + // Return it + return $hash; + } + + /** + * "Getter" for length of hash() output. This will be "cached" to speed up + * things. + * + * @return $length Length of hash() output + */ + public static final function getHashLength () { + // Is it cashed? + if (is_null(self::$hashLength)) { + // No, then hash a string and save its length. + self::$hashLength = strlen(self::hash('abc123')); + } // END - if + + // Return it + return self::$hashLength; + } + + /** + * Checks whether the given number is really a number (only chars 0-9). + * + * @param $num A string consisting only chars between 0 and 9 + * @param $castValue Whether to cast the value to double. Do only use this to secure numbers from Requestable classes. + * @param $assertMismatch Whether to assert mismatches + * @return $ret The (hopefully) secured numbered value + */ + public function bigintval ($num, $castValue = TRUE, $assertMismatch = FALSE) { + // Filter all numbers out + $ret = preg_replace('/[^0123456789]/', '', $num); + + // Shall we cast? + if ($castValue === TRUE) { + // Cast to biggest numeric type + $ret = (double) $ret; + } // END - if + + // Assert only if requested + if ($assertMismatch === TRUE) { + // Has the whole value changed? + assert(('' . $ret . '' != '' . $num . '') && (!is_null($num))); + } // END - if + + // Return result + return $ret; + } + + /** + * Checks whether the given hexadecimal number is really a hex-number (only chars 0-9,a-f). + * + * @param $num A string consisting only chars between 0 and 9 + * @param $assertMismatch Whether to assert mismatches + * @return $ret The (hopefully) secured hext-numbered value + */ + public function hexval ($num, $assertMismatch = FALSE) { + // Filter all numbers out + $ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num); + + // Assert only if requested + if ($assertMismatch === TRUE) { + // Has the whole value changed? + assert(('' . $ret . '' != '' . $num . '') && (!is_null($num))); + } // END - if + + // Return result + return $ret; + } + + /** + * Checks whether start/end marker are set + * + * @param $data Data to be checked + * @return $isset Whether start/end marker are set + */ + public final function ifStartEndMarkersSet ($data) { + // Determine it + $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER)); + + // ... and return it + return $isset; + } + + /** + * Determines if an element is set in the generic array + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to check + * @param $element Element to check + * @return $isset Whether the given key is set + */ + protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); + + // Is it there? + $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]); + + // Return it + return $isset; + } + /** + * Determines if a key is set in the generic array + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to check + * @return $isset Whether the given key is set + */ + protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); + + // Is it there? + $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]); + + // Return it + return $isset; + } + + + /** + * Determines if a group is set in the generic array + * + * @param $keyGroup Main group + * @param $subGroup Sub group + * @return $isset Whether the given group is set + */ + protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); + + // Is it there? + $isset = isset($this->genericArray[$keyGroup][$subGroup]); + + // Return it + return $isset; + } + + /** + * Getter for sub key group + * + * @param $keyGroup Main key group + * @param $subGroup Sub key group + * @return $array An array with all array elements + */ + protected final function getGenericSubArray ($keyGroup, $subGroup) { + // Is it there? + if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { + // No, then abort here + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); + exit; + } // END - if + + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], TRUE)); + + // Return it + return $this->genericArray[$keyGroup][$subGroup]; + } + + /** + * Unsets a given key in generic array + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @return void + */ + protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); + + // Remove it + unset($this->genericArray[$keyGroup][$subGroup][$key]); + } + + /** + * Unsets a given element in generic array + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @param $element Element to unset + * @return void + */ + protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); + + // Remove it + unset($this->genericArray[$keyGroup][$subGroup][$key][$element]); + } + + /** + * Append a string to a given generic array key + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @param $value Value to add/append + * @return void + */ + protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') { + // Debug message + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); + + // Is it already there? + if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { + // Append it + $this->genericArray[$keyGroup][$subGroup][$key] .= $appendGlue . (string) $value; + } else { + // Add it + $this->genericArray[$keyGroup][$subGroup][$key] = (string) $value; + } + } + + /** + * Append a string to a given generic array element + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @param $element Element to check + * @param $value Value to add/append + * @return void + */ + protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') { + // Debug message + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); + + // Is it already there? + if ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { + // Append it + $this->genericArray[$keyGroup][$subGroup][$key][$element] .= $appendGlue . (string) $value; + } else { + // Add it + $this->setStringGenericArrayElement($keyGroup, $subGroup, $key, $element, $value); + } + } + + /** + * Sets a string in a given generic array element + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @param $element Element to check + * @param $value Value to add/append + * @return void + */ + protected final function setStringGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') { + // Debug message + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue); + + // Set it + $this->genericArray[$keyGroup][$subGroup][$key][$element] = (string) $value; + } + + /** + * Initializes given generic array group + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to use + * @param $forceInit Optionally force initialization + * @return void + */ + protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = FALSE) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit)); + + // Is it already set? + if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) { + // Already initialized + trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.'); + exit; + } // END - if + + // Initialize it + $this->genericArray[$keyGroup][$subGroup] = array(); + } + + /** + * Initializes given generic array key + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to use + * @param $forceInit Optionally force initialization + * @return void + */ + protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit)); + + // Is it already set? + if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) { + // Already initialized + trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.'); + exit; + } // END - if + + // Initialize it + $this->genericArray[$keyGroup][$subGroup][$key] = array(); + } + + /** + * Initializes given generic array element + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to use + * @param $element Element to use + * @param $forceInit Optionally force initialization + * @return void + */ + protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = FALSE) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit)); + + // Is it already set? + if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) { + // Already initialized + trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.'); + exit; + } // END - if + + // Initialize it + $this->genericArray[$keyGroup][$subGroup][$key][$element] = array(); + } + + /** + * Pushes an element to a generic key + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to use + * @param $value Value to add/append + * @return $count Number of array elements + */ + protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) { + // Debug message + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + + // Is it set? + if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { + // Initialize array + $this->initGenericArrayKey($keyGroup, $subGroup, $key); + } // END - if + + // Then push it + $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value); + + // Return count + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); + //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL); + return $count; + } + + /** + * Pushes an element to a generic array element + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to use + * @param $element Element to check + * @param $value Value to add/append + * @return $count Number of array elements + */ + protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) { + // Debug message + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + + // Is it set? + if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { + // Initialize array + $this->initGenericArrayElement($keyGroup, $subGroup, $key, $element); + } // END - if + + // Then push it + $count = array_push($this->genericArray[$keyGroup][$subGroup][$key][$element], $value); + + // Return count + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); + //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL); + return $count; + } + + /** + * Pops an element from a generic group + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @return $value Last "popped" value + */ + protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); + + // Is it set? + if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { + // Not found + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.'); + exit; + } // END - if + + // Then "pop" it + $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]); + + // Return value + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); + //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); + return $value; + } + + /** + * Shifts an element from a generic group + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @return $value Last "popped" value + */ + protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); + + // Is it set? + if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { + // Not found + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.'); + exit; + } // END - if + + // Then "shift" it + $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]); + + // Return value + //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE)); + //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL); + return $value; + } + + /** + * Count generic array group + * + * @param $keyGroup Main group for the key + * @return $count Count of given group + */ + protected final function countGenericArray ($keyGroup) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup); + + // Is it there? + if (!isset($this->genericArray[$keyGroup])) { + // Abort here + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.'); + exit; + } // END - if + + // Then count it + $count = count($this->genericArray[$keyGroup]); + + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',count=' . $count); + + // Return it + return $count; + } + + /** + * Count generic array sub group + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @return $count Count of given group + */ + protected final function countGenericArrayGroup ($keyGroup, $subGroup) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); + + // Is it there? + if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) { + // Abort here + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); + exit; + } // END - if + + // Then count it + $count = count($this->genericArray[$keyGroup][$subGroup]); + + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',count=' . $count); + + // Return it + return $count; + } + + /** + * Count generic array elements + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @para $key Key to count + * @return $count Count of given key + */ + protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); + + // Is it there? + if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { + // Abort here + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.'); + exit; + } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) { + // Not valid + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.'); + exit; + } + + // Then count it + $count = count($this->genericArray[$keyGroup][$subGroup][$key]); + + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',count=' . $count); + + // Return it + return $count; + } + + /** + * Getter for whole generic group array + * + * @param $keyGroup Key group to get + * @return $array Whole generic array group + */ + protected final function getGenericArray ($keyGroup) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup); + + // Is it there? + if (!isset($this->genericArray[$keyGroup])) { + // Then abort here + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.'); + exit; + } // END - if + + // Return it + return $this->genericArray[$keyGroup]; + } + + /** + * Setter for generic array key + * + * @param $keyGroup Key group to get + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @param $value Mixed value from generic array element + * @return void + */ + protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) { + // Debug message + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + + // Set value here + $this->genericArray[$keyGroup][$subGroup][$key] = $value; + } + + /** + * Getter for generic array key + * + * @param $keyGroup Key group to get + * @param $subGroup Sub group for the key + * @param $key Key to unset + * @return $value Mixed value from generic array element + */ + protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); + + // Is it there? + if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) { + // Then abort here + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.'); + exit; + } // END - if + + // Return it + return $this->genericArray[$keyGroup][$subGroup][$key]; + } + + /** + * Sets a value in given generic array key/element + * + * @param $keyGroup Main group for the key + * @param $subGroup Sub group for the key + * @param $key Key to set + * @param $element Element to set + * @param $value Value to set + * @return void + */ + protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) { + // Debug message + //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + + // Then set it + $this->genericArray[$keyGroup][$subGroup][$key][$element] = $value; + } + + /** + * Getter for generic array element + * + * @param $keyGroup Key group to get + * @param $subGroup Sub group for the key + * @param $key Key to look for + * @param $element Element to look for + * @return $value Mixed value from generic array element + */ + protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element); + + // Is it there? + if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) { + // Then abort here + trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.'); + exit; + } // END - if + + // Return it + return $this->genericArray[$keyGroup][$subGroup][$key][$element]; + } + + /** + * Checks if a given sub group is valid (array) + * + * @param $keyGroup Key group to get + * @param $subGroup Sub group for the key + * @return $isValid Whether given sub group is valid + */ + protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup); + + // Determine it + $isValid = (($this->isGenericArrayGroupSet($keyGroup, $subGroup)) && (is_array($this->getGenericSubArray($keyGroup, $subGroup)))); + + // Return it + return $isValid; + } + + /** + * Checks if a given key is valid (array) + * + * @param $keyGroup Key group to get + * @param $subGroup Sub group for the key + * @param $key Key to check + * @return $isValid Whether given sub group is valid + */ + protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) { + // Debug message + //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key); + + // Determine it + $isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key)))); + + // Return it + return $isValid; + } + + /** + * Initializes the web output instance + * + * @return void + */ + protected function initWebOutputInstance () { + // Get application instance + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Is this a response instance? + if ($this instanceof Responseable) { + // Then set it in application instance + $applicationInstance->setResponseInstance($this); + } // END - if + + // Init web output instance + $outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance)); + + // Set it locally + $this->setWebOutputInstance($outputInstance); + } + + /** + * Translates boolean TRUE to 'Y' and FALSE to 'N' + * + * @param $boolean Boolean value + * @return $translated Translated boolean value + */ + public static final function translateBooleanToYesNo ($boolean) { + // Make sure it is really boolean + assert(is_bool($boolean)); + + // "Translate" it + $translated = ($boolean === TRUE) ? 'Y' : 'N'; + + // ... and return it + return $translated; + } + + /** + * Encodes raw data (almost any type) by "serializing" it and then pack it + * into a "binary format". + * + * @param $rawData Raw data (almost any type) + * @return $encoded Encoded data + */ + protected function encodeData ($rawData) { + // Make sure no objects or resources pass through + assert(!is_object($rawData)); + assert(!is_resource($rawData)); + + // First "serialize" it (json_encode() is faster than serialize()) + $encoded = $this->packString(json_encode($rawData)); + + // And return it + return $encoded; + } + + /** + * Pack a string into a "binary format". Please execuse me that this is + * widely undocumented. :-( + * + * @param $str Unpacked string + * @return $packed Packed string + * @todo Improve documentation + */ + protected function packString ($str) { + // Debug message + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('str=' . $str . ' - CALLED!'); + + // First compress the string (gzcompress is okay) + $str = gzcompress($str); + + // Init variable + $packed = ''; + + // And start the "encoding" loop + for ($idx = 0; $idx < strlen($str); $idx += $this->packingData[$this->archArrayElement]['step']) { + $big = 0; + for ($i = 0; $i < $this->packingData[$this->archArrayElement]['step']; $i++) { + $factor = ($this->packingData[$this->archArrayElement]['step'] - 1 - $i); + + if (($idx + $i) <= strlen($str)) { + $ord = ord(substr($str, ($idx + $i), 1)); + + $add = $ord * pow(256, $factor); + + $big += $add; + + //print 'idx=' . $idx . ',i=' . $i . ',ord=' . $ord . ',factor=' . $factor . ',add=' . $add . ',big=' . $big . PHP_EOL; + } // END - if + } // END - for + + $l = ($big & $this->packingData[$this->archArrayElement]['left']) >>$this->packingData[$this->archArrayElement]['factor']; + $r = $big & $this->packingData[$this->archArrayElement]['right']; + + $chunk = str_pad(pack($this->packingData[$this->archArrayElement]['format'], $l, $r), 8, '0', STR_PAD_LEFT); + //* NOISY-DEBUG */ print 'big=' . $big . ',chunk('.strlen($chunk) . ')='.md5($chunk).PHP_EOL; + + $packed .= $chunk; + } // END - for + + // Return it + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('packed=' . $packed . ' - EXIT!'); + return $packed; + } + + /** + * Checks whether the given file/path is in open_basedir(). This does not + * gurantee that the file is actually readable and/or writeable. If you need + * such gurantee then please use isReadableFile() instead. + * + * @param $filePathName Name of the file/path to be checked + * @return $isReachable Whether it is within open_basedir() + */ + public static function isReachableFilePath ($filePathName) { + // Is not reachable by default + $isReachable = FALSE; + + // Get open_basedir parameter + $openBaseDir = ini_get('open_basedir'); + + // Is it set? + if (!empty($openBaseDir)) { + // Check all entries + foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) { + // Check on existence + if (substr($filePathName, 0, strlen($dir)) == $dir) { + // Is reachable + $isReachable = TRUE; + } // END - if + } // END - foreach + } else { + // If open_basedir is not set, all is allowed + $isReachable = TRUE; + } + + // Return status + return $isReachable; + } + + /** + * Checks whether the give file is within open_basedir() (done by + * isReachableFilePath()), is actually a file and is readable. + * + * @param $fileName Name of the file to be checked + * @return $isReadable Whether the file is readable (and therefor exists) + */ + public static function isReadableFile ($fileName) { + // Default is not readable + $isReadable = FALSE; + + // Is within parameters, so check if it is a file and readable + $isReadable = ((self::isReachableFilePath($fileName)) && (file_exists($fileName)) && (is_file($fileName)) && (is_readable($fileName))); + + // Return status + return $isReadable; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/class_FrameworkArrayObject.php b/inc/main/classes/class_FrameworkArrayObject.php new file mode 100644 index 00000000..1bf9446f --- /dev/null +++ b/inc/main/classes/class_FrameworkArrayObject.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkArrayObject extends ArrayObject { + /** + * Real class name + */ + private $realClass = ''; + + /** + * Public constructor for setting real class name + * + * @param $className Real class name + * @return void + */ + public function __construct ($className) { + $this->realClass = (string) $className; + } + + /** + * Get real class' name back + * + * @return $realClass The class' real name + */ + public function __toString () { + return $this->realClass; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/client/.htaccess b/inc/main/classes/client/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/client/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/client/class_ b/inc/main/classes/client/class_ new file mode 100644 index 00000000..d44dfd16 --- /dev/null +++ b/inc/main/classes/client/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Client extends BaseClient implements Client { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Client class and prepares it for usage + * + * @return $clientInstance An instance of a Client class + */ + public final static function create???Client () { + // Get a new instance + $clientInstance = new ???Client(); + + // Return the prepared instance + return $clientInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/client/class_BaseClient.php b/inc/main/classes/client/class_BaseClient.php new file mode 100644 index 00000000..751b15cb --- /dev/null +++ b/inc/main/classes/client/class_BaseClient.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseClient extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/client/http/.htaccess b/inc/main/classes/client/http/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/client/http/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/client/http/class_HttpClient.p b/inc/main/classes/client/http/class_HttpClient.p new file mode 100644 index 00000000..c8222de7 --- /dev/null +++ b/inc/main/classes/client/http/class_HttpClient.p @@ -0,0 +1,21 @@ + + // First get a socket + // @TODO Add some DNS caching here + + // Open connection + if ($helperInstance->isProxyUsed() === TRUE) { + // Resolve hostname into IP address + $ip = $helperInstance->resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); + + // Connect to host through proxy connection + $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); + } else { + // Connect to host directly + $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); + } + + // Check if there was an error else + if ($errorNo > 0) { + // Then throw again + throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if diff --git a/inc/main/classes/client/http/class_HttpClient.ph b/inc/main/classes/client/http/class_HttpClient.ph new file mode 100644 index 00000000..76a31133 --- /dev/null +++ b/inc/main/classes/client/http/class_HttpClient.ph @@ -0,0 +1,96 @@ + + /** + * Determines own remote IP address (e.g. can be used to probe if we are + * reachable from outside by determining external address and then connect to it. + * This is accomblished by connecting to the IP of www.shipsimu.org which + * should default to 188.138.90.169 and requesting /ip.php which does only + * return the content of $_SERVER['REMOTE_ADDR']. Of course, this method + * requires a working Internet connection. + * + * This method is taken from a user comment on php.net and heavily rewritten. + * Compare to following link: + * http://de.php.net/manual/en/function.socket-create.php#49368 + * + * @return $externalAddress The determined external address address + * @todo Make IP, host name, port and script name configurable + */ + public static function determineExternalAddress () { + // Get helper instance + $helperInstance = new ConsoleTools(); + + // First get a socket + // @TODO Add some DNS caching here + + // Open connection + if ($helperInstance->isProxyUsed() === TRUE) { + // Resolve hostname into IP address + $ip = $helperInstance->resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); + + // Connect to host through proxy connection + $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); + } else { + // Connect to host directly + $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); + } + + // Check if there was an error else + if ($errorNo > 0) { + // Then throw again + throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + // Prepare the GET request + $request = 'GET ' . ($helperInstance->isProxyUsed() === TRUE ? 'http://shipsimu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL; + $request .= 'Host: shipsimu.org' . self::HTTP_EOL; + $request .= 'User-Agent: ' . $this->getUserAgent() . self::HTTP_EOL; + $request .= 'Connection: close' . self::HTTP_EOL; + + // Do we use proxy? + if ($helperInstance->isProxyUsed() === TRUE) { + // CONNECT method? + if ($helperInstance->getConfigInstance()->getConfigEntry('proxy_connect_method') == 'Y') { + // Setup proxy tunnel + $response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource); + + // If the response is invalid, abort + if ((count($response) == 3) && (empty($response[0])) && (empty($response[1])) && (empty($response[2]))) { + // Invalid response! + $helperInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, TRUE)); + } // END - if + } else { + // Add header for proxy + $request .= 'Proxy-Connection: Keep-Alive' . self::HTTP_EOL; + } + } // END - if + + // Add last HTTP_EOL + $request .= self::HTTP_EOL; + + // Send it to the socket + fwrite($socketResource, $request); + + // Init IP (this will always be the last line) + $externalAddress = 'invalid'; + + // And read the reply + while (!feof($socketResource)) { + // Get line + $externalAddress = trim(fgets($socketResource, 128)); + + // Detect HTTP response + if ((substr($externalAddress, 0, 7) == 'HTTP/1.') && (substr($externalAddress, -6, 6) != '200 OK')) { + // Stop processing + break; + } // END - if + } // END - while + + // Close socket + fclose($socketResource); + + + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Resolved external address: ' . $externalAddress); + + // Return determined external address + return $externalAddress; + } diff --git a/inc/main/classes/client/http/class_HttpClient.php b/inc/main/classes/client/http/class_HttpClient.php new file mode 100644 index 00000000..04ebec46 --- /dev/null +++ b/inc/main/classes/client/http/class_HttpClient.php @@ -0,0 +1,164 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HttpClient extends BaseClient implements Client { + // Constants + const HTTP_EOL = "\r\n"; + const HTTP_USER_AGENT = 'HttpClient-Core/1.0'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Set default user agent string (to allow other classes to override this) + $this->setUserAgent(self::HTTP_USER_AGENT); + + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Client class and prepares it for usage + * + * @param $socketResource Resource of a socket (optional) + * @return $clientInstance An instance of a Client class + */ + public final static function createHttpClient ($socketResouce = FALSE) { + // Get a new instance + $clientInstance = new HttpClient(); + + // Set socket resource + $clientInstance->setSocketResource($socketResource); + + // Return the prepared instance + return $clientInstance; + } + + /** + * Checks wether proxy configuration is used + * + * @return $isUsed Wether proxy is used + */ + protected function isProxyUsed () { + // Do we have cache? + if (!isset($GLOBALS[__METHOD__])) { + // Determine it + $GLOBALS[__METHOD__] = (($this->getConfigInstance()->getConfigEntry('proxy_host') != '') && ($this->getConfigInstance()->getConfigEntry('proxy_port') > 0)); + } // END - if + + // Return cache + return $GLOBALS[__METHOD__]; + } + + /** + * Sets up a proxy tunnel for given hostname and through resource + * + * @param $host Host to connect to + * @param $port Port number to connect to + * @return $response Response array + */ + protected function setupProxyTunnel ($host, $port) { + // Initialize array + $response = array('', '', ''); + + // Do the connect + $respArray = $this->doConnectRequest($host, $port); + + // Analyze first header line + if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) { + // Response code is not 200 + return $response; + } // END - if + + // All fine! + return $respArray; + } + + /** + * Sends a raw HTTP request out to given IP/host and port number + * + * @param $method Request method (GET, POST, HEAD, CONNECT, ...) + * @param $host Host to connect to + * @param $port Port number to connect to + * @return $responseArray Array with raw response + */ + private function sendRawHttpRequest ($method, $host, $port, array $header = array()) { + // Minimum raw HTTP/1.1 request + $rawRequest = $method . ' ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL; + $rawRequest .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL; + + // Use login data to proxy? (username at least) + if ($this->getConfigInstance()->getConfigEntry('proxy_username') != '') { + // Add it as well + $encodedAuth = base64_encode($this->getConfigInstance()->getConfigEntry('proxy_username') . ':' . $this->getConfigInstance()->getConfigEntry('proxy_password')); + $rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL; + } // END - if + + // Add last new-line + $rawRequest .= self::HTTP_EOL; + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HTTP-CLIENT[' . __METHOD__ . ':' . __LINE__ . ']: rawRequest=' . $rawRequest); + + // Write request + fwrite($this->getSocketResource(), $rawRequest); + + // Got response? + if (feof($this->getSocketResource())) { + // No response received + return $response; + } // END - if + + // Read the first line + $resp = trim(fgets($this->getSocketResource(), 10240)); + + // "Explode" the string to an array + $responseArray = explode(' ', $resp); + + // And return it + return $responseArray; + } + + /** + * A HTTP/1.1 CONNECT request + * + * @param $host Host to connect to + * @param $port Port number to connect to + * @return $responseArray An array with the read response + */ + public function doConnectRequest ($host, $port) { + // Prepare extra header(s) + $headers = array( + 'Proxy-Connection' => 'Keep-Alive' + ); + + // Prepare raw request + $responseArray = $this->sendRawHttpRequest('CONNECT', $host, $port, $headers); + + // Return response array + return $responseArray; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/.htaccess b/inc/main/classes/commands/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/commands/class_ b/inc/main/classes/commands/class_ new file mode 100644 index 00000000..424f107d --- /dev/null +++ b/inc/main/classes/commands/class_ @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Command extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function create???Command (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new ???Command(); + + // 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) { + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/class_BaseCommand.php b/inc/main/classes/commands/class_BaseCommand.php new file mode 100644 index 00000000..ac926819 --- /dev/null +++ b/inc/main/classes/commands/class_BaseCommand.php @@ -0,0 +1,112 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCommand extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Sends a generic HTTP response with header, menu, content and footer + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @param $suffix Optional template suffix, e.g. '_form' for forms + * @return void + */ + protected function sendGenericGetResponse (Requestable $requestInstance, Responseable $responseInstance, $suffix = '') { + // This command doesn't handle any POST requests, so only handle get request + assert(!$requestInstance->isPostRequestMethod()); + + // Get the application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Transfer application data + $templateInstance->assignApplicationData($applicationInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the content template + $templateInstance->loadCodeTemplate($this->getResolverInstance()->getCommandName() . $suffix); + + // Assign the content template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable($applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName(), 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_' . $applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_title')); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName($applicationInstance->getAppShortName() . '_' . $this->getResolverInstance()->getCommandName() . '_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/.htaccess b/inc/main/classes/commands/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/commands/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/commands/html/class_Html b/inc/main/classes/commands/html/class_Html new file mode 100644 index 00000000..00341240 --- /dev/null +++ b/inc/main/classes/commands/html/class_Html @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Html???Command extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public final static function createHtml???Command (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new Html???Command(); + + // 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 + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub('Unfinished method.'); + } + + /** + * 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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlConfirmCommand.php b/inc/main/classes/commands/html/class_HtmlConfirmCommand.php new file mode 100644 index 00000000..9cc72c4f --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlConfirmCommand.php @@ -0,0 +1,146 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlConfirmCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlConfirmCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlConfirmCommand(); + + // 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 application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Assign application data with template engine + $templateInstance->assignApplicationData($applicationInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the home template + $templateInstance->loadCodeTemplate('confirm_link'); + + // Assign the home template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('confirm_link', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_confirm_link_title')); + + // Get user instance + try { + $userInstance = Registry::getRegistry()->getInstance('user'); + } catch (NullPointerException $e) { + // Not found user, e.g. when the user is somehow invalid + $responseInstance->redirectToConfiguredUrl('html_cmd_user_is_null'); + } + + // Set username + $templateInstance->assignVariable('username', $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USERNAME)); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('confirm_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlDoFormCommand.php b/inc/main/classes/commands/html/class_HtmlDoFormCommand.php new file mode 100644 index 00000000..05ece9ea --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlDoFormCommand.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlDoFormCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlDoFormCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlDoFormCommand(); + + // 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) { + // Should never be reached... + $this->debugBackTrace('This should never be reached.'); + } + + /** + * 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) { + // Empty for now + } + +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlHomeCommand.php b/inc/main/classes/commands/html/class_HtmlHomeCommand.php new file mode 100644 index 00000000..847f0163 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlHomeCommand.php @@ -0,0 +1,132 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlHomeCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlHomeCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlHomeCommand(); + + // 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 application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Transfer application data + $templateInstance->assignApplicationData($applicationInstance); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the home template + $templateInstance->loadCodeTemplate('home'); + + // Assign the home template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('home', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_home_title')); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('home_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlLoginAreaCommand.php b/inc/main/classes/commands/html/class_HtmlLoginAreaCommand.php new file mode 100644 index 00000000..e1d0eb95 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlLoginAreaCommand.php @@ -0,0 +1,203 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginAreaCommand extends BaseCommand implements Commandable { + /** + * Name of the action + */ + private $actionName = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlLoginAreaCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlLoginAreaCommand(); + + // Set the application instance + $commandInstance->setResolverInstance($resolverInstance); + + // Load general data like user status and such + $commandInstance->prepareCommand(); + + // Return the prepared instance + return $commandInstance; + } + + /** + * Prepares some general data which shall be displayed on every page + * + * @return void + * @todo Add some stuff here: Some personal data, app/game related data + */ + protected function prepareCommand () { + } + + /** + * 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 action instance from registry + $actionInstance = Registry::getRegistry()->getInstance('action'); + + // Do we have an action here? + if ($actionInstance instanceof PerformableAction) { + // Execute the action (shall not output anything, see below why) + $actionInstance->execute($requestInstance, $responseInstance); + } // END - if + + // Get the application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Assign all the application's data with template variables + $templateInstance->assignApplicationData($applicationInstance); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the matching template + $templateInstance->loadCodeTemplate('action_' . $this->actionName); + + // Assign the template with the master template as a content ... ;) + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('action_' . $this->actionName, 'login_content'); + + // Load main template + $templateInstance->loadCodeTemplate('login_main'); + + // Assign the main template with the master template as a content ... ;) + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('login_main', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage($this->actionName . '_title')); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('login_area_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $templateInstance->transferToResponse($responseInstance); + } + + /** + * Adds extra filters to the given controller instance. An corresponding action class must now exist! + * + * @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) { + // Default is no action + $actionInstance = NULL; + + // Get registry + $registryInstance = Registry::getRegistry(); + + // Get our application instance from the registry + $applicationInstance = $registryInstance->getInstance('application'); + + // Default action is the one from configuration + $this->actionName = self::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $this->getConfigInstance()->getConfigEntry('login_default_action'); + + // Get "action" from request + $actReq = $requestInstance->getRequestElement('action'); + + // Do we have a "action" parameter set? + if ((is_string($actReq)) && (!empty($actReq))) { + // Then use it with prefix + $this->actionName = self::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . $actReq; + } // END - if + + // Get application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Get a resolver + $actionResolver = HtmlActionResolver::createHtmlActionResolver($this->actionName, $applicationInstance); + + // Resolve the action + $actionInstance = $actionResolver->resolveAction(); + + // Add more action-specific filters + $actionInstance->addExtraFilters($controllerInstance, $requestInstance); + + // Remember this action in registry + Registry::getRegistry()->addInstance('action', $actionInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlLoginCommand.php b/inc/main/classes/commands/html/class_HtmlLoginCommand.php new file mode 100644 index 00000000..e3235769 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlLoginCommand.php @@ -0,0 +1,138 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginCommand extends BaseCommand implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlLoginCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlLoginCommand(); + + // 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) { + // Set request instance as extra instance + Registry::getRegistry()->addInstance('extra', $this); + + // Get the application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Assign application data with template engine + $templateInstance->assignApplicationData($applicationInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the home template + $templateInstance->loadCodeTemplate('login_form'); + + // Assign the home template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('login_form', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_login_title')); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('login_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlLoginFailedCommand.php b/inc/main/classes/commands/html/class_HtmlLoginFailedCommand.php new file mode 100644 index 00000000..4a73bd2b --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlLoginFailedCommand.php @@ -0,0 +1,135 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginFailedCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlLoginFailedCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlLoginFailedCommand(); + + // 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 application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Assign application data with template engine + $templateInstance->assignApplicationData($applicationInstance); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the login_failed template + $templateInstance->loadCodeTemplate('login_failed'); + + // Assign the login_failed template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('login_failed', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('login_failed_title')); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('login_failed_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlLogoutCommand.php b/inc/main/classes/commands/html/class_HtmlLogoutCommand.php new file mode 100644 index 00000000..47c8fd12 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlLogoutCommand.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLogoutCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlLogoutCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlLogoutCommand(); + + // 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 an auth instance for checking and updating the auth cookies + $authInstance = ObjectFactory::createObjectByConfiguredName('auth_method_class', array($responseInstance)); + + // Set request instance + $authInstance->setRequestInstance($requestInstance); + + // Destroy the auth data + $authInstance->destroyAuthData(); + + // Redirect to "logout done" page + $responseInstance->redirectToConfiguredUrl('logout_done'); + + // Exit here + exit(); + } + + /** + * 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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlLogoutDoneCommand.php b/inc/main/classes/commands/html/class_HtmlLogoutDoneCommand.php new file mode 100644 index 00000000..b02ab925 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlLogoutDoneCommand.php @@ -0,0 +1,135 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLogoutDoneCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlLogoutDoneCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlLogoutDoneCommand(); + + // 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 application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Assign application data + $templateInstance->assignApplicationData($applicationInstance); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the logout_done template + $templateInstance->loadCodeTemplate('logout_done'); + + // Assign the logout_done template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('logout_done', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('logout_done_title')); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('logout_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlProblemCommand.php b/inc/main/classes/commands/html/class_HtmlProblemCommand.php new file mode 100644 index 00000000..1c18dc62 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlProblemCommand.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlProblemCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlProblemCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlProblemCommand(); + + // 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 + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub('Unfinished method.'); + } + + /** + * 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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlRegisterCommand.php b/inc/main/classes/commands/html/class_HtmlRegisterCommand.php new file mode 100644 index 00000000..4f8105d2 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlRegisterCommand.php @@ -0,0 +1,139 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlRegisterCommand extends BaseCommand implements Commandable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlRegisterCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlRegisterCommand(); + + // 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) { + // Set request instance as extra instance + Registry::getRegistry()->addInstance('extra', $this); + + // Get the application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Assign all the application's data with template variables + $templateInstance->assignApplicationData($applicationInstance); + + // Assign base URL + $templateInstance->assignConfigVariable('base_url'); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the register template + $templateInstance->loadCodeTemplate('register_form'); + + // Assign the register template with the master template as a content ... ;) + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('register_form', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_register_title')); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('register_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $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) { + // Empty method + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlResendLinkCommand.php b/inc/main/classes/commands/html/class_HtmlResendLinkCommand.php new file mode 100644 index 00000000..05f66f93 --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlResendLinkCommand.php @@ -0,0 +1,135 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlResendLinkCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlResendLinkCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlResendLinkCommand(); + + // 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 user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get an application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Get a RNG instance (Random Number Generator) + $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); + + // Generate a pseudo-random string + $randomString = $rngInstance->randomString(255); + + // Get a crypto instance + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // Hash and encrypt the string + $hashedString = $cryptoInstance->hashString($cryptoInstance->encryptString($randomString)); + + // Update the user class + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, $hashedString); + + // Re-set config entry to mailer engine + $this->getConfigInstance()->setConfigEntry('html_template_class', $this->getConfigInstance()->getConfigEntry('mail_template_class')); + + // Prepare the template engine + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Assign the application data with the template engine + $templateInstance->assignApplicationData($applicationInstance); + + // Get a mailer class + $mailerInstance = ObjectFactory::createObjectByConfiguredName('mailer_class', array($templateInstance, $applicationInstance, 'resend_link')); + + // Set this mailer in our template engine + $templateInstance->setMailerInstance($mailerInstance); + + // Add template variables we shall get + $mailerInstance->addConfigTemplateVariable('base_url'); + $mailerInstance->addConfigTemplateVariable('admin_email'); + $mailerInstance->addValueTemplateVariable('confirm_hash'); + $mailerInstance->addValueTemplateVariable('username'); + $mailerInstance->addValueTemplateVariable('email'); + + // Add the value instance for the confirmation hash + $mailerInstance->addValueInstance('confirm_hash', $userInstance); + $mailerInstance->addValueInstance('username', $userInstance); + $mailerInstance->addValueInstance('email', $userInstance); + + // Add the recipient + $mailerInstance->addRecipientByUserInstance($userInstance); + + // Use subject line from template + $mailerInstance->useSubjectFromTemplate(); + + // Send the email out + $mailerInstance->deliverEmail($responseInstance); + + // Send out notification to admin (depends on settings) + $mailerInstance->sendAdminNotification($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) { + // Filter for checking if account is unconfirmed + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter')); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/html/class_HtmlStatusCommand.php b/inc/main/classes/commands/html/class_HtmlStatusCommand.php new file mode 100644 index 00000000..e27858ca --- /dev/null +++ b/inc/main/classes/commands/html/class_HtmlStatusCommand.php @@ -0,0 +1,133 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlStatusCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final function createHtmlStatusCommand (CommandResolver $resolverInstance) { + // Get new instance + $commandInstance = new HtmlStatusCommand(); + + // 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 + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the application instance + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // Transfer application data + $templateInstance->assignApplicationData($applicationInstance); + + // Load the master template + $masterTemplate = $applicationInstance->buildMasterTemplateName(); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the status template + $templateInstance->loadCodeTemplate('status'); + + // Assign the status template with the master template as a content ... ;) + $templateInstance->assignTemplateWithVariable('status', 'main_content'); + + // Load the master template + $templateInstance->loadCodeTemplate($masterTemplate); + + // Set title + $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_status_title')); + + // Construct the menu in every command. We could do this in BaseCommand class. But this means + // *every* command has a navigation system and that is want we don't want. + $menuInstance = ObjectFactory::createObjectByConfiguredName('status_menu_class', array($applicationInstance)); + + // Render the menu + $menuInstance->renderMenu(); + + // Transfer it to the template engine instance + $menuInstance->transferContentToTemplateEngine($templateInstance); + + /* + * ... and all variables. This should be merged together in a pattern + * to make things easier. A cache mechanism should be added between + * these two calls to cache compiled templates. + */ + $templateInstance->compileVariables(); + + // Get the content back from the template engine and put it in response class + $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) { + // Empty for now + } +} + +// [EOF] +?> diff --git a/inc/main/classes/commands/image/.htaccess b/inc/main/classes/commands/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/commands/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/commands/image/class_ImageCodeCaptchaCommand.php b/inc/main/classes/commands/image/class_ImageCodeCaptchaCommand.php new file mode 100644 index 00000000..3a02cb6b --- /dev/null +++ b/inc/main/classes/commands/image/class_ImageCodeCaptchaCommand.php @@ -0,0 +1,98 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCodeCaptchaCommand extends BaseCommand implements Commandable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $commandInstance An instance a prepared command class + */ + public static final 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 + $applicationInstance = $this->getResolverInstance()->getApplicationInstance(); + + // Prepare a template instance + $templateInstance = $this->prepareTemplateInstance($applicationInstance); + + // 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/main/classes/compressor/.htaccess b/inc/main/classes/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/compressor/class_Bzip2Compressor.php b/inc/main/classes/compressor/class_Bzip2Compressor.php new file mode 100644 index 00000000..0df4b808 --- /dev/null +++ b/inc/main/classes/compressor/class_Bzip2Compressor.php @@ -0,0 +1,102 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Bzip2Compressor extends BaseFrameworkSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given compression handler or NULL if the required PHP functions are not found. + * + * @return $compressorInstance An instance of this class or NULL if the required PHP functions are not found. + */ + public static final function createBzip2Compressor () { + // Routines not found by default + $compressorInstance = NULL; + + // Get new instance + if ((function_exists('bzcompress')) && (function_exists('bzdecompress'))) { + // Compressor can maybe be used + $compressorInstance = new Bzip2Compressor(); + } // END - if + + // Return the compressor instance + return $compressorInstance; + } + + /** + * BZIP2 compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Return the compressed stream + return bzcompress($streamData, 1); + } + + /** + * BZIP2 decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Decompress it + $streamData = bzdecompress($streamData, TRUE); + + // Return the decompressed stream + return $streamData; + } + + /** + * Getter for the file extension of this compressor + * + * @return $string Returns always 'bz2' + */ + public final function getCompressorExtension () { + return 'bz2'; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/compressor/class_GzipCompressor.php b/inc/main/classes/compressor/class_GzipCompressor.php new file mode 100644 index 00000000..eb7dcee5 --- /dev/null +++ b/inc/main/classes/compressor/class_GzipCompressor.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class GzipCompressor extends BaseFrameworkSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given compression handler or NULL if the required PHP functions are not found. + * + * @return $compressorInstance An instance of this class or NULL if the required PHP functions are not found. + */ + public static final function createGzipCompressor () { + // Routines not found by default + $compressorInstance = NULL; + + // Get new instance + if ((function_exists('gzencode')) && (function_exists('gzdecode'))) { + // Compressor can maybe be used + $compressorInstance = new GzipCompressor(); + } // END - if + + // Return the compressor instance + return $compressorInstance; + } + + /** + * GZIP compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Return the compressed stream + return gzencode($streamData, 1); + } + + /** + * GZIP decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Return the decompressed stream + return gzdecode($streamData); + } + + /** + * Getter for the file extension of this compressor + * + * @return $string Returns always 'gz' + */ + public final function getCompressorExtension () { + return 'gz'; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/compressor/class_NullCompressor.php b/inc/main/classes/compressor/class_NullCompressor.php new file mode 100644 index 00000000..52fbd03d --- /dev/null +++ b/inc/main/classes/compressor/class_NullCompressor.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NullCompressor extends BaseFrameworkSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given compression handler + * + * @return $compressorInstance An instance of this class + */ + public static final function createNullCompressor () { + // Get new instance + $compressorInstance = new NullCompressor(); + + // Return the compressor instance + return $compressorInstance; + } + + /** + * Null compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Return the compressed stream + return $streamData; + } + + /** + * Null decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Return the decompressed stream + return $streamData; + } + + /** + * Getter for the file extension of this compressor + * + * @return $string Returns always 'null' + */ + public final function getCompressorExtension () { + return 'null'; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/compressor/class_ZlibCompressor.php b/inc/main/classes/compressor/class_ZlibCompressor.php new file mode 100644 index 00000000..1816a40b --- /dev/null +++ b/inc/main/classes/compressor/class_ZlibCompressor.php @@ -0,0 +1,99 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ZlibCompressor extends BaseFrameworkSystem implements Compressor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel based a given compression handler or NULL if the required PHP functions are not found. + * + * @return $compressorInstance An instance of this class or NULL if the required PHP functions are not found. + */ + public static final function createZlibCompressor () { + // Routines not found by default + $compressorInstance = NULL; + + // Get new instance + if ((function_exists('gzcompress')) && (function_exists('gzuncompress'))) { + // Compressor can maybe be used + $compressorInstance = new ZlibCompressor(); + } // END - if + + // Return the compressor instance + return $compressorInstance; + } + + /** + * ZLIB compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function compressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Return the compressed stream + return gzcompress($streamData, 1); + } + + /** + * ZLIB decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + public function decompressStream ($streamData) { + if (is_object($streamData)) { + // Throw an exception + throw new InvalidObjectException($streamData, self::EXCEPTION_UNEXPECTED_OBJECT); + } // END - if + + // Return the decompressed stream + return gzuncompress($streamData); + } + + /** + * Getter for the file extension of this compressor + * + * @return $string Returns always 'z' + */ + public final function getCompressorExtension () { + return 'z'; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/console/.htaccess b/inc/main/classes/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/console/class_ConsoleTools.php b/inc/main/classes/console/class_ConsoleTools.php new file mode 100644 index 00000000..7b690ef5 --- /dev/null +++ b/inc/main/classes/console/class_ConsoleTools.php @@ -0,0 +1,402 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleTools extends BaseFrameworkSystem { + // Constants + const HTTP_EOL = "\r\n"; + const HTTP_USER_AGENT = 'ConsoleTools/1.0'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Tries to resolve an IP address from given hostname. Currently only IPv + * addresses are resolved. + * + * @param $hostname Host name we shall resolve + * @return $ip IP address resolved from host name + * @todo We should connect this to a caching class to cache DNS requests + */ + protected function resolveIpAddress ($hostname) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Host name to resolve is: %s', + $this->__toString(), + $hostname + )); + + // Default is an invalid one + $ip = '0.0.0.0'; + + // Resolve it + // @TODO Here should the cacher be implemented + $ipResolved = gethostbyname($hostname); + + // Was it fine? + if (($ipResolved !== FALSE) && ($ipResolved != $hostname)) { + // Okay, this works! + $ip = $ipResolved; + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Resolved IP address is: %s', + $this->__toString(), + $ip + )); + } else { + // Problem while resolving IP address + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Problem resolving IP address for host %s. Please check your /etc/hosts file.', + $this->__toString(), + $hostname + )); + } + + // Return resolved IP + return $ip; + } + + /** + * Checks wether proxy configuration is used + * + * @return $isUsed Wether proxy is used + */ + protected function isProxyUsed () { + // Do we have cache? + if (!isset($GLOBALS[__METHOD__])) { + // Determine it + $GLOBALS[__METHOD__] = (($this->getConfigInstance()->getConfigEntry('proxy_host') != '') && ($this->getConfigInstance()->getConfigEntry('proxy_port') > 0)); + } // END - if + + // Return cache + return $GLOBALS[__METHOD__]; + } + + /** + * Sets up a proxy tunnel for given hostname and through resource + * + * @param $host Host to connect to + * @param $port Port number to connect to + * @param $socketResource Resource of a socket + * @return $response Response array + */ + protected function setupProxyTunnel ($host, $port, $socketResource) { + // Initialize array + $response = array('', '', ''); + $proxyTunnel = ''; + + // Generate CONNECT request header + $proxyTunnel .= 'CONNECT ' . $host . ':' . $port . ' HTTP/1.1' . self::HTTP_EOL; + $proxyTunnel .= 'Host: ' . $host . ':' . $port . self::HTTP_EOL; + $proxyTunnel .= 'Proxy-Connection: Keep-Alive' . self::HTTP_EOL; + + // Use login data to proxy? (username at least!) + if ($this->getConfigInstance()->getConfigEntry('proxy_username') != '') { + // Add it as well + $encodedAuth = base64_encode($this->getConfigInstance()->getConfigEntry('proxy_username') . ':' . $this->getConfigInstance()->getConfigEntry('proxy_password')); + $proxyTunnel .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL; + } // END - if + + // Add last new-line + $proxyTunnel .= self::HTTP_EOL; + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: proxyTunnel=' . $proxyTunnel); + + // Write request + fwrite($socketResource, $proxyTunnel); + + // Got response? + if (feof($socketResource)) { + // No response received + return $response; + } // END - if + + // Read the first line + $resp = trim(fgets($socketResource, 10240)); + $respArray = explode(' ', $resp); + if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) { + // Invalid response! + return $response; + } // END - if + + // All fine! + return $respArray; + } + + /** + * Tried to extract hostname from given raw data. On a Genntoo system, this could be multiple lines with # as comments. So try to get rid of it + * + * @param $rawData Raw data from /etc/hostname file + * @return $hostname Extracted host name + */ + protected function extractHostnameFromRawData ($rawData) { + // Default is invalid + $hostname = 'invalid'; + + // Try to "explode" it + $data = explode(PHP_EOL, $rawData); + + // "Walk" through it + foreach ($data as $line) { + // Trim it + $line = trim($line); + + // Begins with a hash (#) = comment? + if (substr($line, 0, 1) == '#') { + // Then skip it + continue; + } // END - if + + // Has an equals sign? + if (strpos($line, '=') !== FALSE) { + // Then "explode" it again, right part is hostname in quotes + $hostData = explode('=', $line); + + // Make sure only a key=value pair goes through + assert(count($hostData) == 2); + + // Try to get it and abort + $hostname = str_replace(array('"', chr(39)), array('', ''), $hostData[1]); + break; + } else { + // Use it directly + $hostname = $line; + break; + } + } // END - foreach + + // Return it + return $hostname; + } + + /** + * Aquires the IP address of this host by reading the /etc/hostname file + * and solving it. It is now stored in configuration + * + * @return $ip Aquired IP address + */ + public static function acquireSelfIPAddress () { + // Local IP by default + $ip = '127.0.0.1'; + + // Get a new instance + $helperInstance = new ConsoleTools(); + + try { + // Get a file pointer + $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($helperInstance->getConfigInstance()->getConfigEntry('hostname_file'))); + + // Read the file + $rawData = trim($fileInstance->readFromFile()); + + // Close the file + $fileInstance->closeFile(); + + // Extract hostname from it + $hostname = $helperInstance->extractHostnameFromRawData($rawData); + + // Resolve the IP number + $ip = $helperInstance->resolveIpAddress($hostname); + } catch (FileNotFoundException $e) { + // Fall-back to 'SESSION_SVR' which found on my Sun Station + if (isset($_SERVER['SESSION_SVR'])) { + // Resolve it + $ip = $helperInstance->resolveIpAddress($_SERVER['SESSION_SVR']); + } elseif (isset($_SERVER['COMPUTERNAME'])) { + // May happen on some XP systems, so also try this + $ip = $helperInstance->resolveIpAddress($_SERVER['COMPUTERNAME']); + } else { + // Could not find our hostname + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] WARNING: Cannot resolve my own IP address.', + $helperInstance->__toString() + )); + } + } catch (FrameworkException $e) { + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] Problem while resolving own IP address: [%s|%s]:%s', + $helperInstance->__toString(), + $e->__toString(), + $e->getHexCode(), + $e->getMessage() + )); + } + + // Set it in configuration + FrameworkConfiguration::getSelfInstance()->setServerAddress($ip); + + // Return it + return $ip; + } + + /** + * Determines own remote IP address (e.g. can be used to probe if we are + * reachable from outside by determining external address and then connect to it. + * This is accomblished by connecting to the IP of www.shipsimu.org which + * should default to 188.138.90.169 and requesting /ip.php which does only + * return the content of $_SERVER['REMOTE_ADDR']. Of course, this method + * requires a working Internet connection. + * + * This method is taken from a user comment on php.net and heavily rewritten. + * Compare to following link: + * http://de.php.net/manual/en/function.socket-create.php#49368 + * + * @return $externalAddress The determined external address address + * @throws InvalidSocketException If socket initialization wents wrong or if an errors occurs + * @todo This should be moved out to an external class, e.g. HttpClient + * @todo Make IP, host name, port and script name configurable + */ + public static function determineExternalAddress () { + // Get helper instance + $helperInstance = new ConsoleTools(); + + // First get a socket + // @TODO Add some DNS caching here + + // Open connection + if ($helperInstance->isProxyUsed() === TRUE) { + // Resolve hostname into IP address + $ip = $helperInstance->resolveIpAddress($helperInstance->getConfigInstance()->getConfigEntry('proxy_host')); + + // Connect to host through proxy connection + $socketResource = fsockopen($ip, $helperInstance->getConfigInstance()->getConfigEntry('proxy_port'), $errorNo, $errorStr, 30); + } else { + // Connect to host directly + $socketResource = fsockopen('188.138.90.169', 80, $errorNo, $errorStr, 30); + } + + // Check if there was an error else + if ($errorNo > 0) { + // Then throw again + throw new InvalidSocketException(array($helperInstance, $socketResource, $errorNo, $errorStr), BaseListener::EXCEPTION_INVALID_SOCKET); + } // END - if + + // Prepare the GET request + $request = 'GET ' . ($helperInstance->isProxyUsed() === TRUE ? 'http://shipsimu.org' : '') . '/ip.php HTTP/1.0' . self::HTTP_EOL; + $request .= 'Host: shipsimu.org' . self::HTTP_EOL; + $request .= 'User-Agent: ' . self::HTTP_USER_AGENT . self::HTTP_EOL; + $request .= 'Connection: close' . self::HTTP_EOL; + + // Do we use proxy? + if ($helperInstance->isProxyUsed() === TRUE) { + // CONNECT method? + if ($helperInstance->getConfigInstance()->getConfigEntry('proxy_connect_method') == 'Y') { + // Setup proxy tunnel + $response = $helperInstance->setupProxyTunnel('shipsimu.org', 80, $socketResource); + + // If the response is invalid, abort + if ((count($response) == 3) && (empty($response[0])) && (empty($response[1])) && (empty($response[2]))) { + // Invalid response! + $helperInstance->debugBackTrace('Proxy tunnel not working: response=' . print_r($response, TRUE)); + } // END - if + } else { + // Add header for proxy + $request .= 'Proxy-Connection: Keep-Alive' . self::HTTP_EOL; + } + } // END - if + + // Add last HTTP_EOL + $request .= self::HTTP_EOL; + + // Send it to the socket + fwrite($socketResource, $request); + + // Init IP (this will always be the last line) + $externalAddress = 'invalid'; + + // And read the reply + while (!feof($socketResource)) { + // Get line + $externalAddress = trim(fgets($socketResource, 128)); + + // Detect HTTP response + if ((substr($externalAddress, 0, 7) == 'HTTP/1.') && (substr($externalAddress, -6, 6) != '200 OK')) { + // Stop processing + break; + } // END - if + } // END - while + + // Close socket + fclose($socketResource); + + + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONSOLE-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Resolved external address: ' . $externalAddress); + + // Return determined external address + return $externalAddress; + } + + /** + * Analyzes the 'environment', mostly $_SERVER, for presence of elements + * which indicates clearly that e.g. this script has been executed from + * console or web. + * + * @return $type The analyzed type, can be 'http' or 'console' + */ + public static function analyzeEnvironmentForType () { + // Default is the console + $type = 'console'; + + // Now, do we have a request method, or query string set? + if ((isset($_SERVER['REQUEST_METHOD'])) || (isset($_SERVER['QUERY_STRING']))) { + // Possibly HTTP request + $type = 'http'; + } // END - if + + // Return it + return $type; + } + + /** + * Analyzes the 'environment', mostly $_SERVER, for presence of elements + * which indicates clearly that e.g. this script has been executed from + * console or web. This method should be used for class names, they + * currently are named differently. Here is a list to clarify this: + * + * Request type | Class type + * ----------------------------- + * http | web + * console | console + * + * @return $type The analyzed type, can be 'http' or 'console' + */ + public static function analyzeEnvironmentForClassType () { + // Default is the console + $type = 'console'; + + // Now, do we have a request method, or query string set? + if ((isset($_SERVER['REQUEST_METHOD'])) || (isset($_SERVER['QUERY_STRING']))) { + // Possibly HTTP request + $type = 'web'; + } // END - if + + // Return it + return $type; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/container/.htaccess b/inc/main/classes/container/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/container/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/container/class_ b/inc/main/classes/container/class_ new file mode 100644 index 00000000..a64358c1 --- /dev/null +++ b/inc/main/classes/container/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Container extends BaseContainer implements Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Container class and prepares it for usage + * + * @return $containerInstance An instance of this Container class + */ + public final static function create???Container () { + // Get a new instance + $containerInstance = new ???Container(); + + // Return the prepared instance + return $containerInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/container/class_BaseContainer.php b/inc/main/classes/container/class_BaseContainer.php new file mode 100644 index 00000000..ee1dc779 --- /dev/null +++ b/inc/main/classes/container/class_BaseContainer.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseContainer extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/container/socket/.htaccess b/inc/main/classes/container/socket/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/container/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/container/socket/class_SocketContainer.php b/inc/main/classes/container/socket/class_SocketContainer.php new file mode 100644 index 00000000..07058d58 --- /dev/null +++ b/inc/main/classes/container/socket/class_SocketContainer.php @@ -0,0 +1,128 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketContainer extends BaseContainer implements Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Container class and prepares it for usage + * + * @param $socketResource A valid socket resource + * @param $infoInstance An instance of a ShareableInfo class + * @param $packageData Raw package data + * @return $containerInstance An instance of this Container class + */ + public static final function createSocketContainer ($socketResource, ShareableInfo $infoInstance = NULL, array $packageData = array()) { + // Get a new instance + $containerInstance = new SocketContainer(); + + // Remove unneeded entries + unset($packageData[NetworkPackage::PACKAGE_DATA_CONTENT]); + unset($packageData[NetworkPackage::PACKAGE_DATA_HASH]); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']:socketResource=' . $socketResource . ',packageData='.print_r($packageData, TRUE)); + + // Is the info instance set? + if ($infoInstance instanceof ShareableInfo) { + // Get listener/helper from info class + $listenerInstance = $infoInstance->getListenerInstance(); + $helperInstance = $infoInstance->getHelperInstance(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: listenerInstance[]=' . gettype($listenerInstance)); + + // Is there a listener instance set? + if ($listenerInstance instanceof Listenable) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...'); + + // Set it here for later usage + $containerInstance->setListenerInstance($listenerInstance); + } elseif ($helperInstance instanceof ConnectionHelper) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: Setting helperInstance=' . $helperInstance->__toString() . ' ...'); + + // Set it here for later usage + $containerInstance->setHelperInstance($helperInstance); + } + } // END - if + + // Set the resource ... + $containerInstance->setSocketResource($socketResource); + + // ... and package data + $containerInstance->setPackageData($packageData); + + // Return the prepared instance + return $containerInstance; + } + + /** + * Checks whether the given Universal Node Locator matches with the one from package data + * + * @param $unl A Universal Node Locator + * @return $matches Whether $address matches with the one from package data + */ + public final function ifAddressMatches ($unl) { + // Get current package data + $packageData = $this->getPackageData(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',packageData=' . print_r($packageData, TRUE)); + + // So, does both match? + $matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $unl)); + + // Return result + return $matches; + } + + /** + * Checks whether the given socket matches with stored + * + * @param $socketResource A valid socket resource + * @return $matches Whether given socket matches + */ + public final function ifSocketResourceMatches ($socketResource) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); + + // So, does both match? + $matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource())); + + // Return result + return $matches; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/.htaccess b/inc/main/classes/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/controller/class_ b/inc/main/classes/controller/class_ new file mode 100644 index 00000000..7c62f2a8 --- /dev/null +++ b/inc/main/classes/controller/class_ @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Controller extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public final static function create???Controller (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ???Controller(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/class_BaseController.php b/inc/main/classes/controller/class_BaseController.php new file mode 100644 index 00000000..db7521a5 --- /dev/null +++ b/inc/main/classes/controller/class_BaseController.php @@ -0,0 +1,296 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseController extends BaseFrameworkSystem implements Registerable { + // Exception constants + const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10; + + // Names of controller's own filter chains + const FILTER_CHAIN_PRE_COMMAND = 'controller_pre_command'; + const FILTER_CHAIN_POST_COMMAND = 'controller_post_command'; + + /** + * Generic filter chains + */ + private $filterChains = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Initialize both filter chains + $this->initFilterChain(self::FILTER_CHAIN_PRE_COMMAND); + $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND); + + // Add this controller to the registry + Registry::getRegistry()->addInstance('controller', $this); + } + + /** + * Executes a command with pre and post filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeGenericPrePostCommand (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the post filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Handles the given request and response, redirects to login_failed if + * UserAuthorizationException is thrown. + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function genericHanleRequestLoginFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) { + // Get the "form action" + $formAction = $requestInstance->getRequestElement('form'); + + // Get command instance from resolver + $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed'); + + // Exit here + exit(); + } + + /* + * Is the request still valid? Post filters shall only be executed of + * the request is valid + */ + if ($requestInstance->isRequestValid()) { + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Execute *very* generic ppost filters + $this->executePostFilters($requestInstance, $responseInstance); + } // END - if + + // Flush the buffer out + $responseInstance->flushBuffer(); + } + + /** + * Generic execute of the command: pre and post filters with redirect + * but request becomes valid after pre-filters run. + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function genericHanleRequestLoginAreaFailedRedirect (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance from the resolver by sending a request instance to the resolver + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // Add more filters by the command + $commandInstance->addExtraFilters($this, $requestInstance); + + // Try to run the pre filters, if auth exceptions come through redirect here + try { + // Run the pre filters + $this->executePreFilters($requestInstance, $responseInstance); + } catch (UserAuthorizationException $e) { + // Redirect to main page + $responseInstance->redirectToConfiguredUrl('login_failed'); + + // Exit here + exit(); + } + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Run the pre filters + $this->executePostFilters($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } + + /** + * Private method to initialize a given filter chain + * + * @param $filterChain Name of the filter chain + * @return void + */ + protected function initFilterChain ($filterChain) { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START'); + $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED'); + } + + /** + * Adds a filter to a given filter chain + * + * @param $filterChain Chain of the filter + * @param $filterInstance An instance of a filter + * @return void + * @throws InvalidFilterChainException If the filter chain is invalid + */ + protected function addFilter ($filterChain, Filterable $filterInstance) { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START'); + + // Test if the filter is there + if (!isset($this->filterChains[$filterChain])) { + // Throw an exception here + throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID); + } // END - if + + // Add the filter + $this->filterChains[$filterChain]->addFilter($filterInstance); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: FINISH'); + } + + /** + * Adds a filter to the pre filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPreFilter (Filterable $filterInstance) { + // Add the pre filter + $this->addFilter(self::FILTER_CHAIN_PRE_COMMAND, $filterInstance); + } + + /** + * Adds a filter to the post filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPostFilter (Filterable $filterInstance) { + // Add the post filter + $this->addFilter(self::FILTER_CHAIN_POST_COMMAND, $filterInstance); + } + + /** + * Add a shutdown filter + * + * @param $filterInstance A Filterable class + * @return void + */ + public function addShutdownFilter (Filterable $filterInstance) { + $this->addFilter('shutdown', $filterInstance); + } + + /** + * Executes given filter chain chain + * + * @param $filterChain Chain of the filter to execute + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + * @throws InvalidFilterChainException If the filter chain is invalid + */ + protected function executeFilters ($filterChain, Requestable $requestInstance, Responseable $responseInstance) { + // Test if the filter is there + if (!isset($this->filterChains[$filterChain])) { + // Throw an exception here + throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID); + } // END - if + + // Run all filters + $this->filterChains[$filterChain]->processFilters($requestInstance, $responseInstance); + } + + /** + * Executes all pre filters + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) { + // Execute all pre filters + $this->executeFilters(self::FILTER_CHAIN_PRE_COMMAND, $requestInstance, $responseInstance); + } + + /** + * Executes all post filters + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) { + // Execute all post filters + $this->executeFilters(self::FILTER_CHAIN_POST_COMMAND, $requestInstance, $responseInstance); + } + + /** + * Executes all shutdown filters + * + * @param $requestInstance A Requestable class + * @param $responseInstance A Responseable class + * @return void + */ + public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) { + $this->executeFilters('shutdown', $requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/console/.htaccess b/inc/main/classes/controller/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/controller/console/class_ConsoleDefaultController.php b/inc/main/classes/controller/console/class_ConsoleDefaultController.php new file mode 100644 index 00000000..4b0ce90e --- /dev/null +++ b/inc/main/classes/controller/console/class_ConsoleDefaultController.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This controller shall still provide some headlines for sidebars + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleDefaultController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createConsoleDefaultController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ConsoleDefaultController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/console/class_ConsoleDefaultNewsController.php b/inc/main/classes/controller/console/class_ConsoleDefaultNewsController.php new file mode 100644 index 00000000..89ecb683 --- /dev/null +++ b/inc/main/classes/controller/console/class_ConsoleDefaultNewsController.php @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleDefaultNewsController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createConsoleDefaultNewsController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ConsoleDefaultNewsController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add news filters to this controller + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/.htaccess b/inc/main/classes/controller/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/controller/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/controller/html/class_Html b/inc/main/classes/controller/html/class_Html new file mode 100644 index 00000000..e9a95a4d --- /dev/null +++ b/inc/main/classes/controller/html/class_Html @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Html???Controller extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public final static function createHtml???Controller (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new Html???Controller(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filters + //$controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlConfirmController.php b/inc/main/classes/controller/html/class_HtmlConfirmController.php new file mode 100644 index 00000000..ea3e7633 --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlConfirmController.php @@ -0,0 +1,73 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlConfirmController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public static final function createHtmlConfirmController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlConfirmController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add filters for handling confirmation code and username + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlDefaultController.php b/inc/main/classes/controller/html/class_HtmlDefaultController.php new file mode 100644 index 00000000..f94a8c2d --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlDefaultController.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This controller shall still provide some headlines for sidebars + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlDefaultController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHtmlDefaultController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlDefaultController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlDefaultNewsController.php b/inc/main/classes/controller/html/class_HtmlDefaultNewsController.php new file mode 100644 index 00000000..1d346b8a --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlDefaultNewsController.php @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlDefaultNewsController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHtmlDefaultNewsController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlDefaultNewsController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add news filters to this controller + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlLoginController.php b/inc/main/classes/controller/html/class_HtmlLoginController.php new file mode 100644 index 00000000..0db76a75 --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlLoginController.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public static final function createHtmlLoginController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlLoginController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlLoginFailedController.php b/inc/main/classes/controller/html/class_HtmlLoginFailedController.php new file mode 100644 index 00000000..2061064f --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlLoginFailedController.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginFailedController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHtmlLoginFailedController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlLoginFailedController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlLogoutController.php b/inc/main/classes/controller/html/class_HtmlLogoutController.php new file mode 100644 index 00000000..43edba06 --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlLogoutController.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This controller shall still provide some headlines for sidebars + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLogoutController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHtmlLogoutController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlLogoutController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Add user auth filter (we don't need an update of the user here because it will be redirected) + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); + + // User status filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlLogoutDoneController.php b/inc/main/classes/controller/html/class_HtmlLogoutDoneController.php new file mode 100644 index 00000000..b2f93a19 --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlLogoutDoneController.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLogoutDoneController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public static final function createHtmlLogoutDoneController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlLogoutDoneController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlProblemController.php b/inc/main/classes/controller/html/class_HtmlProblemController.php new file mode 100644 index 00000000..f3c37356 --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlProblemController.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlProblemController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public static final function createHtmlProblemController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlProblemController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlRegisterController.php b/inc/main/classes/controller/html/class_HtmlRegisterController.php new file mode 100644 index 00000000..b1d5999a --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlRegisterController.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlRegisterController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some filters to this controller + */ + public static final function createHtmlRegisterController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlRegisterController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/class_HtmlStatusController.php b/inc/main/classes/controller/html/class_HtmlStatusController.php new file mode 100644 index 00000000..f51e8355 --- /dev/null +++ b/inc/main/classes/controller/html/class_HtmlStatusController.php @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This controller shall still provide some headlines for sidebars + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlStatusController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHtmlStatusController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlStatusController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/form/.htaccess b/inc/main/classes/controller/html/form/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/controller/html/form/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/controller/html/form/class_HtmlDoFormController.php b/inc/main/classes/controller/html/form/class_HtmlDoFormController.php new file mode 100644 index 00000000..2dc6b884 --- /dev/null +++ b/inc/main/classes/controller/html/form/class_HtmlDoFormController.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlDoFormController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createHtmlDoFormController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlDoFormController(); + + // Set resolver instance + $controllerInstance->setResolverInstance($resolverInstance); + + // We need the controller instance in resolver class so set it here + $resolverInstance->setControllerInstance($controllerInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic handling with redirect to 'login_failed' + $this->genericHanleRequestLoginFailedRedirect($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/html/login/.htaccess b/inc/main/classes/controller/html/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/controller/html/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/controller/html/login/class_HtmlLoginAreaController.php b/inc/main/classes/controller/html/login/class_HtmlLoginAreaController.php new file mode 100644 index 00000000..375bdeea --- /dev/null +++ b/inc/main/classes/controller/html/login/class_HtmlLoginAreaController.php @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLoginAreaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + * @todo Add some morer filters to this controller + */ + public static final function createHtmlLoginAreaController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new HtmlLoginAreaController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // User auth filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter')); + + // User update filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter')); + + // News fetcher filter + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter')); + + // News proccess/display-preparation + $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + /* + * Generic execute of the command: pre and post filters with redirect + * but request becomes valid after pre-filters run. + */ + $this->genericHanleRequestLoginAreaFailedRedirect($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/image/.htaccess b/inc/main/classes/controller/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/controller/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/controller/image/captcha/.htaccess b/inc/main/classes/controller/image/captcha/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/controller/image/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/controller/image/captcha/class_ImageCodeCaptchaController.php b/inc/main/classes/controller/image/captcha/class_ImageCodeCaptchaController.php new file mode 100644 index 00000000..99b044e9 --- /dev/null +++ b/inc/main/classes/controller/image/captcha/class_ImageCodeCaptchaController.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCodeCaptchaController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final 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_filter')); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Generic pre-post command execution + $this->executeGenericPrePostCommand($requestInstance, $responseInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/controller/image/class_ImageDefaultController.php b/inc/main/classes/controller/image/class_ImageDefaultController.php new file mode 100644 index 00000000..dc8afb97 --- /dev/null +++ b/inc/main/classes/controller/image/class_ImageDefaultController.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageDefaultController extends BaseController implements Controller { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $resolverInstance An instance of a command resolver class + * @return $controllerInstance A prepared instance of this class + */ + public static final function createImageDefaultController (CommandResolver $resolverInstance) { + // Create the instance + $controllerInstance = new ImageDefaultController(); + + // Set the command resolver + $controllerInstance->setResolverInstance($resolverInstance); + + // Return the prepared instance + return $controllerInstance; + } + + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { + // Get the command instance + $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); + + // This request was valid! :-D + $requestInstance->requestIsValid(); + + // Execute the command + $commandInstance->execute($requestInstance, $responseInstance); + + // Flush the response out + $responseInstance->flushBuffer(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/criteria/.htaccess b/inc/main/classes/criteria/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/criteria/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/criteria/class_BaseCriteria.php b/inc/main/classes/criteria/class_BaseCriteria.php new file mode 100644 index 00000000..6c3e7d05 --- /dev/null +++ b/inc/main/classes/criteria/class_BaseCriteria.php @@ -0,0 +1,488 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCriteria extends BaseFrameworkSystem implements Criteria { + /** + * Wrapper class name stored in config entry + */ + private $wrapperConfigEntry = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Initialize all criteria arrays + foreach (array('default', 'choice', 'exclude') as $criteriaType) { + // Init it + $this->initGenericArrayKey('criteria', $criteriaType, 'entries'); + } // END - foreach + } + + /** + * Checks whether given key is set + * + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + public function isKeySet ($criteriaType, $criteriaKey) { + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); + + // Determine it + $isSet = $this->isGenericArrayElementSet('criteria', $criteriaType, 'entries', $criteriaKey); + + // Return it + return $isSet; + } + + /** + * Checks whether given key is set for 'choice' type + * + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + public function isChoiceKeySet ($criteriaKey) { + // Call inner method + return $this->isKeySet('choice', $criteriaKey); + } + + /** + * Checks whether given key is set for 'exclude' type + * + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + public function isExcludeKeySet ($criteriaKey) { + // Call inner method + return $this->isKeySet('exclude', $criteriaKey); + } + + /** + * Setter for wrapper class name + * + * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name + * @return void + */ + public final function setWrapperConfigEntry ($wrapperConfigEntry) { + $this->wrapperConfigEntry = (string) $wrapperConfigEntry; + } + + /** + * Getter for wrapper class name + * + * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name + */ + public final function getWrapperConfigEntry () { + return $this->wrapperConfigEntry; + } + + /** + * Getter for criteria array + * + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $criteria + */ + public final function getCriteriaArray ($criteriaType = 'default') { + return $this->getGenericArrayKey('criteria', $criteriaType, 'entries'); + } + + /** + * Getter for criteria array 'choice' type + * + * @return $criteria + */ + public final function getCriteriaChoiceArray () { + return $this->getCriteriaArray('choice'); + } + + /** + * Getter for criteria array 'exclude' type + * + * @return $criteria + */ + public final function getCriteriaExcludeArray () { + return $this->getCriteriaArray('exclude'); + } + + /** + * Unsets a criteria key from all criteria types + * + * @param $criteriaKey Criteria key to unset + * @return void + */ + public final function unsetCriteria ($criteriaKey) { + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); + + // Convert dashes to underscore + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); + + // "Walk" through all criterias + foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) { + // Remove it + $this->unsetGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); + } // END - foreach + } + + /** + * Add criteria, this method converts dashes to underscores because dashes + * are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return void + */ + public final function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default') { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!'); + + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); + + // Convert dashes to underscore + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey); + + // Append it + $this->appendStringToGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue); + } + + /** + * Set criteria, this method converts dashes to underscores because dashes + * are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return void + */ + public final function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default') { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!'); + + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); + + // Convert dashes to underscore + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey); + + // Set it + $this->setStringGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue); + } + + /** + * Add "choice" criteria, this method converts dashes to underscores because + * dashes are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + public final function addChoiceCriteria ($criteriaKey, $criteriaValue) { + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue); + + // Add it + $this->pushValueToGenericArrayElement('criteria', 'choice', 'entries', self::convertDashesToUnderscores($criteriaKey), (string) $criteriaValue); + } + + /** + * Add "exclude" criteria, this method converts dashes to underscores because + * dashes are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + public final function addExcludeCriteria ($criteriaKey, $criteriaValue) { + // Add it with generic method + $this->addCriteria($criteriaKey, $criteriaValue, 'exclude'); + } + + /** + * Add configured criteria + * + * @param $criteriaKey Criteria key + * @param $configEntry Configuration entry + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return void + */ + public final function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default') { + // Add the configuration entry as a criteria + $value = $this->getConfigInstance()->getConfigEntry($configEntry); + $this->addCriteria($criteriaKey, $value, $criteriaType); + } + + /** + * Get criteria element or FALSE if not found + * + * @param $criteriaKey The requested criteria key + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $value Whether the value of the critera or FALSE + */ + public function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default') { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!'); + + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); + + // Convert dashes to underscore + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)); + + // Default is not found + $value = FALSE; + + // Is the criteria there? + if ($this->isKeySet($criteriaType, $criteriaKey)) { + // Then use it + $value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: value=' . $value . ' - EXIT!'); + + // Return the value + return $value; + } + + /** + * Get criteria element or FALSE if not found for 'choice' type + * + * @param $criteriaKey The requested criteria key + * @return $value Whether the value of the critera or FALSE + */ + public function getCriteriaChoiceElemnent ($criteriaKey) { + // Call inner method + return $this->getCriteriaElemnent($criteriaKey, 'choice'); + } + + /** + * Get criteria element or FALSE if not found for 'exclude' type + * + * @param $criteriaKey The requested criteria key + * @return $value Whether the value of the critera or FALSE + */ + public function getCriteriaExcludeElemnent ($criteriaKey) { + // Call inner method + return $this->getCriteriaElemnent($criteriaKey, 'exclude'); + } + + /** + * Checks whether given array entry matches + * + * @param $entryArray Array with the entries to find + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $matches Whether the entry matches or not + */ + public function ifEntryMatches (array $entryArray, $criteriaType = 'default') { + // First nothing matches and nothing is counted + $matches = FALSE; + $counted = 0; + + // Walk through all entries + foreach ($entryArray as $key => $entry) { + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($key, 'my-') === FALSE) && (strpos($key, 'my_') === FALSE)); + + // Convert dashes to underscore + $key = self::convertDashesToUnderscores($key); + + // Then walk through all search criteria + foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) { + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); + + // Convert dashes to underscore + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); + + // Is the element found and does it match? + if (($key == $criteriaKey) && ($criteriaValue == $entry)) { + // Then count this one up + $counted++; + } // END - if + } // END - foreach + } // END - foreach + + // Now check if expected criteria counts match + $matches = ($counted == $this->countGenericArrayGroup('criteria', $criteriaType)); + + // Return the result + return $matches; + } + + /** + * Checks whether given array 'choice' entry matches + * + * @param $entryArray Array with the entries to find + * @return $matches Whether the entry matches or not + */ + public function ifChoiceMatches (array $entryArray) { + // Call inner method + return $this->ifEntryMatches($entryArray, 'choice'); + } + + /** + * Checks whether given array 'exclude' entry matches + * + * @param $entryArray Array with the entries to find + * @return $matches Whether the entry matches or not + */ + public function ifExcludeMatches (array $entryArray) { + // Call inner method + return $this->ifEntryMatches($entryArray, 'exclude'); + } + + /** + * "Getter" for a cache key + * + * @param $onlyKeys Only use these keys for a cache key + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $cacheKey The key suitable for the cache system + */ + public function getCacheKey ($onlyKeys = array(), $criteriaType = 'default') { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': criteriaType=' . $criteriaType . ',count()=' . $this->countGenericArray('criteria'))); + + // Make sure the criteria is there + assert($this->isValidGenericArrayGroup('criteria', $criteriaType)); + + // Initialize the key + $cacheKey = ''; + + // Now walk through all criterias + foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) { + // Make sure no 'my-' or 'my_' passes this point + assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); + + // $criteriaValue cannot be an array + assert(!is_array($criteriaValue)); + + // Convert dashes to underscore + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); + + // Is the value in array or is $onlyKeys empty? + if ((isset($onlyKeys[$criteriaKey])) || (count($onlyKeys) == 0)) { + // Add the value URL encoded to avoid any trouble with special characters + $cacheKey .= sprintf('%s=%s;', + $criteriaKey, + urlencode($criteriaValue) + ); + } // END - if + } // END - foreach + + // Remove last semicolon + $cacheKey = substr($cacheKey, 0, -1); + + // Is the instance SearchCriteria? + if ($this instanceof SearchCriteria) { + // Check if 'limit' and 'skip' are in + if (((isset($onlyKeys['limit'])) && (isset($onlyKeys['skip']))) || (count($onlyKeys) == 0)) { + // Add limit and skip values + $cacheKey .= sprintf(';%%limit%%=%s;%%skip%%=%s', + $this->getLimit(), + $this->getSkip() + ); + } // END - if + } // END - if + + // Return the cache key + return $cacheKey; + } + + /** + * "Getter" for a cache key ('choice' type) + * + * @param $onlyKeys Only use these keys for a cache key + * @return $cacheKey The key suitable for the cache system + */ + public function getCacheKeyChoice ($onlyKeys = array()) { + // Call inner method + return $this->getCacheKey($onlyKeys, 'choice'); + } + + /** + * "Getter" for a cache key ('exclude' type) + * + * @param $onlyKeys Only use these keys for a cache key + * @return $cacheKey The key suitable for the cache system + */ + public function getCacheKeyExclude ($onlyKeys = array()) { + // Call inner method + return $this->getCacheKey($onlyKeys, 'exclude'); + } + + /** + * Count the criteria, e.g. useful to find out if a database query has no + * limitation (search criteria). + * + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $count Count of all criteria entries + */ + public final function count ($criteriaType = 'default') { + // Return it + return $this->countGenericArrayGroup('criteria', $criteriaType); + } + + /** + * Count 'choice' criteria, e.g. useful to find out if a database query + * has no limitation (search criteria). + * + * @return $count Count of all criteria entries + */ + public final function countChoice () { + return $this->count('choice'); + } + + /** + * Count 'exclude' criteria, e.g. useful to find out if a database query + * has no limitation (search criteria). + * + * @return $count Count of all criteria entries + */ + public final function countExclude () { + return $this->count('exclude'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/criteria/dataset/.htaccess b/inc/main/classes/criteria/dataset/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/criteria/dataset/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/criteria/dataset/class_DataSetCriteria.php b/inc/main/classes/criteria/dataset/class_DataSetCriteria.php new file mode 100644 index 00000000..27452394 --- /dev/null +++ b/inc/main/classes/criteria/dataset/class_DataSetCriteria.php @@ -0,0 +1,220 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DataSetCriteria extends BaseCriteria implements StoreableCriteria { + /** + * Table name + */ + private $tableName = ''; + + /** + * Unique key + */ + private $uniqueKey = ''; + + /** + * Primary key + */ + private $primaryKey = ''; + + /** + * Primary keys + */ + private $primaryKeys = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this criteria + * + * @param $tableName Name of the table + * @return $criteriaInstance An instance of this criteria + */ + public static final function createDataSetCriteria ($tableName) { + // Get a new instance + $criteriaInstance = new DataSetCriteria(); + + // Set table name + $criteriaInstance->setTableName($tableName); + + // Return the instance + return $criteriaInstance; + } + + /** + * Setter for table name + * + * @param $tableName Name of the table to set + * @return void + */ + public final function setTableName ($tableName) { + $this->tableName = (string) $tableName; + } + + /** + * Getter for table name + * + * @return $tableName Name of the table to set + */ + public final function getTableName () { + return $this->tableName; + } + + /** + * Setter for unique key + * + * @param $uniqueKey Column to use as unique key + * @return void + */ + public final function setUniqueKey ($uniqueKey) { + $this->uniqueKey = (string) $uniqueKey; + } + + /** + * Getter for unique key + * + * @return $uniqueKey Column to use as unique key + */ + public final function getUniqueKey () { + return $this->uniqueKey; + } + + /** + * Getter for unique key value + * + * @return $uniqueValue Value of the unique key + */ + public final function getUniqueValue () { + // Get primary key(s) first + $primaryKey = trim($this->getCriteriaElemnent($this->getPrimaryKey())); + $primaryKeys = $this->getPrimaryKeys(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: tableName=' . $this->getTableName() . ',primaryKey=' . $primaryKey . ',primaryKeys()=' . count($primaryKeys)); + + /* + * If this is not set, this could mean a badly written frontend as + * tables should always have a primary key. + */ + if (count($primaryKeys) > 0) { + /* + * Init return value, this can be put all together without any + * separator as it only aids as a "unique value" for generating the + * "row file name". + */ + $return = ''; + + // Combination set, so get all + foreach ($primaryKeys as $primaryKey) { + // Add it + $return .= trim($this->getCriteriaElemnent($primaryKey)); + } // END - foreach + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: tableName=' . $this->getTableName() . ',return=' . $return . ' - EXIT!'); + + // Return it + return $return; + } elseif (!empty($primaryKey)) { + // Return primary key + return $primaryKey; + } else { + // @TODO Issue a warning + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Primary key not set for table ' . $this->getTableName() . ', please fix your table. Falling back to unique key ...'); + + // Get unique key + $uniqueKey = trim($this->getCriteriaElemnent($this->getUniqueKey())); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: tableName=' . $this->getTableName() . ',uniqueKey=' . $uniqueKey); + + // Is it empty, too? + if (empty($uniqueKey)) { + // Bad news, nothing is "unique" by design for this table + ApplicationEntryPoint::app_exit('Table ' . $this->getTableName() . ' has both no primary and unique key, but ' . __METHOD__ . ' was called. Please fix your table.'); + } else { + // Return unique key + return $uniqueKey; + } + } + } + + /** + * Getter for primary key or unique key if not set + * + * @return $primaryKey Primary key or unique key if not set + */ + public final function getPrimaryKey () { + // Get primary key by default + $primaryKey = $this->primaryKey; + + if (empty($primaryKey)) { + // Get uniqueKey + $primaryKey = $this->getUniqueKey(); + } // END - if + + // Return it + return $primaryKey; + } + + /** + * Setter for primary key + * + * @param $primaryKey Primary key to set + * @return void + */ + public final function setPrimaryKey ($primaryKey) { + $this->primaryKey = (string) $primaryKey; + } + + /** + * Setter for primary key array + * + * @param $primaryKeys Primary key array to set + * @return void + */ + public function setPrimaryKeyCombined (array $primaryKeys) { + $this->primaryKeys = $primaryKeys; + } + + /** + * Getter for primary keys + * + * @return $primaryKeys Primary key array + */ + public final function getPrimaryKeys () { + // Return it + return $this->primaryKeys; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/criteria/search/.htaccess b/inc/main/classes/criteria/search/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/criteria/search/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/criteria/search/class_SearchCriteria.php b/inc/main/classes/criteria/search/class_SearchCriteria.php new file mode 100644 index 00000000..3bc2ef14 --- /dev/null +++ b/inc/main/classes/criteria/search/class_SearchCriteria.php @@ -0,0 +1,227 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SearchCriteria extends BaseCriteria implements LocalSearchCriteria { + /** + * Criteria to handle + */ + private $criteria = array(); + + /** + * Limitation for the search + */ + private $limit = 0; + + /** + * Skip these entries before using them + */ + private $skip = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $criteriaInstance An instance of this criteria + */ + public static final function createSearchCriteria () { + // Get a new instance + $criteriaInstance = new SearchCriteria(); + + // Return this instance + return $criteriaInstance; + } + + /** + * Setter for limit + * + * @param $limit Search limit + * @return void + * @todo Find a nice casting here. (int) allows until and including 32766. + */ + public final function setLimit ($limit) { + $this->limit = $limit; + } + + /** + * "Setter" for limit from a configuration entry + * + * @param $configEntry The configuration entry which hold a number as limit + * @return void + */ + public final function setConfiguredLimit ($configEntry) { + // Get the limit from config entry and set it + $limit = $this->getConfigInstance()->getConfigEntry($configEntry); + $this->setLimit($limit); + } + + /** + * Getter for limit + * + * @return $limit Search limit + */ + public final function getLimit () { + return $this->limit; + } + + /** + * Setter for skip + * + * @param $skip Search skip + * @return void + * @todo Find a nice casting here. (int) allows until and including 32766. + */ + public final function setSkip ($skip) { + $this->skip = $skip; + } + + /** + * Getter for skip + * + * @return $skip Search skip + */ + public final function getSkip () { + return $this->skip; + } + + /** + * Checks whether the given key/value pair is matching with 'default' and one of 'choice' and + * never with in 'exclude'. + * + * @param $key Key element to check + * @param $value Value to check + * @param $separator Separator for "exploding" $value (default: ',') + * @return $isMatching Whether the key/value is matching or excluded + */ + public function isCriteriaMatching ($key, $value, $separator = ',') { + // $key/$value cannot be array/NULL/bool, value can be NULL but then NULL must be loocked for + assert((!is_array($value)) && (!is_bool($value)) && (!is_array($key)) && (!is_null($key)) && (!is_bool($key))); + + // "Explode" value + $valueArray = explode($separator, $value); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',value[' . gettype($value) . ']=' . $value . ' - CALLED!'); + + // Get 'default' search value + $searchDefault = $this->getCriteriaElemnent($key); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaElement(' . $key . ')[' . gettype($searchDefault) . ']=' . $searchDefault); + + // 'default' check + $isMatching = (((($searchDefault !== FALSE) && ($searchDefault == $value)) || ((is_null($searchDefault)) && (is_null($value)))) || ($searchDefault === FALSE)); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaElement(' . $key . ')[' . gettype($searchDefault) . ']=' . $searchDefault . ',isMatching=' . intval($isMatching)); + + // Get 'choice' search value (can be NULL or $separator-separated string) + $searchChoice = $this->getCriteriaChoiceElemnent($key); + + // May be FALSE or array + assert(($searchChoice === FALSE) || (is_array($searchChoice))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[' . gettype($searchChoice) . ']=' . print_r($searchChoice, TRUE)); + + // 'choice' check + if ((is_array($searchChoice)) && (count($valueArray) == 1)) { + // $value is a single-search value, so use in_array() + $isMatching = ((($isMatching === TRUE) || (($searchDefault === FALSE) && (!is_null($value)))) && (in_array($value, $searchChoice))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - SINGLE-MATCH'); + } elseif ((is_array($searchChoice)) && (count($valueArray) > 1)) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',valueArray()=' . count($valueArray) . ',isMatching=' . intval($isMatching)); + + // $value is choice-search value, so check all entries + $isMatching = (($isMatching === TRUE) || (($searchDefault === FALSE) && (!is_null($value)))); + $idx = 0; + foreach ($valueArray as $idx => $match) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: match=' . $match . ',count(searchChoice)=' . count($searchChoice)); + + // Is it found? (one is okay) + $isMatching = (($isMatching === TRUE) && (in_array($match, $searchChoice))); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: match=' . $match . ',isMatching=' . intval($isMatching)); + } // END - foreach + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',valueArray()=' . count($valueArray) . ',idx=' . $idx . ',isMatching=' . intval($isMatching) . ' - CHOICE-MATCH'); + } else { + // Choice-match is FALSE + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - FALSE-MATCH'); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaChoiceElement(' . $key . ')[]=' . gettype($searchChoice) . ',isMatching=' . intval($isMatching)); + + // Get 'exclude' search value + $searchExclude = $this->getCriteriaExcludeElemnent($key); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: getCriteriaExcludeElement(' . $key . ')[' . gettype($searchExclude) . ']=' . $searchExclude); + + // 'exclude' check + $isMatching = ( + ( + ( + $isMatching === TRUE + ) && ( + $searchExclude === FALSE + ) + ) || ( + ( + ( + $isMatching === TRUE + ) && ( + $searchExclude !== FALSE + ) && ( + $searchExclude !== $value + ) + ) + ) + ); + + // Return result + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SEARCH-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',value[' . gettype($value) . ']=' . $value . ',isMatching=' . intval($isMatching) . ' - EXIT!'); + return $isMatching; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/criteria/update/.htaccess b/inc/main/classes/criteria/update/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/criteria/update/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/criteria/update/class_UpdateCriteria.php b/inc/main/classes/criteria/update/class_UpdateCriteria.php new file mode 100644 index 00000000..df4470a7 --- /dev/null +++ b/inc/main/classes/criteria/update/class_UpdateCriteria.php @@ -0,0 +1,61 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UpdateCriteria extends BaseCriteria implements LocalUpdateCriteria { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $criteriaInstance An instance of this criteria + */ + public static final function createUpdateCriteria () { + // Get a new instance + $criteriaInstance = new UpdateCriteria(); + + // Return this instance + return $criteriaInstance; + } + + /** + * Getter for update criteria array + * + * @return $updateCriteria Array holding the update criteria + */ + public final function getUpdateCriteria () { + return $this->getCriteriaArray(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/crypto/.htaccess b/inc/main/classes/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/crypto/class_CryptoHelper.php b/inc/main/classes/crypto/class_CryptoHelper.php new file mode 100644 index 00000000..03458ee5 --- /dev/null +++ b/inc/main/classes/crypto/class_CryptoHelper.php @@ -0,0 +1,234 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CryptoHelper extends BaseFrameworkSystem implements Cryptable { + // Exception constants + const EXCEPTION_ENCRYPT_MISSING = 0x1f0; + const EXCEPTION_ENCRYPT_INVALID = 0x1f1; + + /** + * An instance of this own clas + */ + private static $selfInstance = NULL; + + /** + * Instance of the crypto stream + */ + private $cryptoStreamInstance = NULL; + + /** + * Salt for hashing operations + */ + private $salt = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $cryptoInstance An instance of this crypto helper class + */ + public static final function createCryptoHelper () { + // Get a new instance + $cryptoInstance = new CryptoHelper(); + + // Initialize the hasher + $cryptoInstance->initHasher(); + + // Attach a crypto stream + $cryptoInstance->attachCryptoStream(); + + // Return the instance + return $cryptoInstance; + } + + /** + * Get a singleton instance of this class + * + * @return $selfInstance An instance of this crypto helper class + */ + public static final function getSelfInstance () { + // Is no instance there? + if (is_null(self::$selfInstance)) { + // Then get a new one + self::$selfInstance = self::createCryptoHelper(); + } // END - if + + // Return the instance + return self::$selfInstance; + } + + /** + * Attaches a crypto stream to this crypto helper by detecting loaded + * modules. + * + * @return void + */ + protected function attachCryptoStream () { + // Do we have mcrypt loaded? + if ($this->isPhpExtensionLoaded('mcrypt')) { + // Then use it + $this->cryptoStreamInstance = ObjectFactory::createObjectByName('McryptStream', array($this->getRngInstance())); + } else { + // If nothing works ... + $this->cryptoStreamInstance = ObjectFactory::createObjectByName('NullCryptoStream'); + } + } + + /** + * Initializes the hasher for different purposes. + * + * @return void + */ + protected function initHasher () { + // Initialize the random number generator which is required by some crypto methods + $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class')); + + // Generate a salt for the hasher + $this->generateSalt(); + } + + /** + * Generates the salt based on configured length + * + * @return void + */ + private function generateSalt () { + // Get a random string from the RNG + $randomString = $this->getRngInstance()->randomString() . $this->createUuid(); + + // Get config entry for salt length + $length = $this->getConfigInstance()->getConfigEntry('salt_length'); + + // Keep only defined number of characters + $this->salt = substr(sha1($randomString), -$length, $length); + } + + /** + * Returns a UUID (Universal Unique IDentifier) if PECL extension uuid was + * found or an empty string it not. + * + * @return $uuid UUID with leading dash or empty string + */ + public function createUuid () { + // Init empty UUID + $uuid = ''; + + // Is the UUID extension loaded? (see pecl) + if ((extension_loaded('uuid')) && (function_exists('uuid_create'))) { + // Then add it as well + $uuid = uuid_create(); + } // END - if + + // Return it + return $uuid; + } + + /** + * Hashes a string with salt and returns the hash. If an old previous hash + * is supplied the method will use the first X chars of that hash for hashing + * the password. This is useful if you want to check if password is identical + * for authorization purposes. + * + * @param $str Unhashed string + * @param $oldHash A hash from previous hashed string + * @param $withFixed Whether to include a fixed salt (not recommended in p2p applications) + * @return $hashed The hashed and salted string + */ + public function hashString ($str, $oldHash = '', $withFixed = TRUE) { + // Cast the string + $str = (string) $str; + + // Default is the default salt ;-) + $salt = $this->salt; + + // Is the old password set? + if (!empty($oldHash)) { + // Use the salt from hash, first get length + $length = $this->getConfigInstance()->getConfigEntry('salt_length'); + + // Then extract the X first characters from the hash as our salt + $salt = substr($oldHash, 0, $length); + } // END - if + + // Hash the password with salt + //* DEBUG: */ echo "salt=".$salt."/plain=".$str."
    \n"; + if ($withFixed === TRUE) { + // Use additional fixed salt + $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_extra_mask'), + $salt, + $this->getRngInstance()->getFixedSalt(), + $str + )); + } else { + // Use salt+string to hash + $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_normal_mask'), + $salt, + $str + )); + } + + // And return it + return $hashed; + } + + /** + * Encrypt the string with fixed salt + * + * @param $str The unencrypted string + * @param $key Optional key, if none provided, a random key will be generated + * @return $encrypted Encrypted string + */ + public function encryptString ($str, $key = NULL) { + // Encrypt the string through the stream + $encrypted = $this->cryptoStreamInstance->encryptStream($str, $key); + + // Return the string + return $encrypted; + } + + /** + * Decrypt the string with fixed salt + * + * @param $encrypted Encrypted string + * @return $str The unencrypted string + */ + public function decryptString ($encrypted) { + // Encrypt the string through the stream + $str = $this->cryptoStreamInstance->decryptStream($encrypted); + + // Return the string + return $str; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/.htaccess b/inc/main/classes/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/database/backend/.htaccess b/inc/main/classes/database/backend/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/database/backend/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/database/backend/class_CachedLocalFileDatabase.php b/inc/main/classes/database/backend/class_CachedLocalFileDatabase.php new file mode 100644 index 00000000..825a70e4 --- /dev/null +++ b/inc/main/classes/database/backend/class_CachedLocalFileDatabase.php @@ -0,0 +1,673 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend { + /** + * The file's extension + */ + private $fileExtension = 'serialized'; + + /** + * The last read file's name + */ + private $lastFile = ''; + + /** + * The last read file's content including header information + */ + private $lastContents = array(); + + /** + * Whether the "connection is already up + */ + private $alreadyConnected = FALSE; + + /** + * Table information array + */ + private $tableInfo = array(); + + /** + * Element for index + */ + private $indexKey = '__idx'; + + /** + * The protected constructor. Do never instance from outside! You need to + * set a local file path. The class will then validate it. + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an object of CachedLocalFileDatabase and set the save path from + * configuration for local files. + * + * @return $databaseInstance An instance of CachedLocalFileDatabase + */ + public static final function createCachedLocalFileDatabase () { + // Get an instance + $databaseInstance = new CachedLocalFileDatabase(); + + // Get a new compressor channel instance + $compressorInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class'); + + // Set the compressor channel + $databaseInstance->setCompressorChannel($compressorInstance); + + // Get a file IO handler + $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class'); + + // ... and set it + $databaseInstance->setFileIoInstance($fileIoInstance); + + // "Connect" to the database + $databaseInstance->connectToDatabase(); + + // Return database instance + return $databaseInstance; + } + + /** + * Setter for the last read file + * + * @param $fqfn The FQFN of the last read file + * @return void + */ + private final function setLastFile ($fqfn) { + // Cast string and set it + $this->lastFile = (string) $fqfn; + } + + /** + * Getter for last read file + * + * @return $lastFile The last read file's name with full path + */ + public final function getLastFile () { + return $this->lastFile; + } + + /** + * Setter for contents of the last read file + * + * @param $contents An array with header and data elements + * @return void + */ + private final function setLastFileContents (array $contents) { + // Set array + $this->lastContents = $contents; + } + + /** + * Getter for last read file's content as an array + * + * @return $lastContent The array with elements 'header' and 'data'. + */ + public final function getLastContents () { + return $this->lastContents; + } + + /** + * Getter for file extension + * + * @return $fileExtension The array with elements 'header' and 'data'. + */ + public final function getFileExtension () { + return $this->fileExtension; + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return $this->indexKey; + } + + /** + * Reads a local data file and returns it's contents in an array + * + * @param $fqfn The FQFN for the requested file + * @return $dataArray + */ + private function getDataArrayFromFile ($fqfn) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Reading elements from database file ' . $fqfn . ' ...'); + + // Init compressed data + $compressedData = $this->getFileIoInstance()->loadFileContents($fqfn); + $compressedData = $compressedData['data']; + + // Close the file and throw the instance away + unset($fileInstance); + + // Decompress it + $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData); + + // Unserialize it + $dataArray = json_decode($serializedData, TRUE); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, TRUE)); + + // Finally return it + return $dataArray; + } + + /** + * Writes data array to local file + * + * @param $fqfn The FQFN of the local file + * @param $dataArray An array with all the data we shall write + * @return void + */ + private function writeDataArrayToFqfn ($fqfn, array $dataArray) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, TRUE)); + + // Serialize and compress it + $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(json_encode($dataArray)); + + // Write data + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing ' . strlen($compressedData) . ' bytes ...'); + + // Write this data BASE64 encoded to the file + $this->getFileIoInstance()->saveStreamToFile($fqfn, $compressedData, $this); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.'); + } + + /** + * Getter for table information file contents or an empty if info file was not created + * + * @param $dataSetInstance An instance of a database set class + * @return $infoArray An array with all table informations + */ + private function getContentsFromTableInfoFile (StoreableCriteria $dataSetInstance) { + // Default content is no data + $infoArray = array(); + + // Create FQFN for getting the table information file + $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); + + // Get the file contents + try { + $infoArray = $this->getDataArrayFromFile($fqfn); + } catch (FileNotFoundException $e) { + // Not found, so ignore it here + } + + // ... and return it + return $infoArray; + } + + /** + * Generates an FQFN from given dataset instance and string + * + * @param $dataSetInstance An instance of a database set class + * @param $rowName Name of the row + * @return $fqfn The FQFN for this row + */ + private function generateFqfnFromDataSet (Criteria $dataSetInstance, $rowName) { + // This is the FQFN + $fqfn = $this->getConfigInstance()->getConfigEntry('local_db_path') . $dataSetInstance->getTableName() . '/' . $rowName . '.' . $this->getFileExtension(); + + // Return it + return $fqfn; + } + + /** + * Creates the table info file from given dataset instance + * + * @param $dataSetInstance An instance of a database set class + * @return void + */ + private function createTableInfoFile (StoreableCriteria $dataSetInstance) { + // Create FQFN for creating the table information file + $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); + + // Get the data out from dataset in a local array + $this->tableInfo[$dataSetInstance->getTableName()] = array( + 'primary' => $dataSetInstance->getPrimaryKey(), + 'created' => time(), + 'last_updated' => time() + ); + + // Write the data to the file + $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$dataSetInstance->getTableName()]); + } + + /** + * Updates the table info file from given dataset instance + * + * @param $dataSetInstance An instance of a database set class + * @return void + */ + private function updateTableInfoFile (StoreableCriteria $dataSetInstance) { + // Create FQFN for creating the table information file + $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); + + // Get the data out from dataset in a local array + $this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey(); + $this->tableInfo[$tableName]['last_updated'] = time(); + + // Write the data to the file + $this->writeDataArrayToFqfn($fqfn, $this->tableInfo[$dataSetInstance->getTableName()]); + } + + /** + * Updates the primary key information or creates the table info file if not found + * + * @param $dataSetInstance An instance of a database set class + * @return void + */ + private function updatePrimaryKey (StoreableCriteria $dataSetInstance) { + // "Cache" table name + $tableName = $dataSetInstance->getTableName(); + + // Get the information array from lower method + $infoArray = $this->getContentsFromTableInfoFile($dataSetInstance); + + // Is the primary key there? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableInfo=' . print_r($this->tableInfo, TRUE)); + if (!isset($this->tableInfo[$tableName]['primary'])) { + // Then create the info file + $this->createTableInfoFile($dataSetInstance); + } elseif (($this->getConfigInstance()->getConfigEntry('db_update_primary_forced') == 'Y') && ($dataSetInstance->getPrimaryKey() != $this->tableInfo[$tableName]['primary'])) { + // Set the array element + $this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey(); + + // Update the entry + $this->updateTableInfoFile($dataSetInstance); + } + } + + /** + * Makes sure that the database connection is alive + * + * @return void + * @todo Do some checks on the database directory and files here + */ + public function connectToDatabase () { + } + + /** + * Starts a SELECT query on the database by given return type, table name + * and search criteria + * + * @param $tableName Name of the database table + * @param $searchInstance Local search criteria class + * @return $resultData Result data of the query + * @throws UnsupportedCriteriaException If the criteria is unsupported + * @throws SqlException If an 'SQL error' occurs + */ + public function querySelect ($tableName, LocalSearchCriteria $searchInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableName=' . $tableName . ' - CALLED!'); + + // The result is null by any errors + $resultData = NULL; + + // Create full path name + $pathName = $this->getConfigInstance()->getConfigEntry('local_db_path') . $tableName . '/'; + + /* + * A 'select' query is not that easy on local files, so first try to + * find the 'table' which is in fact a directory on the server + */ + try { + // Get a directory pointer instance + $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName)); + + // Initialize the result data, this need to be rewritten e.g. if a local file cannot be read + $resultData = array( + BaseDatabaseBackend::RESULT_INDEX_STATUS => self::RESULT_OKAY, + BaseDatabaseBackend::RESULT_INDEX_ROWS => array() + ); + + // Initialize limit/skip + $limitFound = 0; + $skipFound = 0; + $idx = 1; + + // Read the directory with some exceptions + while (($dataFile = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',this->getFileExtension()=' . $this->getFileExtension()); + + // Does the extension match? + if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { + // Skip this file! + continue; + } // END - if + + // Read the file + $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, TRUE)); + + // Is this an array? + if (is_array($dataArray)) { + // Default is nothing found + $isFound = TRUE; + + // Search in the criteria with FMFW (First Matches, First Wins) + foreach ($dataArray as $key => $value) { + // Make sure value is not bool + assert(!is_bool($value)); + + // Found one entry? + $isFound = (($isFound === TRUE) && ($searchInstance->isCriteriaMatching($key, $value))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: key=' . $key . ',value=' . $value . ',isFound=' . intval($isFound)); + } // END - foreach + + // Is all found? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: isFound=' . intval($isFound) . ',limitFound=' . $limitFound . ',limit=' . $searchInstance->getLimit()); + if ($isFound === TRUE) { + // Shall we skip this entry? + if ($searchInstance->getSkip() > 0) { + // We shall skip some entries + if ($skipFound < $searchInstance->getSkip()) { + // Skip this entry + $skipFound++; + break; + } // END - if + } // END - if + + // Set id number + $dataArray[$this->getIndexKey()] = $idx; + + // Entry found! + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, TRUE)); + array_push($resultData[BaseDatabaseBackend::RESULT_INDEX_ROWS], $dataArray); + + // Count found entries up + $limitFound++; + } // END - if + } else { + // Throw an exception here + throw new SqlException(array($this, sprintf('File '%s' contains invalid data.', $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY); + } + + // Count entry up + $idx++; + } // END - while + + // Close directory and throw the instance away + $directoryInstance->closeDirectory(); + unset($directoryInstance); + + // Reset last exception + $this->resetLastException(); + } catch (PathIsNoDirectoryException $e) { + // Path not found means "table not found" for real databases... + $this->setLastException($e); + + // So throw an SqlException here with faked error message + throw new SqlException (array($this, sprintf('Table '%s' not found', $tableName), self::DB_CODE_TABLE_MISSING), self::EXCEPTION_SQL_QUERY); + } catch (FrameworkException $e) { + // Catch all exceptions and store them in last error + $this->setLastException($e); + } + + // Return the gathered result + return $resultData; + } + + /** + * "Inserts" a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + public function queryInsertDataSet (StoreableCriteria $dataSetInstance) { + // Try to save the request away + try { + // Create full path name + $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, md5($dataSetInstance->getUniqueValue())); + + // Write the data away + $this->writeDataArrayToFqfn($fqfn, $dataSetInstance->getCriteriaArray()); + + // Update the primary key + $this->updatePrimaryKey($dataSetInstance); + + // Reset last exception + $this->resetLastException(); + } catch (FrameworkException $e) { + // Catch all exceptions and store them in last error + $this->setLastException($e); + + // Throw an SQL exception + throw new SqlException(array($this, sprintf('Cannot write data to table '%s', is the table created?', $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY); + } + } + + /** + * "Updates" a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) { + // Create full path name + $pathName = $this->getConfigInstance()->getConfigEntry('local_db_path') . $dataSetInstance->getTableName() . '/'; + + // Try all the requests + try { + // Get a file pointer instance + $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName)); + + // Initialize limit/skip + $limitFound = 0; + $skipFound = 0; + + // Get the criteria array from the dataset + $searchArray = $dataSetInstance->getCriteriaArray(); + + // Get search criteria + $searchInstance = $dataSetInstance->getSearchInstance(); + + // Read the directory with some exceptions + while (($dataFile = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) { + // Does the extension match? + if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!'); + // Skip this file! + continue; + } // END - if + + // Open this file for reading + $dataArray = $this->getDataArrayFromFile($pathName . $dataFile); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, TRUE)); + + // Is this an array? + if (is_array($dataArray)) { + // Default is nothing found + $isFound = TRUE; + + // Search in the criteria with FMFW (First Matches, First Wins) + foreach ($dataArray as $key => $value) { + // Make sure value is not bool + assert(!is_bool($value)); + + // Found one entry? + $isFound = (($isFound === TRUE) && ($searchInstance->isCriteriaMatching($key, $value))); + } // END - foreach + + // Is all found? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: isFound=' . intval($isFound)); + if ($isFound === TRUE) { + // Shall we skip this entry? + if ($searchInstance->getSkip() > 0) { + // We shall skip some entries + if ($skipFound < $searchInstance->getSkip()) { + // Skip this entry + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Found entry, but skipping ...'); + $skipFound++; + break; + } // END - if + } // END - if + + // Entry found, so update it + foreach ($searchArray as $searchKey => $searchValue) { + // Make sure the value is not bool again + assert(!is_bool($searchValue)); + assert($searchKey != $this->indexKey); + + // Debug message + add/update it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: criteriaKey=' . $searchKey . ',criteriaValue=' . $searchValue); + $dataArray[$searchKey] = $searchValue; + } // END - foreach + + // Write the data to a local file + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing dataArray()=' . count($dataArray) . ' to ' . $dataFile . ' ...'); + $this->writeDataArrayToFqfn($pathName . $dataFile, $dataArray); + + // Count found entries up + $limitFound++; + } // END - if + } // END - if + } // END - while + + // Close the file pointer + $directoryInstance->closeDirectory(); + + // Update the primary key + $this->updatePrimaryKey($dataSetInstance); + + // Reset last exception + $this->resetLastException(); + } catch (FrameworkException $e) { + // Catch all exceptions and store them in last error + $this->setLastException($e); + + // Throw an SQL exception + throw new SqlException(array($this, sprintf('Cannot write data to table '%s', is the table created? Exception: %s, message:%s', $dataSetInstance->getTableName(), $e->__toString(), $e->getMessage()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY); + } + } + + /** + * Getter for primary key of specified table or if not found null will be + * returned. This must be database-specific. + * + * @param $tableName Name of the table we need the primary key from + * @return $primaryKey Primary key column of the given table + */ + public function getPrimaryKeyOfTable ($tableName) { + // Default key is null + $primaryKey = NULL; + + // Does the table information exist? + if (isset($this->tableInfo[$tableName])) { + // Then return the primary key + $primaryKey = $this->tableInfo[$tableName]['primary']; + } // END - if + + // Return the column + return $primaryKey; + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + * @todo Add more generic non-public data for removal + */ + public function removeNonPublicDataFromArray (array $data) { + // Remove '__idx' + unset($data[$this->indexKey]); + + // Return it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: data[' . gettype($data) . ']='.print_r($data, TRUE)); + return $data; + } + + /** + * Counts total rows of given table + * + * @param $tableName Table name + * @return $count Total rows of given table + */ + public function countTotalRows($tableName) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableName=' . $tableName . ' - CALLED!'); + + // Create full path name + $pathName = $this->getConfigInstance()->getConfigEntry('local_db_path') . $tableName . '/'; + + // Try all the requests + try { + // Get a file pointer instance + $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName)); + + // Initialize counter + $count = 0; + + // Read the directory with some exceptions + while ($dataFile = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) { + // Does the extension match? + if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!'); + // Skip this file! + continue; + } // END - if + + // Count this row up + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',getFileExtension()=' . $this->getFileExtension() . ' - COUNTED!'); + $count++; + } // END - while + } catch (FrameworkException $e) { + // Catch all exceptions and store them in last error + $this->setLastException($e); + + // Throw an SQL exception + throw new SqlException(array($this, sprintf('Cannot count on table '%s', is the table created?', $dataSetInstance->getTableName()), self::DB_CODE_TABLE_NOT_FOUND), self::EXCEPTION_SQL_QUERY); + } + + // Return count + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableName=' . $tableName . ',count=' . $count . ' - EXIT!'); + return $count; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/class_ b/inc/main/classes/database/class_ new file mode 100644 index 00000000..3a967f4c --- /dev/null +++ b/inc/main/classes/database/class_ @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class extends BaseDatabaseBackend implements DatabaseBackendInterface { + /** + * Protected constructor + * + * @return void + */ + protected function __construct($class = __CLASS__) { + // Call parent constructor + parent::__construct($class); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/class_BaseDatabaseBackend.php b/inc/main/classes/database/class_BaseDatabaseBackend.php new file mode 100644 index 00000000..62805655 --- /dev/null +++ b/inc/main/classes/database/class_BaseDatabaseBackend.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseDatabaseBackend extends BaseFrameworkSystem implements DatabaseBackend { + // Constants for exceptions + const EXCEPTION_SQL_QUERY = 0x140; + + // Result array indexes + const RESULT_INDEX_ROWS = 'rows'; + const RESULT_INDEX_STATUS = 'status'; + const RESULT_INDEX_EXCEPTION = 'exception'; + + // Constants for MySQL backward-compatiblity (PLEASE FIX THEM!) + const DB_CODE_TABLE_MISSING = 0x100; + const DB_CODE_TABLE_UNWRITEABLE = 0x101; + const DB_CODE_DATA_FILE_CORRUPT = 0x102; + + // Status results + const RESULT_OKAY = 'ok'; + + /** + * Last thrown exception or NULL if all is fine + */ + private $lastException = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for last exception + * + * @return $lastException Last thrown exception + */ + public final function getLastException () { + return $this->lastException; + } + + /** + * Setter for last exception + * + * @param $lastException Last thrown exception + * @return void + */ + public final function setLastException (FrameworkException $exceptionInstance) { + $this->lastException = $exceptionInstance; + } + + /** + * Reset the last exception instance. This should be done after a "query" + * was completed without any errors. + * + * @return void + */ + protected final function resetLastException () { + $this->lastException = NULL; + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public abstract function removeNonPublicDataFromArray (array $data); +} + +// [EOF] +?> diff --git a/inc/main/classes/database/class_BaseDatabaseResult.php b/inc/main/classes/database/class_BaseDatabaseResult.php new file mode 100644 index 00000000..d41bdcc8 --- /dev/null +++ b/inc/main/classes/database/class_BaseDatabaseResult.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDatabaseResult extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @return void + */ + protected function __construct($class = __CLASS__) { + // Call parent constructor + parent::__construct($class); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/class_BaseDatabaseWrapper.php b/inc/main/classes/database/class_BaseDatabaseWrapper.php new file mode 100644 index 00000000..c2a18b86 --- /dev/null +++ b/inc/main/classes/database/class_BaseDatabaseWrapper.php @@ -0,0 +1,280 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDatabaseWrapper extends BaseFrameworkSystem { + /** + * Cache instance + */ + private $cacheInstance = NULL; + + /** + * Current table name to use + */ + private $tableName = 'unknown'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct ($class) { + // Call parent constructor + parent::__construct($class); + + // Initialize the cache instance + $this->initCacheInstance(); + } + + /** + * Initializes the cache instance with a new object + * + * @return void + */ + private final function initCacheInstance () { + // Is the cache enabled? + if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { + // Set the new instance + $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache(); + } // END - if + } + + /** + * Setter for table name + * + * @param $tableName Name of table name to set + * @return void + */ + protected final function setTableName ($tableName) { + $this->tableName = (string) $tableName; + } + + /** + * Getter for table name + * + * @return $tableName Name of table name to set + */ + protected final function getTableName () { + return $this->tableName; + } + + /** + * 'Inserts' a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @param $onlyKeys Only use these keys for a cache key + * @return void + */ + protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) { + // Default cache key is NULL + $cacheKey = NULL; + + // Is cache enabled? + if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { + // First get a key suitable for our cache and extend it with this class name + $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); + } // END - if + + // Does this key exists in cache? + if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey))) { + // Purge the cache + $this->cacheInstance->purgeOffset($cacheKey); + } // END - if + + // Handle it over to the middleware + $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance); + } + + /** + * 'Updates' a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @param $onlyKeys Only use these keys for a cache key + * @return void + */ + protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) { + // Init cache key + $cacheKey = NULL; + + // Is cache enabled? + if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { + // First get a key suitable for our cache and extend it with this class name + $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...'); + } // END - if + + // Does this key exists in cache? + if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey))) { + // Purge the cache + $this->cacheInstance->purgeOffset($cacheKey); + } // END - if + + // Handle it over to the middleware + $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return $this->getDatabaseInstance()->getIndexKey(); + } + + /** + * Getter for last exception + * + * @return $lastException Last exception or NULL if none occured + */ + public final function getLastException () { + return $this->getDatabaseInstance()->getLastException(); + } + + /** + * Do a "select" query on the current table with the given search criteria and + * store it in cache for later usage + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $resultInstance An instance of a database result class + */ + public function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) { + // Default cache key if cache is not enabled + $cacheKey = NULL; + + // Is the cache enabled? + if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { + // First get a key suitable for our cache and extend it with this class name + $cacheKey = $this->getCacheKeyByCriteria($criteriaInstance, $onlyKeys); + } // END - if + + // Does this key exists in cache? + if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey . ':' . print_r($this->cacheInstance->offsetGet($cacheKey), TRUE)); + + // Then use this result + $result = $this->cacheInstance->offsetGet($cacheKey); + } else { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey); + + // Now it's time to ask the database layer for this select statement + $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: result[]=' . gettype($result)); + + // Cache the result if not null + if (!is_null($result)) { + // Is cache enabled? + if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) { + // A valid result has returned from the database layer + $this->cacheInstance->offsetSet($cacheKey, $result); + } // END - if + } else { + // This invalid result must be wrapped + $result = array( + BaseDatabaseBackend::RESULT_INDEX_STATUS => 'invalid', + BaseDatabaseBackend::RESULT_INDEX_EXCEPTION => $this->getDatabaseInstance()->getLastException() + ); + } + } + + // Create an instance of a CachedDatabaseResult class with the given result + // @TODO Minor: Update above comment to e.g. BaseDatabaseResult + $resultInstance = ObjectFactory::createObjectByConfiguredName('database_result_class', array($result)); + + // And return the instance + return $resultInstance; + } + + /** + * Count the numbers of rows we shall receive + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $numRows Numbers of rows of database entries + */ + public function doSelectCountByCriteria (Criteria $criteriaInstance, $onlyKeys = array()) { + // Total numbers is -1 so we can distinglish between failed and valid queries + $numRows = 0; + + // Get the result from above method + $resultInstance = $this->doSelectByCriteria($criteriaInstance, $onlyKeys); + + // Was that query fine? + if ($resultInstance->ifStatusIsOkay()) { + // Then get the number of rows + $numRows = $resultInstance->getAffectedRows(); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: numRows=' . $numRows); + } // END - if + + // Return the result + return $numRows; + } + + /** + * Getter for primary key used in wrapped table + * + * @return $primaryKey Primary key used in wrapped table + */ + public final function getPrimaryKeyValue () { + // Get the table name and a database instance and ask for it + $primaryKey = $this->getDatabaseInstance()->getPrimaryKeyOfTable($this->getTableName()); + + // Return value + return $primaryKey; + } + + /** + * Count rows of this table + * + * @return $count Count of total rows in this table + */ + public final function countTotalRows () { + // Get the table name and a database instance and ask for it + $count = $this->getDatabaseInstance()->countTotalRows($this->getTableName()); + + // Return value + return $count; + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray (array $data) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('WRAPPER[' . $this->__toString() . ']: Calling this->getDatabaseInstance()->removeNonPublicDataFromArray(data) ...'); + $data = $this->getDatabaseInstance()->removeNonPublicDataFromArray($data); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data)); + return $data; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/frontend/.htaccess b/inc/main/classes/database/frontend/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/database/frontend/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/database/frontend/class_NewsDatabaseWrapper.php b/inc/main/classes/database/frontend/class_NewsDatabaseWrapper.php new file mode 100644 index 00000000..328a0e29 --- /dev/null +++ b/inc/main/classes/database/frontend/class_NewsDatabaseWrapper.php @@ -0,0 +1,57 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Add missing own interface for public methods + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NewsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable { + // Constants for database table names + const DB_TABLE_NEWS = 'news'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createNewsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new NewsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_NEWS); + + // Return the instance + return $wrapperInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/frontend/class_PaymentsDatabaseWrapper.php b/inc/main/classes/database/frontend/class_PaymentsDatabaseWrapper.php new file mode 100644 index 00000000..6e50f07e --- /dev/null +++ b/inc/main/classes/database/frontend/class_PaymentsDatabaseWrapper.php @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Add missing own interface for public methods + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PaymentsDatabaseWrapper extends BaseDatabaseWrapper implements Registerable { + // Constants for exceptions + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; + + // Constants for database table names + const DB_TABLE_PAYMENTS = 'payments'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createPaymentsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new PaymentsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_PAYMENTS); + + // Return the instance + return $wrapperInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/frontend/class_UserDatabaseWrapper.php b/inc/main/classes/database/frontend/class_UserDatabaseWrapper.php new file mode 100644 index 00000000..263a0e87 --- /dev/null +++ b/inc/main/classes/database/frontend/class_UserDatabaseWrapper.php @@ -0,0 +1,134 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserDatabaseWrapper extends BaseDatabaseWrapper implements ManageableAccountWrapper, Registerable { + // Constants for exceptions + const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180; + + // Constants for database columns + const DB_COLUMN_USERID = 'userid'; + const DB_COLUMN_USERNAME = 'username'; + const DB_COLUMN_EMAIL = 'email'; + const DB_COLUMN_CONFIRM_HASH = 'confirm_hash'; + const DB_COLUMN_USER_STATUS = 'user_status'; + + // Constants for database table names + const DB_TABLE_USER = 'user'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createUserDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new UserDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_USER); + + // Return the instance + return $wrapperInstance; + } + + /** + * Handles inserting the registration data from a registration instance into the database + * + * @param $registrationInstance An instance of a registration class + * @return void + */ + public function insertRegistrationObject (UserRegister $registrationInstance) { + // Generate a data set for the request + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); + + // Add registration elements to the dataset + $registrationInstance->addElementsToDataSet($dataSetInstance, NULL); + + // "Insert" this request instance completely into the database + $this->queryInsertDataSet($dataSetInstance); + } + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a Updateable database result + * @return void + * @throws NullPointerException If $updateInstance or $searchInstance is null + */ + public function doUpdateByResult (UpdateableResult $resultInstance) { + // Get the search instance from result + $searchInstance = $resultInstance->getSearchInstance(); + + // Is this null? + if (is_null($searchInstance)) { + // Get the update instance + $updateInstance = $resultInstance->getUpdateInstance(); + + // Is this null? + if (is_null($updateInstance)) { + // Throw an exception here + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get search instance from update instance + $searchInstance = $updateInstance->getSearchInstance(); + + // Is it still null? + if (is_null($searchInstance)) { + // Throw an exception here + throw new NullPointerException($updateInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + } // END - if + + // Generate a data set object + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER)); + + // Add seach criteria + $dataSetInstance->setSearchInstance($searchInstance); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_USERNAME); + + // Add all update criteria to the database set + $resultInstance->addElementsToDataSet($dataSetInstance, NULL); + + // "Update" this request with the database + $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/frontend/class_UserPointsDatabaseWrapper.php b/inc/main/classes/database/frontend/class_UserPointsDatabaseWrapper.php new file mode 100644 index 00000000..18eef5b9 --- /dev/null +++ b/inc/main/classes/database/frontend/class_UserPointsDatabaseWrapper.php @@ -0,0 +1,111 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserPointsDatabaseWrapper extends BaseDatabaseWrapper implements BookablePointsWrapper, Registerable { + /** + * Constants for database table names + */ + const DB_TABLE_USER_POINTS = 'user_points'; + + /** + * Name of the user->points column + */ + const DB_COLUMN_POINTS_UID = 'points_uid'; + + /** + * Name of the points column + */ + const DB_COLUMN_POINTS = 'points'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this database wrapper by a provided user class + * + * @return $wrapperInstance An instance of the created wrapper class + */ + public static final function createUserPointsDatabaseWrapper () { + // Get a new instance + $wrapperInstance = new UserPointsDatabaseWrapper(); + + // Set (primary!) table name + $wrapperInstance->setTableName(self::DB_TABLE_USER_POINTS); + + // Return the instance + return $wrapperInstance; + } + + /** + * Inserts the given points for the given user in the database + * + * @param $pointsInstance An instance of a user class + * @return void + */ + public function insertUserPoints (BookablePoints $pointsInstance) { + // Generate a data set for the request + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); + + // Add registration elements to the dataset + $pointsInstance->addElementsToDataSet($dataSetInstance, NULL); + + // "Insert" this request instance completely into the database + $this->queryInsertDataSet($dataSetInstance); + } + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a Updateable database result + * @return void + */ + public function doUpdateByResult (UpdateableResult $resultInstance) { + // Generate a data set object + $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_USER_POINTS)); + + // Add all update criteria to the database set + $resultInstance->addElementsToDataSet($dataSetInstance, NULL); + + // Add seach criteria + $dataSetInstance->setSearchInstance($resultInstance->getUpdateInstance()->getSearchInstance()); + + // Set the primary key + $dataSetInstance->setUniqueKey(self::DB_COLUMN_POINTS_UID); + + // "Update" this request with the database + $this->getDatabaseInstance()->queryUpdateDataSet($dataSetInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/database/result/.htaccess b/inc/main/classes/database/result/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/database/result/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/database/result/class_CachedDatabaseResult.php b/inc/main/classes/database/result/class_CachedDatabaseResult.php new file mode 100644 index 00000000..a2e1d2cd --- /dev/null +++ b/inc/main/classes/database/result/class_CachedDatabaseResult.php @@ -0,0 +1,419 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CachedDatabaseResult extends BaseDatabaseResult implements SearchableResult, UpdateableResult, SeekableIterator { + // Exception constants + const EXCEPTION_INVALID_DATABASE_RESULT = 0x1c0; + const EXCEPTION_RESULT_UPDATE_FAILED = 0x1c1; + + /** + * Current position in array + */ + private $currentPos = -1; + + /** + * Current row + */ + private $currentRow = NULL; + + /** + * Result array + */ + private $resultArray = array(); + + /** + * Array of out-dated entries + */ + private $outDated = array(); + + /** + * Affected rows + */ + private $affectedRows = 0; + + /** + * Found value + */ + private $foundValue = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this result by a provided result array + * + * @param $resultArray The array holding the result from query + * @return $resultInstance An instance of this class + */ + public static final function createCachedDatabaseResult (array $resultArray) { + // Get a new instance + $resultInstance = new CachedDatabaseResult(); + + // Set the result array + $resultInstance->setResultArray($resultArray); + + // Set affected rows + $resultInstance->setAffectedRows(count($resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS])); + + // Return the instance + return $resultInstance; + } + + /** + * Setter for result array + * + * @param $resultArray The array holding the result from query + * @return void + */ + protected final function setResultArray (array $resultArray) { + $this->resultArray = $resultArray; + } + + /** + * Updates the current entry by given update criteria + * + * @param $updateInstance An instance of an Updateable criteria + * @return void + */ + private function updateCurrentEntryByCriteria (LocalUpdateCriteria $updateInstance) { + // Get the current entry key + $entryKey = $this->key(); + + // Now get the update criteria array and update all entries + foreach ($updateInstance->getUpdateCriteria() as $criteriaKey => $criteriaValue) { + // Update data + $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$entryKey][$criteriaKey] = $criteriaValue; + + // Mark it as out-dated + $this->outDated[$criteriaKey] = 1; + } // END - foreach + } + + /** + * "Iterator" method next() to advance to the next valid entry. This method + * does also check if result is invalid + * + * @return $nextValid Whether the next entry is valid + */ + public function next () { + // Default is not valid + $nextValid = FALSE; + + // Is the result valid? + if ($this->valid()) { + // Next entry found, so count one up and cache it + $this->currentPos++; + $this->currentRow = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos]; + $nextValid = TRUE; + } // END - if + + // Return the result + return $nextValid; + } + + /** + * Seeks for to a specified position + * + * @param $index Index to seek for + * @return void + */ + public function seek ($index) { + // Rewind to beginning + $this->rewind(); + + // Search for the entry + while (($this->currentPos < $index) && ($this->valid())) { + // Continue on + $this->next(); + } // END - while + } + + /** + * Gives back the current position or null if not found + * + * @return $current Current element to give back + */ + public function current () { + // Default is not found + $current = NULL; + + // Does the current enty exist? + if (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos])) { + // Then get it + $current = $this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][$this->currentPos]; + } // END - if + + // Return the result + return $current; + } + + /** + * Checks if next() and rewind will give a valid result + * + * @return $isValid Whether the next/rewind entry is valid + */ + public function valid () { + // By default nothing is valid + $isValid = FALSE; + + // Debug message + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] this->currentPos=' . $this->currentPos); + + // Check if all is fine ... + if (($this->ifStatusIsOkay()) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][($this->currentPos + 1)])) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][0]))) { + // All fine! + $isValid = TRUE; + } // END - if + + // Return the result + return $isValid; + } + + /** + * Returns count of entries + * + * @return $isValid Whether the next/rewind entry is valid + */ + public function count () { + // Return it + return count($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS]); + } + + /** + * Determines whether the status of the query was fine (BaseDatabaseBackend::RESULT_OKAY) + * + * @return $ifStatusOkay Whether the status of the query was okay + */ + public function ifStatusIsOkay () { + $ifStatusOkay = ((isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS])) && ($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS] === BaseDatabaseBackend::RESULT_OKAY)); + //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] ifStatusOkay=' . intval($ifStatusOkay)); + return $ifStatusOkay; + } + + /** + * Gets the current key of iteration + * + * @return $currentPos Key from iterator + */ + public function key () { + return $this->currentPos; + } + + /** + * Rewind to the beginning and clear array $currentRow + * + * @return void + */ + public function rewind () { + $this->currentPos = -1; + $this->currentRow = array(); + } + + /** + * Searches for an entry in data result and returns it + * + * @param $criteriaInstance The criteria to look inside the data set + * @return $result Found result entry + * @todo 0% done + */ + public function searchEntry (LocalSearchCriteria $criteriaInstance) { + $this->debugBackTrace('[' . '[' . __METHOD__ . ':' . __LINE__ . ']: Unfinished!'); + } + + /** + * Adds an update request to the database result for writing it to the + * database layer + * + * @param $criteriaInstance An instance of a updateable criteria + * @return void + * @throws ResultUpdateException If no result was updated + */ + public function add2UpdateQueue (LocalUpdateCriteria $criteriaInstance) { + // Rewind the pointer + $this->rewind(); + + // Get search criteria + $searchInstance = $criteriaInstance->getSearchInstance(); + + // And start looking for the result + $foundEntries = 0; + while (($this->valid()) && ($foundEntries < $searchInstance->getLimit())) { + // Get next entry + $this->next(); + $currentEntry = $this->current(); + + // Is this entry found? + if ($searchInstance->ifEntryMatches($currentEntry)) { + // Update this entry + $this->updateCurrentEntryByCriteria($criteriaInstance); + + // Count one up + $foundEntries++; + } // END - if + } // END - while + + // If no entry is found/updated throw an exception + if ($foundEntries == 0) { + // Throw an exception here + throw new ResultUpdateException($this, self::EXCEPTION_RESULT_UPDATE_FAILED); + } // END - if + + // Set affected rows + $this->setAffectedRows($foundEntries); + + // Set update instance + $this->setUpdateInstance($criteriaInstance); + } + + /** + * Setter for affected rows + * + * @param $rows Number of affected rows + * @return void + */ + public final function setAffectedRows ($rows) { + $this->affectedRows = $rows; + } + + /** + * Getter for affected rows + * + * @return $rows Number of affected rows + */ + public final function getAffectedRows () { + return $this->affectedRows; + } + + /** + * Getter for found value of previous found() call + * + * @return $foundValue Found value of previous found() call + */ + public final function getFoundValue () { + return $this->foundValue; + } + + /** + * Checks whether we have out-dated entries or not + * + * @return $needsUpdate Whether we have out-dated entries + */ + public function ifDataNeedsFlush () { + $needsUpdate = (count($this->outDated) > 0); + return $needsUpdate; + } + + /** + * Adds registration elements to a given dataset instance + * + * @param $criteriaInstance An instance of a StoreableCriteria class + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { + // Walk only through out-dated columns + foreach ($this->outDated as $key => $dummy) { + // Does this key exist? + //* DEBUG: */ echo "outDated: {$key}
    \n"; + if ($this->find($key)) { + // Then update it + $criteriaInstance->addCriteria($key, $this->getFoundValue()); + } // END - if + } // END - foreach + } + + /** + * Find a key inside the result array + * + * @param $key The key we shall find + * @return $found Whether the key was found or not + */ + public function find ($key) { + // By default nothing is found + $found = FALSE; + + // Rewind the pointer + $this->rewind(); + + // Walk through all entries + while ($this->valid()) { + // Advance to next entry + $this->next(); + + // Get the whole array + $currentEntry = $this->current(); + + // Is the element there? + if (isset($currentEntry[$key])) { + // Okay, found! + $found = TRUE; + + // So "cache" it + $this->foundValue = $currentEntry[$key]; + + // And stop searching + break; + } // END - if + } // END - while + + // Return the result + return $found; + } + + /** + * Solver for result index value with call-back method + * + * @param $databaseColumn Database column where the index might be found + * @param $wrapperInstance The wrapper instance to ask for array element + * @para $callBack Call-back object for setting the index; + * 0=object instance,1=method name + * @return void + * @todo Find a caching way without modifying the result array + */ + public function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack) { + // By default nothing is found + $indexValue = 0; + + // Is the element in result itself found? + if ($this->find($databaseColumn)) { + // Use this value + $indexValue = $this->getFoundValue(); + } elseif ($this->find($wrapperInstance->getIndexKey())) { + // Use this value + $indexValue = $this->getFoundValue(); + } + + // Set the index + call_user_func_array($callBack, array($indexValue)); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/decorator/.htaccess b/inc/main/classes/decorator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/decorator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/decorator/cache/.htaccess b/inc/main/classes/decorator/cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/decorator/cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/decorator/class_BaseDecorator.php b/inc/main/classes/decorator/class_BaseDecorator.php new file mode 100644 index 00000000..3ef6c49a --- /dev/null +++ b/inc/main/classes/decorator/class_BaseDecorator.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDecorator extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/decorator/template/.htaccess b/inc/main/classes/decorator/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/decorator/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php b/inc/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php new file mode 100644 index 00000000..e96a111d --- /dev/null +++ b/inc/main/classes/decorator/template/class_XmlRewriterTemplateDecorator.php @@ -0,0 +1,445 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableTemplate { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $innerTemplateInstance A CompileableTemplate instance + * @return $templateInstance An instance of TemplateEngine + */ + public static final function createXmlRewriterTemplateDecorator (CompileableTemplate $innerTemplateInstance) { + // Get a new instance + $templateInstance = new XmlRewriterTemplateDecorator(); + + // Set the inner template engine + $templateInstance->setTemplateInstance($innerTemplateInstance); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Settter for variable group + * + * @param $groupName Name of variable group + * @param $add Whether add this group + * @return void + */ + public function setVariableGroup ($groupName, $add = TRUE) { + // Call the inner class' method + $this->getTemplateInstance()->setVariableGroup($groupName, $add); + } + + /** + * Adds a variable to current group + * + * @param $var Variable to set + * @param $value Value to store in variable + * @return void + */ + public function addGroupVariable ($var, $value) { + // Call the inner class' method + $this->getTemplateInstance()->addGroupVariable($var, $value); + } + + /** + * Getter for base path + * + * @return $templateBasePath The relative base path for all templates + */ + public final function getTemplateBasePath () { + // Call the inner class' method + return $this->getTemplateInstance()->getTemplateBasePath(); + } + + /** + * Getter for generic base path + * + * @return $templateBasePath The relative base path for all templates + */ + public final function getGenericBasePath () { + // Call the inner class' method + return $this->getTemplateInstance()->getGenericBasePath(); + } + + /** + * Getter for template extension + * + * @return $templateExtension The file extension for all uncompiled templates + */ + public final function getRawTemplateExtension () { + // Call the inner class' method + return $this->getTemplateInstance()->getRawTemplateExtension(); + } + + /** + * Getter for given variable group + * + * @param $variableGroup Variable group to check + * @return $varStack Found variable group + */ + public function getVarStack ($variableGroup) { + // Call the inner class' method + return $this->getTemplateInstance()->getVarStack($variableGroup); + } + + /** + * Getter for code-template extension + * + * @return $codeExtension The file extension for all code templates + */ + public final function getCodeTemplateExtension () { + // Call the inner class' method + return $this->getTemplateInstance()->getCodeTemplateExtension(); + } + + /** + * Getter for template type + * + * @return $templateType The current template's type + */ + public final function getTemplateType () { + // Call the inner class' method + return $this->getTemplateInstance()->getTemplateType(); + } + + /** + * Assign (add) a given variable with a value + * + * @param $var The variable we are looking for + * @param $value The value we want to store in the variable + * @return void + * @throws EmptyVariableException If the variable name is left empty + */ + public function assignVariable ($var, $value) { + // Call the inner class' method + $this->getTemplateInstance()->assignVariable($var, $value); + } + + /** + * Removes a given variable + * + * @param $variableName The variable we are looking for + * @param $variableGroup Name of variable group (default: 'general') + * @return void + */ + public function removeVariable ($variableName, $variableGroup = 'general') { + // Call the inner class' method + $this->getTemplateInstance()->removeVariable($variableName, $variableGroup); + } + + /** + * Load a specified HTML template into the engine + * + * @param $template The web template we shall load which is located in + * 'html' by default + * @return void + */ + public function loadHtmlTemplate ($template) { + // Call the inner class' method + $this->getTemplateInstance()->loadHtmlTemplate($template); + } + + /** + * Assign a given congfiguration variable with a value + * + * @param $variableName The configuration variable we want to assign + * @return void + */ + public function assignConfigVariable ($variableName) { + // Call the inner class' method + $this->getTemplateInstance()->assignConfigVariable($variableName); + } + + /** + * Load a specified code template into the engine + * + * @param $template The code template we shall load which is + * located in 'code' by default + * @return void + */ + public function loadCodeTemplate ($template) { + // Call the inner class' method + $this->getTemplateInstance()->loadCodeTemplate($template); + } + + /** + * Load a specified email template into the engine for later compilation + * with other code/web/email templates. + * + * @param $template The email template we shall load which is + * located in "html" by default + * @return void + */ + public function loadEmailTemplate ($template) { + // Call the inner class' method + $this->getTemplateInstance()->loadEmailTemplate($template); + } + + /** + * Compiles configuration place-holders in all variables. This 'walks' + * through the variable stack 'general'. It interprets all values from that + * variables as configuration entries after compiling them. + * + * @return void + */ + public function compileConfigInVariables () { + // Call the inner class' method + $this->getTemplateInstance()->compileConfigInVariables(); + } + + /** + * Compile all variables by inserting their respective values + * + * @return void + */ + public function compileVariables () { + // Call the inner class' method + $this->getTemplateInstance()->compileVariables(); + } + + /** + * Compile all required templates into the current loaded one + * + * @return void + */ + public function compileTemplate () { + // Call the inner class' method + $this->getTemplateInstance()->compileTemplate(); + } + + /** + * Assigns the last loaded raw template content with a given variable + * + * @param $templateName Name of the template we want to assign + * @param $variableName Name of the variable we want to assign + * @return void + */ + public function assignTemplateWithVariable ($templateName, $variableName) { + // Call the inner class' method + $this->getTemplateInstance()->assignTemplateWithVariable($templateName, $variableName); + } + + /** + * Transfers the content of this template engine to a given response instance + * + * @param $responseInstance An instance of a response class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + // Call the inner class' method + $this->getTemplateInstance()->transportToResponse($responseInstance); + } + + /** + * Assigns all the application data with template variables + * + * @param $applicationInstance A manageable application instance + * @return void + */ + public function assignApplicationData (ManageableApplication $applicationInstance) { + // Call the inner class' method + $this->getTemplateInstance()->assignApplicationData($applicationInstance); + } + + /** + * "Compiles" a variable by replacing {?var?} with it's content + * + * @param $rawCode Raw code to compile + * @param $setMatchAsCode Sets $match if readVariable() returns empty result + * @return $rawCode Compile code with inserted variable value + */ + public function compileRawCode ($rawCode, $setMatchAsCode = FALSE) { + return $this->getTemplateInstance()->compileRawCode($rawCode, $setMatchAsCode); + } + + /** + * Getter for variable group array + * + * @return $variableGroups All variable groups + */ + public final function getVariableGroups () { + // Call the inner class' method + return $this->getTemplateInstance()->getVariableGroups(); + } + + /** + * Getter for raw template data + * + * @return $rawTemplateData The raw data from the template + */ + public function getRawTemplateData () { + // Call the inner class' method + return $this->getTemplateInstance()->getRawTemplateData(); + } + + /** + * Renames a variable in code and in stack + * + * @param $oldName Old name of variable + * @param $newName New name of variable + * @return void + */ + public function renameVariable ($oldName, $newName) { + // Call the inner class' method + $this->getTemplateInstance()->renameVariable($oldName, $newName); + } + + /** + * Renders the given XML content + * + * @param $content Valid XML content or if not set the current loaded raw content + * @return void + * @throws XmlParserException If an XML error was found + */ + public function renderXmlContent ($content = NULL) { + // Call the inner class' method + $this->getTemplateInstance()->renderXmlContent($content); + } + + /** + * Enables or disables language support + * + * @param $languageSupport New language support setting + * @return void + */ + public function enableLanguageSupport ($languageSupport = TRUE) { + // Call the inner class' method + $this->getTemplateInstance()->enableLanguageSupport($languageSupport); + } + + /** + * Checks whether language support is enabled + * + * @return $languageSupport Whether language support is enabled or disabled + */ + public function isLanguageSupportEnabled () { + // Call the inner class' method + return $this->getTemplateInstance()->isLanguageSupportEnabled(); + } + + /** + * Enables or disables XML compacting + * + * @param $xmlCompacting New XML compacting setting + * @return void + */ + public function enableXmlCompacting ($xmlCompacting = TRUE) { + // Call the inner class' method + $this->getTemplateInstance()->enableXmlCompacting($xmlCompacting); + } + + /** + * Checks whether XML compacting is enabled + * + * @return $xmlCompacting Whether XML compacting is enabled or disabled + */ + public function isXmlCompactingEnabled () { + // Call the inner class' method + return $this->getTemplateInstance()->isXmlCompactingEnabled(); + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + public function startElement ($resource, $element, array $attributes) { + // Call the inner class' method + $this->getTemplateInstance()->startElement($resource, $element, $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + public function finishElement ($resource, $nodeName) { + // Call the inner class' method + $this->getTemplateInstance()->finishElement($resource, $nodeName); + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Call the inner class' method but trim the characters before + $this->getTemplateInstance()->characterHandler($resource, trim($characters)); + } + + /** + * Removes all comments, tabs and new-line charcters to compact the content + * + * @param $uncompactedContent The uncompacted content + * @return $compactedContent The compacted content + */ + public function compactContent ($uncompactedContent) { + // Compact it ... + $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent); + + // ... and return it + return $compactedContent; + } + + /** + * Assigns a lot variables into the stack of currently loaded template. + * This method should only be used in very rare circumstances, e.g. when + * you have to copy a whole set of variables into the template engine. + * Before you use this method, please make sure you have considered all + * other possiblities. + * + * @param $variables An array with variables to be assigned + * @return void + */ + public function assignMultipleVariables (array $variables) { + // Call the inner class' method but trim the characters before + $this->getTemplateInstance()->assignMultipleVariables($variables); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/decorator/xml/.htaccess b/inc/main/classes/decorator/xml/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/decorator/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/decorator/xml/class_XmlCompactorDecorator.php b/inc/main/classes/decorator/xml/class_XmlCompactorDecorator.php new file mode 100644 index 00000000..8d7eea8e --- /dev/null +++ b/inc/main/classes/decorator/xml/class_XmlCompactorDecorator.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlCompactorDecorator extends BaseDecorator implements Parseable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class Parser and prepares it for usage + * + * @param $innerParserInstance A Parseable instance + * @return $parserInstance An instance of this parser + */ + public static final function createXmlCompactorDecorator (Parseable $innerParserInstance) { + // Get a new instance + $parserInstance = new XmlCompactorDecorator(); + + // Get a new decorator instance for the template engine + $templateInstance = ObjectFactory::createObjectByConfiguredName('deco_xml_rewriter_template_class', array($innerParserInstance->getTemplateInstance())); + + // Re-set the parser's template instance to the decorator instance + $innerParserInstance->setTemplateInstance($templateInstance); + + // Set the inner parser instance + $parserInstance->setParserInstance($innerParserInstance); + + // Return the prepared instance + return $parserInstance; + } + + /** + * Parses the given XML content + * + * @param $content Valid XML content + * @return void + * @throws XmlCompactorDecoratorException If an XML error was found + */ + public function parseXmlContent ($content) { + // Remove all comments for better compacting + $content = $this->getParserInstance()->getTemplateInstance()->compactContent($content); + + // Parse the content + $this->getParserInstance()->parseXmlContent($content); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/discovery/.htaccess b/inc/main/classes/discovery/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/discovery/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/discovery/class_ b/inc/main/classes/discovery/class_ new file mode 100644 index 00000000..0bc50eb8 --- /dev/null +++ b/inc/main/classes/discovery/class_ @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Discovery extends BaseDiscovery implements Discoverable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @return $discoveryInstance An instance of this discovery class + */ + public final static function create???Discovery () { + // Get an instance of this class + $discoveryInstance = new ???Discovery(); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Discovers the request + * + * @param $requestInstance An instance of a Requestable class + * @return void + * @todo 0% done + */ + public function discover (Requestable $requestInstance) { + $this->partialStub("Please implement this method."); + } + + /** + * Adds the database result in a human-readable format to the helper class + * + * @param $helperInstance An instance of a helper class + * @return void + * @todo 0% done + */ + public function addResultsToHelper (HelpableTemplate $helperInstance) { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/discovery/class_BaseDiscovery.php b/inc/main/classes/discovery/class_BaseDiscovery.php new file mode 100644 index 00000000..0ec5f465 --- /dev/null +++ b/inc/main/classes/discovery/class_BaseDiscovery.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDiscovery extends BaseFrameworkSystem { + /** + * Action name for payment discovery + */ + private $actionName = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Protected setter for action name + * + * @param $actionName Action name to set + * @return void + */ + protected final function setActionName ($actionName) { + $this->actionName = (string) $actionName; + } + + /** + * Private getter for action name + * + * @return $actionName Action name to set + */ + protected final function getActionName () { + return $this->actionName; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/discovery/payment/.htaccess b/inc/main/classes/discovery/payment/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/discovery/payment/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/discovery/payment/class_LocalPaymentDiscovery.php b/inc/main/classes/discovery/payment/class_LocalPaymentDiscovery.php new file mode 100644 index 00000000..9785bef4 --- /dev/null +++ b/inc/main/classes/discovery/payment/class_LocalPaymentDiscovery.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create an instance of this class + * + * @param $filterInstance An instance of a filter + * @return $discoveryInstance An instance of this discovery class + */ + public static final function createLocalPaymentDiscovery (Filterable $filterInstance) { + // Get an instance of this class + $discoveryInstance = new LocalPaymentDiscovery(); + + // Set the action from filter + $discoveryInstance->setActionName($filterInstance->getActionName()); + + // Return the prepared instance + return $discoveryInstance; + } + + /** + * Discovers the request + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function discover (Requestable $requestInstance) { + // Now get a search criteria and set app name and payment action as search critera + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + $criteriaInstance->addCriteria('app_name', $requestInstance->getRequestElement('app')); + $criteriaInstance->addCriteria('payment_action', $this->getActionName() . '_action'); + $criteriaInstance->setLimit(1); + + // Get a wrapper instance + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('payment_db_wrapper_class'); + + // Get result back + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Advanced to next entry and assert on it as it should always be there + assert($resultInstance->valid()); + + // Set the result instance + $this->setResultInstance($resultInstance); + } + + /** + * Adds the database result in a human-readable format to the helper class + * + * @param $helperInstance An instance of a helper class + * @return void + * @todo 0% done + */ + public function addResultsToHelper (HelpableTemplate $helperInstance) { + // Undone part + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/.htaccess b/inc/main/classes/factories/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/cache/.htaccess b/inc/main/classes/factories/cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/cache/class_CacheFactory.php b/inc/main/classes/factories/cache/class_CacheFactory.php new file mode 100644 index 00000000..06016528 --- /dev/null +++ b/inc/main/classes/factories/cache/class_CacheFactory.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CacheFactory extends BaseFactory { + /** + * Singleton instance + */ + private static $selfInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton getter for this class + * + * @return $selfInstance An instance of this class + */ + public static final function getFactory () { + // Is the instance null? + if (is_null(self::$selfInstance)) { + // Set a new one + self::$selfInstance = new CacheFactory(); + } // END - if + + // Return the instance + return self::$selfInstance; + } + + /** + * Creates a configured cache instance + * + * @return $cacheInstance An instance of the configured cache + */ + public function createConfiguredCache () { + // Read the config entry + $cacheType = $this->getConfigInstance()->getConfigEntry('cache_class'); + + // And get a new instance + $cacheInstance = ObjectFactory::createObjectByName($cacheType); + + // Return the instance + return $cacheInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/class_ b/inc/main/classes/factories/class_ new file mode 100644 index 00000000..d05b8441 --- /dev/null +++ b/inc/main/classes/factories/class_ @@ -0,0 +1,37 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Factory extends BaseFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/class_BaseFactory.php b/inc/main/classes/factories/class_BaseFactory.php new file mode 100644 index 00000000..4d5d274b --- /dev/null +++ b/inc/main/classes/factories/class_BaseFactory.php @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFactory extends BaseFrameworkSystem { + /** + * Total objects generated + */ + private static $total = 0; + + /** + * Counter of all objects + */ + private static $objectCounters = array(); + + /** + * Protected constructor + * + * @param $className Name of the real class (not BaseFactory) + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Count given object + * + * @param $className Name of the class we shall count + */ + protected static final function countObject ($className) { + // Count it up in total sum + self::$total++; + + // Do we have an entry? + if (!isset(self::$objectCounters[$className])) { + // No, then generate one + self::$objectCounters[$className] = 0; + } // END - if + + // Count it up again + //* NOISY-DEBUG: */ print __METHOD__.': className=' .$className . PHP_EOL; + self::$objectCounters[$className]++; + } + + /** + * Static getter for total object count + * + * @return $total Total amount of generated objects + */ + public static final function getTotal () { + return self::$total; + } + + /** + * Static getter for all object counters + * + * @return $objectCounters An array with all object counters + */ + public static final function getAllCounters () { + return self::$objectCounters; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/client/.htaccess b/inc/main/classes/factories/client/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/client/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/client/class_ClientFactory.php b/inc/main/classes/factories/client/class_ClientFactory.php new file mode 100644 index 00000000..113a9e25 --- /dev/null +++ b/inc/main/classes/factories/client/class_ClientFactory.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ClientFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates a client object for given protocol. This method uses the + * registry pattern to cache those instances. + * + * @param $protocolInstance An instance of a HandleableProtocol class to create a client object for (e.g. 'http' for a HTTP/1.1 client) + * @param $socketResource A valid socket resource (optional) + * @return $clientInstance An instance of the requested client + */ + public static final function createClientByProtocolInstance (HandleableProtocol $protocolInstance, $socketResource = FALSE) { + // Default is NULL (to initialize variable) + $clientInstance = NULL; + + // Generate registry key + $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client'; + + // Is the key already in registry? + if (Registry::getRegistry()->instanceExists($registryKey)) { + // Then use that instance + $clientInstance = Registry::getRegistry()->getInstance($registryKey); + + // Set socket resource + $clientInstance->setSocketResource($socketResource); + } else { + // Generate object instance + $clientInstance = self::createObjectByConfiguredName($registryKey, array($socketResource)); + + // Set it in registry for later re-use + Registry::getRegistry()->addInstance($registryKey, $clientInstance); + } + + // Return the prepared instance + return $clientInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/database/.htaccess b/inc/main/classes/factories/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/database/class_DatabaseWrapperFactory.php b/inc/main/classes/factories/database/class_DatabaseWrapperFactory.php new file mode 100644 index 00000000..5ecdea49 --- /dev/null +++ b/inc/main/classes/factories/database/class_DatabaseWrapperFactory.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseWrapperFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton socket registry instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $wrapperInstance A database wrapper instance + */ + public static final function createWrapperByConfiguredName ($wrapperName) { + // Get registry instance + $registryInstance = Registry::getRegistry(); + + // Do we have an instance in the registry? + if ($registryInstance->instanceExists($wrapperName)) { + // Then use this instance + $wrapperInstance = $registryInstance->getInstance($wrapperName); + } else { + // Get the registry instance + $wrapperInstance = self::createObjectByConfiguredName($wrapperName); + + // Set the instance in registry for further use + $registryInstance->addInstance($wrapperName, $wrapperInstance); + } + + // Return the instance + return $wrapperInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/html/.htaccess b/inc/main/classes/factories/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/html/class_HtmlNewsFactory.php b/inc/main/classes/factories/html/class_HtmlNewsFactory.php new file mode 100644 index 00000000..135409de --- /dev/null +++ b/inc/main/classes/factories/html/class_HtmlNewsFactory.php @@ -0,0 +1,84 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlNewsFactory extends BaseFactory { + /** + * Instance of a request class + */ + private $requestInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton getter for a special factory instance depending on the given + * request + * + * @param $requestInstance An instance of a request class + * @return $factoryInstance An instance of a HtmlNewsFactory class + */ + public static final function createFactoryByRequest (Requestable $requestInstance) { + // Set default news reader class + $configEntry = 'news_reader_class'; + + // Get "page" + $command = $requestInstance->getRequestElement('command'); + + // Is 'command' used? + if (!empty($command)) { + // Then add it + $configEntry = sprintf('news_reader_%s_class', $command); + + // Get 'action' + $action = $requestInstance->getRequestElement('action'); + + // Is it also there? + if (!empty($action)) { + // Then use both for config entry + $configEntry = sprintf('news_reader_%s_%s_class', $command, $action); + } // END - if + } // END - if + + // Get the news reader class name from config + $className = $requestInstance->getConfigInstance()->getConfigEntry($configEntry); + + // Once we have that name, try to load initialize it + $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); + + // Initialize the reader + $newsInstance->initializeReader(); + + // Return the prepared factory instance + return $newsInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/index/.htaccess b/inc/main/classes/factories/index/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/index/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/index/class_FileStackIndexFactory.php b/inc/main/classes/factories/index/class_FileStackIndexFactory.php new file mode 100644 index 00000000..7a9f23b0 --- /dev/null +++ b/inc/main/classes/factories/index/class_FileStackIndexFactory.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileStackIndexFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) StackableFile instance + * + * @param $stackName Name of the stack's file + * @return $indexInstance An instance of a IndexableStack class + */ + public static final function createFileStackIndexInstance ($fileName, $type) { + // If there is no handler? + if (Registry::getRegistry()->instanceExists($type . '_index')) { + // Get handler from registry + $indexInstance = Registry::getRegistry()->getInstance($type . '_index'); + } else { + // Get the handler instance + $indexInstance = self::createObjectByConfiguredName($type . '_file_stack_index_class', array($fileName)); + + // Add check for interface + assert($indexInstance instanceof IndexableStack); + + // Add it to the registry + Registry::getRegistry()->addInstance($type . '_index', $indexInstance); + } + + // Return the instance + return $indexInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/logger/.htaccess b/inc/main/classes/factories/logger/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/logger/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/logger/class_LoggerFactory.php b/inc/main/classes/factories/logger/class_LoggerFactory.php new file mode 100644 index 00000000..202f23d0 --- /dev/null +++ b/inc/main/classes/factories/logger/class_LoggerFactory.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LoggerFactory extends BaseFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates a logger instance for given FrameworkInterface. This allows every + * class that implements FrameworkInterface to have an own logger. Surely + * this factory and the logger itself cannot have an own logger as this would + * lead to an endless loop: Get factory instance, get a logger for the factory + * instance which ivokes the factory's method again. + * + * @param $objectInstance An instance of a FrameworkInterface class + * @return $loggerInstance An instance of a Logger class + */ + public static final function createLoggerInstance (FrameworkInterface $objectInstance) { + // @TODO Unfinished work + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/login/.htaccess b/inc/main/classes/factories/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/login/class_LoginFactory.php b/inc/main/classes/factories/login/class_LoginFactory.php new file mode 100644 index 00000000..3faf50eb --- /dev/null +++ b/inc/main/classes/factories/login/class_LoginFactory.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LoginFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton login instance for given request instance. + * + * @param $requestInstance An instance of a Requestable class + * @return $loginInstance An instance of a login helper (@TODO Use actual interface name) + */ + public static final function createLoginObjectByRequest (Requestable $requestInstance) { + // Get registry instance + $registryInstance = Registry::getRegistry(); + + // Do we have an instance in the registry? + if ($registryInstance->instanceExists('login_helper')) { + // Then use this instance + $loginInstance = $registryInstance->getInstance('login_helper'); + } else { + // Probe on member instance + try { + // Try to instance member login class + $loginInstance = self::createObjectByConfiguredName('user_login_class'); + + // Test login + $loginInstance->testLogin($requestInstance); + } catch (UnexpectedGuestAccountException $e) { + // Then try guest login + $loginInstance = self::createObjectByConfiguredName('guest_login_class'); + + // Test login again + $loginInstance->testLogin($requestInstance); + } + + // Set the instance in registry for further use + $registryInstance->addInstance('login_helper', $loginInstance); + } + + // Return the instance + return $loginInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/objects/.htaccess b/inc/main/classes/factories/objects/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/objects/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/objects/class_ObjectFactory.php b/inc/main/classes/factories/objects/class_ObjectFactory.php new file mode 100644 index 00000000..718b9403 --- /dev/null +++ b/inc/main/classes/factories/objects/class_ObjectFactory.php @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ObjectFactory extends BaseFactory { + /** + * Protected constructor + * + * @param $className Name of this class + * @return void + */ + protected function __construct ($className = __CLASS__) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Creates a new object given by the name or throws an exception if + * the class was not found. No parameters for the object are currently + * supported. + * + * @param $className Name of the class we shall construct + * @param $args Arguments in an indexed array + * @return $objectInstance An instance of the requested object + * @throws NoClassException If the requested class was not found + * @throws EmptyVariableException If a variable is empty unexpectly + */ + public static final function createObjectByName ($className, array $args=array()) { + // First get an instance of this factory + $factoryInstance = new ObjectFactory(); + + // Is the class name valid and is the class there? + if (empty($className)) { + // Throw an exception here + throw new EmptyVariableException(array($factoryInstance, 'className'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!class_exists($className)) { + // Then throw an exception + throw new NoClassException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND); + } + + // Create method name + $methodName = sprintf('create%s', $className); + + // Run the user function + $objectInstance = call_user_func_array(array($className, $methodName), $args); + + // Count this one up + self::countObject($className); + + // Return the prepared instance + return $objectInstance; + } + + /** + * Creates an object by it's configured name + * + * @param $configEnttry Configuration entry to read + * @param $args Arguments in an indexed array + * @return $objectInstance An instance of the requested object + */ + public static final function createObjectByConfiguredName ($configEntry, array $args=array()) { + // Read the configuration entry + $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($configEntry); + + // Send this to the other factory... + $objectInstance = self::createObjectByName($className, $args); + + // Return the instance + return $objectInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/registry/.htaccess b/inc/main/classes/factories/registry/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/registry/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/registry/class_SocketRegistryFactory.php b/inc/main/classes/factories/registry/class_SocketRegistryFactory.php new file mode 100644 index 00000000..4d2c1dad --- /dev/null +++ b/inc/main/classes/factories/registry/class_SocketRegistryFactory.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketRegistryFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton socket registry instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @return $registryInstance A socket registry instance + */ + public static final function createSocketRegistryInstance () { + // Get registry instance + $registryInstance = Registry::getRegistry(); + + // Do we have an instance in the registry? + if ($registryInstance->instanceExists('socket_registry')) { + // Then use this instance + $registryInstance = $registryInstance->getInstance('socket_registry'); + } else { + // Get the registry instance + $registryInstance = ObjectFactory::createObjectByConfiguredName('socket_registry_class'); + + // Set the instance in registry for further use + $registryInstance->addInstance('socket_registry', $registryInstance); + } + + // Return the instance + return $registryInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/stacks/.htaccess b/inc/main/classes/factories/stacks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/stacks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/stacks/class_FileStackFactory.php b/inc/main/classes/factories/stacks/class_FileStackFactory.php new file mode 100644 index 00000000..81aea448 --- /dev/null +++ b/inc/main/classes/factories/stacks/class_FileStackFactory.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileStackFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton (registry-based) StackableFile instance + * + * @param $prefix Class prefix + * @param $stackName Name of the stack + * @return $stackInstance An instance of a StackableFile class + */ + public static final function createFileStackInstance ($prefix, $stackName) { + // Construct file stack name + $stackFileName = sprintf('%s%s/%s.%s', + FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path'), + FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_file_stacks_path'), + $stackName, + FrameworkConfiguration::getSelfInstance()->getConfigEntry('file_stacks_extension') + ); + + // If there is no handler? + if (Registry::getRegistry()->instanceExists($stackName . '_stack')) { + // Get handler from registry + $stackInstance = Registry::getRegistry()->getInstance($stackName . '_stack'); + } else { + // Get the handler instance + $stackInstance = self::createObjectByConfiguredName($prefix . '_' . $stackName . '_stack_class', array($stackFileName, $prefix . '_' . $stackName)); + + // Add it to the registry + Registry::getRegistry()->addInstance($stackName . '_stack', $stackInstance); + } + + // Return the instance + return $stackInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/user/.htaccess b/inc/main/classes/factories/user/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/user/class_UserFactory.php b/inc/main/classes/factories/user/class_UserFactory.php new file mode 100644 index 00000000..929038dc --- /dev/null +++ b/inc/main/classes/factories/user/class_UserFactory.php @@ -0,0 +1,75 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton user instance for given request instance. + * + * @param $requestInstance An instance of a Requestable class + * @return $userInstance An instance of a user class (@TODO use actual interface name) + */ + public static final function createUserByRequest (Requestable $requestInstance) { + // Get registry instance + $registryInstance = Registry::getRegistry(); + + // Do we have an instance in the registry? + if ($registryInstance->instanceExists('user')) { + // Then use this instance + $userInstance = $registryInstance->getInstance('user'); + } else { + // Probe on member instance + try { + // Get class name + $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry('user_class'); + + // Try to instance it + $userInstance = call_user_func_array(array($className, 'createMemberByRequest'), array($requestInstance)); + } catch (UnexpectedGuestAccountException $e) { + // Then try it with guest account + $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry('guest_class'); + + // Try to instance it + $userInstance = call_user_func_array(array($className, 'createGuestByRequest'), array($requestInstance)); + } + + // Set the instance in registry for further use + $registryInstance->addInstance('user', $userInstance); + } + + // Return the instance + return $userInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/factories/xml/.htaccess b/inc/main/classes/factories/xml/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/factories/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/factories/xml/class_XmlTemplateEngineFactory.php b/inc/main/classes/factories/xml/class_XmlTemplateEngineFactory.php new file mode 100644 index 00000000..7c1e2008 --- /dev/null +++ b/inc/main/classes/factories/xml/class_XmlTemplateEngineFactory.php @@ -0,0 +1,73 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlTemplateEngineFactory extends ObjectFactory { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Returns a singleton network package instance. If an instance is found in + * the registry it will be returned, else a new instance is created and + * stored in the same registry entry. + * + * @param $configEntry Config entry name for the template engine + * @return $templateInstance A template engine instance + */ + public static final function createXmlTemplateEngineInstance ($configEntry) { + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists($configEntry)) { + // Then use this instance + $templateInstance = Registry::getRegistry()->getInstance($configEntry); + } else { + // Now prepare the tags instance + $templateInstance = ObjectFactory::createObjectByConfiguredName($configEntry); + + // Disable language support + $templateInstance->enableLanguageSupport(FALSE); + + /* + * Enable compacting/rewriting of the XML to save bandwidth from XML + * comments. This is expensive and should be avoided in general. + */ + $templateInstance->enableXmlCompacting(); + + // Set the instance in registry for further use + Registry::getRegistry()->addInstance($configEntry, $templateInstance); + } + + // Return the instance + return $templateInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/feature/.htaccess b/inc/main/classes/feature/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/feature/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/feature/class_ b/inc/main/classes/feature/class_ new file mode 100644 index 00000000..4d525b9c --- /dev/null +++ b/inc/main/classes/feature/class_ @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Feature extends BaseFeature implements Feature { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Feature class and prepares it for usage + * + * @return $featureInstance An instance of this Feature class + */ + public final static function create???Feature () { + // Get a new instance + $featureInstance = new ???Feature(); + + // Return the prepared instance + return $featureInstance; + } + + /** + * Checks whether this feature can be made available to other classes. + * + * @return $isAvailable Whether this feature is available + * @todo 0% done + */ + public function isFeatureAvailable () { + // Default is not available + $isAvailable = FALSE; + + // Unfinished: + $this->partialSub('Please implement this method.'); + + // Return status + return $isAvailable; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/feature/class_BaseFeature.php b/inc/main/classes/feature/class_BaseFeature.php new file mode 100644 index 00000000..11870cff --- /dev/null +++ b/inc/main/classes/feature/class_BaseFeature.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFeature extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/feature/class_FrameworkFeature.php b/inc/main/classes/feature/class_FrameworkFeature.php new file mode 100644 index 00000000..4c16afe6 --- /dev/null +++ b/inc/main/classes/feature/class_FrameworkFeature.php @@ -0,0 +1,170 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkFeature extends BaseFrameworkSystem { + // Exception code constants + const EXCEPTION_FEATURE_METHOD_NOT_CALLABLE = 0x400; + + /** + * "Cache" for enabled, available feature instances + * + * A typical available entry looks like this: + * + * array( + * 'is_enabled' => TRUE, + * 'is_available' => TRUE, + * 'instance' => SomeFeature Object + * ) + * + * And a typical disabled entry looks like this: + * + * array( + * 'is_enabled' => FALSE, + * 'is_available' => FALSE, + * 'instance' => NULL + * ) + */ + private static $enabledFeatures = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Checks whether the given feature is enabled in configuration. The user + * shall be able to disable features, even when they *could* be available. + * + * @param $featureName Name of the feature to be checked + * @return $isEnabled Whether the given feature is enabled + */ + public static function isFeatureEnabled ($featureName) { + // Is the cache set? + if (!isset(self::$enabledFeatures[$featureName]['is_enabled'])) { + // Generate config key + $configKey = sprintf('enable_feature_%s', $featureName); + + // Check configuration + self::$enabledFeatures[$featureName]['is_enabled'] = (FrameworkConfiguration::getSelfInstance()->getConfigEntry($configKey) === 'Y'); + } // END - if + + // Return "cached" status + return self::$enabledFeatures[$featureName]['is_enabled']; + } + + /** + * Checks whether the given feature is enabled and available. It may be + * enabled by the user, but is not available due to e.g. a missing PECL + * extension or whatever is needed to have this feature available. If you + * don't write a pre filters for checking PHP requirements, this is the + * method you want to use. + * + * @param $featureName Name of the feature to be checked on availability + * @return $isAvailable Whether the given feature is available + */ + public static function isFeatureAvailable ($featureName) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: featureName=%s - CALLED!', __METHOD__, __LINE__, $featureName)); + + // Is the cache set? + if (!isset(self::$enabledFeatures[$featureName]['is_available'])) { + // Default is not available + self::$enabledFeatures[$featureName]['is_available'] = FALSE; + self::$enabledFeatures[$featureName]['instance'] = NULL; + + // Is the feature enabled? + if (!self::isFeatureEnabled($featureName)) { + // Then it can't be available + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Feature "%s"is not enabled.', __METHOD__, __LINE__, $featureName)); + return FALSE; + } // END - if + + // Create config key (for feature class lookup) + $configKey = sprintf('feature_%s_class', $featureName); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: configKey=%s', __METHOD__, __LINE__, $configKey)); + + // Now try to get the instance + try { + // Try to get an instance + self::$enabledFeatures[$featureName]['instance'] = ObjectFactory::createObjectByConfiguredName($configKey); + + // Now let the feature test itself's availability + self::$enabledFeatures[$featureName]['is_available'] = self::$enabledFeatures[$featureName]['instance']->isFeatureAvailable(); + } catch (NoClassException $e) { + // Feature class not found + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Feature "%s"is not available due to missing feature class. Disabling feature ...', __METHOD__, __LINE__, $featureName)); + } + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: featureName=%s,isAvailable=%d - EXIT!', __METHOD__, __LINE__, $featureName, intval(self::$enabledFeatures[$featureName]['is_available']))); + + // Return "cached" status + return self::$enabledFeatures[$featureName]['is_available']; + } + + /** + * Calls the feature's method and handles some arguments (if not given, + * NULL) to it. Any returned value is being forwarded to the caller, even + * when the doc-tag says 'void' as returned value. + * + * @param $featureName Name of the feature, it must be available at this point + * @param $featureMethod Method name of the feature's class + * @param $args Any arguments that should be handled over + * @return $return Anything the feature's method has returned + * @throws FeatureMethodNotCallableException If the requested method cannot be called + */ + public static function callFeature ($featureName, $featureMethod, array $args = NULL) { + /* + * Please make sure that isFeatureAvailable() has been called and it has + * returned TRUE before calling this method. + */ + assert(self::isFeatureAvailable($featureName)); + + // Array for call-back + $callable = array(self::$enabledFeatures[$featureName]['instance'], 'featureMethod' . self::convertToClassName($featureMethod)); + + // So is the feature's method callable? + if (!is_callable($callable)) { + // Not callable method requested + throw new FeatureMethodNotCallableException(array(self::$enabledFeatures[$featureName]['instance'], $featureMethod), self::EXCEPTION_FEATURE_METHOD_NOT_CALLABLE); + } // END - if + + // Then call it + $return = call_user_func_array($callable, $args); + + // Return any returned value + return $return; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/feature/fuse/.htaccess b/inc/main/classes/feature/fuse/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/feature/fuse/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/feature/fuse/class_FuseFeature.php b/inc/main/classes/feature/fuse/class_FuseFeature.php new file mode 100644 index 00000000..3f68cd7c --- /dev/null +++ b/inc/main/classes/feature/fuse/class_FuseFeature.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FuseFeature extends BaseFeature implements Feature { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Feature class and prepares it for usage + * + * @return $featureInstance An instance of this Feature class + */ + public final static function createFuseFeature () { + // Get a new instance + $featureInstance = new FuseFeature(); + + // Return the prepared instance + return $featureInstance; + } + + /** + * Checks whether this feature can be made available to other classes. + * + * @return $isAvailable Whether this feature is available + * @todo 0% done + */ + public function isFeatureAvailable () { + // Default is not available + $isAvailable = FALSE; + + // Unfinished: + $this->partialSub('Please implement this method.'); + + // Return status + return $isAvailable; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/.htaccess b/inc/main/classes/file_directories/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/binary/.htaccess b/inc/main/classes/file_directories/binary/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/binary/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/binary/class_BaseBinaryFile.php b/inc/main/classes/file_directories/binary/class_BaseBinaryFile.php new file mode 100644 index 00000000..e4c3aeb5 --- /dev/null +++ b/inc/main/classes/file_directories/binary/class_BaseBinaryFile.php @@ -0,0 +1,854 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseBinaryFile extends BaseAbstractFile { + /** + * Separator for header data + */ + const SEPARATOR_HEADER_DATA = 0x01; + + /** + * Separator header->entries + */ + const SEPARATOR_HEADER_ENTRIES = 0x02; + + /** + * Separator group->hash + */ + const SEPARATOR_GROUP_HASH = 0x03; + + /** + * Separator hash->value + */ + const SEPARATOR_HASH_VALUE = 0x04; + + /** + * Separator entry->entry + */ + const SEPARATOR_ENTRIES = 0x05; + + /** + * Separator type->position + */ + const SEPARATOR_TYPE_POSITION = 0x06; + + /** + * Length of count + */ + const LENGTH_COUNT = 20; + + /** + * Length of position + */ + const LENGTH_POSITION = 20; + + /** + * Length of group + */ + const LENGTH_GROUP = 10; + + /** + * Maximum length of entry type + */ + const LENGTH_TYPE = 20; + + //***** Array elements for 'gaps' array ***** + + /** + * Start of gap + */ + const GAPS_INDEX_START = 'start'; + + /** + * End of gap + */ + const GAPS_INDEX_END = 'end'; + + /** + * Current seek position + */ + private $seekPosition = 0; + + /** + * Size of header + */ + private $headerSize = 0; + + /** + * File header + */ + private $header = array(); + + /** + * Seek positions for gaps ("fragmentation") + */ + private $gaps = array(); + + /** + * Seek positions for damaged entries (e.g. mismatching hash sum, ...) + */ + private $damagedEntries = array(); + + /** + * Back-buffer + */ + private $backBuffer = ''; + + /** + * Currently loaded block (will be returned by current()) + */ + private $currentBlock = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init counters and gaps array + $this->initCountersGapsArray(); + } + + /** + * Checks whether the abstracted file only contains gaps by counting all + * gaps' bytes together and compare it to total length. + * + * @return $isGapsOnly Whether the abstracted file only contains gaps + */ + private function isFileOnlyGaps () { + // First/last gap found? + /* Only for debugging + if (isset($this->gaps[0])) { + // Output first and last gap + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] this->gaps[0]=%s,this->gaps[%s]=%s', __METHOD__, __LINE__, print_r($this->gaps[0], TRUE), (count($this->gaps) - 1), print_r($this->gaps[count($this->gaps) - 1], TRUE))); + } // END - if + */ + + // Now count every gap + $gapsSize = 0; + foreach ($this->gaps as $gap) { + // Calculate size of found gap: end-start including both + $gapsSize += ($gap[self::GAPS_INDEX_END] - $gap[self::GAPS_INDEX_START]); + } // END - if + + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] gapsSize=%s,this->headerSize=%s', __METHOD__, __LINE__, $gapsSize, $this->getHeaderSize())); + + // Total gap size + header size must be same as file size + $isGapsOnly = (($this->getHeaderSize() + $gapsSize) == $this->getFileSize()); + + // Return status + return $isGapsOnly; + } + + /** + * Initializes counter for valid entries, arrays for damaged entries and + * an array for gap seek positions. If you call this method on your own, + * please re-analyze the file structure. So you are better to call + * analyzeFile() instead of this method. + * + * @return void + */ + public function initCountersGapsArray () { + // Init counter and seek position + $this->setCounter(0); + $this->setSeekPosition(0); + + // Init arrays + $this->gaps = array(); + $this->damagedEntries = array(); + } + + /** + * Getter for header size + * + * @return $totalEntries Size of file header + */ + public final function getHeaderSize () { + // Get it + return $this->headerSize; + } + + /** + * Setter for header size + * + * @param $headerSize Size of file header + * @return void + */ + public final function setHeaderSize ($headerSize) { + // Set it + $this->headerSize = $headerSize; + } + + /** + * Getter for header array + * + * @return $totalEntries Size of file header + */ + public final function getHeader () { + // Get it + return $this->header; + } + + /** + * Setter for header + * + * @param $header Array for a file header + * @return void + */ + public final function setHeader (array $header) { + // Set it + $this->header = $header; + } + + /** + * Getter for seek position + * + * @return $seekPosition Current seek position (stored here in object) + */ + public final function getSeekPosition () { + // Get it + return $this->seekPosition; + } + + /** + * Setter for seek position + * + * @param $seekPosition Current seek position (stored here in object) + * @return void + */ + protected final function setSeekPosition ($seekPosition) { + // And set it + $this->seekPosition = $seekPosition; + } + + /** + * Updates seekPosition attribute from file to avoid to much access on file. + * + * @return void + */ + public function updateSeekPosition () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Get key (= seek position) + $seekPosition = $this->key(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Setting seekPosition=%s', __METHOD__, __LINE__, $seekPosition)); + + // And set it here + $this->setSeekPosition($seekPosition); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Seeks to beginning of file, updates seek position in this object and + * flushes the header. + * + * @return void + */ + protected function rewindUpdateSeekPosition () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // flushFileHeader must be callable + assert(is_callable(array($this, 'flushFileHeader'))); + + // Seek to beginning of file + $this->rewind(); + + // And update seek position ... + $this->updateSeekPosition(); + + // ... to write it back into the file + $this->flushFileHeader(); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Seeks to old position + * + * @return void + */ + protected function seekToOldPosition () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Seek to currently ("old") saved position + $this->seek($this->getSeekPosition()); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Checks whether the block separator has been found + * + * @param $str String to look in + * @return $isFound Whether the block separator has been found + */ + public static function isBlockSeparatorFound ($str) { + // Determine it + $isFound = (strpos($str, chr(self::SEPARATOR_ENTRIES)) !== FALSE); + + // Return result + return $isFound; + } + + /** + * Initializes the back-buffer by setting it to an empty string. + * + * @return void + */ + private function initBackBuffer () { + // Simply call the setter + $this->setBackBuffer(''); + } + + /** + * Setter for backBuffer field + * + * @param $backBuffer Characters to "store" in back-buffer + * @return void + */ + private function setBackBuffer ($backBuffer) { + // Cast to string (so no arrays or objects) + $backBuffer = (string) $backBuffer; + + // ... and set it + $this->backBuffer = $backBuffer; + } + + /** + * Getter for backBuffer field + * + * @return $backBuffer Characters "stored" in back-buffer + */ + private function getBackBuffer () { + return $this->backBuffer; + } + + /** + * Setter for currentBlock field + * + * @param $currentBlock Characters to set a currently loaded block + * @return void + */ + private function setCurrentBlock ($currentBlock) { + // Cast to string (so no arrays or objects) + $currentBlock = (string) $currentBlock; + + // ... and set it + $this->currentBlock = $currentBlock; + } + + /** + * Gets currently read data + * + * @return $current Currently read data + */ + public function getCurrentBlock () { + // Return it + return $this->currentBlock; + } + + /** + * Initializes this file class + * + * @param $fileName Name of this abstract file + * @return void + */ + protected function initFile ($fileName) { + // Get a file i/o pointer instance + $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileName)); + + // ... and set it here + $this->setPointerInstance($pointerInstance); + } + + /** + * Writes data at given position + * + * @param $seekPosition Seek position + * @param $data Data to be written + * @param $flushHeader Whether to flush the header (default: flush) + * @return void + */ + public function writeData ($seekPosition, $data, $flushHeader = TRUE) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data()=%d - CALLED!', __METHOD__, __LINE__, $seekPosition, strlen($data))); + + // Write data at given position + $this->getPointerInstance()->writeAtPosition($seekPosition, $data); + + // Increment counter + $this->incrementCounter(); + + // Update seek position + $this->updateSeekPosition(); + + // Flush the header? + if ($flushHeader === TRUE) { + // Flush header + $this->flushFileHeader(); + + // Seek to old position + $this->seekToOldPosition(); + } // END - if + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Marks the currently loaded block as empty (with length of the block) + * + * @param $length Length of the block + * @return void + */ + protected function markCurrentBlockAsEmpty ($length) { + // Get current seek position + $currentPosition = $this->key(); + + // Now add it as gap entry + array_push($this->gaps, array( + self::GAPS_INDEX_START => ($currentPosition - $length), + self::GAPS_INDEX_END => $currentPosition, + )); + } + + /** + * Checks whether the file header is initialized + * + * @return $isInitialized Whether the file header is initialized + */ + public function isFileHeaderInitialized () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Default is not initialized + $isInitialized = FALSE; + + // Is the file initialized? + if ($this->isFileInitialized()) { + // Some bytes has been written, so rewind to start of it. + $rewindStatus = $this->rewind(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] rewindStatus=%s', __METHOD__, __LINE__, $rewindStatus)); + + // Is the rewind() call successfull? + if ($rewindStatus != 1) { + // Something bad happened + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Could not rewind().', __METHOD__, __LINE__)); + } // END - if + + // Read file header + $this->readFileHeader(); + + // The above method does already check the header + $isInitialized = TRUE; + } // END - if + + // Return result + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] isInitialized=%d - EXIT!', __METHOD__, __LINE__, intval($isInitialized))); + return $isInitialized; + } + + /** + * Checks whether the assigned file has been initialized + * + * @return $isInitialized Whether the file's size is zero + */ + public function isFileInitialized () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Get it from iterator which holds the pointer instance. If FALSE is returned + $fileSize = $this->size(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] fileSize=%s', __METHOD__, __LINE__, $fileSize)); + + /* + * The returned file size should not be FALSE or NULL as this means + * that the pointer class does not work correctly. + */ + assert(is_int($fileSize)); + + // Is more than 0 returned? + $isInitialized = ($fileSize > 0); + + // Return result + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] isInitialized=%d - EXIT!', __METHOD__, __LINE__, intval($isInitialized))); + return $isInitialized; + } + + /** + * Creates the assigned file + * + * @return void + */ + public function createFileHeader () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // The file's header should not be initialized here + assert(!$this->isFileHeaderInitialized()); + + // Simple flush file header which will create it. + $this->flushFileHeader(); + + // Rewind seek position (to beginning of file) and update/flush file header + $this->rewindUpdateSeekPosition(); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Pre-allocates file (if enabled) with some space for later faster write access. + * + * @param $type Type of the file + * @return void + */ + public function preAllocateFile ($type) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Is it enabled? + if ($this->getConfigInstance()->getConfigEntry($type . '_pre_allocate_enabled') != 'Y') { + // Not enabled + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Not pre-allocating file.', __METHOD__, __LINE__)); + + // Don't continue here. + return; + } // END - if + + // Message to user + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Pre-allocating file ...', __METHOD__, __LINE__)); + + // Calculate minimum length for one entry + $minLengthEntry = $this->getBlockInstance()->calculateMinimumBlockLength(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] minLengthEntry=%s', __METHOD__, __LINE__, $minLengthEntry)); + + // Calulcate seek position + $seekPosition = $minLengthEntry * $this->getConfigInstance()->getConfigEntry($type . '_pre_allocate_count'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s', __METHOD__, __LINE__, $seekPosition)); + + // Now simply write a NUL there. This will pre-allocate the file. + $this->writeData($seekPosition, chr(0)); + + // Rewind seek position (to beginning of file) and update/flush file header + $this->rewindUpdateSeekPosition(); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + */ + public function determineSeekPosition () { + // Call pointer instance + return $this->getPointerInstance()->determineSeekPosition(); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + */ + public function seek ($offset, $whence = SEEK_SET) { + // Call pointer instance + return $this->getPointerInstance()->seek($offset, $whence); + } + + /** + * Reads given amount of bytes from file. + * + * @param $bytes Amount of bytes to read + * @return $data Data read from file + */ + public function read ($bytes = NULL) { + // $bytes shall be integer + assert(is_int($bytes)); + + // Call pointer instance + return $this->getPointerInstance()->read($bytes); + } + + /** + * Rewinds to the beginning of the file + * + * @return $status Status of this operation + */ + public function rewind () { + // Call pointer instance + return $this->getPointerInstance()->rewind(); + } + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + */ + public function analyzeFile () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Make sure the file is initialized + assert($this->isFileInitialized()); + + // Init counters and gaps array + $this->initCountersGapsArray(); + + // Output message (as this may take some time) + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Analyzing file structure ... (this may take some time)', __METHOD__, __LINE__)); + + // First rewind to the begining + $this->rewind(); + + // Then try to load all entries + while ($this->valid()) { + // Go to next entry + $this->next(); + + // Get current entry + $current = $this->getCurrentBlock(); + + /* + * If the block is empty, maybe the whole file is? This could mean + * that the file has been pre-allocated. + */ + if (empty($current)) { + // Then skip this part + continue; + } // END - if + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] current()=%d', __METHOD__, __LINE__, strlen($current))); + } // END - while + + // If the last read block is empty, check gaps + if (empty($current)) { + // Output message + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Found a total of %s gaps.', __METHOD__, __LINE__, count($this->gaps))); + + // Check gaps, if the whole file is empty. + if ($this->isFileOnlyGaps()) { + // Only gaps, so don't continue here. + return; + } // END - if + + /* + * The above call has calculated a total size of all gaps. If the + * percentage of gaps passes a "soft" limit and last + * defragmentation is to far in the past, or if a "hard" limit has + * reached, run defragmentation. + */ + if ($this->isDefragmentationNeeded()) { + // Run "defragmentation" + $this->doRunDefragmentation(); + } // END - if + } // END - if + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Advances to next "block" of bytes + * + * @return void + */ + public function next () { + // Is there nothing to read? + if (!$this->valid()) { + // Nothing to read + return; + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] key()=%d', __FUNCTION__, __LINE__, $this->key())); + + // Make sure the block instance is set + assert($this->getBlockInstance() instanceof CalculatableBlock); + + // First calculate minimum block length + $length = $this->getBlockInstance()->calculateMinimumBlockLength(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] length=%s', __FUNCTION__, __LINE__, $length)); + + // Short be more than zero! + assert($length > 0); + + // Read possibly back-buffered bytes from previous call of next(). + $data = $this->getBackBuffer(); + + /* + * Read until a entry/block separator has been found. The next read + * "block" may not fit, so this loop will continue until the EOB or EOF + * has been reached whatever comes first. + */ + while ((!$this->isEndOfFileReached()) && (!self::isBlockSeparatorFound($data))) { + // Then read the next possible block + $block = $this->read($length); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] block()=%d,length=%s', __FUNCTION__, __LINE__, strlen($block), $length)); + + // Is it all empty? + if (strlen(trim($block)) == 0) { + // Mark this block as empty + $this->markCurrentBlockAsEmpty(strlen($block)); + + // Skip to next block + continue; + } // END - if + + // At this block then + $data .= $block; + + // A debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] data()=%d', __FUNCTION__, __LINE__, strlen($data))); + } // END - while + + // EOF reached? + if ($this->isEndOfFileReached()) { + // Set whole data as current read block + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('Calling setCurrentBlock(' . strlen($data) . ') ...'); + $this->setCurrentBlock($data); + + // Then abort here silently + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('EOF reached.'); + return; + } // END - if + + /* + * Init back-buffer which is the data that has been found beyond the + * separator. + */ + $this->initBackBuffer(); + + // Separate data + $dataArray = explode(chr(self::SEPARATOR_ENTRIES), $data); + + // This array must contain two elements + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('dataArray=' . print_r($dataArray, TRUE)); + assert(count($dataArray) == 2); + + // Left part is the actual block, right one the back-buffer data + $this->setCurrentBlock($dataArray[0]); + $this->setBackBuffer($dataArray[1]); + } + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + */ + public function valid () { + // Make sure the block instance is set + assert($this->getBlockInstance() instanceof Block); + + // First calculate minimum block length + $length = $this->getBlockInstance()->calculateMinimumBlockLength(); + + // Short be more than zero! + assert($length > 0); + + // Get current seek position + $seekPosition = $this->key(); + + // Then try to read it + $data = $this->read($length); + + // If some bytes could be read, all is fine + $isValid = ((is_string($data)) && (strlen($data) > 0)); + + // Get header size + $headerSize = $this->getHeaderSize(); + + // Is the seek position at or beyond the header? + if ($seekPosition >= $headerSize) { + // Seek back to old position + $this->seek($seekPosition); + } else { + // Seek directly behind the header + $this->seek($headerSize); + } + + // Return result + return $isValid; + } + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + */ + public function key () { + // Call pointer instance + return $this->getPointerInstance()->determineSeekPosition(); + } + + /** + * Reads the file header + * + * @return void + */ + public function readFileHeader () { + // Make sure the block instance is set + assert($this->getBlockInstance() instanceof Block); + + // Call block instance + $this->getBlockInstance()->readFileHeader(); + } + + /** + * Flushes the file header + * + * @return void + */ + public function flushFileHeader () { + // Make sure the block instance is set + assert($this->getBlockInstance() instanceof Block); + + // Call block instance + $this->getBlockInstance()->flushFileHeader(); + } + + /** + * Searches for next suitable gap the given length of data can fit in + * including padding bytes. + * + * @param $length Length of raw data + * @return $seekPosition Found next gap's seek position + */ + public function searchNextGap ($length) { + // If the file is only gaps, no need to seek + if ($this->isFileOnlyGaps()) { + // The first empty block is the first one right after the header + return ($this->getHeaderSize() + 1); + } // END - if + + // @TODO Unfinished + $this->partialStub('length=' . $length); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/binary/index/.htaccess b/inc/main/classes/file_directories/binary/index/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/binary/index/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/binary/index/class_IndexFile.php b/inc/main/classes/file_directories/binary/index/class_IndexFile.php new file mode 100644 index 00000000..8fd85d3d --- /dev/null +++ b/inc/main/classes/file_directories/binary/index/class_IndexFile.php @@ -0,0 +1,85 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class IndexFile extends BaseBinaryFile implements Block { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this File class and prepares it for usage + * + * @param $fileName Name of the index file + * @param $blockInstance An instance of a Block class + * @return $fileInstance An instance of this File class + */ + public final static function createIndexFile ($fileName, Block $blockInstance) { + // Get a new instance + $fileInstance = new IndexFile(); + + // Set block instance here for callbacks + $fileInstance->setBlockInstance($blockInstance); + + // Init this abstract file + $fileInstance->initFile($fileName); + + // Return the prepared instance + return $fileInstance; + } + + /** + * Writes given value to the file and returns a hash and gap position for it + * + * @param $groupId Group identifier + * @param $value Value to be added to the stack + * @return $data Hash and gap position + * @throws UnsupportedOperationException If this method is called + */ + public function writeValueToFile ($groupId, $value) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Writes given raw data to the file and returns a gap position and length + * + * @param $groupId Group identifier + * @param $hash Hash from encoded value + * @param $encoded Encoded value to be written to the file + * @return $data Gap position and length of the raw data + * @throws UnsupportedOperationException If this method is called + */ + public function writeDataToFreeGap ($groupId, $hash, $encoded) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',encoded()=' . strlen($encoded)); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/binary/stack/.htaccess b/inc/main/classes/file_directories/binary/stack/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/binary/stack/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/binary/stack/class_StackFile.php b/inc/main/classes/file_directories/binary/stack/class_StackFile.php new file mode 100644 index 00000000..cf562b87 --- /dev/null +++ b/inc/main/classes/file_directories/binary/stack/class_StackFile.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class StackFile extends BaseBinaryFile implements Block { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this File class and prepares it for usage + * + * @param $fileName Name of the stack file + * @param $blockInstance An instance of a Block class + * @return $fileInstance An instance of this File class + */ + public final static function createStackFile ($fileName, Block $blockInstance) { + // Get a new instance + $fileInstance = new StackFile(); + + // Set block instance here for callbacks + $fileInstance->setBlockInstance($blockInstance); + + // Init this abstract file + $fileInstance->initFile($fileName); + + // Return the prepared instance + return $fileInstance; + } + + /** + * Writes given value to the file and returns a hash and gap position for it + * + * @param $groupId Group identifier + * @param $value Value to be added to the stack + * @return $data Hash and gap position + */ + public function writeValueToFile ($groupId, $value) { + // Make sure no objects/resources are added as the serialization may fail + assert(!is_object($value)); + assert(!is_resource($value)); + + // Encode/convert the value into a "binary format" + $encoded = $this->encodeData($value); + + // Get a strong hash for the "encoded" data + $hash = self::hash($encoded); + + // Then write it to the next free gap + $data = $this->getBlockInstance()->writeDataToFreeGap($groupId, $hash, $encoded); + + // Return info + return $data; + } + + /** + * Writes given raw data to the file and returns a gap position and length + * + * @param $groupId Group identifier + * @param $hash Hash from encoded value + * @param $encoded Encoded value to be written to the file + * @return $data Gap position and length of the raw data + * @throws UnsupportedOperationException If this method is called + */ + public function writeDataToFreeGap ($groupId, $hash, $encoded) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',hash=' . $hash . ',encoded()=' . strlen($encoded)); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/class_BaseAbstractFile.php b/inc/main/classes/file_directories/class_BaseAbstractFile.php new file mode 100644 index 00000000..e26c58bb --- /dev/null +++ b/inc/main/classes/file_directories/class_BaseAbstractFile.php @@ -0,0 +1,201 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseAbstractFile extends BaseFrameworkSystem { + /** + * Counter for total entries + */ + private $totalEntries = 0; + + /** + * The current file we are working in + */ + private $fileName = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Destructor for cleaning purposes, etc + * + * @return void + */ + public final function __destruct() { + // Try to close a file + $this->closeFile(); + + // Call the parent destructor + parent::__destruct(); + } + + /** + * "Getter" for abstracted file size + * + * @return $fileSize Size of abstracted file + */ + public function getFileSize () { + // Call pointer instanze + return $this->getPointerInstance()->getFileSize(); + } + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + public final function getCounter () { + // Get it + return $this->totalEntries; + } + + /** + * Setter for total entries + * + * @param $totalEntries Total entries in this file + * @return void + */ + protected final function setCounter ($counter) { + // Set it + $this->totalEntries = $counter; + } + + /** + * Increment counter + * + * @return void + */ + protected final function incrementCounter () { + // Get it + $this->totalEntries++; + } + + /** + * Getter for the file pointer + * + * @return $filePointer The file pointer which shall be a valid file resource + * @throws UnsupportedOperationException If this method is called + */ + public final function getPointer () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for file name + * + * @param $fileName The new file name + * @return void + */ + protected final function setFileName ($fileName) { + $fileName = (string) $fileName; + $this->fileName = $fileName; + } + + /** + * Getter for file name + * + * @return $fileName The current file name + */ + public final function getFileName () { + return $this->fileName; + } + + /** + * Close a file source and set it's instance to null and the file name + * to empty + * + * @return void + */ + private function closeFile () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName())); + + // Close down pointer instance as well by unsetting it + $this->unsetPointerInstance(); + + // Remove file name + $this->setFileName(''); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__)); + } + + /** + * Size of this file + * + * @return $size Size (in bytes) of file + * @todo Handle seekStatus + */ + public function size () { + // Call pointer instance + return $this->getPointerInstance()->size(); + } + + /** + * Read data a file pointer + * + * @return mixed The result of fread() + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + */ + public function readFromFile () { + // Call pointer instance + return $this->getPointerInstance()->readFromFile(); + } + + /** + * Write data to a file pointer + * + * @param $dataStream The data stream we shall write to the file + * @return mixed Number of writes bytes or FALSE on error + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + * an invalid file resource + */ + public function writeToFile ($dataStream) { + // Call pointer instance + return $this->getPointerInstance()->writeToFile($dataStream); + } + + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + */ + public final function isEndOfFileReached () { + // Call pointer instance + return $this->getPointerInstance()->isEndOfFileReached(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/class_BaseFileIo.php b/inc/main/classes/file_directories/class_BaseFileIo.php new file mode 100644 index 00000000..d52d02fa --- /dev/null +++ b/inc/main/classes/file_directories/class_BaseFileIo.php @@ -0,0 +1,196 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFileIo extends BaseFrameworkSystem { + /** + * The current file we are working in + */ + private $fileName = ''; + + /** + * The file pointer + */ + private $filePointer = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Destructor for cleaning purposes, etc + * + * @return void + */ + public final function __destruct() { + // Is there a resource pointer? Then we have to close the file here! + if (is_resource($this->getPointer())) { + // Try to close a file + $this->closeFile(); + } // END - if + + // Call the parent destructor + parent::__destruct(); + } + + /** + * Close a file source and set it's instance to null and the file name + * to empty. + * + * @return void + * @throws NullPointerException If the file pointer instance is not set by setPointer() + * @throws InvalidResourceException If there is being set + */ + private function closeFile () { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: fileName=%s - CALLED!', __METHOD__, __LINE__, $this->getFileName())); + + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: Closing file %s ...', __METHOD__, __LINE__, $this->getFileName())); + + // Close the file pointer and reset the instance variable + @fclose($this->getPointer()); + $this->setPointer(NULL); + $this->setFileName(''); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: EXIT!', __METHOD__, __LINE__)); + } + + /** + * Setter for the file pointer + * + * @param $filePointer File resource + * @return void + */ + protected final function setPointer ($filePointer) { + $this->filePointer = $filePointer; + } + + /** + * Getter for the file pointer + * + * @return $filePointer The file pointer which shall be a valid file resource + */ + public final function getPointer () { + return $this->filePointer; + } + + /** + * Setter for file name + * + * @param $fileName The new file name + * @return void + */ + protected final function setFileName ($fileName) { + $fileName = (string) $fileName; + $this->fileName = $fileName; + } + + /** + * Getter for file name + * + * @return $fileName The current file name + */ + public final function getFileName () { + return $this->fileName; + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + */ + public final function determineSeekPosition () { + return ftell($this->getPointer()); + } + + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + */ + public final function isEndOfFileReached () { + return feof($this->getPointer()); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + */ + public function seek ($offset, $whence = SEEK_SET) { + // Seek to position + $status = fseek($this->getPointer(), $offset, $whence); + + // Return status + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] status=%d', __METHOD__, __LINE__, $status)); + return $status; + } + + /** + * Size of this file + * + * @return $size Size (in bytes) of file + * @todo Handle seekStatus + */ + public function size () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Get current seek position + $seekPosition = $this->determineSeekPosition(); + + // Seek to end + $seekStatus = $this->seek(0, SEEK_END); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus)); + + // Get position again (which is the end of the file) + $size = $this->determineSeekPosition(); + + // Reset seek position to old + $this->seek($seekPosition); + + // Return size + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] size=%s - EXIT!', __METHOD__, __LINE__, $size)); + return $size; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/directory/.htaccess b/inc/main/classes/file_directories/directory/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/directory/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php b/inc/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php new file mode 100644 index 00000000..b855a62c --- /dev/null +++ b/inc/main/classes/file_directories/directory/class_FrameworkDirectoryPointer.php @@ -0,0 +1,256 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkDirectoryPointer extends BaseFrameworkSystem implements FrameworkDirectory { + /** + * The current path we are working in + */ + private $pathName = ''; + + /** + * The directory iterator instance + */ + private $iteratorInstance = NULL; + + /** + * Protected constructor + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Destructor for cleaning purposes, etc + */ + public function __destruct() { + // Is there a resource pointer? Then we have to close the directory here! + if ($this->getDirectoryIteratorInstance() instanceof DirectoryIterator) { + // Try to close a directory + $this->closeDirectory(); + } // END - if + + // Call the parent destructor + parent::__destruct(); + } + + /** + * Create a directory pointer based on the given path. The path will also + * be verified here. + * + * @param $pathName The path name we shall pass to opendir() + * @param $inConstructor If we are in de/con-structor or from somewhere else + * @return $pointerInstance A prepared instance of FrameworkDirectoryPointer + * @throws PathIsEmptyException If the provided path name is empty + * @throws InvalidPathStringException If the provided path name is not a string + * @throws PathIsNoDirectoryException If the provided path name is not valid + * @throws PathReadProtectedException If the provided path name is read-protected + * @todo Get rid of inConstructor, could be old-lost code. + */ + public static final function createFrameworkDirectoryPointer ($pathName, $inConstructor = FALSE) { + // Some pre-sanity checks... + if (is_null($pathName)) { + // No pathname given + if ($inConstructor) { + return NULL; + } else { + throw new PathIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } + } elseif (!is_string($pathName)) { + // Is not a string + if ($inConstructor) { + return NULL; + } else { + throw new InvalidPathStringException(NULL, self::EXCEPTION_INVALID_STRING); + } + } elseif (!is_dir($pathName)) { + // Not a directory + if ($inConstructor) { + return NULL; + } else { + throw new PathIsNoDirectoryException($pathName, self::EXCEPTION_INVALID_PATH_NAME); + } + } elseif (!is_readable($pathName)) { + // Not readable + if ($inConstructor) { + return NULL; + } else { + throw new PathReadProtectedException($pathName, self::EXCEPTION_READ_PROTECED_PATH); + } + } + + // Create new instance + $pointerInstance = new FrameworkDirectoryPointer(); + + // Get an iterator for the directory + $iteratorInstance = new DirectoryIterator($pathName); + + // ... and rewind back + $iteratorInstance->rewind(); + + // Set directory pointer and path name + $pointerInstance->setDirectoryIteratorInstance($iteratorInstance); + $pointerInstance->setPathName($pathName); + + // Return the instance + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: Opened pathName=' . $pathName . ' - EXIT!'); + return $pointerInstance; + } + + /** + * Read raw lines of data from a directory pointer and return the data + * + * @return $currentEntry Current entry from encapsulated iterator + */ + public function readRawDirectory () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . '] - CALLED!'); + + // Can the next entry be read? + assert($this->getDirectoryIteratorInstance()->valid()); + + // Read data from the directory pointer and return it + $currentEntry = $this->getDirectoryIteratorInstance()->current(); + + // Return found entry + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: currentEntry[]=' . gettype($currentEntry) . ' - EXIT!'); + return $currentEntry; + } + + /** + * Read lines from the current directory pointer except some parts + * + * @param $except Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored + * @return string Directory and/or file names read from the current directory pointer + */ + public function readDirectoryExcept (array $except = array()) { + // No exceptions given? + if (count($except) == 0) { + // No exception given, so read all files and directories, but not recursive + self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: No exceptions given, please use readRawDirectory() instead!'); + return $this->readRawDirectory(); + } elseif (!$this->getDirectoryIteratorInstance()->valid()) { + // No more left to read + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: EOD reached.'); + return NULL; + } + + // Init raw line + $rawLine = NULL; + + // Read a raw line... + $currentEntry = $this->readRawDirectory(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: currentEntry[]=' . gettype($currentEntry)); + + // Shall we exclude directories? + if (is_object($currentEntry)) { + // Get file name + $rawLine = $currentEntry->getFilename(); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine . ',isDot=' . intval($this->getDirectoryIteratorInstance()->isDot())); + + // Is it a dot-directory or excluded? + if (($this->getDirectoryIteratorInstance()->isDot()) || (in_array($rawLine, $except))) { + // To next entry + $this->getDirectoryIteratorInstance()->next(); + + // Exclude this part + $rawLine = $this->readDirectoryExcept($except); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!'); + } // END - if + } // END - if + + // To next entry + $this->getDirectoryIteratorInstance()->next(); + + // Return read line + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine); + return $rawLine; + } + + /** + * Close a directory source and set it's instance to null and the path name + * to empty + * + * @return void + */ + public function closeDirectory () { + // Close the directory by unsetting it + $this->unsetDirectoryIteratorInstance(); + $this->setPathName(''); + } + + /** + * Setter for the directory pointer + * + * @param $iteratorInstance An instanceof a DirectoryIterator class + * @return void + */ + protected final function setDirectoryIteratorInstance (DirectoryIterator $iteratorInstance) { + // Set instance + $this->iteratorInstance = $iteratorInstance; + } + + /** + * Getter for the directory pointer + * + * @return $iteratorInstance The directory pointer which shall be a valid directory resource + */ + public final function getDirectoryIteratorInstance () { + return $this->iteratorInstance; + } + + /** + * Remove directory iterator instance (effectively closing it) by setting + * it to NULL. This will trigger a call on the destructor which will then + * "close" the iterator. + * + * @param $iteratorInstance An instanceof a DirectoryIterator class + * @return void + */ + protected final function unsetDirectoryIteratorInstance () { + // "Unset" the instance + $this->iteratorInstance = NULL; + } + + /** + * Setter for path name + * + * @param $pathName The new path name + * @return void + */ + protected final function setPathName ($pathName) { + $pathName = (string) $pathName; + $this->pathName = $pathName; + } + + /** + * Getter for path name + * + * @return $pathName The current path name + */ + public final function getPathName () { + return $this->pathName; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/input/.htaccess b/inc/main/classes/file_directories/input/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/input/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/input/raw/.htaccess b/inc/main/classes/file_directories/input/raw/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/input/raw/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php b/inc/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php new file mode 100644 index 00000000..9fb6e1db --- /dev/null +++ b/inc/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php @@ -0,0 +1,174 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a file pointer based on the given file. The file will also + * be verified here. + * + * @param $fileName The file name we shall pass to fopen() + * @throws FileIsEmptyException If the provided file name is empty. + * @throws FileIoException If the file is not reachable + * @throws FileReadProtectedException If the file is not found or cannot be read + * @throws FileNotFoundException If the file does not exist + * @return void + */ + public static final function createFrameworkRawFileInputPointer ($fileName) { + // Some pre-sanity checks... + if ((is_null($fileName)) || (empty($fileName))) { + // No filename given + throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) { + // File cannot be accessed (due to open_basedir restriction) + throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE); + } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (file_exists($fileName))) { + // File exists but cannot be read from + throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); + } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (!file_exists($fileName))) { + // File does not exist + throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_NOT_FOUND); + } + + // Try to open a handler + $filePointer = fopen($fileName, 'rb'); + if ((is_null($filePointer)) || ($filePointer === FALSE)) { + // Something bad happend + throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID); + } // END - if + + // Create new instance + $pointerInstance = new FrameworkRawFileInputPointer(); + + // Set file pointer and file name + $pointerInstance->setPointer($filePointer); + $pointerInstance->setFileName($fileName); + + // Return the instance + return $pointerInstance; + } + + /** + * Read data a file pointer + * + * @return mixed The result of fread() + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + */ + public function readFromFile () { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } + + // Read data from the file pointer and return it + return $this->read(1024); + } + + /** + * Reads a line, maximum 4096 Bytes from current file pointer + * + * @return $data Read data from file + * @throws UnsupportedOperationException If this method is called + */ + public function readLine () { + // Not supported in binary files ... + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Reads given amount of bytes from file. + * + * @param $bytes Amount of bytes to read + * @return $data Data read from file + */ + public function read ($bytes = NULL) { + // $bytes shall be integer + assert(is_int($bytes)); + + // Try to read given characters + $data = fread($this->getPointer(), $bytes); + + // Then return it + return $data; + } + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function analyzeFile () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Advances to next "block" of bytes + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function next () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + * @throws UnsupportedOperationException If this method is called + */ + public function valid () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + * @throws UnsupportedOperationException If this method is called + */ + public function key () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/input/text/.htaccess b/inc/main/classes/file_directories/input/text/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/input/text/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php b/inc/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php new file mode 100644 index 00000000..16e43d52 --- /dev/null +++ b/inc/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php @@ -0,0 +1,176 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a file pointer based on the given file. The file will also + * be verified here. + * + * @param $fileName The file name we shall pass to fopen() + * @throws FileIsEmptyException If the provided file name is empty. + * @throws FileIoException If the file is not reachable + * @throws FileReadProtectedException If the file cannot be read from + * @return void + */ + public static final function createFrameworkTextFileInputPointer ($fileName) { + // Some pre-sanity checks... + if ((is_null($fileName)) || (empty($fileName))) { + // No filename given + throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) { + // File cannot be reached + throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE); + } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (!file_exists($fileName))) { + // File does not exist! + throw new FileNotFoundException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); + } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (file_exists($fileName))) { + // File cannot be read from (but exists) + throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); + } + + // Try to open a handler + $filePointer = fopen($fileName, 'r'); + if ((is_null($filePointer)) || ($filePointer === FALSE)) { + // Something bad happend + throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID); + } // END - if + + // Create new instance + $pointerInstance = new FrameworkTextFileInputPointer(); + + // Set file pointer and file name + $pointerInstance->setPointer($filePointer); + $pointerInstance->setFileName($fileName); + + // Return the instance + return $pointerInstance; + } + + /** + * Read data a file pointer + * + * @return $data Read data from file + */ + public function readFromFile () { + // Read 1024 Byte data from the file pointer and return it + return $this->read(1024); + } + + /** + * Reads a line, maximum 4096 Bytes from current file pointer + * + * @return $data Read data from file + */ + public function readLine () { + // Read whole line from the file pointer and return it + return $this->read(); + } + + /** + * Reads given amount of bytes from file. + * + * @param $bytes Amount of bytes to read or whole line (only text files) + * @return $data Data read from file + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + */ + public function read ($bytes = NULL) { + // Some sanity checks + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } + + // Is $bytes set? + if (is_int($bytes)) { + // Try to read given characters + $data = fgets($this->getPointer(), $bytes); + } else { + // Try to read whole line + $data = fgets($this->getPointer()); + } + + // Then return it + return $data; + } + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function analyzeFile () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Advances to next "block" of bytes + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function next () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + * @throws UnsupportedOperationException If this method is called + */ + public function valid () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + * @throws UnsupportedOperationException If this method is called + */ + public function key () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/io/.htaccess b/inc/main/classes/file_directories/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php b/inc/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php new file mode 100644 index 00000000..ae372f35 --- /dev/null +++ b/inc/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php @@ -0,0 +1,274 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputPointer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a file pointer based on the given file. The file will also + * be verified here. + * + * @param $fileName The file name we shall pass to fopen() + * @return void + * @throws FileIsEmptyException If the given file name is NULL or empty + * @throws FileReadProtectedException If PHP cannot read an existing file + * @throws FileWriteProtectedException If PHP cannot write an existing file + * @throws PathWriteProtectedException If PHP cannot write to an existing path + * @throws FileIoException If fopen() returns not a file resource + */ + public static final function createFrameworkFileInputOutputPointer ($fileName) { + // Some pre-sanity checks... + if ((is_null($fileName)) || (empty($fileName))) { + // No filename given + throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!BaseFrameworkSystem::isReachableFilePath($fileName)) { + // File exists but cannot be read + throw new FileIoException($fileName, self::EXCEPTION_FILE_NOT_REACHABLE); + } elseif ((!BaseFrameworkSystem::isReadableFile($fileName)) && (file_exists($fileName))) { + // File exists but cannot be read + throw new FileReadProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_READ); + } elseif ((file_exists($fileName)) && (!is_writable($fileName))) { + // File exists but cannot be written + throw new FileWriteProtectedException($fileName, self::EXCEPTION_FILE_CANNOT_BE_WRITTEN); + } elseif (!is_writable(dirname($fileName))) { + // Path is not writable + throw new PathWriteProtectedException($fileName, self::EXCEPTION_PATH_CANNOT_BE_WRITTEN); + } + + // Try to open a handler + $filePointer = fopen($fileName, 'c+b'); + if ((is_null($filePointer)) || ($filePointer === FALSE)) { + // Something bad happend + throw new FileIoException($fileName, self::EXCEPTION_FILE_POINTER_INVALID); + } // END - if + + // Create new instance + $pointerInstance = new FrameworkFileInputOutputPointer(); + + // Set file pointer and file name + $pointerInstance->setPointer($filePointer); + $pointerInstance->setFileName($fileName); + + // Return the instance + return $pointerInstance; + } + + /** + * Validates file pointer and throws exceptions. This method does not return + * anything (not reliable) as this method checks the file pointer and on + * case of an error it throws an exception. If this method does not throw + * any exceptions, the file pointer seems to be fine. + * + * @return void + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + */ + private function validateFilePointer () { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } + + // All fine here + } + + /** + * Read 1024 bytes data from a file pointer + * + * @return mixed The result of fread() + */ + public function readFromFile () { + // Validate the pointer + $this->validateFilePointer(); + + // Read data from the file pointer and return it + return $this->read(1024); + } + + /** + * Write data to a file pointer + * + * @param $dataStream The data stream we shall write to the file + * @return mixed Number of writes bytes or FALSE on error + */ + public function writeToFile ($dataStream) { + // Validate the pointer + $this->validateFilePointer(); + + // Write data to the file pointer and return written bytes + return fwrite($this->getPointer(), $dataStream, strlen($dataStream)); + } + + /** + * Writes at given position by seeking to it. + * + * @param $seekPosition Seek position in file + * @param $data Data to be written + * @return mixed Number of writes bytes or FALSE on error + */ + public function writeAtPosition ($seekPosition, $data) { + // First seek to it + $this->seek($seekPosition); + + // Then write the data at that position + return $this->writeToFile($data); + } + + /** + * Rewinds to the beginning of the file + * + * @return $status Status of this operation + */ + public function rewind () { + // Validate the pointer + $this->validateFilePointer(); + + // Rewind the pointer + return rewind($this->getPointer()); + } + + /** + * Seeks to given position + * + * @param $seekPosition Seek position in file + * @param $whence "Seek mode" (see http://de.php.net/fseek) + * @return $status Status of this operation + */ + public function seek ($seekPosition, $whence = SEEK_SET) { + // Validate the pointer + $this->validateFilePointer(); + + // Move the file pointer + return fseek($this->getPointer(), $seekPosition, $whence); + } + + /** + * Reads a line, maximum 4096 Bytes from current file pointer + * + * @return $data Read data from file + */ + public function readLine () { + // Read whole line + return $this->read(); + } + + /** + * Reads given amount of bytes from file. + * + * @param $bytes Amount of bytes to read + * @return $data Data read from file + */ + public function read ($bytes = NULL) { + // Validate the pointer + $this->validateFilePointer(); + + // Is $bytes set? + if (is_int($bytes)) { + // Try to read given characters + $data = fread($this->getPointer(), $bytes); + } else { + // Try to read whole line + $data = fread($this->getPointer()); + } + + // Then return it + return $data; + } + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function analyzeFile () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Advances to next "block" of bytes + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function next () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + * @throws UnsupportedOperationException If this method is called + */ + public function valid () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + * @throws UnsupportedOperationException If this method is called + */ + public function key () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * "Getter" for file size + * + * @return $fileSize Size of currently loaded file + */ + public function getFileSize () { + // Check if the pointer is still valid + $this->validateFilePointer(); + + // Get file's data + $fileData = fstat($this->getPointer()); + + // Make sure the required array key is there + assert(isset($fileData['size'])); + + // Return size + return $fileData['size']; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/io_stream/.htaccess b/inc/main/classes/file_directories/io_stream/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/io_stream/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/io_stream/class_FileIoStream.php b/inc/main/classes/file_directories/io_stream/class_FileIoStream.php new file mode 100644 index 00000000..d0ff5490 --- /dev/null +++ b/inc/main/classes/file_directories/io_stream/class_FileIoStream.php @@ -0,0 +1,292 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, FileOutputStreamer { + /** + * File header indicator + */ + const FILE_IO_FILE_HEADER_ID = '@head'; + + /** + * Data block indicator + */ + const FILE_IO_DATA_BLOCK_ID = '@data'; + + /** + * Separator #1 + */ + const FILE_IO_CHUNKER = ':'; + + /** + * Separator #2 + */ + const FILE_IO_SEPARATOR = '^'; + + /** + * Protected constructor + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a file IO stream. This is a class for performing all actions + * on files like creating, deleting and loading them. + * + * @return $ioInstance An instance of FileIoStream + */ + public static final function createFileIoStream () { + // Create new instance + $ioInstance = new FileIoStream(); + + // Return the instance + return $ioInstance; + } + + /** + * Saves data to a given local file and create missing directory structures + * + * @param $fileName The file name for the to be saved file + * @param $dataArray The data we shall store to the file + * @return void + * @see FileOutputStreamer + * @todo This method needs heavy rewrite + */ + public final function saveFile ($fileName, array $dataArray) { + // Try it five times + $dirName = ''; + $fileInstance = NULL; + + for ($idx = 0; $idx < 5; $idx++) { + // Get a file output pointer + try { + $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', array($fileName, 'wb')); + } catch (FileNotFoundException $e) { + // Bail out + ApplicationEntryPoint::app_exit('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage()); + } + } // END - for + + // Write a header information for validation purposes + $fileInstance->writeToFile(sprintf('%s%s%s%s%s%s%s%s%s' . PHP_EOL, + self::FILE_IO_FILE_HEADER_ID, + self::FILE_IO_SEPARATOR, + $dataArray[0], + self::FILE_IO_CHUNKER, + time(), + self::FILE_IO_CHUNKER, + strlen($dataArray[1]), + self::FILE_IO_CHUNKER, + md5($dataArray[1]) + )); + + // Encode the (maybe) binary stream with Base64 + $b64Stream = base64_encode($dataArray[1]); + + // write the data line by line + $line = str_repeat(' ', 50); $idx = 0; + while (strlen($line) == 50) { + // Get 50 chars or less + $line = substr($b64Stream, $idx, 50); + + // Save it to the stream + $fileInstance->writeToFile(sprintf('%s%s%s%s%s' . PHP_EOL, + self::FILE_IO_DATA_BLOCK_ID, + self::FILE_IO_SEPARATOR, + $line, + self::FILE_IO_CHUNKER, + md5($line) + )); + + // Advance to the next 50-chars block + $idx += 50; + } // END - while + + // Close the file + unset($fileInstance); + } + + /** + * Reads from a local file + * + * @param $fqfn The full-qualified file-name which we shall load + * @return $array An array with the element 'header' and 'data' + * @see FileInputStreamer + */ + public final function loadFileContents ($fqfn) { + // Initialize some variables and arrays + $inputBuffer = ''; + $lastBuffer = ''; + $header = array(); + $data = array(); + $readData = ''; // This will contain our read data + + // Get a file input handler + $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', array($fqfn)); + + // Read all it's contents (we very and transparently decompress it below) + while ($readRawLine = $fileInstance->readFromFile()) { + // Add the read line to the buffer + $inputBuffer .= $readRawLine; + + // Break infinite loop maybe caused by the input handler + if ($lastBuffer == $inputBuffer) { + break; + } // END - if + + // Remember last read line for avoiding possible infinite loops + $lastBuffer = $inputBuffer; + } // END - while + + // Close directory handle + unset($fileInstance); + + // Convert it into an array + $inputBuffer = explode(chr(10), $inputBuffer); + + // Now process the read lines and verify it's content + foreach ($inputBuffer as $rawLine) { + // Trim it a little but not the leading spaces/tab-stops + $rawLine = rtrim($rawLine); + + // Analyze this line + if (substr($rawLine, 0, 5) == self::FILE_IO_FILE_HEADER_ID) { + // Header found, so let's extract it + $header = explode(self::FILE_IO_SEPARATOR, $rawLine); + $header = trim($header[1]); + + // Now we must convert it again into an array + $header = explode(self::FILE_IO_CHUNKER, $header); + + // Is the header (maybe) valid? + if (count($header) != 4) { + // Throw an exception + throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); + } // END - if + } elseif (substr($rawLine, 0, 5) == self::FILE_IO_DATA_BLOCK_ID) { + // Is a data line! + $data = explode(self::FILE_IO_SEPARATOR, $rawLine); + $data = $data[1]; + + // First element is the data, second the MD5 checksum + $data = explode(self::FILE_IO_CHUNKER, $data); + + // Validate the read line + if (count($data) == 2) { + if (md5($data[0]) != $data[1]) { + // MD5 hash did not match! + throw new InvalidMD5ChecksumException(array($this, md5($data[0]), $data[1]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); + } // END - if + } else { + // Invalid count! + throw new InvalidArrayCountException(array($this, 'data', count($data), 2), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); + } + + // Add this to the readData string + $readData .= $data[0]; + } else { + // Other raw lines than header/data tagged lines and re-add the new-line char + $readData .= $rawLine . PHP_EOL; + } + } // END - foreach + + // Was raw lines read and no header/data? + if ((!empty($readData)) && (count($header) == 0) && (count($data) == 0)) { + // Return raw lines back + return $readData; + } // END - if + + // Was a header found? + if (count($header) != 4) { + // Throw an exception + throw new InvalidArrayCountException(array($this, 'header', count($header), 4), self::EXCEPTION_ARRAY_HAS_INVALID_COUNT); + } // END - if + + // Decode all from Base64 + $readData = @base64_decode($readData); + + // Does the size match? + if (strlen($readData) != $header[2]) { + // Size did not match + throw new InvalidDataLengthException(array($this, strlen($readData), $header[2]), self::EXCEPTION_UNEXPECTED_STRING_SIZE); + } // END - if + + // Validate the decoded data with the final MD5 hash + if (md5($readData) != $header[3]) { + // MD5 hash did not match! + throw new InvalidMD5ChecksumException(array($this, md5($readData), $header[3]), self::EXCEPTION_MD5_CHECKSUMS_MISMATCH); + } // END - if + + // Return all in an array + return array( + 'header' => $header, + 'data' => $readData + ); + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @todo 0% done + */ + public function determineSeekPosition () { + $this->partialStub(); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + */ + public function seek ($offset, $whence = SEEK_SET) { + $this->partialStub('offset=' . $offset . ',whence=' . $whence); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + public function size () { + $this->partialStub(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/output/.htaccess b/inc/main/classes/file_directories/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/output/raw/.htaccess b/inc/main/classes/file_directories/output/raw/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/output/raw/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php b/inc/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php new file mode 100644 index 00000000..42eebfd5 --- /dev/null +++ b/inc/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php @@ -0,0 +1,150 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a file pointer based on the given file. The file will also + * be verified here. + * + * @param $fileName The file name we shall pass to fopen() + * @param $mode The output mode ('w', 'a' are valid) + * @throws FileIsEmptyException If the provided file name is empty. + * @throws FileIoException If fopen() returns not a file resource + * @return void + */ + public static final function createFrameworkRawFileOutputPointer ($fileName, $mode) { + // Some pre-sanity checks... + if (is_null($fileName)) { + // No filename given + throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Try to open a handler + $filePointer = @fopen($fileName, $mode); + if ((is_null($filePointer)) || ($filePointer === FALSE)) { + // Something bad happend + throw new FileIoException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID); + } // END - if + + // Create new instance + $pointerInstance = new FrameworkRawFileOutputPointer(); + + // Set file pointer and file name + $pointerInstance->setPointer($filePointer); + $pointerInstance->setFileName($fileName); + + // Return the instance + return $pointerInstance; + } + + /** + * Write data to a file pointer + * + * @param $dataStream The data stream we shall write to the file + * @return mixed Number of writes bytes or FALSE on error + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + * an invalid file resource + */ + public function writeToFile ($dataStream) { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } + + // Write data to the file pointer and return written bytes + return fwrite($this->getPointer(), $dataStream); + } + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function analyzeFile () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Writes at given position by seeking to it. + * + * @param $seekPosition Seek position in file + * @param $data Data to be written + * @return mixed Number of writes bytes or FALSE on error + * @throws UnsupportedOperationException If this method is called + */ + public function writeAtPosition ($seedPosition, $data) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Advances to next "block" of bytes + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function next () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + * @throws UnsupportedOperationException If this method is called + */ + public function valid () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + * @throws UnsupportedOperationException If this method is called + */ + public function key () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/output/text/.htaccess b/inc/main/classes/file_directories/output/text/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/output/text/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php b/inc/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php new file mode 100644 index 00000000..42eebfd5 --- /dev/null +++ b/inc/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php @@ -0,0 +1,150 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a file pointer based on the given file. The file will also + * be verified here. + * + * @param $fileName The file name we shall pass to fopen() + * @param $mode The output mode ('w', 'a' are valid) + * @throws FileIsEmptyException If the provided file name is empty. + * @throws FileIoException If fopen() returns not a file resource + * @return void + */ + public static final function createFrameworkRawFileOutputPointer ($fileName, $mode) { + // Some pre-sanity checks... + if (is_null($fileName)) { + // No filename given + throw new FileIsEmptyException(NULL, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Try to open a handler + $filePointer = @fopen($fileName, $mode); + if ((is_null($filePointer)) || ($filePointer === FALSE)) { + // Something bad happend + throw new FileIoException ($fileName, self::EXCEPTION_FILE_POINTER_INVALID); + } // END - if + + // Create new instance + $pointerInstance = new FrameworkRawFileOutputPointer(); + + // Set file pointer and file name + $pointerInstance->setPointer($filePointer); + $pointerInstance->setFileName($fileName); + + // Return the instance + return $pointerInstance; + } + + /** + * Write data to a file pointer + * + * @param $dataStream The data stream we shall write to the file + * @return mixed Number of writes bytes or FALSE on error + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + * an invalid file resource + */ + public function writeToFile ($dataStream) { + if (is_null($this->getPointer())) { + // Pointer not initialized + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } elseif (!is_resource($this->getPointer())) { + // Pointer is not a valid resource! + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } + + // Write data to the file pointer and return written bytes + return fwrite($this->getPointer(), $dataStream); + } + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function analyzeFile () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Writes at given position by seeking to it. + * + * @param $seekPosition Seek position in file + * @param $data Data to be written + * @return mixed Number of writes bytes or FALSE on error + * @throws UnsupportedOperationException If this method is called + */ + public function writeAtPosition ($seedPosition, $data) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Advances to next "block" of bytes + * + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function next () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + * @throws UnsupportedOperationException If this method is called + */ + public function valid () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + * @throws UnsupportedOperationException If this method is called + */ + public function key () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/text/.htaccess b/inc/main/classes/file_directories/text/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/text/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/text/class_BaseTextFile.php b/inc/main/classes/file_directories/text/class_BaseTextFile.php new file mode 100644 index 00000000..ca7ff6ef --- /dev/null +++ b/inc/main/classes/file_directories/text/class_BaseTextFile.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseTextFile extends BaseAbstractFile { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + */ + public function determineSeekPosition () { + // Not possible in text files + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + */ + public function seek ($offset, $whence = SEEK_SET) { + // Not possible in text files + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Reads from a local or remote file + * + * @param $fqfn The file's FQFN we shall load + * @return $array An array containing all read lines + * @throws InvalidArrayCountException If an array has not the expected size + * @throws InvalidMD5ChecksumException If two MD5 hashes did not match + */ + public function loadFileContents ($fqfn) { + /* + * This class (or its implementations) are special file readers/writers. + * There is no need to read/write the whole file. + */ + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fqfn=' . $fqfn); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/text/input/.htaccess b/inc/main/classes/file_directories/text/input/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/text/input/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/text/input/class_BaseInputTextFile.php b/inc/main/classes/file_directories/text/input/class_BaseInputTextFile.php new file mode 100644 index 00000000..a35b6cce --- /dev/null +++ b/inc/main/classes/file_directories/text/input/class_BaseInputTextFile.php @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseInputTextFile extends BaseTextFile { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initializes this text file for reading + * + * @param $fileName File's name + * @return void + */ + protected function initFile ($fileName) { + // Get a file i/o pointer instance + $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_input_class', array($fileName)); + + // ... and set it here + $this->setPointerInstance($pointerInstance); + } + + /** + * Reads a line from currently referenced file + * + * @return $data Read data from referenced file + */ + public function readLine () { + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/text/input/csv/.htaccess b/inc/main/classes/file_directories/text/input/csv/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/text/input/csv/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/text/input/csv/class_CsvInputFile.php b/inc/main/classes/file_directories/text/input/csv/class_CsvInputFile.php new file mode 100644 index 00000000..9792c663 --- /dev/null +++ b/inc/main/classes/file_directories/text/input/csv/class_CsvInputFile.php @@ -0,0 +1,172 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CsvInputFile extends BaseInputTextFile implements CsvInputStreamer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this File class and prepares it for usage + * + * @param $fileName Name of the index file + * @return $fileInstance An instance of this File class + */ + public final static function createCsvInputFile ($fileName) { + // Get a new instance + $fileInstance = new CsvInputFile(); + + // Set file name + $fileInstance->setFileName($fileName); + + // Init this abstract file + $fileInstance->initFile($fileName); + + // Return the prepared instance + return $fileInstance; + } + + /** + * Reads a line from CSV file and returns it as an indexed array. Please + * note that strings *must* be always in double-quotes, else any found + * column separators will be parsed or they may be interpreted incorrectly. + * + * @param $columnSeparator Character to use separting columns + * @return $lineArray An indexed array with the read line + */ + public function readCsvFileLine ($columnSeparator) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] columnSeparator=%s - CALLED!', __METHOD__, __LINE__, $columnSeparator)); + + // Read raw line + $data = $this->getPointerInstance()->readLine(); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data()=%d', __METHOD__, __LINE__, strlen($data))); + + // Parse data + $lineArray = $this->parseDataToIndexedArray($data, $columnSeparator); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - EXIT!', __METHOD__, __LINE__, count($lineArray))); + + // Return it + return $lineArray; + } + + /** + * Parses given data into an array + * + * @param $data Raw data e.g. returned from readLine() + * @param $columnSeparator Character to use separting columns + * @return $lineArray An indexed array with the read line + */ + private function parseDataToIndexedArray ($data, $columnSeparator) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data()=%d,columnSeparator=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $columnSeparator)); + + // Init return array + $lineArray = array(); + + // Whether the parser reads a quoted string (which may contain the column separator again) + $isInQuotes = FALSE; + + // Init column data + $column = ''; + + // Now parse the line + for ($idx = 0; $idx < strlen($data); $idx++) { + // "Cache" char + $char = substr($data, $idx, 1); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] idx=%s,char=%s ...', __METHOD__, __LINE__, $idx, $char)); + + // Is the column separator found and not within quotes? + if (($isInQuotes === FALSE) && ($char == $columnSeparator)) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Adding column=%s ...', __METHOD__, __LINE__, $column)); + + // Add this line to the array + array_push($lineArray, $column); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - After add!', __METHOD__, __LINE__, count($lineArray))); + + // Clear variable ... + $column = ''; + + // ... and skip it + continue; + } elseif ($char == chr(34)) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] column=%s ...', __METHOD__, __LINE__, $column)); + + // $column must be empty at this point if we are at starting quote + assert(($isInQuotes === TRUE) || (empty($column))); + + // Double-quote found, so flip variable + $isInQuotes = (!$isInQuotes); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] isInQuotes=%d ...', __METHOD__, __LINE__, intval($isInQuotes))); + + // Skip double-quote (escaping of them is not yet supported) + continue; + } + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Adding char=%s ...', __METHOD__, __LINE__, $idx, $char)); + + // Add char to column + $column .= $char; + } // END - for + + // Is there something outstanding? + if (!empty($column)) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Adding column=%s ...', __METHOD__, __LINE__, $column)); + + // Then don't forget this. :-) + array_push($lineArray, $column); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - After add!', __METHOD__, __LINE__, count($lineArray))); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] lineArray()=%d - EXIT!', __METHOD__, __LINE__, count($lineArray))); + + // Return it + return $lineArray; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/file_directories/text/output/.htaccess b/inc/main/classes/file_directories/text/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/file_directories/text/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/file_directories/text/output/class_BaseOutputTextFile.php b/inc/main/classes/file_directories/text/output/class_BaseOutputTextFile.php new file mode 100644 index 00000000..df3857e2 --- /dev/null +++ b/inc/main/classes/file_directories/text/output/class_BaseOutputTextFile.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseOutputTextFile extends BaseAbstractFile { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initializes this text file for reading + * + * @param $fileName File's name + * @return void + */ + protected function initFile ($fileName) { + // Get a file i/o pointer instance + $pointerInstance = ObjectFactory::createObjectByConfiguredName('text_file_output_class', array($fileName)); + + // ... and set it here + $this->setPointerInstance($pointerInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/.htaccess b/inc/main/classes/filter/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/auth/.htaccess b/inc/main/classes/filter/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/auth/class_UserAuthFilter.php b/inc/main/classes/filter/auth/class_UserAuthFilter.php new file mode 100644 index 00000000..bdefcd96 --- /dev/null +++ b/inc/main/classes/filter/auth/class_UserAuthFilter.php @@ -0,0 +1,137 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserAuthFilter extends BaseFilter implements Filterable { + // Exception constants + const EXCEPTION_AUTH_DATA_INVALID = 0x1b0; + + /** + * The login method we shall choose + */ + private $authMethod = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserAuthFilter () { + // Get a new instance + $filterInstance = new UserAuthFilter(); + + // Set default auth method + $filterInstance->setDefaultAuthMethod(); + + // Return the instance + return $filterInstance; + } + + /** + * Setter for default login method from config + * + * @return void + */ + protected function setDefaultAuthMethod () { + $this->authMethod = $this->getConfigInstance()->getConfigEntry('auth_method_class'); + } + + /** + * 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 UserAuthorizationException If the auth login was not found or if it was invalid + * @throws UserPasswordMismatchException If the supplied password hash does not match + * @throws NoClassException If the user (guest/member) class was not found + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Then get an auth instance for checking and updating the auth cookies + $authInstance = ObjectFactory::createObjectByName($this->authMethod, array($responseInstance)); + + // Set request instance + $authInstance->setRequestInstance($requestInstance); + + // Now, get the auth data for comparison + $authLogin = $authInstance->getUserAuth(); + $authHash = $authInstance->getPasswordAuth(); + + // If one is empty stop here + if ((empty($authLogin)) || (empty($authHash))) { + // Destroy the auth data + $authInstance->destroyAuthData(); + + // Mark the request as invalid + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('auth_data_incomplete'); + + // Stop here + throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID); + } // END - if + + // Regular user account + $className = $this->getConfigInstance()->getConfigEntry('user_class'); + $methodName = 'createMemberByUserName'; + + // Now, try to get a user or guest instance + if ($authLogin == $this->getConfigInstance()->getConfigEntry('guest_login_user')) { + // Set class + $className = $this->getConfigInstance()->getConfigEntry('guest_class'); + $methodName = 'createGuestByUserName'; + } // END - if + + // Does the guest class exist? + if (!class_exists($className)) { + // Then abort here + throw new NoClassException (array($this, $className), self::EXCEPTION_CLASS_NOT_FOUND); + } // END - if + + // Now try the dynamic login + $userInstance = call_user_func_array(array($className, $methodName), array($authLogin)); + + // Is the password correct? + if ($userInstance->getPasswordHash() !== $authHash) { + // Mismatching password + throw new UserPasswordMismatchException(array($this, $userInstance), BaseUser::EXCEPTION_USER_PASS_MISMATCH); + } // END - if + + // Remember auth and user instances in registry + Registry::getRegistry()->addInstance('auth', $authInstance); + Registry::getRegistry()->addInstance('user', $userInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/change/.htaccess b/inc/main/classes/filter/change/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/change/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/change/class_EmailChangeFilter.php b/inc/main/classes/filter/change/class_EmailChangeFilter.php new file mode 100644 index 00000000..a7c4ef7e --- /dev/null +++ b/inc/main/classes/filter/change/class_EmailChangeFilter.php @@ -0,0 +1,122 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmailChangeFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createEmailChangeFilter () { + // Get a new instance + $filterInstance = new EmailChangeFilter(); + + // 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 FilterChainException If this filter fails to operate + * @todo Implement email change of the user here. HINT: Use the User class! + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get both emails + $email1 = $requestInstance->getRequestElement('email1'); + $email2 = $requestInstance->getRequestElement('email2'); + + // Is only first email set? + if ((!empty($email1)) && (empty($email2))) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Email 2 is empty + $responseInstance->addFatalMessage('email2_empty'); + + // Stop processing here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Is only second email set? + if ((empty($email1)) && (!empty($email2))) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Email 1 is empty + $responseInstance->addFatalMessage('email1_empty'); + + // Stop processing here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Do both match? + if ($email1 != $email2) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Emails are mismatching + $responseInstance->addFatalMessage('emails_mismatch'); + + // Stop processing here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Are email and confirmation empty? + if ((empty($email1)) && (empty($email2))) { + // No email change required! + return TRUE; + } // END - if + + // Now, get a user instance for comparison + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get the email field + $userEmail = $userInstance->getField('email'); + + // Are they different? + if ($userEmail == $email1) { + // Nothing has been changed is fine... + return TRUE; + } // END - if + + // Update the "new_email" field + $this->partialStub('Unfinished part.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/change/class_PasswordChangeFilter.php b/inc/main/classes/filter/change/class_PasswordChangeFilter.php new file mode 100644 index 00000000..9693f6ce --- /dev/null +++ b/inc/main/classes/filter/change/class_PasswordChangeFilter.php @@ -0,0 +1,114 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordChangeFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $controllerInstance An instance of a controller class + * @return $filterInstance An instance of this filter class + */ + public static final function createPasswordChangeFilter () { + // Get a new instance + $filterInstance = new PasswordChangeFilter(); + + // 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 + * @todo Finished updating user password hash here. HINT: Use the User class again. + * @throws FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get both passwords + $pass1 = $requestInstance->getRequestElement('pass1'); + $pass2 = $requestInstance->getRequestElement('pass2'); + + // Is only first email set? + if ((!empty($pass1)) && (empty($pass2))) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Email 2 is empty + $responseInstance->addFatalMessage('pass2_empty'); + + // Stop processing here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Is only second pass set? + if ((empty($pass1)) && (!empty($pass2))) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Email 1 is empty + $responseInstance->addFatalMessage('pass1_empty'); + + // Stop processing here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Are password and confirmation empty? + if ((empty($pass1)) && (empty($pass2))) { + // Don't change password here + return TRUE; + } // END - if + + // Do both match? + if ($pass1 != $pass2) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Emails are mismatching + $responseInstance->addFatalMessage('pass_mismatch'); + + // Stop processing here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Now, get a user instance for comparison + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Update the "password" field + $this->partialStub('Unfinished part.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/checkboxes/.htaccess b/inc/main/classes/filter/checkboxes/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/checkboxes/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/checkboxes/class_RulesAcceptedFilter.php b/inc/main/classes/filter/checkboxes/class_RulesAcceptedFilter.php new file mode 100644 index 00000000..95650659 --- /dev/null +++ b/inc/main/classes/filter/checkboxes/class_RulesAcceptedFilter.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RulesAcceptedFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createRulesAcceptedFilter () { + // Get a new instance + $filterInstance = new RulesAcceptedFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get the "rules" value from request + $rules = $requestInstance->getRequestElement('rules'); + + // Was the "rules" value found in form? And is it set? + if (is_null($rules)) { + // Not found in form so stop processing here + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('rules_unchecked'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/class_ b/inc/main/classes/filter/class_ new file mode 100644 index 00000000..39a538cf --- /dev/null +++ b/inc/main/classes/filter/class_ @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Filter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function create???Filter () { + // Get a new instance + $filterInstance = new ???Filter(); + + // 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 FilterChainException If this filter fails to operate + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Implement this! + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/class_BaseFilter.php b/inc/main/classes/filter/class_BaseFilter.php new file mode 100644 index 00000000..0a067a48 --- /dev/null +++ b/inc/main/classes/filter/class_BaseFilter.php @@ -0,0 +1,41 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFilter extends BaseFrameworkSystem { + // Exception constants + const EXCEPTION_FILTER_CHAIN_ABORTED = 0x1a0; + + /** + * Protected constructor + * + * @param $className Name of the filter class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/class_BaseFilterDecorator.php b/inc/main/classes/filter/class_BaseFilterDecorator.php new file mode 100644 index 00000000..81b987a6 --- /dev/null +++ b/inc/main/classes/filter/class_BaseFilterDecorator.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class BaseFilterDecorator extends BaseFrameworkSystem implements Filterable { + /** + * The decorated filter instance + */ + private $filterInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of the real class' name + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for the decorated filter instance + * + * @param $filterInstance An instance of a filter + * @return void + */ + protected final function setFilterInstance (Filterable $filterInstance) { + $this->filterInstance = $filterInstance; + } + + /** + * Getter for the decorated filter instance + * + * @return $filterInstance An instance of a filter + */ + protected final function getFilterInstance () { + return $this->filterInstance; + } + + /** + * Execute the inner filter + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public final function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->getFilterInstance()->execute($requestInstance, $responseInstance); + } + + + /** + * Do the execution of the filter + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance); +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/class_FilterChain.php b/inc/main/classes/filter/class_FilterChain.php new file mode 100644 index 00000000..e80c956d --- /dev/null +++ b/inc/main/classes/filter/class_FilterChain.php @@ -0,0 +1,136 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FilterChain extends BaseFrameworkSystem implements Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $chainInstance An instance of this class + */ + public static final function createFilterChain () { + // Get a new instance + $chainInstance = new FilterChain(); + + // Return the prepared instance + return $chainInstance; + } + + /** + * Add a new filter + * + * @param $filerInstance An instance of a filter class + * @return void + */ + public final function addFilter (Filterable $filterInstance) { + $this->pushValueToGenericArrayKey('filters', 'generic', 'dummy', $filterInstance); + } + + /** + * Add a new post-filter + * + * @param $filerInstance An instance of a post-filter class + * @return void + */ + public final function addPostFilter (Filterable $filterInstance) { + $this->pushValueToGenericArrayKey('filters', 'post', 'dummy', $filterInstance); + } + + /** + * "Getter" for filters array + * + * @return $filters The filters array holding all filter instances + */ + protected function getFilters () { + // Default is nothing found + $filters = array(); + + // Are some filters set? + if ($this->isValidGenericArrayKey('filters', 'generic', 'dummy')) { + // Then get them + $filters = $this->getGenericArrayKey('filters', 'generic', 'dummy'); + } // END - if + + // Return it + return $filters; + } + + /** + * "Getter" for post-filters array + * + * @return $filters The filters array holding all post-filter instances + */ + protected function getPostFilters () { + // Default is nothing found + $filters = array(); + + // Are some filters set? + if ($this->isValidGenericArrayKey('filters', 'post', 'dummy')) { + // Then get them + $filters = $this->getGenericArrayKey('filters', 'post', 'dummy'); + } // END - if + + // Return it + return $filters; + } + + /** + * Process all added filters. Please note that filters must throw + * FilterChainException if they need to interrupt the filter chain. + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + public function processFilters (Requestable $requestInstance, Responseable $responseInstance) { + // Run all filters + //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('COUNT=' . $this->countGenericArray('filters')); + foreach ($this->getFilters() as $filterInstance) { + // Must be an instance of Filterable + assert($filterInstance instanceof Filterable); + + // Try to execute this filter + try { + //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing started.'); + $filterInstance->execute($requestInstance, $responseInstance); + //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('FILTER: ' . $filterInstance->__toString() . ': Processing ended.'); + } catch (FilterChainException $e) { + // This exception can be thrown to just skip any further processing + self::createDebugInstance(__CLASS__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); + break; + } + } // END - foreach + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/crypto/.htaccess b/inc/main/classes/filter/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/crypto/class_CaptchaEncryptFilter.php b/inc/main/classes/filter/crypto/class_CaptchaEncryptFilter.php new file mode 100644 index 00000000..e019b35b --- /dev/null +++ b/inc/main/classes/filter/crypto/class_CaptchaEncryptFilter.php @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CaptchaEncryptFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final 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()->getConfigEntry('captcha_string_length')) { + // Not found, so request is invalid + $requestInstance->requestIsValid(FALSE); + + // Throw exception + throw new EncryptInvalidLengthException($this, CryptoHelper::EXCEPTION_ENCRYPT_INVALID); + } // END - if + + // Write it to the request + $requestInstance->setRequestElement('decrypted', $decryptedString); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/decorator/.htaccess b/inc/main/classes/filter/decorator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/decorator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/guest/.htaccess b/inc/main/classes/filter/guest/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/guest/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/guest/class_UserNameIsGuestFilter.php b/inc/main/classes/filter/guest/class_UserNameIsGuestFilter.php new file mode 100644 index 00000000..1382f2ca --- /dev/null +++ b/inc/main/classes/filter/guest/class_UserNameIsGuestFilter.php @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserNameIsGuestFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserNameIsGuestFilter () { + // Get a new instance + $filterInstance = new UserNameIsGuestFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('username'); + + // Does the user name match the guest login? + if ($userName == $this->getConfigInstance()->getConfigEntry('guest_login_user')) { + // Then set the password to the configured password + $requestInstance->setRequestElement('pass1', $this->getConfigInstance()->getConfigEntry('guest_login_passwd')); + $requestInstance->setRequestElement('pass2', $this->getConfigInstance()->getConfigEntry('guest_login_passwd')); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/news/.htaccess b/inc/main/classes/filter/news/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/news/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/news/class_NewsDownloadFilter.php b/inc/main/classes/filter/news/class_NewsDownloadFilter.php new file mode 100644 index 00000000..2e1fb8df --- /dev/null +++ b/inc/main/classes/filter/news/class_NewsDownloadFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NewsDownloadFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNewsDownloadFilter () { + // Get a new instance + $filterInstance = new NewsDownloadFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a news instance + $newsInstance = HtmlNewsFactory::createFactoryByRequest($requestInstance); + + // Store the news instance in registry + Registry::getRegistry()->addInstance('news', $newsInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/news/class_NewsProcessFilter.php b/inc/main/classes/filter/news/class_NewsProcessFilter.php new file mode 100644 index 00000000..27ea97e8 --- /dev/null +++ b/inc/main/classes/filter/news/class_NewsProcessFilter.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NewsProcessFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNewsProcessFilter () { + // Get a new instance + $filterInstance = new NewsProcessFilter(); + + // 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 + * @todo Unfinished stub, add functionality here + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/null/.htaccess b/inc/main/classes/filter/null/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/null/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/null/class_NullFilter.php b/inc/main/classes/filter/null/class_NullFilter.php new file mode 100644 index 00000000..c340c6f3 --- /dev/null +++ b/inc/main/classes/filter/null/class_NullFilter.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NullFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createNullFilter () { + // Get a new instance + $filterInstance = new NullFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Not implemented, just passing through + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/payment/.htaccess b/inc/main/classes/filter/payment/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/payment/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/payment/class_PaymentDiscoveryFilter.php b/inc/main/classes/filter/payment/class_PaymentDiscoveryFilter.php new file mode 100644 index 00000000..7a016ece --- /dev/null +++ b/inc/main/classes/filter/payment/class_PaymentDiscoveryFilter.php @@ -0,0 +1,136 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PaymentDiscoveryFilter extends BaseFilter implements Filterable { + /** + * Action name for payment discovery + */ + private $actionName = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @param $actionInstance A performable action + * @return $filterInstance An instance of this filter class + * @throws NullPointerException If the resolver is not set + */ + public static final function createPaymentDiscoveryFilter (PerformableAction $actionInstance) { + // Get a new instance + $filterInstance = new PaymentDiscoveryFilter(); + + // Get resolver from action + $resolverInstance = $actionInstance->getResolverInstance(); + + // Is the resolver set? + if (is_null($resolverInstance)) { + // Throw an exception here + throw new NullPointerException($filterInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the action name from resolver + $actionName = $resolverInstance->getActionName(); + + // Store it away in this class + $filterInstance->setActionName($actionName); + + // Return the instance + return $filterInstance; + } + + /** + * Protected setter for action name + * + * @param $actionName Action name to set + * @return void + */ + protected final function setActionName ($actionName) { + $this->actionName = (string) $actionName; + } + + /** + * Getter for action name + * + * @return $actionName Action name to set + */ + public final function getActionName () { + return $this->actionName; + } + + /** + * 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 + * @todo 0% done + * @throws FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Try to get real discovery class + try { + // Get an instance from the object factory + $discoveryInstance = ObjectFactory::createObjectByConfiguredName($this->getActionName() . '_payment_discovery', array($this)); + + // Call the discovery method + $discoveryInstance->discover($requestInstance); + + // Remember this instance if all wents fine + Registry::getRegistry()->addInstance('payments', $discoveryInstance); + } catch (NoConfigEntryException $e) { + // Something bad happend + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('payment_config_entry_error'); + $responseInstance->addFatalMessagePlain($e->getMessage()); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } catch (NoClassException $e) { + // Something bad happend + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('payment_class_error'); + $responseInstance->addFatalMessagePlain($e->getMessage()); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/update/.htaccess b/inc/main/classes/filter/update/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/update/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php b/inc/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php new file mode 100644 index 00000000..810103e6 --- /dev/null +++ b/inc/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserStatusConfimedUpdateFilter () { + // Get a new instance + $filterInstance = new UserStatusConfimedUpdateFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get "confirmed" status from config + $confirmed = $this->getConfigInstance()->getConfigEntry('user_status_confirmed'); + + // Update the user status to "confirmed" here + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS, $confirmed); + + // Wipe out the confirm hash for extra security + $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, ''); + + // Write all updates to the database + $userInstance->flushPendingUpdates(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/update/class_UserUpdateFilter.php b/inc/main/classes/filter/update/class_UserUpdateFilter.php new file mode 100644 index 00000000..c9a054db --- /dev/null +++ b/inc/main/classes/filter/update/class_UserUpdateFilter.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserUpdateFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserUpdateFilter () { + // Get a new instance + $filterInstance = new UserUpdateFilter(); + + // 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 + * @todo Add more user updates here + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Now update last activity + $userInstance->updateLastActivity($requestInstance); + + // Update auth data as well + $authInstance = Registry::getRegistry()->getInstance('auth'); + $authInstance->updateAuthData(); + + // Write all updates to the database + $userInstance->flushPendingUpdates(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/validator/.htaccess b/inc/main/classes/filter/validator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/validator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/validator/class_EmailValidatorFilter.php b/inc/main/classes/filter/validator/class_EmailValidatorFilter.php new file mode 100644 index 00000000..d01d8256 --- /dev/null +++ b/inc/main/classes/filter/validator/class_EmailValidatorFilter.php @@ -0,0 +1,169 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmailValidatorFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createEmailValidatorFilter () { + // Get a new instance + $filterInstance = new EmailValidatorFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get Email from request + $email = $requestInstance->getRequestElement('email'); + + // Is the Email set? + if ((is_null($email)) || ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y')) { + // Try it again + $email1 = $requestInstance->getRequestElement('email1'); + $email2 = $requestInstance->getRequestElement('email2'); + + // Is the email still not set? + if ((is_null($email1)) || (is_null($email2))) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('email_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ((empty($email1)) || (empty($email2))) { + // Email is empty + $requestInstance->requestIsValid(FALSE); + + // Is the email empty? + if (empty($email1)) { + // Add a message to the response + $responseInstance->addFatalMessage('email1_empty'); + } // END - if + + // Is the confirmation empty? + if (empty($email2)) { + // Add a message to the response + $responseInstance->addFatalMessage('email2_empty'); + } // END - if + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ($this->ifEmailIsTaken($email1)) { + // Email is already taken + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('email_taken'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ($email1 != $email2) { + // Emails didn't match + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('emails_mismatch'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - elseif + } elseif (empty($email)) { + // Empty field! + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('email_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - elseif + } + + /** + * Check whether the email as already been taken + * + * @param $email Email to check for existence + * @return $alreadyTaken Whether the email has been taken + */ + private function ifEmailIsTaken ($email) { + // Default is already taken + $alreadyTaken = TRUE; + + // Initialize instance + $userInstance = NULL; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setEmailAddress($email); + } else { + // If this instance is created then the username *does* exist + $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByEmail'), array($email)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } + + // Does the email exist? + if ($userInstance->ifEmailAddressExists() === FALSE) { + // This email has not being used yet + $alreadyTaken = FALSE; + } + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/validator/class_PasswordValidatorFilter.php b/inc/main/classes/filter/validator/class_PasswordValidatorFilter.php new file mode 100644 index 00000000..e8c381a7 --- /dev/null +++ b/inc/main/classes/filter/validator/class_PasswordValidatorFilter.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordValidatorFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createPasswordValidatorFilter () { + // Get a new instance + $filterInstance = new PasswordValidatorFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get passwords + $password1 = $requestInstance->getRequestElement('pass1'); + $password2 = $requestInstance->getRequestElement('pass2'); + + // Is the password still not set? + if ((is_null($password1)) || (is_null($password2))) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ((empty($password1)) || (empty($password2))) { + // Password is empty + $requestInstance->requestIsValid(FALSE); + + // Is the password empty? + if (empty($password1)) { + // Add a message to the response + $responseInstance->addFatalMessage('pass1_empty'); + } // END - if + + // Is the confirmation empty? + if (empty($password2)) { + // Add a message to the response + $responseInstance->addFatalMessage('pass2_empty'); + } // END - if + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ($password1 != $password2) { + // Passwords didn't match + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('pass_mismatch'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - elseif + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/validator/class_UserNameValidatorFilter.php b/inc/main/classes/filter/validator/class_UserNameValidatorFilter.php new file mode 100644 index 00000000..256bf3d6 --- /dev/null +++ b/inc/main/classes/filter/validator/class_UserNameValidatorFilter.php @@ -0,0 +1,139 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserNameValidatorFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserNameValidatorFilter () { + // Get a new instance + $filterInstance = new UserNameValidatorFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('username'); + + // Is the username set? + if (is_null($userName)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($userName)) { + // Empty field! + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ($this->ifUserNameIsTaken($userName)) { + // Username is already taken + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_taken'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + } + + /** + * Check whether the username as already been taken + * + * @param $userName Username to check for existence + * @return $alreadyTaken Whether the username has been taken + */ + private function ifUserNameIsTaken ($userName) { + // Default is already taken + $alreadyTaken = TRUE; + + // Initialize instance + $userInstance = NULL; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setUserName($userName); + } else { + // If this instance is created then the username *does* exist + try { + // Get a new instance + $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByUsername'), array($userName)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } catch (UsernameMissingException $e) { + // User was not found + } + } + + // Does the username exist? + if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === FALSE)) { + // This username is still available + $alreadyTaken = FALSE; + } // END - if + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/.htaccess b/inc/main/classes/filter/verifier/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/filter/verifier/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php b/inc/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php new file mode 100644 index 00000000..80ca36fd --- /dev/null +++ b/inc/main/classes/filter/verifier/class_AccountPasswordVerifierFilter.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AccountPasswordVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createAccountPasswordVerifierFilter () { + // Get a new instance + $filterInstance = new AccountPasswordVerifierFilter(); + + // 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 AccountPasswordMismatchException If the account password does not match + * @throws FilterChainException If this filter fails to operate + * @todo Rewrite handling of different password fields + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get password + $password = $requestInstance->getRequestElement('pass_old'); + + // Is the password still not set? + if (is_null($password)) { + // Get password from alternative location + $password = $requestInstance->getRequestElement('password'); + + // Is the password still not set? + if (is_null($password)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + } // END - if + + if (empty($password)) { + // Password is empty + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('password_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Get a user instance + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get current hash + $currentHash = $userInstance->getField('pass_hash'); + + // Get an encryption helper and encrypt the password + $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash); + + // Does it match? + if ($currentHash != $passHash) { + // Throw an exception here to stop the proccessing + throw new AccountPasswordMismatchException($this, BaseUser::EXCEPTION_USER_PASS_MISMATCH); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_BirthdayVerifierFilter.php b/inc/main/classes/filter/verifier/class_BirthdayVerifierFilter.php new file mode 100644 index 00000000..eb7122df --- /dev/null +++ b/inc/main/classes/filter/verifier/class_BirthdayVerifierFilter.php @@ -0,0 +1,114 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BirthdayVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createBirthdayVerifierFilter () { + // Get a new instance + $filterInstance = new BirthdayVerifierFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Day of birth set? + if (!$requestInstance->isRequestElementSet('birth_day')) { + // Day of birth isn't set + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('day_of_birth_unset'); + } // END - if + + // Month of birth set? + if (!$requestInstance->isRequestElementSet('birth_month')) { + // Month of birth isn't set + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('month_of_birth_unset'); + } // END - if + + // Year of birth set? + if (!$requestInstance->isRequestElementSet('birth_year')) { + // Year of birth isn't set + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('year_of_birth_unset'); + } // END - if + + // Is the request still valid? + if (!$requestInstance->isRequestValid()) { + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Now comes the final check + $birthCheck = mktime( + 0, + 0, + 0, + (int) $requestInstance->getRequestElement('birth_day'), + (int) $requestInstance->getRequestElement('birth_month'), + (int) $requestInstance->getRequestElement('birth_year') + ); + + // Is there a number or such? (we don't care about the value itself here) + if (empty($birthCheck)) { + // Validation has failed + $requestInstance->requestIsValid(false); + + // Add a message to the response + $responseInstance->addFatalMessage('birthday_invalid'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php b/inc/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php new file mode 100644 index 00000000..36d9e1c4 --- /dev/null +++ b/inc/main/classes/filter/verifier/class_ConfirmCodeVerifierFilter.php @@ -0,0 +1,102 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfirmCodeVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createConfirmCodeVerifierFilter () { + // Get a new instance + $filterInstance = new ConfirmCodeVerifierFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get confirmation code from request + $confirmCode = $requestInstance->getRequestElement('confirm'); + + // Is this code set? + if (is_null($confirmCode)) { + // Is not in request + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($confirmCode)) { + // Email is empty + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('confirm_code_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + + // Get a user instance from registry + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Get the confirm code from user for comparison + $userCode = $userInstance->getField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH); + + // Do we have the same code or different? + if ($userCode != $confirmCode) { + // Email is empty + $requestInstance->requestIsValid(FALSE); + + // Redirect to error page + $responseInstance->redirectToConfiguredUrl('confirm_code_invalid'); + + // Stop processing here + exit(); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php b/inc/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php new file mode 100644 index 00000000..5dc0f575 --- /dev/null +++ b/inc/main/classes/filter/verifier/class_GraphicalCodeCaptchaVerifierFilter.php @@ -0,0 +1,149 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class GraphicalCodeCaptchaVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createGraphicalCodeCaptchaVerifierFilter () { + // Get a new instance + $filterInstance = new GraphicalCodeCaptchaVerifierFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Is the form set? + if (($requestInstance->getRequestElement('command') !== 'do_form') || (!$requestInstance->isRequestElementSet('form'))) { + // Required field not set + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('command_form_invalid'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - if + + // Create config entry + $configKey = sprintf('%s_captcha_secured', + $requestInstance->getRequestElement('form') + ); + + // Is the CAPTCHA enabled? + if ($this->getConfigInstance()->getConfigEntry($configKey) != 'Y') { + // Not enabled, so don't check + return; + } // END - if + + // Get the captcha code + $captchaCode = $requestInstance->getRequestElement('c_code'); + + // Is this set? + if (is_null($captchaCode)) { + // Not set so request is invalid + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_code_unset'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($captchaCode)) { + // Empty value so request is invalid + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_code_empty'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + + // Get the hash as well + $captchaHash = $requestInstance->getRequestElement('hash'); + + // Is this set? + if (is_null($captchaHash)) { + // Not set so request is invalid + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_hash_unset'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($captchaHash)) { + // Empty value so request is invalid + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_hash_empty'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + + // Now, both are set hash the given one. First get a crypto instance + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // Then hash the code + $hashedCode = $cryptoInstance->hashString($captchaCode, $captchaHash); + + // Is this CAPTCHA valid? + if ($hashedCode != $captchaHash) { + // Not the same so request is invalid + $requestInstance->requestIsValid(FALSE); + + // Add fatal message + $responseInstance->addFatalMessage('captcha_hash_mismatch'); + + // Skip further processing + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } // END - not the same! + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_PasswordGuestVerifierFilter.php b/inc/main/classes/filter/verifier/class_PasswordGuestVerifierFilter.php new file mode 100644 index 00000000..0f085da6 --- /dev/null +++ b/inc/main/classes/filter/verifier/class_PasswordGuestVerifierFilter.php @@ -0,0 +1,85 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordGuestVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createPasswordGuestVerifierFilter () { + // Get a new instance + $filterInstance = new PasswordGuestVerifierFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get password + $password = $requestInstance->getRequestElement('passwd'); + + // Is the password still not set? + if (is_null($password)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($password)) { + // Password is empty + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('password_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_PasswordVerifierFilter.php b/inc/main/classes/filter/verifier/class_PasswordVerifierFilter.php new file mode 100644 index 00000000..d5db67df --- /dev/null +++ b/inc/main/classes/filter/verifier/class_PasswordVerifierFilter.php @@ -0,0 +1,85 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PasswordVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createPasswordVerifierFilter () { + // Get a new instance + $filterInstance = new PasswordVerifierFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get password + $password = $requestInstance->getRequestElement('pass'); + + // Is the password still not set? + if (is_null($password)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('password_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($password)) { + // Password is empty + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('password_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_UserGuestVerifierFilter.php b/inc/main/classes/filter/verifier/class_UserGuestVerifierFilter.php new file mode 100644 index 00000000..dde15e7f --- /dev/null +++ b/inc/main/classes/filter/verifier/class_UserGuestVerifierFilter.php @@ -0,0 +1,142 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserGuestVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserGuestVerifierFilter () { + // Get a new instance + $filterInstance = new UserGuestVerifierFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('user'); + + // Is the username set? + if (is_null($userName)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_guest_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($userName)) { + // Empty field! + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_guest_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ($this->ifUserGuestIsTaken($userName) === FALSE) { + // Username is already taken + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_guest_not_found'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + + // Set the element for compatiblity reasons + $requestInstance->setRequestElement('username', $userName); + } + + /** + * Check whether the username as already been taken + * + * @param $userName Username to check for existence + * @return $alreadyTaken Whether the username has been taken + */ + private function ifUserGuestIsTaken ($userName) { + // Default is already taken + $alreadyTaken = TRUE; + + // Initialize instance + $userInstance = NULL; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setUserGuest($userName); + } else { + // If this instance is created then the username *does* exist + try { + // Get a new instance + $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('guest_class'), 'createGuestByUsername'), array($userName)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } catch (UsernameMissingException $e) { + // User was not found + } + } + + // Does the username exist? + if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === FALSE)) { + // This username is still available + $alreadyTaken = FALSE; + } + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_UserNameVerifierFilter.php b/inc/main/classes/filter/verifier/class_UserNameVerifierFilter.php new file mode 100644 index 00000000..ffa45412 --- /dev/null +++ b/inc/main/classes/filter/verifier/class_UserNameVerifierFilter.php @@ -0,0 +1,139 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserNameVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserNameVerifierFilter () { + // Get a new instance + $filterInstance = new UserNameVerifierFilter(); + + // 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 FilterChainException If this filter fails to operate + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get username from request + $userName = $requestInstance->getRequestElement('username'); + + // Is the username set? + if (is_null($userName)) { + // Not found in form so stop the filtering process + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_unset'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif (empty($userName)) { + // Empty field! + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_empty'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } elseif ($this->ifUserNameIsTaken($userName) === FALSE) { + // Username is already taken + $requestInstance->requestIsValid(FALSE); + + // Add a message to the response + $responseInstance->addFatalMessage('username_not_found'); + + // Abort here + throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED); + } + } + + /** + * Check whether the username as already been taken + * + * @param $userName Username to check for existence + * @return $alreadyTaken Whether the username has been taken + */ + private function ifUserNameIsTaken ($userName) { + // Default is already taken + $alreadyTaken = TRUE; + + // Initialize instance + $userInstance = NULL; + + // Get a registry instance + $registry = Registry::getRegistry(); + + // Is the user already there? + if ($registry->instanceExists('user')) { + // Use the instance for checking for the email + $userInstance = $registry->getInstance('user'); + $userInstance->setUserName($userName); + } else { + // If this instance is created then the username *does* exist + try { + // Get a new instance + $userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByUsername'), array($userName)); + + // Remember this user instance in our registry for later usage + $registry->addInstance('user', $userInstance); + } catch (UsernameMissingException $e) { + // User was not found + } + } + + // Does the username exist? + if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === FALSE)) { + // This username is still available + $alreadyTaken = FALSE; + } // END - if + + // Return the result + return $alreadyTaken; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_UserStatusVerifierFilter.php b/inc/main/classes/filter/verifier/class_UserStatusVerifierFilter.php new file mode 100644 index 00000000..94b62a23 --- /dev/null +++ b/inc/main/classes/filter/verifier/class_UserStatusVerifierFilter.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserStatusVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserStatusVerifierFilter () { + // Get a new instance + $filterInstance = new UserStatusVerifierFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a user instance for comparison + $userInstance = Registry::getRegistry()->getInstance('user'); + + // Is the user account confirmed? + if ((!$userInstance->isConfirmed()) && (!$userInstance->isGuest()) && ($requestInstance->getRequestElement('action') != $this->getConfigInstance()->getConfigEntry('action_status_problem'))) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('login_user_status'); + + // Stop processing here + exit(); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php b/inc/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php new file mode 100644 index 00000000..897951d4 --- /dev/null +++ b/inc/main/classes/filter/verifier/class_UserUnconfirmedVerifierFilter.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createUserUnconfirmedVerifierFilter () { + // Get a new instance + $filterInstance = new UserUnconfirmedVerifierFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get a user instance for comparison + $userInstance = UserFactory::createUserByRequest($requestInstance); + + // Is the email address valid? + if ($userInstance->ifEmailAddressExists() === FALSE) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('user_unconfirmed_email_missing'); + + // Stop processing here + exit(); + } // END - if + + // Is the user account confirmed? + if ($userInstance->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) != $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed')) { + // Request is invalid! + $requestInstance->requestIsValid(FALSE); + + // Redirect to configured URL + $responseInstance->redirectToConfiguredUrl('user_not_unconfirmed'); + + // Stop processing here + exit(); + } // END - if + + // Add this instance to registry + Registry::getRegistry()->addInstance('user', $userInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/handler/.htaccess b/inc/main/classes/handler/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/handler/class_ b/inc/main/classes/handler/class_ new file mode 100644 index 00000000..8bb9ced3 --- /dev/null +++ b/inc/main/classes/handler/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Handler extends BaseHandler implements Handleable___ { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('!!!'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a !!! class + */ + public final static function create???Handler () { + // Get new instance + $handlerInstance = new ???Handler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/handler/class_BaseHandler.php b/inc/main/classes/handler/class_BaseHandler.php new file mode 100644 index 00000000..e9512006 --- /dev/null +++ b/inc/main/classes/handler/class_BaseHandler.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHandler extends BaseFrameworkSystem implements HandleableDataSet { + /** + * Handler name + */ + private $handlerName = 'invalid'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for handler name + * + * @return $handlerName Name of this handler + */ + public final function getHandlerName () { + return $this->handlerName; + } + + /** + * Setter for handler name + * + * @param $handlerName Name of this handler + * @return void + */ + protected final function setHandlerName ($handlerName) { + $this->handlerName = $handlerName; + } + + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + * @todo Rewrite this to use DHT + */ + public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) { + // Add some generic data all messageData arrays provide + /* + $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]); + $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_MESSAGE_TYPE , $messageData[NetworkPackage::MESSAGE_ARRAY_TYPE]); + */ + } +} + +// [EOF] +?> diff --git a/inc/main/classes/handler/raw_data/.htaccess b/inc/main/classes/handler/raw_data/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/handler/raw_data/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/handler/raw_data/class_ b/inc/main/classes/handler/raw_data/class_ new file mode 100644 index 00000000..1a215b06 --- /dev/null +++ b/inc/main/classes/handler/raw_data/class_ @@ -0,0 +1,73 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('!!!'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a Networkable class + */ + public final static function create???NetworkPackageHandler () { + // Get new instance + $handlerInstance = new ???NetworkPackageHandler(); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Processes a package from given resource. This is mostly useful for TCP + * package handling and is implemented in the TcpListener class + * + * @param $resource A valid resource identifier + * @return void + * @throws InvalidResourceException If the given resource is invalid + * @todo 0% + */ + public function processResourcePackage ($resource) { + // Check the resource + if (!is_resource($resource)) { + // Throw an exception + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } // END - if + + // Implement processing here + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/handler/tasks/.htaccess b/inc/main/classes/handler/tasks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/handler/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/handler/tasks/class_TaskHandler.php b/inc/main/classes/handler/tasks/class_TaskHandler.php new file mode 100644 index 00000000..da7c2af6 --- /dev/null +++ b/inc/main/classes/handler/tasks/class_TaskHandler.php @@ -0,0 +1,347 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TaskHandler extends BaseHandler implements Registerable, HandleableTask { + // Exception constants + const EXCEPTION_TASK_IS_INVALID = 0xb00; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('task'); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableTask class + */ + public static final function createTaskHandler () { + // Get new instance + $handlerInstance = new TaskHandler(); + + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Initializing task handler.'); + + // Init the task list + $handlerInstance->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class')); + + // Get default instance + $handlerInstance->setIteratorInstance($handlerInstance->getListInstance()->getIterator()); + + // Init visitor instance for faster loop + $handlerInstance->setVisitorInstance(ObjectFactory::createObjectByConfiguredName('active_task_visitor_class')); + + // Register the first (and generic) idle-loop task + $taskInstance = ObjectFactory::createObjectByConfiguredName('idle_task_class'); + $handlerInstance->registerTask('idle_loop', $taskInstance); + + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task handler initialized.'); + + // Return the prepared instance + return $handlerInstance; + } + + /** + * Tries to execute the given task. If as task should not be started (yet) + * or the interval time (see task_interval_delay) is not yet reached the + * task is quietly skipped. + * + * @return void + * @throws InvalidTaskException If the current task is invalid + */ + private function executeCurrentTask () { + // Update no task by default + $updateTask = FALSE; + + // Is the current task valid? + if (!$this->getListInstance()->getIterator()->valid()) { + // Not valid! + throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID); + } // END - if + + // Get current task + $currentTask = $this->getListInstance()->getIterator()->current(); + + // Is the task not yet started? + if ($currentTask['task_started'] === FALSE) { + // Determine difference between current time and registration + $diff = ($this->getMilliTime() - $currentTask['task_registered']) * 1000; + + // Should we start now? + if ($diff < $currentTask['task_startup_delay']) { + // Skip this silently + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' not started: diff=' . $diff . ',task_startup_delay=' . $currentTask['task_startup_delay']); + return; + } // END - if + + // Launch the task and mark it as updated + $currentTask['task_started'] = TRUE; + $updateTask = TRUE; + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms'); + } // END - if + + // Get time difference from interval delay + $diff = ($this->getMilliTime() - $currentTask['task_last_activity']) * 1000; + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' diff=' . $diff . ',task_interval_delay=' . $currentTask['task_interval_delay'] . ',task_max_runs=' . $currentTask['task_max_runs'] . ',task_total_runs=' . $currentTask['task_total_runs']); + + // Is the interval delay reached? + if ((($diff < $currentTask['task_interval_delay']) && ($currentTask['task_max_runs'] == 0)) || (($currentTask['task_max_runs'] > 0) && ($currentTask['task_total_runs'] == $currentTask['task_max_runs']))) { + // Should we update the task from startup? + if ($updateTask === TRUE) { + // Update the task before leaving + $this->updateTask($currentTask); + } // END - if + + // Skip this silently + return; + } // END - if + + // Set last activity + $currentTask['task_last_activity'] = $this->getMilliTime(); + + // Count this run + $currentTask['task_total_runs']++; + + // Update the task + $this->updateTask($currentTask); + + // And visit/run it + // @TODO Messurement can be added around this call + $currentTask['task_instance']->accept($this->getVisitorInstance()); + } + + /** + * Updates given task by updating the underlaying list + * + * @param $taskEntry An array with a task + * @return void + */ + private function updateTask (array $taskEntry) { + // Get the key from current iteration + $key = $this->getListInstance()->getIterator()->key(); + + // Get the hash from key + $hash = $this->getListInstance()->getHash($key); + + // Update the entry + $this->getListInstance()->updateCurrentEntryByHash($hash, $taskEntry); + } + + /** + * Unregisters the given task + * + * @param $taskData Data of the task + * @return void + */ + private function unregisterTask (array $taskData) { + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - CALLED!'); + + // Remove the entry + $this->getListInstance()->removeEntry('tasks', $taskData); + + // Debug output + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - EXIT!'); + } + + /** + * Searches a task by given instance + * + * @param $taskInstanc An instanceof a Taskable class + * @return $taskName Name of the task as used while registration + */ + public function searchTask (Taskable $taskInstance) { + // Default is an empty (not found) task name + $taskName = ''; + + // Get whole list + $taskList = $this->getListInstance()->getArrayFromList('tasks'); + + // Search all instances + foreach ($taskList as $currentTask) { + // Does it match given task instance? + if ($currentTask['task_instance']->equals($taskInstance)) { + // Found it + $taskName = $currentTask['id']; + + // Abort here + break; + } // END - if + } // END - foreach + + // Return found name + return $taskName; + } + + /** + * Registers a task with a task handler. + * + * @param $taskName A task name to register the task on + * @param $taskInstance The instance we should register as a task + * @return void + */ + public function registerTask ($taskName, Visitable $taskInstance) { + // Get interval delay + $intervalDelay = $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_interval_delay'); + $startupDelay = $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_startup_delay'); + + // If the task is 'idle_loop', a deplay of zero seconds is fine + assert($intervalDelay >= 0); + assert(($taskName === 'idle_loop') || (($taskName != 'idle_loop') && ($intervalDelay > 0))); + assert(($taskName === 'idle_loop') || (($taskName != 'idle_loop') && ($startupDelay > 0))); + + // Create the entry + $taskEntry = array( + // Identifier for the generateHash() method + 'id' => $taskName, + // Whether the task is started + 'task_started' => FALSE, + // Whether the task is paused (not yet implemented) + 'task_paused' => FALSE, + // Whether the task can be paused (not yet implemented) + 'task_pauseable' => TRUE, + // Timestamp of registration + 'task_registered' => $this->getMilliTime(), + // Last activity timestamp + 'task_last_activity' => 0, + // Total runs of this task + 'task_total_runs' => 0, + // Task instance itself + 'task_instance' => $taskInstance, + // Startup delay in milliseconds + 'task_startup_delay' => $startupDelay, + // Interval time (delay) in milliseconds before this task is executed again + 'task_interval_delay' => $intervalDelay, + // How often should this task run? + 'task_max_runs' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_max_runs'), + ); + + // Add the entry + $this->getListInstance()->addEntry('tasks', $taskEntry); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task registered: taskName=' . $taskName . + ' (taskInstance=' . $taskInstance->__toString() . ')' . + ', startupDelay=' . $taskEntry['task_startup_delay'] . 'ms' . + ', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms' . + ', maxRuns=' . $taskEntry['task_max_runs'] . ' ...' + ); + } + + /** + * Checks whether tasks are left including idle task + * + * @return $tasksLeft Whether there are tasks left to handle + */ + public function hasTasksLeft () { + // Do we have tasks there? + $tasksLeft = (($this->getListInstance() instanceof Listable) && ($this->getListInstance()->count() > 0)); + + // Return result + return $tasksLeft; + } + + /** + * Handles all tasks by checking if they should startup or if it is their + * turn to run. You should use this method in a while() loop in conjuntion + * with hasTasksLeft() so you can e.g. shutdown by adding a ShutdownTask + * which will attempt to remove all tasks from the task handler. + * + * @return void + */ + public function handleTasks () { + // Should we rewind? + if (!$this->getListInstance()->getIterator()->valid()) { + // Rewind to the beginning for next loop + $this->getListInstance()->getIterator()->rewind(); + } // END - if + + // Try to execute the task + $this->executeCurrentTask(); + + // Go to next entry + $this->getListInstance()->getIterator()->next(); + } + + /** + * Shuts down all tasks and the task handler itself. This method should be + * called from a corresponding filter class. + * + * @return void + */ + public function doShutdown () { + // Always rewind to the beginning for next loop + $this->getListInstance()->getIterator()->rewind(); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down all ' . $this->getListInstance()->count() . ' tasks...'); + + // Remember all tasks that has been shutdown for removal + $tasks = array(); + + // Instance a visitor + $this->setVisitorInstance(ObjectFactory::createObjectByConfiguredName('shutdown_task_visitor_class')); + + // Shutdown all tasks in once go + while ($this->getListInstance()->getIterator()->valid()) { + // Get current entry + $currentTask = $this->getListInstance()->getIterator()->current(); + + // Output debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...'); + + // Shutdown the task + $currentTask['task_instance']->accept($this->getVisitorInstance()); + + // Remember this task + array_push($tasks, $currentTask); + + // Advance to next one + $this->getListInstance()->getIterator()->next(); + } // END - while + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutdown of all tasks completed.'); + + // Remove all tasks + foreach ($tasks as $entry) { + $this->unregisterTask($entry); + } // END - foreach + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/.htaccess b/inc/main/classes/helper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/captcha/.htaccess b/inc/main/classes/helper/captcha/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/captcha/class_ b/inc/main/classes/helper/captcha/class_ new file mode 100644 index 00000000..939cdf6d --- /dev/null +++ b/inc/main/classes/helper/captcha/class_ @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Captcha extends BaseCaptcha implements SolveableCaptcha { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this captcha class + * + * @param $templateInstance An instance of a template engine + * @param $extraInstance An extra instance, just for better hash data + * @return $captchaInstance An instance of this captcha class + */ + public final static function create???Captcha (CompileableTemplate $templateInstance, FrameworkInterface $extraInstance = null) { + // Get a new instance + $captchaInstance = new ???Captcha(); + + // Set template instance + $captchaInstance->setTemplateInstance($templateInstance); + + // Initialize the RNG + $captchaInstance->initializeRandomNumberGenerator($extraInstance); + + // Return the instance + return $captchaInstance; + } + + /** + * Initiates the CAPTCHA + * + * @return void + * @todo 0% done + */ + public function initiateCaptcha () { + $this->partialStub("Please implement this method."); + } + + /** + * Render the CAPTCHA code + * + * @return void + * @todo 0% done + */ + public function renderCode () { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/captcha/class_BaseCaptcha.php b/inc/main/classes/helper/captcha/class_BaseCaptcha.php new file mode 100644 index 00000000..836190e2 --- /dev/null +++ b/inc/main/classes/helper/captcha/class_BaseCaptcha.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCaptcha extends BaseHelper { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initializes the random number generator (RNG) + * + * @param $extraInstance An extra instance, just for better hash data + * @return void + */ + protected final function initializeRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) { + // Get an RNG from factory + $this->setRngInstance(ObjectFactory::createObjectByConfiguredName('rng_class', array($extraInstance))); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/captcha/images/.htaccess b/inc/main/classes/helper/captcha/images/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/captcha/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/captcha/images/class_ImageHelper.php b/inc/main/classes/helper/captcha/images/class_ImageHelper.php new file mode 100644 index 00000000..cfe97e28 --- /dev/null +++ b/inc/main/classes/helper/captcha/images/class_ImageHelper.php @@ -0,0 +1,396 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class 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 = ''; + + /** + * Base image + */ + private $baseImage = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__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 helper + */ + public static final 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 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 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(4, 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->loadImageTemplate($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 to keep this helper in sync with template engine + $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->renderXmlContent($imageContent); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/captcha/web/.htaccess b/inc/main/classes/helper/captcha/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/captcha/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php b/inc/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php new file mode 100644 index 00000000..3d097bdb --- /dev/null +++ b/inc/main/classes/helper/captcha/web/class_GraphicalCodeCaptcha.php @@ -0,0 +1,157 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class GraphicalCodeCaptcha extends BaseCaptcha implements SolveableCaptcha { + /** + * Hash of the CAPTCHA string + */ + private $hashedString = ''; + + /** + * Encrypted string + */ + private $encryptedString = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this captcha class + * + * @param $helperInstance An instance of a helper class + * @param $extraInstance An extra instance, just for better hash data + * @return $captchaInstance An instance of this captcha class + */ + public static final function createGraphicalCodeCaptcha (HelpableTemplate $helperInstance, FrameworkInterface $extraInstance = NULL) { + // Get a new instance + $captchaInstance = new GraphicalCodeCaptcha(); + + // Set template instance + $captchaInstance->setHelperInstance($helperInstance); + + // Initialize the RNG + $captchaInstance->initializeRandomNumberGenerator($extraInstance); + + // Return the instance + return $captchaInstance; + } + + /** + * Initiates the CAPTCHA + * + * @return void + */ + public function initiateCaptcha () { + // Get total length + $captchaLength = $this->getConfigInstance()->getConfigEntry('captcha_string_length'); + + // Get max string length + $strLength = $this->getConfigInstance()->getConfigEntry('random_string_length'); + + // Calculate starting position based on random place + $start = $this->getRngInstance()->randomNumber(0, ($strLength - $captchaLength)); + + // Test it + assert($start >= 0); + + // Generate a random string for confirmation + $randomString = $this->getRngInstance()->randomString($strLength); + + // Encode the string with BASE64 + $base64String = base64_encode($randomString); + + // Make this string a bit more readable for humans + $captchaString = substr($base64String, $start, $captchaLength); + + // Get all characters we want to replace + $searchChars = $this->getConfigInstance()->getConfigEntry('captcha_search_chars'); + + // Get fixed salt and use it as "replacement characters" + $replaceChars = $this->getRngInstance()->getExtraSalt(); + + // Remove any plus, equals or slashes + for ($searchIdx = 0; $searchIdx < strlen($searchChars); $searchIdx++) { + // Get search character + $search = substr($searchChars, $searchIdx, 1); + + // Random array index + $charIdx = $this->getRngInstance()->randomNumber(0, (strlen($replaceChars) - 1)); + + // Get replacement + $replace = substr($replaceChars, $charIdx, 1); + + // Replace character + $captchaString = str_replace($search, $replace, $captchaString, $captchaLength); + } // END - foreach + + // Get crypto instance + $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class'); + + // Hash the CAPTCHA code for later comparison + $this->hashedString = $cryptoInstance->hashString($captchaString); + + // Encrypt the string for later usage + $this->encryptedString = $cryptoInstance->encryptString($captchaString); + } + + /** + * Render the CAPTCHA code + * + * @return void + */ + public function renderCode () { + // Get helper instance + $helperInstance = $this->getHelperInstance(); + + // Get template instance + $templateInstance = $helperInstance->getTemplateInstance(); + + // Load a template for this CAPTCHA + $templateInstance->loadCodeTemplate('captch_graphic_code'); + + // Rename variable + $templateInstance->renameVariable('captcha_code', $helperInstance->getFormName() . '_captcha'); + $templateInstance->renameVariable('captcha_hash', $helperInstance->getFormName() . '_hash'); + $templateInstance->renameVariable('encrypted_code', $helperInstance->getFormName() . '_encrypt'); + + // Assign variables + $templateInstance->assignVariable($helperInstance->getFormName() . '_encrypt', urlencode(base64_encode($this->encryptedString))); + $templateInstance->assignVariable($helperInstance->getFormName() . '_hash', $this->hashedString); + + // Compile the template + $templateInstance->compileTemplate(); + + // Get the content back + $this->addContent($templateInstance->getRawTemplateData()); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/class_ b/inc/main/classes/helper/class_ new file mode 100644 index 00000000..283d1d50 --- /dev/null +++ b/inc/main/classes/helper/class_ @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Helper extends BaseHelper { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function create???Helper () { + // Get new instance + $helperInstance = new ???Helper(); + + // Return the prepared instance + return $helperInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/class_BaseHelper.php b/inc/main/classes/helper/class_BaseHelper.php new file mode 100644 index 00000000..c06f86fd --- /dev/null +++ b/inc/main/classes/helper/class_BaseHelper.php @@ -0,0 +1,554 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHelper extends BaseFrameworkSystem { + /** + * Instance to the class which provides field values + */ + private $valueInstance = NULL; + + /** + * Extra instance to the class which provides field values + */ + private $extraInstance = NULL; + + /** + * Rendered content created by the helper class + */ + private $content = ''; + + /** + * Array with groups + */ + private $groups = array(); + + /** + * Array with sub group + */ + private $subGroups = array(); + + /** + * Previously opened group + */ + private $previousGroupId = ''; + + /** + * Previously opened sub group + */ + private $previousSubGroupId = ''; + + /** + * Total counter for groups and sub groups + */ + private $totalCounter = 0; + + // Exception constants + const EXCEPTION_GROUP_NOT_OPENED = 0x1e3; + const EXCEPTION_GROUP_ALREADY_FOUND = 0x1e4; + const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e5; + const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e6; + const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e7; + + /** + * Protected constructor + * + * @param $className Real name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Adds content directly + * + * @param $newContent New content to add + * @return void + */ + protected final function addContent ($newContent) { + $this->content .= (string) trim($newContent) . PHP_EOL; + } + + /** + * Add header content to the helper + * + * @param $content Content to to the base + * @return void + */ + protected function addHeaderContent ($content) { + // Add the header content + $this->groups['header']['content'] = (string) trim($content); + } + + /** + * Add footer content to the helper + * + * @param $content Content to to the base + * @return void + */ + protected function addFooterContent ($content) { + // Add the footer content + $this->groups['footer']['content'] = (string) trim($content); + } + + /** + * Adds content to the previously opened group or sub group. If a sub group + * was found it will be taken. If no group/sub group is opened at the moment + * the code will be passed to addContent(). + * + * @param $newContent New content to add + * @return void + */ + protected final function addContentToPreviousGroup ($newContent) { + // Check for sub/group + if ($this->ifSubGroupOpenedPreviously()) { + // Get sub group id + $subGroupId = $this->getPreviousSubGroupId(); + + // Add the content + $this->subGroups[$subGroupId]['content'] .= $newContent; + } elseif ($this->ifGroupOpenedPreviously()) { + // Get group id + $groupId = $this->getPreviousGroupId(); + + // Add the content + $this->groups[$groupId]['content'] .= $newContent; + } else { + // Add it directly + $this->addContent($newContent); + } + } + + /** + * Getter for content + * + * @return $content The rendered content by this helper + */ + protected final function getContent () { + return $this->content; + } + + /** + * Public setter for extra instance + * + * @param $extraInstance An extra instance of FrameworkInterface to set + * @return void + */ + public final function setExtraInstance (FrameworkInterface $extraInstance) { + $this->extraInstance = $extraInstance; + } + + /** + * Assigns a field from the value instance with a template variable + * + * @param $fieldName Name of the field to assign + * @return void + */ + public function assignField ($fieldName) { + // Get the value from value instance + $fieldValue = $this->getValueField($fieldName); + + // Assign it with a template variable + $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $fieldValue); + } + + /** + * Assigns a field from the value instance with a template variable but + * parses its content through a given filter method of the value instance + * + * @param $fieldName Name of the field to assign + * @param $filterMethod Method name to call of the value instance + * @return void + * @todo Rewrite this method using a helper class for filtering data + */ + public function assignFieldWithFilter ($fieldName, $filterMethod) { + // Get the value + $fieldValue = $this->getValueField($fieldName); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'='.$fieldValue); + + // Now filter it through the value through the filter method + $filteredValue = call_user_func_array(array($this, 'doFilter' . self::convertToClassName($filterMethod)), array($fieldValue)); + + // Assign it with a template variable + $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $filteredValue); + } + + /** + * Pre-fetches field default values from the given registry key instance into this class + * + * @param $registryKey Registry key which holds an object with values + * @param $extraKey Extra value instance key used if registryKey is null + * @return void + * @throws NullPointerException If recovery of requested value instance failed + */ + public function prefetchValueInstance ($registryKey, $extraKey = NULL) { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('O:'.$registryKey.'/'.$extraKey); + try { + // Get the required instance + $this->valueInstance = Registry::getRegistry()->getInstance($registryKey); + } catch (NullPointerException $e) { + // Not set in registry + // @TODO Try to log it here + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($registryKey.'=NULL!'); + } + + // Shall we get an extra instance? + if (!is_null($extraKey)) { + try { + // Get the extra instance. + $this->extraInstance = Registry::getRegistry()->getInstance($extraKey); + } catch (NullPointerException $e) { + // Try to create it + $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance)); + } + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!'); + } // END - if + + // Is the value instance valid? + if (is_null($this->valueInstance)) { + // Get the requested instance + $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance)); + } // END - if + } + + /** + * Opens a helper group with given group id and content or throws an + * exception if that group is already found regardless if it is open or + * closed. + * + * @param $groupId Group id to open + * @param $content Initial content to add to the group + * @param $tag HTML tag used to open this group + * @return void + * @throws HelperGroupAlreadyCreatedException If the group was already created before + */ + protected function openGroupByIdContent ($groupId, $content, $tag) { + //* DEBUG: */ echo "OPEN:groupId={$groupId},content=
    ".htmlentities($content)."
    \n"; + // Is the group already there? + if (isset($this->groups[$groupId])) { + // Then throw an exception here + throw new HelperGroupAlreadyCreatedException(array($this, $groupId), self::EXCEPTION_GROUP_ALREADY_FOUND); + } // END - if + + // Count one up + $this->totalCounter++; + + // Add the group to the stack + $this->groups[$this->totalCounter] = $groupId; + $this->groups[$groupId]['opened'] = TRUE; + $this->groups[$groupId]['content'] = sprintf( + '%s' . PHP_EOL, + $groupId, + strlen($content), + $tag, + $content + ); + $this->groups[$groupId]['tag'] = $tag; + + // Mark this group as previously opened + $this->setPreviousGroupId($groupId); + } + + /** + * Closes the previously opened group by added given content to it or + * throws an exception if no previous group was opened + * + * @param $content Content for previously opened group, or empty to use tag of opener + * @return void + * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found + */ + public function closePreviousGroupByContent ($content = '') { + // Check if any sub group was opened before + if ($this->ifSubGroupOpenedPreviously()) { + // Close it automatically + $this->closePreviousSubGroupByContent(); + } // END - if + + // Check if any group was opened before + if ($this->ifGroupOpenedPreviously() === FALSE) { + // Then throw an exception + throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Get previous group + $groupId = $this->getPreviousGroupId(); + + // Is the content empty? + if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) { + // Get it from opener + $content = sprintf( + "", + $groupId, + $this->groups[$groupId]['tag'] + ); + } // END - if + + // Add content to it and mark it as closed + $this->groups[$groupId]['content'] .= sprintf( + "%s\n", + $groupId, + strlen($content), + $this->groups[$groupId]['tag'], + $content + ); + $this->groups[$groupId]['opened'] = FALSE; + + // Mark previous group as closed + $this->setPreviousGroupId(''); + //* DEBUG: */ echo "CLOSE:groupId={$groupId}
    \n"; + } + + /** + * Opens a helper sub group with given group id and content or throws an + * exception if that sub group is already found regardless if it is open or + * closed. + * + * @param $subGroupId Sub group id to open + * @param $content Initial content to add to the sub group + * @param $tag HTML tag used to open this group + * @return void + * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before + */ + protected function openSubGroupByIdContent ($subGroupId, $content, $tag) { + //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."
    \n"; + // Is the group already there? + if (isset($this->subGroups[$subGroupId])) { + // Then throw an exception here + throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND); + } // END - if + + // Count one up + $this->totalCounter++; + + // Add the group to the stack + $this->subGroups[$this->totalCounter] = $subGroupId; + $this->subGroups[$subGroupId]['opened'] = TRUE; + $this->subGroups[$subGroupId]['content'] = sprintf("%s\n", $subGroupId, strlen($content), $tag, $content); + $this->subGroups[$subGroupId]['tag'] = $tag; + + // Mark this group as previously opened + $this->setPreviousSubGroupId($subGroupId); + } + + /** + * Closes the previously opened sub group by added given content to it or + * throws an exception if no previous sub group was opened + * + * @param $content Content for previously opened sub group, or leave empty to use div/span of openener + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + */ + public function closePreviousSubGroupByContent ($content = '') { + // Check if any sub group was opened before + if ($this->ifSubGroupOpenedPreviously() === FALSE) { + // Then throw an exception + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Get previous sub group + $subGroupId = $this->getPreviousSubGroupId(); + + // Is the content empty? + if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) { + // Get it from opener + $content = sprintf('', $subGroupId, $this->subGroups[$subGroupId]['tag']); + } // END - if + + // Add content to it and mark it as closed + $this->subGroups[$subGroupId]['content'] .= sprintf('%s' . PHP_EOL, $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content); + $this->subGroups[$subGroupId]['opened'] = FALSE + ; + + // Mark previous sub group as closed + $this->setPreviousSubGroupId(''); + //* DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}
    \n"; + } + + /** + * Renders all group and sub group in their order + * + * @return $content Rendered HTML content + */ + public function renderContent () { + // Initialize content + $content = ''; + + // Is header content there? + if (isset($this->groups['header'])) { + // Then add it + $content .= $this->groups['header']['content'] . PHP_EOL; + } // END - if + + // Initiate content + $content .= $this->getContent(); + + // Now "walk" through all groups and sub-groups + for ($idx = 1; $idx <= $this->totalCounter; $idx++) { + // Is this a sub/group and is it closed? + if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === FALSE)) { + // Then add it's content + $groupContent = trim($this->groups[$this->groups[$idx]]['content']); + //* DEBUG: */ echo "group={$this->groups[$idx]},content=
    ".htmlentities($groupContent)."

    \n"; + $content .= $groupContent; + } elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === FALSE)) { + // Then add it's content + $subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content']; + //* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=
    ".htmlentities($subGroupContent)."

    \n"; + $content .= trim($subGroupContent); + } else { + // Something went wrong + $this->debugInstance(__METHOD__ . '(): Something unexpected happened here.'); + } + } // END - for + + // Is footer content there? + if (isset($this->groups['footer'])) { + // Then add it + $content .= $this->groups['footer']['content'] . PHP_EOL; + } // END - if + + // Return it + //* DEBUG: */ echo "content=
    ".htmlentities($content)."
    (".strlen($content).")
    \n"; + return $content; + } + + /** + * Checks whether the specified group is opened + * + * @param $groupId Id of group to check + * @return $isOpened Whether the specified group is open + */ + protected function ifGroupIsOpened ($groupId) { + // Is the group open? + $isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === TRUE)); + + // Return status + return $isOpened; + } + + /** + * Getter for direct field values + * + * @param $fieldName Name of the field we shall fetch + * @return $fieldValue Value from field + * @throws NullPointerException Thrown if $valueInstance is null + */ + public function getValueField ($fieldName) { + // Init value + $fieldValue = NULL; + + // The $valueInstance attribute should not be null! + if (is_null($this->getValueInstance())) { + // Throws an exception here + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Is the field set? + if ($this->getValueInstance()->isFieldSet($fieldName)) { + // Get the field value + $fieldValue = $this->getValueInstance()->getField($fieldName); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!'); + } elseif ((!is_null($this->extraInstance)) && ($this->extraInstance->isFieldSet($fieldName))) { + // So try the extra instance + $fieldValue = $this->extraInstance->getField($fieldName); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!'); + } else { + // Field is not set + $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fieldName=' . $fieldName . ' is not set! - @TODO'); + } // END - if + + // Return it + return $fieldValue; + } + + /** + * Getter for value instance + * + * @return $valueInstance Instance of the class holding our values + */ + public final function getValueInstance () { + return $this->valueInstance; + } + + /** + * Check whether a group was opened previously + * + * @return $groupOpened Whether any group was opened before + */ + protected final function ifGroupOpenedPreviously () { + $groupOpened = (!empty($this->previousGroupId)); + return $groupOpened; + } + + /** + * Check whether a group was opened previously + * + * @return $subGroupOpened Whether any group was opened before + */ + protected final function ifSubGroupOpenedPreviously () { + $subGroupOpened = (!empty($this->previousSubGroupId)); + return $subGroupOpened; + } + + /** + * Getter for previous group id + * + * @return $previousGroupId Id of previously opened group + */ + protected final function getPreviousGroupId () { + return $this->previousGroupId; + } + + /** + * Setter for previous group id + * + * @param $previousGroupId Id of previously opened group + * @return void + */ + protected final function setPreviousGroupId ($previousGroupId) { + $this->previousGroupId = (string) $previousGroupId; + } + + /** + * Getter for previous sub group id + * + * @return $previousSubGroupId Id of previously opened sub group + */ + protected final function getPreviousSubGroupId () { + return $this->previousSubGroupId; + } + + /** + * Setter for previous sub group id + * + * @param $previousSubGroupId Id of previously opened sub group + * @return void + */ + protected final function setPreviousSubGroupId ($previousSubGroupId) { + $this->previousSubGroupId = (string) $previousSubGroupId; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/html/.htaccess b/inc/main/classes/helper/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/html/blocks/.htaccess b/inc/main/classes/helper/html/blocks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/html/blocks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/html/blocks/class_HtmlBlockHelper.php b/inc/main/classes/helper/html/blocks/class_HtmlBlockHelper.php new file mode 100644 index 00000000..b0fc6605 --- /dev/null +++ b/inc/main/classes/helper/html/blocks/class_HtmlBlockHelper.php @@ -0,0 +1,151 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlBlockHelper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Name of the block + */ + private $blockName = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $blockName Name of the block we shall generate + * @return $helperInstance A prepared instance of this helper + */ + public static final function createHtmlBlockHelper (CompileableTemplate $templateInstance, $blockName) { + // Get new instance + $helperInstance = new HtmlBlockHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set block name + $helperInstance->setBlockName($blockName); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Setter for block name + * + * @param $blockName Name of the block we shall generate + * @return void + */ + protected final function setBlockName ($blockName) { + $this->blockName = (string) $blockName; + } + + /** + * Getter for block name + * + * @return $blockName Name of the block we shall generate + */ + public final function getBlockName () { + return $this->blockName; + } + + /** + * Checks whether include registration date in this block + * + * @return $withRegistration Whether with registration date + */ + public function ifIncludeRegistrationStamp () { + $withRegistration = ($this->getConfigInstance()->getConfigEntry('block_shows_registration') == 'Y'); + return $withRegistration; + } + + /** + * Assignes a template variable with a message from a given message id + * + * @param $templateVariable Template variable to assign + * @param $messageId Message id to load an assign + * @return void + */ + public function assignMessageField ($templateVariable, $messageId) { + // Get message + $message = $this->getLanguageInstance()->getMessage($messageId); + + // And assign it + $this->getTemplateInstance()->assignVariable($templateVariable, $message); + } + + /** + * Assigns a link field with a given value + * + * @param $linkField "Link field" (variable) to assign + * @param $actionValue Action value to assign + * @return void + */ + public function assignLinkFieldWithAction ($linkField, $actionValue) { + $this->getTemplateInstance()->assignVariable($linkField . '_action', $actionValue); + } + + /** + * "Filter" method for translating the raw user status into something human-readable + * + * @param $userStatus Raw user status from database layer + * @return $translated Translated user status + */ + protected function doFilterUserStatusTranslator ($userStatus) { + // Generate message id + $messageId = 'user_status_' . strtolower($userStatus); + + // Get that message + $translated = $this->getLanguageInstance()->getMessage($messageId); + + // Return it + return $translated; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + */ + public function flushContent () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the template named like this block + $templateInstance->loadCodeTemplate('block_' . $this->getBlockName()); + + // Transfer it to the template instance + $templateInstance->assignVariable($this->getBlockName(), $templateInstance->getRawTemplateData()); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/html/class_ b/inc/main/classes/helper/html/class_ new file mode 100644 index 00000000..09466e18 --- /dev/null +++ b/inc/main/classes/helper/html/class_ @@ -0,0 +1,76 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Html???Helper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Name of the ??? + */ + private $???Name = ""; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set part description + $this->setObjectDescription(""); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $???Name Name of the ??? we shall generate + * @return $helperInstance A prepared instance of this helper + */ + public final static function createHtml???Helper (CompileableTemplate $templateInstance, $???Name) { + // Get new instance + $helperInstance = new Html???Helper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set ??? name + $helperInstance->set???Name($???Name); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + * @todo 0% done + */ + public function flushContent () { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/html/class_BaseHtmlHelper.php b/inc/main/classes/helper/html/class_BaseHtmlHelper.php new file mode 100644 index 00000000..02497dde --- /dev/null +++ b/inc/main/classes/helper/html/class_BaseHtmlHelper.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHtmlHelper extends BaseHelper { + /** + * Protected constructor + * + * @param $className The real class name + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/html/forms/.htaccess b/inc/main/classes/helper/html/forms/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/html/forms/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/html/forms/class_HtmlFormHelper.php b/inc/main/classes/helper/html/forms/class_HtmlFormHelper.php new file mode 100644 index 00000000..3f4bc598 --- /dev/null +++ b/inc/main/classes/helper/html/forms/class_HtmlFormHelper.php @@ -0,0 +1,938 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlFormHelper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Whether the form tag is opened (keep at FALSE or else your forms will + * never work!) + */ + private $formOpened = FALSE; + + /** + * Name of the form + */ + private $formName = ''; + + /** + * Whether form tag is enabled (default: TRUE) + */ + private $formEnabled = TRUE; + + // Class Constants + const EXCEPTION_FORM_NAME_INVALID = 0x120; + const EXCEPTION_CLOSED_FORM = 0x121; + const EXCEPTION_OPENED_FORM = 0x122; + const EXCEPTION_UNEXPECTED_CLOSED_GROUP = 0x123; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class with the given template engine instance and form name + * + * @param $templateInstance An instance of a valid template engine + * @param $formName Name of the form + * @param $formId Value for 'id' attribute (default: $formName) + * @param $withForm Whether include the form tag + * @return $helperInstance A preparedf instance of this helper + */ + public static final function createHtmlFormHelper (CompileableTemplate $templateInstance, $formName, $formId = FALSE, $withForm = TRUE) { + // Get new instance + $helperInstance = new HtmlFormHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Is the form id not set? + if ($formId === FALSE) { + // Use form id from form name + $formId = $formName; + } // END - if + + // Set form name + $helperInstance->setFormName($formName); + + // A form-less field may say 'FALSE' here... + if ($withForm === TRUE) { + // Create the form + $helperInstance->addFormTag($formName, $formId); + } else { + // Disable form + $helperInstance->enableForm(FALSE); + } + + // Return the prepared instance + return $helperInstance; + } + + /** + * Add the form tag or close it an already opened form tag + * + * @param $formName Name of the form (default: FALSE) + * @param $formId Id of the form (attribute 'id'; default: FALSE) + * @return void + * @throws InvalidFormNameException If the form name is invalid ( = FALSE) + * @todo Add some unique PIN here to bypass problems with some browser and/or extensions + */ + public function addFormTag ($formName = FALSE, $formId = FALSE) { + // When the form is not yet opened at least form name must be valid + if (($this->formOpened === FALSE) && ($formName === FALSE)) { + // Thrown an exception + throw new InvalidFormNameException ($this, self::EXCEPTION_FORM_NAME_INVALID); + } // END - if + + // Close the form is default + $formContent = ''; + + // Check whether we shall open or close the form + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Add HTML code + $formContent = sprintf("
    getConfigInstance()->getConfigEntry('base_url'), + $this->getConfigInstance()->getConfigEntry('form_action'), + $this->getConfigInstance()->getConfigEntry('form_method'), + $this->getConfigInstance()->getConfigEntry('form_target') + ); + + // Add form id as well + $formContent .= sprintf(" id=\"%s_form\"", + $formId + ); + + // Add close bracket + $formContent .= '>'; + + // Open the form and remeber the form name + $this->formOpened = TRUE; + + // Add it to the content + $this->addHeaderContent($formContent); + } else { + // Add the hidden field required to identify safely this form + $this->addInputHiddenField('form', $this->getFormName()); + + // Is a group open? + if ($this->ifGroupOpenedPreviously()) { + // Then automatically close it here + $this->addFormGroup(); + } // END - if + + // Simply close it + $this->formOpened = FALSE; + + // Add it to the content + $this->addFooterContent($formContent); + } + } + + /** + * Add a text input tag to the form or throw an exception if it is not yet + * opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputTextField ($fieldName, $fieldValue = '') { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $fieldValue + ); + + // And add it maybe with a 'li' tag + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a text input tag to the form with pre-loaded default value + * + * @param $fieldName Input field name + * @return void + */ + public function addInputTextFieldWithDefault ($fieldName) { + // Get the value from instance + $fieldValue = $this->getValueField($fieldName); + //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
    \n"; + + // Add the text field + $this->addInputTextField($fieldName, $fieldValue); + } + + /** + * Add a password input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputPasswordField ($fieldName, $fieldValue = '') { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $fieldValue + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a hidden input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldValue Input default value (default: empty) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputHiddenField ($fieldName, $fieldValue = '') { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldValue + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a hidden input tag to the form with pre-loaded default value + * + * @param $fieldName Input field name + * @return void + */ + public function addInputHiddenFieldWithDefault ($fieldName) { + // Get the value from instance + $fieldValue = $this->getValueField($fieldName); + //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
    \n"; + + // Add the text field + $this->addInputHiddenField($fieldName, $fieldValue); + } + + /** + * Add a hidden input tag to the form with configuration value + * + * @param $fieldName Input field name + * @param $prefix Prefix for configuration without trailing _ + * @return void + */ + public function addInputHiddenConfiguredField ($fieldName, $prefix) { + // Get the value from instance + $fieldValue = $this->getConfigInstance()->getConfigEntry("{$prefix}_{$fieldName}"); + //* DEBUG: */ print __METHOD__.':'.$fieldName.'='.$fieldValue."
    \n"; + + // Add the text field + $this->addInputHiddenField($fieldName, $fieldValue); + } + + /** + * Add a checkbox input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $fieldName Input field name + * @param $fieldChecked Whether the field is checked (defaut: checked) + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputCheckboxField ($fieldName, $fieldChecked = TRUE) { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Set whether the check box is checked... + $checked = " checked=\"checked\""; + if ($fieldChecked === FALSE) $checked = ' '; + + // Generate the content + $inputContent = sprintf("", + $fieldName, + $fieldName, + $checked + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a reset input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $buttonText Text displayed on the button + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputResetButton ($buttonText) { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'reset'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $this->getFormName(), + $buttonText + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a reset input tag to the form or throw an exception if it is not + * yet opened. The field's name will be set as id. + * + * @param $buttonText Text displayed on the button + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputSubmitButton ($buttonText) { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'submit'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("", + $this->getFormName(), + $this->getFormName(), + $buttonText + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add a form group or close an already opened and open a new one + * + * @param $groupId Name of the group or last opened if empty + * @param $groupText Text including HTML to show above this group + * @return void + * @throws FormClosedException If no form has been opened before + * @throws EmptyVariableException If $groupId is not set + */ + public function addFormGroup ($groupId = '', $groupText = '') { + // Is a form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw exception here + throw new FormClosedException(array($this, $groupId), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // At least the group name should be set + if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === FALSE)) { + // Throw exception here + throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (empty($groupId)) { + // Close the last opened + $groupId = $this->getPreviousGroupId(); + } + + // Same group to open? + if (($this->ifGroupOpenedPreviously() === FALSE) && ($groupId === $this->getPreviousGroupId())) { + // Abort here silently + return FALSE; + } // END - if + + // Initialize content with closing div by default + $content = "
    \n
    "; + + // Is this group opened? + if ($this->ifGroupOpenedPreviously() === FALSE) { + // Begin the div/span blocks + $content = sprintf(" +
    + + %s + +
    ", + $groupId, + $groupId, + $groupId, + $groupText, + $groupId + ); + + // Switch the state + $this->openGroupByIdContent($groupId, $content, "div"); + } else { + // Is a sub group opened? + if ($this->ifSubGroupOpenedPreviously()) { + // Close it here + $this->addFormSubGroup(); + } // END - if + + // Get previous group id + $prevGroupId = $this->getPreviousGroupId(); + + // Switch the state + $this->closePreviousGroupByContent($content); + + // All call it again if group name is not empty + if ((!empty($groupId)) && ($groupId != $prevGroupId)) { + //* DEBUG: */ echo $groupId.'/'.$prevGroupId."
    \n"; + $this->addFormGroup($groupId, $groupText); + } // END - if + } + } + + /** + * Add a form sub group or close an already opened and open a new one or + * throws an exception if no group has been opened before or if sub group + * name is empty. + * + * @param $subGroupId Name of the group or last opened if empty + * @param $subGroupText Text including HTML to show above this group + * @return void + * @throws FormFormClosedException If no group has been opened before + * @throws EmptyVariableException If $subGroupId is not set + */ + public function addFormSubGroup ($subGroupId = '', $subGroupText = '') { + // Is a group opened? + if ($this->ifGroupOpenedPreviously() === FALSE) { + // Throw exception here + throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP); + } // END - if + + // At least the sub group name should be set + if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === FALSE)) { + // Throw exception here + throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (empty($subGroupId)) { + // Close the last opened + $subGroupId = $this->getPreviousSubGroupId(); + } + + // Same sub group to open? + if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($subGroupId == $this->getPreviousSubGroupId())) { + // Abort here silently + return FALSE; + } // END - if + + // Initialize content with closing div by default + $content = "
    \n
    "; + + // Is this group opened? + if ($this->ifSubGroupOpenedPreviously() === FALSE) { + // Begin the span block + $content = sprintf(" +
    + + %s + +
    ", + $subGroupId, + $subGroupId, + $subGroupId, + $subGroupText, + $subGroupId + ); + + // Switch the state and remeber the name + $this->openSubGroupByIdContent($subGroupId, $content, "div"); + } else { + // Get previous sub group id + $prevSubGroupId = $this->getPreviousSubGroupId(); + + // Switch the state + $this->closePreviousSubGroupByContent($content); + + // All call it again if sub group name is not empty + if ((!empty($subGroupId)) && ($subGroupId != $prevSubGroupId)) { + $this->addFormSubGroup($subGroupId, $subGroupText); + } // END - if + } + } + + /** + * Add text surrounded by a span block when there is a group opened before + * or else by a div block. + * + * @param $fieldName Field name + * @param $fieldText Text for the field + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addFieldText ($fieldName, $fieldText) { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, $fieldName), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Set the block type + $block = 'div'; + if ($this->ifGroupOpenedPreviously()) $block = 'span'; + + // Generate the content + $inputContent = sprintf(" <%s id=\"%s_text\"> + %s + ", + $block, + $fieldName, + $fieldText, + $block + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Add text (notes) surrounded by a div block. Still opened groups or sub + * groups will be automatically closed. + * + * @param $noteId Id for this note + * @param $formNotes The form notes we shell addd + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addFormNote ($noteId, $formNotes) { + // Is the form opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Generate the content + $inputContent = sprintf("
    + %s +
    ", + $noteId, + $formNotes + ); + + // And add it + $this->addContentToPreviousGroup($inputContent); + } + + /** + * Adds a selection box as a sub group to the form. Do not box this into + * another sub group. Sub-sub groups are not (yet) supported. + * + * @param $selectId Id of the selection box + * @param $firstEntry Content to be added as first non-selectable entry + * @return void + * @throws FormClosedException If the form is not yet opened + */ + public function addInputSelectField ($selectId, $firstEntry) { + // Is the form group opened? + if (($this->formOpened === FALSE) && ($this->formEnabled === TRUE)) { + // Throw an exception + throw new FormClosedException (array($this, 'form_notes'), self::EXCEPTION_CLOSED_FORM); + } // END - if + + // Shall we close or open the sub group? + if (($this->ifSubGroupOpenedPreviously() === FALSE) && ($this->getPreviousSubGroupId() !== $selectId)) { + // Initialize first entry (which might be non-selectable if content is provided + if (!empty($firstEntry)) { + // Add selection around it + $firstEntry = sprintf("\n", + $firstEntry + ); + } // END - if + + // Construct the opening select tag + $content = sprintf(""); + } + } + + /** + * Adds a non-selectable sub option to a previously added selection box. + * This method does *not* validate if there is already a sub option added + * with the same name. We need to finish this here! + * + * @param $subName Name of the sub action + * @param $subValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added + */ + public function addSelectSubOption ($subName, $subValue) { + // Is there a sub group (shall be a selection box!) + if ($this->ifSubGroupOpenedPreviously() === FALSE) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $subName, + $subValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); + } + + /** + * Adds a selectable option to a previously added selection box. This method + * does *not* validate if there is already a sub option added with the same + * name. We need to finish this here! + * + * @param $optionName Name of the sub action + * @param $optionValue Value of the sub action + * @return void + * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found + * @todo Add checking if sub option is already added + */ + public function addSelectOption ($optionName, $optionValue) { + // Is there a sub group (shall be a selection box!) + if ($this->ifSubGroupOpenedPreviously() === FALSE) { + // Then throw an exception here + throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED); + } // END - if + + // Render the content + $content = sprintf("\n", + $optionName, + $optionName, + $optionValue + ); + + // Add the content to the previously opened sub group + $this->addContentToPreviousGroup($content); + } + + /** + * Adds a pre-configured CAPTCHA + * + * @return void + */ + public function addCaptcha () { + // Init instance + $extraInstance = NULL; + + try { + // Get last executed pre filter + $extraInstance = Registry::getRegistry()->getInstance('extra'); + } catch (NullPointerException $e) { + // Instance in registry is not set (NULL) + // @TODO We need to log this later + } + + // Get a configured instance + $captchaInstance = ObjectFactory::createObjectByConfiguredName($this->getFormName() . '_captcha_class', array($this, $extraInstance)); + + // Initiate the CAPTCHA + $captchaInstance->initiateCaptcha(); + + // Render the CAPTCHA code + $captchaInstance->renderCode(); + + // Get the content and add it to the helper + $this->addContentToPreviousGroup($captchaInstance->renderContent()); + } + + /** + * Enables/disables the form tag usage + * + * @param $formEnabled Whether form is enabled or disabled + * @return void + */ + public final function enableForm ($formEnabled = TRUE) { + $this->formEnabled = (bool) $formEnabled; + } + + /** + * Setter for form name + * + * @param $formName Name of this form + * @return void + */ + public final function setFormName ($formName) { + $this->formName = (string) $formName; + } + + /** + * Getter for form name + * + * @return $formName Name of this form + */ + public final function getFormName () { + return $this->formName; + } + + /** + * Checks whether the registration requires a valid email address + * + * @return $required Whether the email address is required + */ + public function ifRegisterRequiresEmailVerification () { + $required = ($this->getConfigInstance()->getConfigEntry('register_requires_email') == 'Y'); + return $required; + } + + /** + * Checks whether profile data shall be asked + * + * @return $required Whether profile data shall be asked + */ + public function ifRegisterIncludesProfile () { + $required = ($this->getConfigInstance()->getConfigEntry('register_includes_profile') == 'Y'); + return $required; + } + + /** + * Checks whether this form is secured by a CAPTCHA + * + * @return $isSecured Whether this form is secured by a CAPTCHA + */ + public function ifFormSecuredWithCaptcha () { + $isSecured = ($this->getConfigInstance()->getConfigEntry($this->getFormName() . '_captcha_secured') == 'Y'); + return $isSecured; + } + + /** + * Checks whether personal data shall be asked + * + * @return $required Whether personal data shall be asked + */ + public function ifRegisterIncludesPersonaData () { + $required = ($this->getConfigInstance()->getConfigEntry('register_personal_data') == 'Y'); + return $required; + } + + /** + * Checks whether for birthday shall be asked + * + * @return $required Whether birthday shall be asked + */ + public function ifProfileIncludesBirthDay () { + $required = ($this->getConfigInstance()->getConfigEntry('profile_includes_birthday') == 'Y'); + return $required; + } + + /** + * Checks whether email addresses can only be once used + * + * @return $isUnique + */ + public function ifEmailMustBeUnique () { + $isUnique = ($this->getConfigInstance()->getConfigEntry('register_email_unique') == 'Y'); + return $isUnique; + } + + /** + * Checks whether the specified chat protocol is enabled in this form + * + * @return $required Whether the specified chat protocol is enabled + */ + public function ifChatEnabled ($chatProtocol) { + $required = ($this->getConfigInstance()->getConfigEntry('chat_enabled_' . $chatProtocol) == 'Y'); + return $required; + } + + /** + * Checks whether login is enabled or disabled + * + * @return $isEnabled Whether the login is enabled or disabled + */ + public function ifLoginIsEnabled () { + $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_enabled') == 'Y'); + return $isEnabled; + } + + /** + * Checks whether login shall be done by username + * + * @return $isEnabled Whether the login shall be done by username + */ + public function ifLoginWithUsername () { + $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "username"); + return $isEnabled; + } + + /** + * Checks whether login shall be done by email + * + * @return $isEnabled Whether the login shall be done by email + */ + public function ifLoginWithEmail () { + $isEnabled = ($this->getConfigInstance()->getConfigEntry('login_type') == "email"); + return $isEnabled; + } + + /** + * Checks whether guest login is allowed + * + * @return $isAllowed Whether guest login is allowed + */ + public function ifGuestLoginAllowed () { + $isAllowed = ($this->getConfigInstance()->getConfigEntry('guest_login_allowed') == 'Y'); + return $isAllowed; + } + + /** + * Checks whether the email address change must be confirmed + * + * @return $requireConfirm Whether email change must be confirmed + */ + public function ifEmailChangeRequireConfirmation () { + $requireConfirm = ($this->getConfigInstance()->getConfigEntry('email_change_confirmation') == 'Y'); + return $requireConfirm; + } + + /** + * Checks whether the rules has been updated + * + * @return $rulesUpdated Whether rules has been updated + * @todo Implement check if rules have been changed + */ + public function ifRulesHaveChanged () { + return FALSE; + } + + /** + * Checks whether email change is allowed + * + * @return $emailChange Whether changing email address is allowed + */ + public function ifEmailChangeAllowed () { + $emailChange = ($this->getConfigInstance()->getConfigEntry('email_change_allowed') == 'Y'); + return $emailChange; + } + + /** + * Checks whether the user account is unconfirmed + * + * @return $isUnconfirmed Whether the user account is unconfirmed + */ + public function ifUserAccountUnconfirmed () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_unconfirmed')); + return $isUnconfirmed; + } + + /** + * Checks whether the user account is locked + * + * @return $isUnconfirmed Whether the user account is locked + */ + public function ifUserAccountLocked () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_locked')); + return $isUnconfirmed; + } + + /** + * Checks whether the user account is a guest + * + * @return $isUnconfirmed Whether the user account is a guest + */ + public function ifUserAccountGuest () { + $isUnconfirmed = ($this->getValueField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) === $this->getConfigInstance()->getConfigEntry('user_status_guest')); + return $isUnconfirmed; + } + + /** + * Checks whether the refill page is active which should be not the default + * on non-web applications. + * + * @return $refillActive Whether the refill page is active + */ + public function ifRefillPageActive () { + $refillActive = ($this->getConfigInstance()->getConfigEntry('refill_page_active') == 'Y'); + return $refillActive; + } + + /** + * Flushs the content out (not yet secured against open forms, etc.!) or + * close the form automatically + * + * @return void + * @throws FormOpenedException If the form is still open + */ + public function flushContent () { + // Is the form still open? + if (($this->formOpened === TRUE) && ($this->formEnabled === TRUE)) { + // Close the form automatically + $this->addFormTag(); + } elseif ($this->formEnabled === FALSE) { + if ($this->ifSubGroupOpenedPreviously()) { + // Close sub group + $this->addFormSubGroup(); + } elseif ($this->ifGroupOpenedPreviously()) { + // Close group + $this->addFormGroup(); + } + } + + // Send content to template engine + //* DEBUG: */ print __METHOD__.": form=".$this->getFormName().", size=".strlen($this->renderContent())."
    \n"; + $this->getTemplateInstance()->assignVariable($this->getFormName(), $this->renderContent()); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/html/links/.htaccess b/inc/main/classes/helper/html/links/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/html/links/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/html/links/class_HtmlLinkHelper.php b/inc/main/classes/helper/html/links/class_HtmlLinkHelper.php new file mode 100644 index 00000000..5ac067e5 --- /dev/null +++ b/inc/main/classes/helper/html/links/class_HtmlLinkHelper.php @@ -0,0 +1,345 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlLinkHelper extends BaseHtmlHelper implements HelpableTemplate { + /** + * Name of the link + */ + private $linkName = ''; + + /** + * Base of the link + */ + private $linkBase = ''; + + /** + * First parameter separator + */ + const FIRST_PARAMETER_SEPARATOR = '?'; + + /** + * SEPARATOR for more paraemters + */ + const EXTRA_PARAMETER_SEPARATOR = '&'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates the helper class + * + * @param $templateInstance An instance of a template engine + * @param $linkName Name of the link we shall generate + * @param $linkBase Link base for the link. This parameter is deprecated. + * @return $helperInstance A prepared instance of this helper + * @throws NoConfigEntryException A deprecated exception at this point + */ + public static final function createHtmlLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = NULL) { + // Get new instance + $helperInstance = new HtmlLinkHelper(); + + // Set template instance + $helperInstance->setTemplateInstance($templateInstance); + + // Set link name + $helperInstance->setLinkName($linkName); + + // Get the application instance + $applicationInstance = Registry::getRegistry()->getInstance('application'); + + // Get the request instance + $requestInstance = $applicationInstance->getRequestInstance(); + + // Sanity-check on it + if (is_null($requestInstance)) { + // Throw an exception here + throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get page (this will throw an exception if not set) + $command = $helperInstance->convertDashesToUnderscores($requestInstance->getRequestElement('command')); + + // Construct config entry + $configEntry = $command . '_' . $linkName . '_action_url'; + + // Is the deprecated parameter set? + if (!is_null($linkBase)) { + // Then output a deprecation message + $helperInstance->deprecationWarning('[' . __METHOD__ . ':' . __LINE__ . ']: linkBase is deprecated. Please remove it from your templates and add a config entry ' . $configEntry . ' in your config.php file.'); + } // END - if + + // Determine link base from config now and 'command' request + try { + $newLinkBase = $helperInstance->getConfigInstance()->getConfigEntry($configEntry); + $linkBase = $newLinkBase; + } catch (NoConfigEntryException $e) { + // Is the deprecated linkBase not set? + if (is_null($linkBase)) { + // Then throw again the exception + throw new NoConfigEntryException(array(__CLASS__, ($configEntry)), FrameworkConfiguration::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); + } // END - if + } + + // Set link base + $helperInstance->setLinkBase($linkBase); + + // Add default group + $helperInstance->openGroupByIdContent('main', '', ''); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Renders the link content (HTML code) with given link text and optional + * extra content + * + * @param $linkText Link text to set in link + * @param $linkTitle Link title to set in link + * @param $extraContent Optional extra HTML content + * @return $linkContent Rendered text link content + */ + private function renderLinkContentWithTextExtraContent ($linkText, $linkTitle, $extraContent='') { + // Construct link content + $linkContent = sprintf('%s', + $this->getLinkBase(), + $extraContent, + $linkTitle, + $linkText + ); + + // Return it + return $linkContent; + } + + /** + * Setter for link name + * + * @param $linkName Name of the link we shall generate + * @return void + */ + protected final function setLinkName ($linkName) { + $this->linkName = (string) $linkName; + } + + /** + * Getter for link name + * + * @return $linkName Name of the link we shall generate + */ + public final function getLinkName () { + return $this->linkName; + } + + /** + * Setter for link base + * + * @param $linkBase Base of the link we shall generate + * @return void + */ + protected final function setLinkBase ($linkBase) { + $this->linkBase = (string) $linkBase; + } + + /** + * Getter for link base + * + * @return $linkBase Base of the link we shall generate + */ + public final function getLinkBase () { + return $this->linkBase; + } + + /** + * Flush the content out,e g. to a template variable + * + * @return void + * @todo Completely unimplemented + */ + public function flushContent () { + // Is a previous opened group still open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it + $this->closePreviousGroupByContent(''); + } // END - if + + // Get the content + $content = $this->renderContent(); + + // Get template engine + $templateInstance = $this->getTemplateInstance(); + + // Add content to variable + $templateInstance->assignVariable($this->getLinkName(), $content); + } + + /** + * Adds a link group (like the form group is) with some raw language to the + * helper. + * + * @param $groupId Id string of the group + * @param $groupText Text for this group to add + * @param $groupCode Code to open and close groups + * @return void + */ + public function addLinkGroup ($groupId, $groupText, $groupCode = 'div') { + // Is a group with that name open? + if ($this->ifGroupOpenedPreviously()) { + // Then close it here + $this->closePreviousGroupByContent(''); + } // END - if + + // Generate the group content + $content = sprintf('<%s id="group_%s_%s">%s', + $groupCode, + $this->getLinkName(), + $groupId, + $groupText + ); + + // Open the new group + $this->openGroupByIdContent($groupId, $content, $groupCode); + } + + /** + * Adds text (note) to the previously opened group or throws an exception + * if no previous group was opened. + * + * @param $groupId Group id to set + * @param $groupNote Note to be added to a group + * @param $groupCode Code to open and close groups + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + public function addLinkNote ($groupId, $groupNote, $groupCode = 'div') { + // Check if a previous group was opened + if ($this->ifGroupOpenedPreviously() === FALSE) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Is a previous sub group open? + if ($this->ifSubGroupOpenedPreviously()) { + // Then close it + $this->closePreviousSubGroupByContent(''); + } // END - if + + // Generate the group content + $content = sprintf('<%s id="subgroup_%s_%s">%s', + $groupCode, + $this->getLinkName(), + $groupId, + $groupNote + ); + + // Open the sub group + $this->openSubGroupByIdContent($groupId, $content, $groupCode); + } + + /** + * Adds a link to the previously opened group or throws an exception if no group has been opened + * + * @param $linkAction Action (action=xxx) value for the link + * @param $linkText Link text and title (title="xxx") for the link + * @return void + * @throws NoGroupOpenedException If no previous group was opened + */ + protected function addActionLink ($linkAction, $linkText, $linkTitle) { + // Check if a previous group was opened + if ($this->ifGroupOpenedPreviously() === FALSE) { + // No group was opened before! + throw new NoGroupOpenedException(array($this, $linkAction . '(' . $linkText . ')'), self::EXCEPTION_GROUP_NOT_OPENED); + } // END - if + + // Default parameter SEPARATOR is & + $separator = self::EXTRA_PARAMETER_SEPARATOR; + + // Is there a question mark in? + $linkArray = explode(self::FIRST_PARAMETER_SEPARATOR, $this->getLinkBase()); + if (count($linkArray) == 0) { + // No question mark + $separator = self::FIRST_PARAMETER_SEPARATOR; + } // END - if + + // Prepare action + $action = sprintf('%saction=%s', + $separator, + $linkAction + ); + + // Renders the link content + $linkContent = $this->renderLinkContentWithTextExtraContent($linkText, $linkTitle, $action); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); + } + + /** + * Adds a link to the previously opened group with a text from language system + * + * @param $linkAction Action (action=xxx) value for the link + * @param $languageId Language id string to use + * @return void + */ + public function addActionLinkById ($linkAction, $languageId) { + // Resolve the language string + $languageResolvedText = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_text'); + + // Resolve the language string + $languageResolvedTitle = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_title'); + + // Add the action link + $this->addActionLink($linkAction, $languageResolvedText, $languageResolvedTitle); + } + + /** + * Adds a default link (no extra parameters) to the content with specified + * language id string. + * + * @param $languageId Language id string to use + * @return void + */ + public function addLinkWithTextById ($languageId) { + // Resolve the language string + $languageResolvedText = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_text'); + + // Resolve the language string + $languageResolvedTitle = $this->getLanguageInstance()->getMessage('link_' . $languageId . '_title'); + + // Now add the link + $linkContent = $this->renderLinkContentWithTextExtraContent($languageResolvedText, $languageResolvedTitle); + + // Add the content to the previous group + $this->addContentToPreviousGroup($linkContent); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/helper/login/.htaccess b/inc/main/classes/helper/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/helper/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/helper/login/class_BaseLoginHelper.php b/inc/main/classes/helper/login/class_BaseLoginHelper.php new file mode 100644 index 00000000..6f6bee44 --- /dev/null +++ b/inc/main/classes/helper/login/class_BaseLoginHelper.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseLoginHelper extends BaseHelper { + /** + * Protected constructor + * + * @param $className Real name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/images/.htaccess b/inc/main/classes/images/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/images/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/images/class_ b/inc/main/classes/images/class_ new file mode 100644 index 00000000..77dbf732 --- /dev/null +++ b/inc/main/classes/images/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Image extends BaseImage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this image class + * + * @return $imageInstance An instance of this image class + */ + public final static function create???Image() { + // Get a new instance + $imageInstance = new ???Image(); + + // Set image type + $imageInstance->setImageType("???"); + + // Return the instance + return $imageInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/images/class_BaseImage.php b/inc/main/classes/images/class_BaseImage.php new file mode 100644 index 00000000..3c44ef60 --- /dev/null +++ b/inc/main/classes/images/class_BaseImage.php @@ -0,0 +1,561 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseImage extends BaseFrameworkSystem implements Registerable { + /** + * Image type + */ + private $imageType = ''; + + /** + * Width of the image + */ + private $width = ''; + + /** + * Height of the image + */ + private $height = ''; + + /** + * X/Y + */ + private $x = ''; + private $y = ''; + + /** + * Font size + */ + private $fontSize = ''; + + /** + * Image string + */ + private $imageString = ''; + + /** + * Background color in RGB + */ + private $backgroundColor = array( + 'red' => '', + 'green' => '', + 'blue' => '' + ); + + /** + * Foreground color in RGB + */ + private $foregroundColor = array( + 'red' => '', + 'green' => '', + 'blue' => '' + ); + + /** + * Current choosen color array + */ + private $colorMode = ''; + + /** + * Image resource + */ + private $imageResource = NULL; + + /** + * Image name + */ + private $imageName = ''; + + /** + * String name + */ + private $stringName = ''; + + /** + * Groupable image strings? + */ + private $groupable = 'single'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Private setter for all colors + * + * @param $colorMode Whether background or foreground color + * @param $colorChannel Red, green or blue channel? + * @param $colorValue Value to set + */ + private final function setColor ($colorMode, $colorChannel, $colorValue) { + // Construct the eval() command + $eval = sprintf("\$this->%s['%s'] = \"%s\";", + $colorMode, + $colorChannel, + $colorValue + ); + + // Run the command + //* DEBUG: */ echo "mode={$colorMode}, channel={$colorChannel}, value={$colorValue}
    \n"; + eval($eval); + } + + /** + * Setter for image width + * + * @param $width Width of the image + * @return void + */ + public final function setWidth ($width) { + $this->width = $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 = $height; + } + + /** + * Getter for image height + * + * @return $height Height of the image + */ + public final function getHeight () { + return $this->height; + } + + /** + * Finish the type handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishType () { + // Empty at the momemt + } + + /** + * Prepares the class for resolution (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function initResolution () { + // Empty at the momemt + } + + /** + * Finish resolution handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishResolution () { + // Empty at the momemt + } + + /** + * Prepares the class for base (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function initBase () { + // Empty at the momemt + } + + /** + * Finish base handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishBase () { + // Empty at the momemt + } + + /** + * Prepares the class for background color + * + * @return void + */ + public function initBackgroundColor () { + $this->colorMode = 'backgroundColor'; + } + + /** + * Finish background color handling + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishBackgroundColor () { + // Empty at the moment + } + + /** + * Prepares the class for foreground color + * + * @return void + */ + public function initForegroundColor () { + $this->colorMode = 'foregroundColor'; + } + + /** + * Finish foreground color handling + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishForegroundColor () { + // Empty at the moment + } + + /** + * Prepares the class for string (unused at the moment) + * + * @param $groupable Whether this image string is groupable or single + * @return void + * @todo Find something usefull for this method. + */ + public function initImageString ($groupable = 'single') { + $this->groupable = $groupable; + } + + /** + * Finish string handling (unused at the moment) + * + * @return void + * @todo Find something usefull for this method. + */ + public function finishImageString () { + // Empty at the momemt + } + + /** + * Setter for red color + * + * @param $red Red color value + * @return void + */ + public final function setRed ($red) { + // Get array name + $arrayName = $this->colorMode; + + // Set image color + $this->setColor($arrayName, 'red', $red); + } + + /** + * Setter for green color + * + * @param $green Green color value + * @return void + */ + public final function setGreen ($green) { + // Get array name + $arrayName = $this->colorMode; + + // Set image color + $this->setColor($arrayName, 'green', $green); + } + + /** + * Setter for blue color + * + * @param $blue Blue color value + * @return void + */ + public final function setBlue ($blue) { + // Get array name + $arrayName = $this->colorMode; + + // Set image color + $this->setColor($arrayName, 'blue', $blue); + } + + /** + * Setter for image string + * + * @param $string String to set in image + * @return void + */ + public final function setString ($string) { + $this->imageString = (string) $string; + } + + /** + * Getter for image string + * + * @return $string String to set in image + */ + public final function getString () { + return $this->imageString; + } + + /** + * Setter for image type + * + * @param $imageType Type to set in image + * @return void + */ + protected final function setImageType ($imageType) { + $this->imageType = (string) $imageType; + } + + /** + * Getter for image type + * + * @return $imageType Type to set in image + */ + public final function getImageType () { + return $this->imageType; + } + + /** + * Setter for image name + * + * @param $name Name of the image + * @return void + */ + public final function setImageName ($name) { + $this->imageName = (string) $name; + } + + /** + * Getter for image name + * + * @return $name Name of the image + */ + public final function getImageName () { + return $this->imageName; + } + + /** + * Getter for image resource + * + * @return $imageResource An image resource from imagecreatetruecolor() function + */ + public final function getImageResource() { + return $this->imageResource; + } + + /** + * Setter for X coordinate + * + * @param $x X coordinate + * @return void + */ + public final function setX ($x) { + $this->x = $x; + } + + /** + * Getter for X coordinate + * + * @return $x X coordinate + */ + public final function getX () { + return $this->x; + } + + /** + * Setter for Y coordinate + * + * @param $y Y coordinate + * @return void + */ + public final function setY ($y) { + $this->y = $y; + } + + /** + * Getter for Y coordinate + * + * @return $y Y coordinate + */ + public final function getY () { + return $this->y; + } + + /** + * Setter for font size + * + * @param $fontSize Font size for strings + * @return void + */ + public final function setFontSize ($fontSize) { + $this->fontSize = $fontSize; + } + + /** + * Getter for font size + * + * @return $fontSize Font size for strings + */ + public final function getFontSize () { + return $this->fontSize; + } + + /** + * Setter for string name + * + * @param $stringName String name to set + * @return void + */ + public final function setStringName($stringName) { + $this->stringName = $stringName; + } + + /** + * Finish this image by producing it + * + * @return void + */ + public function finishImage () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Compile width and height + $width = $templateInstance->compileRawCode($this->getWidth()); + $height = $templateInstance->compileRawCode($this->getHeight()); + + // Set both again + $this->setWidth($width); + $this->setHeight($height); + + // Get a image resource + $this->imageResource = imagecreatetruecolor($width, $height); + + // Compile background colors + $red = $templateInstance->compileRawCode($this->backgroundColor['red']); + $green = $templateInstance->compileRawCode($this->backgroundColor['green']); + $blue = $templateInstance->compileRawCode($this->backgroundColor['blue']); + + // Set all back + $this->initBackgroundColor(); + $this->setRed($red); + $this->setGreen($green); + $this->setBlue($blue); + + // Get a pointer for background color + $backColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue); + + // Fill the image + imagefill($this->getImageResource(), 0, 0, $backColor); + + // Compile foreground colors + $red = $templateInstance->compileRawCode($this->foregroundColor['red']); + $green = $templateInstance->compileRawCode($this->foregroundColor['green']); + $blue = $templateInstance->compileRawCode($this->foregroundColor['blue']); + + // Set all fore + $this->initForegroundColor(); + $this->setRed($red); + $this->setGreen($green); + $this->setBlue($blue); + + // Get a pointer for foreground color + $foreColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue); + + switch ($this->groupable) { + case 'single': // Single image string + // Compile image string + $imageString = $templateInstance->compileRawCode($this->getString()); + + // Set it back + $this->setString($imageString); + + // Compile X/Y coordinates and font size + $x = $templateInstance->compileRawCode($this->getX()); + $y = $templateInstance->compileRawCode($this->getY()); + $size = $templateInstance->compileRawCode($this->getFontSize()); + + // Set the image string + imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor); + break; + + case 'groupable': // More than one string allowed + // Walk through all groups + foreach ($templateInstance->getVariableGroups() as $group => $set) { + // Set the group + $templateInstance->setVariableGroup($group, FALSE); + + // Compile image string + $imageString = $templateInstance->compileRawCode($this->getString()); + + // Compile X/Y coordinates and font size + $x = $templateInstance->compileRawCode($this->getX()); + $y = $templateInstance->compileRawCode($this->getY()); + $size = $templateInstance->compileRawCode($this->getFontSize()); + + // Set the image string + //* DEBUG: */ print __METHOD__.": size={$size}, x={$x}, y={$y}, string={$imageString}
    \n"; + imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor); + } // END - foreach + break; + } + + // You need finishing in your image class! + } + + /** + * Getter for full created image content + * + * @return $imageContent The raw image content + */ + public function getContent () { + // Get cache file name + $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn(); + + // Load the content + $imageContent = file_get_contents($cacheFile); + + // And return it + return $imageContent; + } +} +// [EOF] +?> diff --git a/inc/main/classes/images/extended/.htaccess b/inc/main/classes/images/extended/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/images/extended/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/images/extended/class_PngImage.php b/inc/main/classes/images/extended/class_PngImage.php new file mode 100644 index 00000000..ec0b89f1 --- /dev/null +++ b/inc/main/classes/images/extended/class_PngImage.php @@ -0,0 +1,79 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PngImage extends BaseImage { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this image class + * + * @param $templateInstance A template instance + * @return $imageInstance An instance of this image class + */ + public static final function createPngImage(CompileableTemplate $templateInstance) { + // Get a new instance + $imageInstance = new PngImage(); + + // Set template instance + $imageInstance->setTemplateInstance($templateInstance); + + // Set image type + $imageInstance->setImageType('png'); + + // Return the instance + return $imageInstance; + } + + /** + * Finish this image by producing it + * + * @return void + */ + public function finishImage () { + // Call parent method + parent::finishImage(); + + // Get a file name for our image + $cacheFile = $this->getTemplateInstance()->getImageCacheFqfn(); + + // Does it exist? + if (BaseFrameworkSystem::isReadableFile($cacheFile)) { + // Remove it + @unlink($cacheFile); + } // END - if + + // Finish the image and send it to a cache file + imagepng($this->getImageResource(), $cacheFile, 9, PNG_ALL_FILTERS); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/index/.htaccess b/inc/main/classes/index/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/index/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/index/class_ b/inc/main/classes/index/class_ new file mode 100644 index 00000000..b4736931 --- /dev/null +++ b/inc/main/classes/index/class_ @@ -0,0 +1,54 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Index extends BaseIndex implements Indexable, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Index class and prepares it for usage + * + * @param $fileName Name of the file stack to create an index file for + * @return $indexInstance An instance of this Index class + */ + public final static function create???Index ($fileName) { + // Get a new instance + $indexInstance = new ???Index(); + + // Initialize index + $indexInstance->initIndex($fileName); + + // Return the prepared instance + return $indexInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/index/class_BaseIndex.php b/inc/main/classes/index/class_BaseIndex.php new file mode 100644 index 00000000..d853bca0 --- /dev/null +++ b/inc/main/classes/index/class_BaseIndex.php @@ -0,0 +1,355 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseIndex extends BaseFrameworkSystem { + /** + * Magic for this index + */ + const INDEX_MAGIC = 'INDEXv0.1'; + + /** + * Separator group->hash + */ + const SEPARATOR_GROUP_HASH = 0x01; + + /** + * Separator hash->gap position + */ + const SEPARATOR_HASH_GAP_POSITION = 0x02; + + /** + * Separator gap position->length + */ + const SEPARATOR_GAP_LENGTH = 0x03; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Reads the file header + * + * @return void + */ + public function readFileHeader () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // First rewind to beginning as the header sits at the beginning ... + $this->getIteratorInstance()->rewind(); + + // Then read it (see constructor for calculation) + $data = $this->getIteratorInstance()->read($this->getIteratorInstance()->getHeaderSize()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getIteratorInstance()->getHeaderSize())); + + // Have all requested bytes been read? + assert(strlen($data) == $this->getIteratorInstance()->getHeaderSize()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Last character must be the separator + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data(-1)=%s', __METHOD__, __LINE__, dechex(ord(substr($data, -1, 1))))); + assert(substr($data, -1, 1) == chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Okay, then remove it + $data = substr($data, 0, -1); + + // And update seek position + $this->getIteratorInstance()->updateSeekPosition(); + + /* + * Now split it: + * + * 0 => magic + * 1 => total entries + */ + $header = explode(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), $data); + + // Set it here + $this->getIteratorInstance()->setHeader($header); + + // Check if the array has only 3 elements + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, TRUE))); + assert(count($header) == 2); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Check magic + assert($header[0] == self::INDEX_MAGIC); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Check length of count + assert(strlen($header[1]) == BaseBinaryFile::LENGTH_COUNT); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Decode count + $header[1] = hex2bin($header[1]); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Flushes the file header + * + * @return void + */ + public function flushFileHeader () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Put all informations together + $header = sprintf('%s%s%s%s', + // Magic + self::INDEX_MAGIC, + + // Separator header data + chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), + + // Total entries + str_pad($this->dec2hex($this->getIteratorInstance()->getCounter()), BaseBinaryFile::LENGTH_COUNT, '0', STR_PAD_LEFT), + + // Separator header<->entries + chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES) + ); + + // Write it to disk (header is always at seek position 0) + $this->getIteratorInstance()->writeData(0, $header, FALSE); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Initializes this index + * + * @param $fileName File name of this index + * @return void + * @todo Currently the index file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole index file. + */ + protected function initIndex ($fileName) { + // Append index file extension + $fileName .= $this->getConfigInstance()->getConfigEntry('index_extension'); + + // Get a file i/o pointer instance for index file + $fileInstance = ObjectFactory::createObjectByConfiguredName('index_file_class', array($fileName, $this)); + + // Get iterator instance + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', array($fileInstance)); + + // Is the instance implementing the right interface? + assert($iteratorInstance instanceof SeekableWritableFileIterator); + + // Set iterator here + $this->setIteratorInstance($iteratorInstance); + + // Calculate header size + $this->getIteratorInstance()->setHeaderSize( + strlen(self::INDEX_MAGIC) + + strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) + + BaseBinaryFile::LENGTH_COUNT + + strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)) + ); + + // Init counters and gaps array + $this->getIteratorInstance()->initCountersGapsArray(); + + // Is the file's header initialized? + if (!$this->getIteratorInstance()->isFileHeaderInitialized()) { + // No, then create it (which may pre-allocate the index) + $this->getIteratorInstance()->createFileHeader(); + + // And pre-allocate a bit + $this->getIteratorInstance()->preAllocateFile('index'); + } // END - if + + // Load the file header + $this->readFileHeader(); + + // Count all entries in file + $this->getIteratorInstance()->analyzeFile(); + } + + /** + * Calculates minimum length for one entry/block + * + * @return $length Minimum length for one entry/block + */ + public function calculateMinimumBlockLength () { + // Calulcate it + $length = BaseBinaryFile::LENGTH_TYPE + strlen(chr(BaseBinaryFile::SEPARATOR_TYPE_POSITION)) + BaseBinaryFile::LENGTH_POSITION + strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES)); + + // Return it + return $length; + } + + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + * @throws UnsupportedOperationException If this method is called + */ + public function isEndOfFileReached () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for file name + * + * @return $fileName The current file name + * @throws UnsupportedOperationException If this method is called + */ + public function getFileName () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Initializes counter for valid entries, arrays for damaged entries and + * an array for gap seek positions. If you call this method on your own, + * please re-analyze the file structure. So you are better to call + * analyzeFile() instead of this method. + * + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function initCountersGapsArray () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for header size + * + * @return $totalEntries Size of file header + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getHeaderSize () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for header size + * + * @param $headerSize Size of file header + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function setHeaderSize ($headerSize) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for header array + * + * @return $totalEntries Size of file header + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getHeader () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for header + * + * @param $header Array for a file header + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function setHeader (array $header) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Updates seekPosition attribute from file to avoid to much access on file. + * + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function updateSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getCounter () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * "Getter" for file size + * + * @return $fileSize Size of currently loaded file + */ + public function getFileSize () { + // Call iterator's method + return $this->getIteratorInstance()->getFileSize(); + } + + /** + * Writes data at given position + * + * @param $seekPosition Seek position + * @param $data Data to be written + * @param $flushHeader Whether to flush the header (default: flush) + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function writeData ($seekPosition, $data, $flushHeader = TRUE) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data[]=%s,flushHeader=%d', __METHOD__, __LINE__, $seekPosition, gettype($data), intval($flushHeader))); + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Writes given value to the file and returns a hash and gap position for it + * + * @param $groupId Group identifier + * @param $value Value to be added to the stack + * @return $data Hash and gap position + * @throws UnsupportedOperationException If this method is called + */ + public function writeValueToFile ($groupId, $value) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Writes given raw data to the file and returns a gap position and length + * + * @param $groupId Group identifier + * @param $hash Hash from encoded value + * @param $encoded Encoded value to be written to the file + * @return $data Gap position and length of the raw data + */ + public function writeDataToFreeGap ($groupId, $hash, $encoded) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] groupId=' . $groupId . ',hash=' . $hash . ',encoded()=' . strlen($encoded)); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/index/file_stack/.htaccess b/inc/main/classes/index/file_stack/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/index/file_stack/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/index/file_stack/class_FileStackIndex.php b/inc/main/classes/index/file_stack/class_FileStackIndex.php new file mode 100644 index 00000000..f5a4585d --- /dev/null +++ b/inc/main/classes/index/file_stack/class_FileStackIndex.php @@ -0,0 +1,106 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileStackIndex extends BaseIndex implements IndexableStack, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this Index class and prepares it for usage + * + * @param $fileName Name of the file stack to create an index file for + * @return $indexInstance An instance of this Index class + */ + public final static function createFileStackIndex ($fileName) { + // Get a new instance + $indexInstance = new FileStackIndex(); + + // Initialize index + $indexInstance->initIndex($fileName); + + // Return the prepared instance + return $indexInstance; + } + + /** + * Adds given hash to an index file + * + * @param $groupId Name of stack to add hash for + * @param $data Hash and gap position to be added to the index + * @return void + */ + public function addHashToIndex ($groupId, array $data) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,gap=%d,length=%d - CALLED!', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], $data[BaseFileStack::ARRAY_INDEX_GAP_POSITION], $data[BaseFileStack::ARRAY_INDEX_DATA_LENGTH])); + + // Raw data been written to the file + $rawData = sprintf('%s%s%s%s%s%s%s', + $groupId, + self::SEPARATOR_GROUP_HASH, + hex2bin($data[BaseFileStack::ARRAY_INDEX_HASH]), + self::SEPARATOR_HASH_GAP_POSITION, + $data[BaseFileStack::ARRAY_INDEX_GAP_POSITION], + self::SEPARATOR_GAP_LENGTH, + $data[BaseFileStack::ARRAY_INDEX_DATA_LENGTH] + ); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], strlen($rawData))); + + // Search for next free gap + $gapPosition = $this->getIteratorInstance()->searchNextGap(strlen($rawData)); + + // Gap position cannot be smaller than header length + 1 + assert($gapPosition > $this->getIteratorInstance()->getHeaderSize()); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,gapPosition=%s', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], $gapPosition)); + + // Then write the data at that gap + $this->getIteratorInstance()->writeData($gapPosition, $rawData); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d - EXIT!', __METHOD__, __LINE__, $groupId, $data[BaseFileStack::ARRAY_INDEX_HASH], strlen($rawData))); + } + + /** + * Searches for next suitable gap the given length of data can fit in + * including padding bytes. + * + * @param $length Length of raw data + * @return $seekPosition Found next gap's seek position + */ + public function searchNextGap ($length) { + $this->partialStub('length=' . $length); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/iterator/.htaccess b/inc/main/classes/iterator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/iterator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/iterator/class_ b/inc/main/classes/iterator/class_ new file mode 100644 index 00000000..22122d4a --- /dev/null +++ b/inc/main/classes/iterator/class_ @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Iterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance of a Iterator class + */ + public final static function create???Iterator () { + // Get new instance + $iteratorInstance = new ???Iterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/iterator/class_BaseIterator.php b/inc/main/classes/iterator/class_BaseIterator.php new file mode 100644 index 00000000..80513e77 --- /dev/null +++ b/inc/main/classes/iterator/class_BaseIterator.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseIterator extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/iterator/default/.htaccess b/inc/main/classes/iterator/default/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/iterator/default/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/iterator/default/class_DefaultIterator.php b/inc/main/classes/iterator/default/class_DefaultIterator.php new file mode 100644 index 00000000..81050c5f --- /dev/null +++ b/inc/main/classes/iterator/default/class_DefaultIterator.php @@ -0,0 +1,122 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DefaultIterator extends BaseIterator implements Iterator { + /** + * Key for the global list index + */ + private $indexKey = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A list of a Listable + * @return $iteratorInstance An instance a Iterator class + */ + public static final function createDefaultIterator (Listable $listInstance) { + // Get new instance + $iteratorInstance = new DefaultIterator(); + + // Set the list + $iteratorInstance->setListInstance($listInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + * @throws IndexOutOfBoundsException If $indexKey is out of bounds + */ + public function current () { + // Default is null + $current = NULL; + + // Is the entry valid? + if (!$this->valid()) { + // Throw an exception here + throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS); + } // END - if + + // Now get the entry + $current = $this->getListInstance()->getEntry($this->key()); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $indexKey Current key in iteration + */ + public function key () { + return $this->indexKey; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->indexKey++; + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->indexKey = 0; + } + + /** + * Checks whether the current entry is valid (not at the end of the list) + * + * @return $isValid Whether the current entry is there + */ + public function valid () { + // Check for total active peers and if we are not at the end + $isValid = ($this->key() < $this->getListInstance()->count()); + + // Return result + return $isValid; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/iterator/file/.htaccess b/inc/main/classes/iterator/file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/iterator/file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/iterator/file/class_FileIterator.php b/inc/main/classes/iterator/file/class_FileIterator.php new file mode 100644 index 00000000..ff981732 --- /dev/null +++ b/inc/main/classes/iterator/file/class_FileIterator.php @@ -0,0 +1,330 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIterator extends BaseIterator implements SeekableWritableFileIterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $pointerInstance An instance of a Block class + * @return $iteratorInstance An instance of a Iterator class + */ + public final static function createFileIterator (Block $blockInstance) { + // Get new instance + $iteratorInstance = new FileIterator(); + + // Set the instance here + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d] Setting blockInstance=%s ...', __METHOD__, __LINE__, $blockInstance->__toString())); + $iteratorInstance->setBlockInstance($blockInstance); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Gets currently read data + * + * @return $current Currently read data + */ + public function current () { + // Call block instance + return $this->getBlockInstance()->current(); + } + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + */ + public function key () { + // Return it + return $this->getBlockInstance()->determineSeekPosition(); + } + + /** + * Advances to next "block" of bytes + * + * @return void + */ + public function next () { + // Call block instance + $this->getBlockInstance()->next(); + } + + /** + * Rewinds to the beginning of the file + * + * @return $status Status of this operation + */ + public function rewind () { + // Call block instance + return $this->getBlockInstance()->rewind(); + } + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + */ + public function valid () { + // Call block instance + return $this->getBlockInstance()->valid(); + } + + /** + * Seeks to given position + * + * @param $seekPosition Seek position in file + * @return $status Status of this operation + */ + public function seek ($seekPosition) { + // Call block instance + return $this->getBlockInstance()->seek($seekPosition); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + public function size () { + // Call the block object + $size = $this->getBlockInstance()->size(); + + // Return result + return $size; + } + + /** + * Reads given amount of bytes from file. + * + * @param $bytes Amount of bytes to read + * @return $data Data read from file + */ + public function read ($bytes = NULL) { + // Call block instance + return $this->getBlockInstance()->read($bytes); + } + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + */ + public function analyzeFile () { + // Just call the block instance + $this->getBlockInstance()->analyzeFile(); + } + + /** + * Checks whether the file header is initialized + * + * @return $isInitialized Whether the file header is initialized + */ + public function isFileHeaderInitialized () { + // Just call the block instance + return $this->getBlockInstance()->isFileHeaderInitialized(); + } + + /** + * Creates the assigned file + * + * @return void + */ + public function createFileHeader () { + // Just call the block instance + $this->getBlockInstance()->createFileHeader(); + } + + /** + * Pre-allocates file (if enabled) with some space for later faster write access. + * + * @param $type Type of the file + * @return void + */ + public function preAllocateFile ($type) { + // Just call the block instance + $this->getBlockInstance()->preAllocateFile($type); + } + + /** + * Initializes counter for valid entries, arrays for damaged entries and + * an array for gap seek positions. If you call this method on your own, + * please re-analyze the file structure. So you are better to call + * analyzeFile() instead of this method. + * + * @return void + */ + public function initCountersGapsArray () { + // Call block instance + $this->getBlockInstance()->initCountersGapsArray(); + } + + /** + * Getter for header size + * + * @return $totalEntries Size of file header + */ + public final function getHeaderSize () { + // Call block instance + return $this->getBlockInstance()->getHeaderSize(); + } + + /** + * Setter for header size + * + * @param $headerSize Size of file header + * @return void + */ + public final function setHeaderSize ($headerSize) { + // Call block instance + $this->getBlockInstance()->setHeaderSize($headerSize); + } + + /** + * Getter for header array + * + * @return $totalEntries Size of file header + */ + public final function getHeader () { + // Call block instance + return $this->getBlockInstance()->getHeader(); + } + + /** + * Setter for header + * + * @param $header Array for a file header + * @return void + */ + public final function setHeader (array $header) { + // Call block instance + $this->getBlockInstance()->setHeader($header); + } + + /** + * Updates seekPosition attribute from file to avoid to much access on file. + * + * @return void + */ + public function updateSeekPosition () { + // Call block instance + $this->getBlockInstance()->updateSeekPosition(); + } + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + public final function getCounter () { + // Call block instance + return $this->getBlockInstance()->getCounter(); + } + + /** + * "Getter" for file size + * + * @return $fileSize Size of currently loaded file + */ + public function getFileSize () { + // Call block instance + return $this->getBlockInstance()->getFileSize(); + } + + /** + * Writes data at given position + * + * @param $seekPosition Seek position + * @param $data Data to be written + * @param $flushHeader Whether to flush the header (default: flush) + * @return void + */ + public function writeData ($seekPosition, $data, $flushHeader = TRUE) { + // Call block instance + $this->getBlockInstance()->writeData($seekPosition, $data, $flushHeader); + } + + /** + * Getter for seek position + * + * @return $seekPosition Current seek position (stored here in object) + */ + public function getSeekPosition () { + // Call block instance + return $this->getBlockInstance()->getSeekPosition(); + } + + /** + * Writes given value to the file and returns a hash and gap position for it + * + * @param $groupId Group identifier + * @param $value Value to be added to the stack + * @return $data Hash and gap position + */ + public function writeValueToFile ($groupId, $value) { + // Call block instance + return $this->getBlockInstance()->writeValueToFile($groupId, $value); + } + + /** + * Writes given raw data to the file and returns a gap position and length + * + * @param $groupId Group identifier + * @param $hash Hash from encoded value + * @param $encoded Encoded value to be written to the file + * @return $data Gap position and length of the raw data + */ + public function writeDataToFreeGap ($groupId, $hash, $encoded) { + // Call block instance + return $this->getBlockInstance()->writeDataToFreeGap($groupId, $hash, $encoded); + } + + /** + * Searches for next suitable gap the given length of data can fit in + * including padding bytes. + * + * @param $length Length of raw data + * @return $seekPosition Found next gap's seek position + */ + public function searchNextGap ($length) { + // Call block instance + print $this->getBlockInstance()->__toString() . PHP_EOL; + return $this->getBlockInstance()->searchNextGap($length); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/language/.htaccess b/inc/main/classes/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/language/class_LanguageSystem.php b/inc/main/classes/language/class_LanguageSystem.php new file mode 100644 index 00000000..ece1ad57 --- /dev/null +++ b/inc/main/classes/language/class_LanguageSystem.php @@ -0,0 +1,193 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage, Registerable { + /** + * The full-qualified base path for the language include files + */ + private $languageBasePath = ''; + + /** + * The 2-char language code + */ + private $langCode = 'xx'; // This will later be overwritten! + + /** + * The array-object for all language strings + */ + private $langStrings = NULL; + + /** + * An instance of this class + */ + private static $selfInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class LanguageSystem and prepares it for usage + * + * @param $languageBasePath The local base path for all language strings or emty for auto-detection + * @return $langInstance An instance of LanguageSystem + * @throws LanguagePathIsEmptyException If the provided $languageBasePath is empty + * @throws InvalidLanguagePathStringException If $languageBasePath is no string + * @throws LanguagePathIsNoDirectoryException If $languageBasePath is no + * directory or not found + * @throws LanguagePathReadProtectedException If $languageBasePath is + * read-protected + */ + public static final function createLanguageSystem ($languageBasePath = '') { + // Get a new instance + $langInstance = new LanguageSystem(); + + // Is the base path set? + if (empty($languageBasePath)) { + // No, then attempt "auto-dection": + // 1) Get application + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // 2) Try to build it + $languageBasePath = sprintf('%sapplication/%s/language/', + $langInstance->getConfigInstance()->getConfigEntry('base_path'), + // Don't allow any underscores/dashes in application names + str_replace(array('_', '-'), array('', ''), $applicationInstance->getAppShortName()) + ); + } // END - if + + // Is the base path valid? + if (empty($languageBasePath)) { + // Language path is empty + throw new LanguagePathIsEmptyException($langInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($languageBasePath)) { + // Is not a string + throw new InvalidLanguagePathStringException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($languageBasePath)) { + // Is not a path + throw new LanguagePathIsNoDirectoryException(array($langInstance, $languageBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($languageBasePath)) { + // Is not readable + throw new LanguagePathReadProtectedException(array($langInstance, $languageBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $langInstance->setLanguageBasePath($languageBasePath); + + // Initialize the variable stack + $langInstance->initLanguageStrings(); + + // Set language code from default config + $langInstance->setLanguageCode(FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_lang')); + + // Remember this instance + self::$selfInstance = $langInstance; + + // Return the prepared instance + return $langInstance; + } + + /** + * Singleton getter for this instance + * + * @return $selfInstance An instance of this class + */ + public static final function getSelfInstance () { + return self::$selfInstance; + } + + /** + * Setter for base path + * + * @param $languageBasePath The relative base path for all language files + * @return void + */ + protected final function setLanguageBasePath ($languageBasePath) { + // And set it + $this->languageBasePath = (string) $languageBasePath; + } + + /** + * Setter for language code + * + * @param $langCode The language code for the current application + * @return void + */ + protected final function setLanguageCode ($langCode) { + // Cast it + $langCode = (string) $langCode; + + // And set it (only 2 chars) + $this->langCode = substr($langCode, 0, 2); + } + + /** + * Initialize the array-object for all later language strings + * + * @return void + */ + public function initLanguageStrings () { + $this->langStrings = new FrameworkArrayObject('FakedLanguageStrings'); + } + + /** + * Getter for language code + * + * @return $langCode The language code for the current application + */ + public final function getLanguageCode () { + return $this->langCode; + } + + /** + * Get the plain message from the cache variable for the given message id + * + * @param $messageId The message id we shall find in the cache variable + * @return $messageText The plain message text + */ + public function getMessage ($messageId) { + // Default is missing message text + $messageText = sprintf('!%s!', + $messageId + ); + + // Try to look it up in the cache variable + if ($this->langStrings->offsetExists($messageId)) { + // Return the message string + $messageText = $this->langStrings->offsetGet($messageId); + } // END - if + + // Return the text + return $messageText; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/listener/.htaccess b/inc/main/classes/listener/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/listener/class_ b/inc/main/classes/listener/class_ new file mode 100644 index 00000000..5d3309f5 --- /dev/null +++ b/inc/main/classes/listener/class_ @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Listener extends BaseListener implements Listenable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance A NodeHelper instance + * @return $listenerInstance An instance a prepared listener class + */ + public final static function create???Listener (NodeHelper $nodeInstance) { + // Get new instance + $listenerInstance = new ???Listener(); + + // Set the application instance + $listenerInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $listenerInstance; + } + + /** + * Initializes the listener by setting up the required socket server + * + * @return void + * @todo 0% done + */ + public function initListener() { + $this->partialStub('Need to implement this method.'); + } + + /** + * "Listens" for incoming network packages + * + * @return void + * @todo 0% done + */ + public function doListen() { + $this->partialStub('Need to implement this method.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/listener/class_BaseListener.php b/inc/main/classes/listener/class_BaseListener.php new file mode 100644 index 00000000..5a572135 --- /dev/null +++ b/inc/main/classes/listener/class_BaseListener.php @@ -0,0 +1,292 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseListener extends BaseFrameworkSystem implements Visitable { + // Exception code constants + const EXCEPTION_INVALID_SOCKET = 0xa00; + const EXCEPTION_SOCKET_ALREADY_REGISTERED = 0xa01; + const EXCEPTION_SOCKET_CREATION_FAILED = 0xa02; + const EXCEPTION_NO_SOCKET_ERROR = 0xa03; + const EXCEPTION_CONNECTION_ALREADY_REGISTERED = 0xa04; + const EXCEPTION_UNEXPECTED_PACKAGE_STATUS = 0xa05; + const EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER = 0xa06; + const EXCEPTION_FINAL_CHUNK_VERIFICATION = 0xa07; + const EXCEPTION_INVALID_DATA_CHECKSUM = 0xa08; + + /** + * Address (IP mostly) we shall listen on + */ + private $listenAddress = '0.0.0.0'; // This is the default and listens on all interfaces + + /** + * Port we shall listen on (or wait for incoming data) + */ + private $listenPort = 0; // This port MUST be changed by your application + + /** + * Whether we are in blocking or non-blocking mode (default: non-blocking + */ + private $blockingMode = FALSE; + + /** + * A peer pool instance + */ + private $poolInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Checks whether the given socket resource is a server socket + * + * @param $socketResource A valid socket resource + * @return $isServerSocket Whether the socket resource is a server socket + */ + protected function isServerSocketResource ($socketResource) { + // Check it + $isServerSocket = ((is_resource($socketResource)) && (!@socket_getpeername($socketResource, $peerName))); + + // We need to clear the error here if it is a resource + if ($isServerSocket === TRUE) { + // Clear the error + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('socketResource[]=' . gettype($socketResource)); + socket_clear_error($socketResource); + } // END - if + + // Check peer name, it must be empty + $isServerSocket = (($isServerSocket) && (empty($peerName))); + + // Return result + return $isServerSocket; + } + + /** + * Setter for listen address + * + * @param $listenAddress The address this listener should listen on + * @return void + */ + protected final function setListenAddress ($listenAddress) { + $this->listenAddress = (string) $listenAddress; + } + + /** + * Getter for listen address + * + * @return $listenAddress The address this listener should listen on + */ + public final function getListenAddress () { + return $this->listenAddress; + } + + /** + * Setter for listen port + * + * @param $listenPort The port this listener should listen on + * @return void + */ + protected final function setListenPort ($listenPort) { + $this->listenPort = (int) $listenPort; + } + + /** + * Getter for listen port + * + * @return $listenPort The port this listener should listen on + */ + public final function getListenPort () { + return $this->listenPort; + } + + /** + * "Setter" to set listen address from configuration entry + * + * @param $configEntry The configuration entry holding our listen address + * @return void + */ + public final function setListenAddressByConfiguration ($configEntry) { + $this->setListenAddress($this->getConfigInstance()->getConfigEntry($configEntry)); + } + + /** + * "Setter" to set listen port from configuration entry + * + * @param $configEntry The configuration entry holding our listen port + * @return void + */ + public final function setListenPortByConfiguration ($configEntry) { + $this->setListenPort($this->getConfigInstance()->getConfigEntry($configEntry)); + } + + /** + * Setter for blocking-mode + * + * @param $blockingMode Whether blocking-mode is disabled (default) or enabled + * @return void + */ + protected final function setBlockingMode ($blockingMode) { + $this->blockingMode = (boolean) $blockingMode; + } + + /** + * Checks whether blocking-mode is enabled or disabled + * + * @return $blockingMode Whether blocking mode is disabled or enabled + */ + public final function isBlockingModeEnabled () { + return $this->blockingMode; + } + + /** + * Setter for peer pool instance + * + * @param $poolInstance The peer pool instance we shall set + * @return void + */ + protected final function setPoolInstance (PoolablePeer $poolInstance) { + $this->poolInstance = $poolInstance; + } + + /** + * Getter for peer pool instance + * + * @return $poolInstance The peer pool instance we shall set + */ + public final function getPoolInstance () { + return $this->poolInstance; + } + + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + public final function getConnectionType () { + // Wrap the real getter + return $this->getProtocolName(); + } + + /** + * Registeres the given socket resource for "this" listener instance. This + * will be done in a seperate class to allow package writers to use it + * again. + * + * @param $socketResource A valid server socket resource + * @return void + * @throws InvalidServerSocketException If the given resource is no server socket + * @throws SocketAlreadyRegisteredException If the given resource is already registered + */ + protected function registerServerSocketResource ($socketResource) { + // First check if it is valid + if (!$this->isServerSocketResource($socketResource)) { + // No server socket + throw new InvalidServerSocketException(array($this, $socketResource), self::EXCEPTION_INVALID_SOCKET); + } elseif ($this->isServerSocketRegistered($socketResource)) { + // Already registered + throw new SocketAlreadyRegisteredException($this, self::EXCEPTION_SOCKET_ALREADY_REGISTERED); + } + + // Get a socket registry instance (singleton) + $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); + + // Get a connection info instance + $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); + + // Will the info instance with listener data + $infoInstance->fillWithListenerInformation($this); + + // Register the socket + $registryInstance->registerSocket($infoInstance, $socketResource); + + // And set it here + $this->setSocketResource($socketResource); + } + + /** + * Checks whether given socket resource is registered in socket registry + * + * @param $socketResource A valid server socket resource + * @return $isRegistered Whether given server socket is registered + */ + protected function isServerSocketRegistered ($socketResource) { + // Get a socket registry instance (singleton) + $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); + + // Get a connection info instance + $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); + + // Will the info instance with listener data + $infoInstance->fillWithListenerInformation($this); + + // Check it + $isRegistered = $registryInstance->isSocketRegistered($infoInstance, $socketResource); + + // Return result + return $isRegistered; + } + + /** + * Accepts the visitor to process the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!'); + + // Visit this listener + $visitorInstance->visitListener($this); + + // Visit the pool if set + if ($this->getPoolInstance() instanceof Poolable) { + $this->getPoolInstance()->accept($visitorInstance); + } // END - if + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); + } + + /** + * Monitors incoming raw data from the handler and transfers it to the + * given receiver instance. This method should not be called, please call + * the decorator's version instead to separator node/client traffic. + * + * @return void + * @throws UnsupportedOperatorException If this method is called by a mistake + */ + public function monitorIncomingRawData () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/lists/.htaccess b/inc/main/classes/lists/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/lists/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/lists/class_ b/inc/main/classes/lists/class_ new file mode 100644 index 00000000..4e0a5e8f --- /dev/null +++ b/inc/main/classes/lists/class_ @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???List extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public final static function create???List () { + // Get new instance + $listInstance = new ???List(); + + // Return the prepared instance + return $listInstance; + } + + /** + * "Getter" for an iterator instance of this list + * + * @return $iteratorInstance An instance of a Iterator class + * @todo 0% done + */ + public function getListIterator () { + $this->partialStub('Please implement this method.'); + } + + /** + * Clears this list by cleaning up all groups together. + * + * @return void + * @todo 0% done + */ + public function clearList () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/lists/class_BaseList.php b/inc/main/classes/lists/class_BaseList.php new file mode 100644 index 00000000..cdeaf33b --- /dev/null +++ b/inc/main/classes/lists/class_BaseList.php @@ -0,0 +1,481 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseList extends BaseFrameworkSystem implements IteratorAggregate, Countable { + // Exception constants + const EXCEPTION_GROUP_ALREADY_ADDED = 0xf20; + const EXCEPTION_GROUP_NOT_FOUND = 0xf21; + const EXCEPTION_INVALID_HASH = 0xf22; + + /** + * List groups array + */ + private $listGroups = array(); + + /** + * List entries array + */ + private $listEntries = array(); + + /** + * List index array + */ + private $listIndex = array(); + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for iterator instance from this list + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getIterator () { + // Get iterator from here + $iteratorInstance = $this->getIteratorInstance(); + + // Is the instance set? + if (is_null($iteratorInstance)) { + // Prepare a default iterator + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('default_iterator_class', array($this)); + + // Set it here + $this->setIteratorInstance($iteratorInstance); + } // END - if + + // And return it + return $iteratorInstance; + } + + /** + * Checks whether the given group is set + * + * @param $groupName Group to check if found in list + * @return $isset Whether the group is valid + */ + public function isGroupSet ($groupName) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName); + return isset($this->listGroups[$groupName]); + } + + /** + * Adds the given group or if already added issues a ListGroupAlreadyAddedException + * + * @param $groupName Group to add + * @return void + * @throws ListGroupAlreadyAddedException If the given group is already added + */ + public function addGroup ($groupName) { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); + // Is the group already added? + if ($this->isGroupSet($groupName)) { + // Throw the exception here + throw new ListGroupAlreadyAddedException(array($this, $groupName), self::EXCEPTION_GROUP_ALREADY_ADDED); + } // END - if + + // Add the group which is a simple array + $this->listGroups[$groupName] = ObjectFactory::createObjectByConfiguredName('list_group_class'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); + } + + /** + * Adds the given instance to list group and sub group + * + * @param $groupName Group to add instance to + * @param $subGroup Sub group to add instance to + * @param $visitableInstance An instance of Visitable + * @return void + * @throws NoListGroupException If the given group is not found + */ + public function addInstance ($groupName, $subGroup, Visitable $visitableInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); + + // Is the group there? + if (!$this->isGroupSet($groupName)) { + // Throw the exception here + throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Is the sub group there? + if (!$this->listGroups[$groupName]->isGroupSet($subGroup)) { + // Automatically add it + $this->listGroups[$groupName]->addGroup($subGroup); + } // END - if + + // Generate the hash + $hash = $this->generateHash($groupName, $subGroup, $visitableInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ',hash=' . $hash . ' - Calling addEntry() ...'); + + // Now add it to the group list and hash it + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',this->listGroups[' . $groupName . ']=' . $this->listGroups[$groupName]->__toString()); + //$this->listGroups[$groupName]->addEntry($subGroup, $hash); + + // Add the hash to the index + array_push($this->listIndex, $hash); + + // Add the instance itself to the list + $this->listEntries[$hash] = $visitableInstance; + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',subGroup=' . $subGroup . ' - EXIT!'); + } + + /** + * Gets an array from given list + * + * @param $list The requested list + * @return $array The requested array + * @throws NoListGroupException If the given group is not found + */ + public final function getArrayFromList ($list) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ' - CALLED!'); + + // Is the group there? + if ((!is_null($list)) && (!$this->isGroupSet($list))) { + // Throw the exception here + throw new NoListGroupException(array($this, $list), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Init array + $array = array(); + + // Is there another list? + if (!is_null($list)) { + // Then get it as well + $array = $this->listGroups[$list]->getArrayFromList(NULL); + } // END - if + + // Walk through all entries + foreach ($this->listIndex as $hash) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash); + + // Is the list entry set? + if ($this->isHashValid($hash)) { + // Add it + array_push($array, $this->listEntries[$hash]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: hash=' . $hash . ',array(' . count($array) . ')=' . print_r($array, TRUE) . ' - ADDED!'); + } // END - if + } // END - foreach + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',list[' . gettype($list) . ']=' . $list . ',array()=' . count($array) . ' - EXIT!'); + + // Return it + return $array; + } + + /** + * Adds the given entry to list group + * + * @param $groupName Group to add instance to + * @param $entry An entry of any type + * @return void + * @throws NoListGroupException If the given group is not found + */ + public function addEntry ($groupName, $entry) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); + + // Is the group already added? + if (!$this->isGroupSet($groupName)) { + // Throw the exception here + throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Generate hash + $hash = $this->generateHash($groupName, $groupName, $entry); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . print_r($entry, TRUE) . ', hash=' . $hash); + + // Add the hash to the index + array_push($this->listIndex, $hash); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries)); + + // Now add the entry to the list + $this->listEntries[$hash] = $entry; + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',listEntries()=' . count($this->listEntries) . ' - EXIT!'); + } + + /** + * Removes given entry from the list group + * + * @param $groupName Group where we should remove the entry from + * @param $entry The entry we should remove + * @return void + * @throws NoListGroupException If the given group is not found + */ + public function removeEntry ($groupName, $entry) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - CALLED!'); + + // Is the group already added? + if (!$this->isGroupSet($groupName)) { + // Throw the exception here + throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Generate hash + $hash = $this->generateHash($groupName, $groupName, $entry); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ',entry=' . $entry . ', hash=' . $hash); + + // Remove it from the list ... + unset($this->listEntries[$hash]); + + // ... and hash list as well + unset($this->listIndex[array_search($hash, $this->listIndex)]); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: this=' . $this->__toString() . ',groupName=' . $groupName . ' - EXIT!'); + } + + /** + * Generates a hash from given group, sub group and entry + * + * @param $groupName Group to add instance to + * @param $subGroup Sub group to add instance to + * @param $entry An entry of any type + * @return $hash The generated + */ + private function generateHash ($groupName, $subGroup, $entry) { + // Created entry, 'null' is default + $entry2 = 'null'; + + // Determine type of entry + if (is_null($entry)) { + // Ignore this + } elseif ($entry instanceof FrameworkInterface) { + // Own instance detected + $entry2 = $entry->hashCode(); + } elseif ((is_int($entry)) || (is_float($entry)) || (is_resource($entry))) { + // Integer/float/resource detected + $entry2 = gettype($entry) . ':' . $entry; + } elseif (is_string($entry)) { + // String found + $entry2 = crc32($entry) . ':' . strlen($entry); + } elseif ((is_array($entry)) && (isset($entry['id']))) { + // Supported array found + $entry2 = crc32($entry['id']) . ':' . count($entry); + } elseif ((is_array($entry)) && (isset($entry[BasePool::SOCKET_ARRAY_RESOURCE])) && (isset($entry[BasePool::SOCKET_ARRAY_CONN_TYPE]))) { + // Is a socket resource array + $entry2 = crc32($entry[BasePool::SOCKET_ARRAY_RESOURCE] . ':' . $entry[BasePool::SOCKET_ARRAY_CONN_TYPE]); + } else { + // Unsupported type detected + self::createDebugInstance(__CLASS__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.'); + + // @TODO Extend this somehow? + $entry2 = gettype($entry); + } + + // Construct string which we shall hash + $hashString = $groupName . ':' . $subGroup . ':' . $entry2; + + // Hash it with fastest hasher + $hash = crc32($hashString); + + // And return it + return $hash; + } + + /** + * Clears an array of groups, all are being checked for existence + * + * @param $groupNames An array with existing list groups + * @return void + */ + protected function clearGroups (array $groupNames) { + // Walk through all groups + foreach ($groupNames as $groupName) { + // Clear this group + $this->clearGroup($groupName); + } // END - foreach + } + + /** + * Clears a single group by resetting it to its initial state (empty array) + * + * @param $groupName Name of an existing group to clear + * @return void + */ + protected function clearGroup ($groupName) { + // Does this group exist? + if (!$this->isGroupSet($groupName)) { + // Throw the exception here + throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Then clear this group list + $this->listGroups[$groupName]->clearList(); + + // Clear this list + $this->listIndex = array(); + $this->listEntries = array(); + } + + /** + * Counts all entries in this list + * + * @return $count All entries in this list + */ + public final function count () { + return count($this->listIndex); + } + + /** + * Checks whether the given hash is valid + * + * @param $hash The hash we should validate + * @return $isValid Whether the given hash is valid + */ + public final function isHashValid ($hash) { + // Check it + $isValid = ((in_array($hash, $this->listIndex)) && (isset($this->listEntries[$hash]))); + + // Return the result + return $isValid; + } + + /** + * Getter for hash from given hash index + * + * @param $hashIndex Index holding the hash + * @return $hash The hash + */ + public final function getHash ($hashIndex) { + // Get it ... + $hash = $this->listIndex[$hashIndex]; + + // ... and return it + return $hash; + } + + /** + * Gets an entry from given hash index + * + * @param $hashIndex The hash index to resolve the mapped entry + * @return $entry Solved entry from list + * @throws InvalidListHashException If the solved hash index is invalid + */ + public function getEntry ($hashIndex) { + // Get the hash value + $hash = $this->getHash($hashIndex); + + // Is the hash valid? + if (!$this->isHashValid($hash)) { + // Throw an exception here + throw new InvalidListHashException(array($this, $hash, $hashIndex), self::EXCEPTION_INVALID_HASH); + } // END - if + + // Now copy the entry + $entry = $this->listEntries[$hash]; + + // Return it + return $entry; + } + + /** + * Gets a full array from given group name + * + * @param $groupName The group name to get a list for + * @return $entries The array with all entries + * @throws NoListGroupException If the specified group is invalid + */ + public function getArrayFromProtocolInstance ($groupName) { + // Is the group valid? + if (!$this->isGroupSet($groupName)) { + // Throw the exception here + throw new NoListGroupException(array($this, $groupName), self::EXCEPTION_GROUP_NOT_FOUND); + } // END - if + + // Init the entries' array + $entries = array(); + + // Get an iterator + $iteratorInstance = $this->listGroups[$groupName]->getIterator(); + + // Rewind the iterator for this round + $iteratorInstance->rewind(); + + // Go through all entries + while ($iteratorInstance->valid()) { + // Get key + $entryIndex = $iteratorInstance->key(); + + // ... and the final entry which is the stored instance + $entry = $this->getEntry($entryIndex); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('LIST: Adding entry ' . $entry . ' ...'); + + // Add it to the list + $entries[$iteratorInstance->current()] = $entry; + + // Skip to next one + $iteratorInstance->next(); + } // END - while + + // Return the list + return $entries; + } + + /** + * Updates the given entry by hash with given array + * + * @param $hash Hash for this entry + * @param $entryArray Array with entry we should update + * @return void + * @throws InvalidListHashException If the solved hash index is invalid + */ + public function updateCurrentEntryByHash ($hash, array $entryArray) { + // Is the hash valid? + if (!$this->isHashValid($hash)) { + // Throw an exception here, hashIndex is unknown at this point + throw new InvalidListHashException(array($this, $hash, -999), self::EXCEPTION_INVALID_HASH); + } // END - if + + // Set the entry + $this->listEntries[$hash] = $entryArray; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/lists/groups/.htaccess b/inc/main/classes/lists/groups/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/lists/groups/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/lists/groups/class_ListGroupList.php b/inc/main/classes/lists/groups/class_ListGroupList.php new file mode 100644 index 00000000..666bd0bd --- /dev/null +++ b/inc/main/classes/lists/groups/class_ListGroupList.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ListGroupList extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public static final function createListGroupList () { + // Get new instance + $listInstance = new ListGroupList(); + + // Return the prepared instance + return $listInstance; + } + + /** + * "Getter" for an iterator instance of this list (not implemented) + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getListIterator () { + $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); + } + + /** + * Clears this list by cleaning up all groups together. + * + * @return void + * @todo 0% done + */ + public function clearList () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/lists/tasks/.htaccess b/inc/main/classes/lists/tasks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/lists/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/lists/tasks/class_TaskList.php b/inc/main/classes/lists/tasks/class_TaskList.php new file mode 100644 index 00000000..5e3fc8fd --- /dev/null +++ b/inc/main/classes/lists/tasks/class_TaskList.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class TaskList extends BaseList implements Listable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $listInstance An instance a Listable class + */ + public static final function createTaskList () { + // Get new instance + $listInstance = new TaskList(); + + // Add tasks group + $listInstance->addGroup('tasks'); + + // Return the prepared instance + return $listInstance; + } + + /** + * "Getter" for an iterator instance of this list (not implemented) + * + * @return $iteratorInstance An instance of a Iterator class + */ + public function getListIterator () { + $this->debugInstance($this->__toString() . ' uses the default iterator. Please call getIterator() instead!'); + } + + /** + * Clears this list by cleaning up all groups together. + * + * @return void + */ + public function clearList () { + // Clear the only one group + $this->clearGroup('tasks'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/mailer/.htaccess b/inc/main/classes/mailer/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/mailer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/mailer/class_ b/inc/main/classes/mailer/class_ new file mode 100644 index 00000000..c3b3e13b --- /dev/null +++ b/inc/main/classes/mailer/class_ @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Mailer extends BaseMailer implements DeliverableMail { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this mailer class + * + * @return $mailerInstance An instance of this mailer class + */ + public final static function create???Mailer () { + // Get a new instance + $mailerInstance = new ???Mailer(); + + // Return the instance + return $mailerInstance; + } + + /** + * Deliver email to the recipient(s) + * + * @return void + * @todo 0% done + */ + public function deliverEmail() { + $this->partialStub("You have to implement this method."); + } + + /** + * Send notification to the admin + * + * @return void + * @todo 0% done + */ + public function sendAdminNotification() { + $this->partialStub("You have to implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/mailer/class_BaseMailer.php b/inc/main/classes/mailer/class_BaseMailer.php new file mode 100644 index 00000000..db07b20d --- /dev/null +++ b/inc/main/classes/mailer/class_BaseMailer.php @@ -0,0 +1,193 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMailer extends BaseFrameworkSystem { + /** + * Template name + */ + private $templateName = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Loads a text or HTML template depending on configuration into the template engine + * + * @param $templateName Name of the template we shall load + * @return void + */ + protected final function loadTemplate ($templateName) { + // Set template name + $this->setTemplateName($templateName); + + // Get configuration entry + $templatePrefix = $this->getConfigInstance()->getConfigEntry('email_tpl_' . $templateName); + + // Load this email template + $this->getTemplateInstance()->loadEmailTemplate($templatePrefix . '_' . $templateName); + } + + /** + * Adds a user class to the recipient list for current template + * + * @param $userInstance An instance of a user class + * @return void + */ + public function addRecipientByUserInstance (ManageableMember $userInstance) { + // Get template name + $templateName = $this->getTemplateName(); + + // Is the list initialized? + $this->pushValueToGenericArrayKey('recipients', $templateName, 'recipients', $userInstance); + } + + /** + * Adds a template variable (just the name) to the recipient list in given section of current template + * + * @param $section Section can be 'config' or "value" currently + * @param $variableName Template variable name to add + * @return void + */ + private final function addTemplateVariable ($section, $variableName) { + // Get template name + $templateName = $this->getTemplateName(); + + // Generate full section name + $sectionName = $section . '_vars'; + + // Is the list initialized? + $this->setGenericArrayElement('recipients', $templateName, $sectionName, $variableName, 'OK'); + } + + /** + * Adds a config template variable to the recipient list of current template + * + * @param $variableName Template variable name to add + * @return void + */ + public final function addConfigTemplateVariable ($variableName) { + $this->addTemplateVariable('config', $variableName); + } + + /** + * Adds a 'value' template variable to the recipient list of current template + * + * @param $variableName Template variable name to add + * @return void + */ + public final function addValueTemplateVariable ($variableName) { + $this->addTemplateVariable('value', $variableName); + } + + /** + * Adds a value instance for a given variable name. It should be set! + * + * @param $variableName Template variable we want to assign a value instance + * @param $valueInstance An object instance which can provide "field values" + * @return void + */ + public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) { + $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'values', $variableName, $valueInstance); + } + + /** + * Protected setter for template name + * + * @param $templateName Name of email template + * @return void + */ + public final function setTemplateName ($templateName) { + $this->templateName = (string) $templateName; + } + + /** + * Protected getter for template name + * + * @return $templateName Name of email template + */ + protected final function getTemplateName () { + return $this->templateName; + } + + /** + * Setter for subject line + * + * @param $subjectLine Subject line to set + * @return void + */ + public final function setSubjectLine ($subjectLine) { + $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'generic', 'subject', $subjectLine); + } + + /** + * Getter for subject line or null if not found + * + * @return $subjectLine Subject line to set + */ + public final function getSubjectLine () { + // Default subject is null + $subjectLine = NULL; + + // Get template name + $templateName = $this->getTemplateName(); + + // Does the subject line exist? + if ((!empty($templateName)) && ($this->isGenericArrayElementSet('recipients', $templateName, 'generic', 'subject'))) { + // Then use it + $subjectLine = $this->getGenericArrayElement('recipients', $templateName, 'generic', 'subject'); + } // END - if + + // Return it + return $subjectLine; + } + + /** + * Use subject line provided by the (XML) template otherwise a subject line must be set + * + * @return void + */ + public function useSubjectFromTemplate () { + // Set the subject line + $this->setSubjectLine('{?subject?}'); + } + + /** + * Getter for recipient list array + * + * @return $recipientList Array with reciepients + */ + public final function getRecipientList () { + return $this->getGenericArray('recipients'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/mailer/debug/.htaccess b/inc/main/classes/mailer/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/mailer/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/mailer/debug/class_DebugMailer.php b/inc/main/classes/mailer/debug/class_DebugMailer.php new file mode 100644 index 00000000..3a37c02a --- /dev/null +++ b/inc/main/classes/mailer/debug/class_DebugMailer.php @@ -0,0 +1,175 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugMailer extends BaseMailer implements DeliverableMail { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this mailer class + * + * @param $templateInstance A template instance + * @param $applicationInstance An application helper class + * @param $templateName Name of email template to set + * @return $mailerInstance An instance of this mailer class + */ + public static final function createDebugMailer (CompileableTemplate $templateInstance, ManageableApplication $applicationInstance, $templateName) { + // Get a new instance + $mailerInstance = new DebugMailer(); + + // Set template instance + $mailerInstance->setTemplateInstance($templateInstance); + + // Set application instance + $mailerInstance->setApplicationInstance($applicationInstance); + + // Set template name + $mailerInstance->setTemplateName($templateName); + + // Return the instance + return $mailerInstance; + } + + /** + * Deliver email to the recipient(s) + * + * @return void + * @throws InvalidInterfaceException If the recipient instance does not implement ManageableMember + */ + public function deliverEmail () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // "Deliver" all emails + foreach ($this->getRecipientList() as $templateName => $recipientList) { + // Walk through all recipients and "sent", or better print, it out + foreach ($recipientList['recipients'] as $recipientInstance) { + // The recipient should be a user instance, right? + if (!$recipientInstance instanceof ManageableMember) { + // Invalid entry found! + throw new InvalidInterfaceException(array($this, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING); + } // END - if + + // User class found, so entry is valid, first load the template + $this->loadTemplate($templateName); + + // Set subject line + $templateInstance->assignVariable('subject', $this->getSubjectLine()); + + // Walk through all variables, first config to assign them + foreach ($recipientList['config_vars'] as $variable => $dummy) { + // Load the config value and set it + $templateInstance->assignConfigVariable($variable); + } // END - if + + // Now do the same with the values but ask the "value instance" instead! + foreach ($recipientList['value_vars'] as $variable => $dummy) { + // Is the value instance there? + if (!isset($recipientList['values'][$variable])) { + // Throw exception + throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the field from the value instance + $fieldValue = $recipientList['values'][$variable]->getField($variable); + + // Set it in template engine + $templateInstance->assignVariable($variable, $fieldValue); + } + + // Render the content + $templateInstance->renderXmlContent(); + + // Get responce instance + $responseInstance = $this->getApplicationInstance()->getResponseInstance(); + + // Transfer the data to the response + $templateInstance->transferToResponse($responseInstance); + } // END - foreach + } // END - foreach + } + + /** + * Send notification to the admin + * + * @return void + * @todo 0% done + */ + public function sendAdminNotification () { + // Unfinished work + } + + /** + * Invokes the mail delivery process which will prepare the output of the message in a code template + * + * @return void + */ + public function invokeMailDelivery () { + // Get template instance + $templateInstance = $this->getTemplateInstance(); + + // Get the compiled message and set it as new template variable + $message = $templateInstance->getCompiledData(); + $templateInstance->assignVariable('message', $message); + + // Load the code template + $templateInstance->loadCodeTemplate('mail_debug'); + + // Compile the template + $templateInstance->compileTemplate(); + + // Assign this template with variable + $templateInstance->assignTemplateWithVariable('mail_debug', 'main_content'); + + // Load header template + $templateInstance->loadCodeTemplate('header'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('header', 'header'); + + // Load footer template + $templateInstance->loadCodeTemplate('footer'); + + // Compile and assign it with a variable + $templateInstance->compileTemplate(); + $templateInstance->assignTemplateWithVariable('footer', 'footer'); + + // Load the master template + $templateInstance->loadCodeTemplate($this->getApplicationInstance()->buildMasterTemplateName()); + + // Then compile it again + $templateInstance->compileVariables(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/menu/.htaccess b/inc/main/classes/menu/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/menu/class_BaseMenu.php b/inc/main/classes/menu/class_BaseMenu.php new file mode 100644 index 00000000..7bb97e16 --- /dev/null +++ b/inc/main/classes/menu/class_BaseMenu.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMenu extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Renders the menu by loading the base template and a menu-specific + * template. + * + * @return void + */ + public function renderMenu () { + // Initialize the menu system by preparing it's template instance + $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this)); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Load the menu template for all + $templateInstance->loadMenuTemplate('generic_menu_entries'); + + // Get the 'command' from request instance + $command = $this->getApplicationInstance()->getRequestInstance()->getRequestElement('command'); + + // If page is empty, choose default + if (empty($command)) { + // Use default page as none has been specified + $command = $this->getConfigInstance()->getConfigEntry('default_' . $this->getApplicationInstance()->getAppShortName() . '_' . self::getResponseTypeFromSystem() . '_command'); + } // END - if + + // Load the menu template for this page + try { + $templateInstance->loadMenuTemplate($command . '_menu_entries'); + } catch (FileNotFoundException $e) { + // Log exception @TODO Maybe to intrusive? + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Exception caught: ' . $e->__toString() . ', with message: ' . $e->getMessage()); + } + + // Render template data here + $templateInstance->renderXmlContent(); + //exit(__METHOD__ . ':!OK'); + } + + /** + * Transfers the rendered menu to a given template engine by assigning + * the rendered content with a template variable. + * + * @param $templateInstance An instance of a CompileableTemplate class + * @return void + */ + public function transferContentToTemplateEngine (CompileableTemplate $templateInstance) { + // Assign menu content to variable + $templateInstance->assignVariable('menu', $this->getTemplateInstance()->getMenuContent()); + //* DEBUG */ $templateInstance->debugInstance(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/.htaccess b/inc/main/classes/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/class_ b/inc/main/classes/output/class_ new file mode 100644 index 00000000..01161ac5 --- /dev/null +++ b/inc/main/classes/output/class_ @@ -0,0 +1,113 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Output extends BaseOutput implements OutputStreamer, Registerable { + /** + * The instance for the singleton design pattern + */ + private static $!!!Instance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a new !!! output system and set the content type + * + * @param $applicationInstance An instance of a ManageableApplication class + * @return $debugInstance An instance of this middleware class + */ + public static final function createWebOutput (ManageableApplication $applicationInstance) { + // Is the self-instance already set? + if (is_null(self::$!!!Instance)) { + // Get a new instance and set it + self::$!!!Instance = new WebOutput(); + + // Get the content type + $contentType = self::$!!!Instance->getConfigInstance()->getConfigEntry('!!!_content_type'); + + // Set the content type + if (!empty($contentType)) { + // Set the header + $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType); + } // END - if + } // END - if + + // Return instance + return self::$!!!Instance; + } + + /** + * Output the code + * + * @param $outStream Stream to output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + * @todo 0% done + */ + public final function output ($outStream = FALSE, $stripTags = FALSE) { + $this->partialStub('Please implement this method. outStream()=' . strlen($outStream) . ',stripTags=' . intval($stripTags)); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/class_BaseOutput.php b/inc/main/classes/output/class_BaseOutput.php new file mode 100644 index 00000000..484db423 --- /dev/null +++ b/inc/main/classes/output/class_BaseOutput.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseOutput extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/console/.htaccess b/inc/main/classes/output/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/console/class_ConsoleOutput.php b/inc/main/classes/output/console/class_ConsoleOutput.php new file mode 100644 index 00000000..7d93422b --- /dev/null +++ b/inc/main/classes/output/console/class_ConsoleOutput.php @@ -0,0 +1,129 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleOutput extends BaseOutput implements OutputStreamer { + /** + * The instance for the singleton design pattern + */ + private static $consoleInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a new web output system and set the content type + * + * @param $contentType A valid content-type + * @return $debugInstance An instance of this middleware class + */ + public static final function createConsoleOutput ($contentType) { + // Cast the content-type to string + $contentType = (string) $contentType; + $contentType = trim($contentType); + + // Get instance + self::$consoleInstance = new ConsoleOutput(); + + // Set the content type + // @TODO Need to rewrite this to $requestInstance->addHeader() + if (!empty($contentType)) { + @header(sprintf('Content-type: %s', + $contentType + )); + } // END - if + + // Return instance + return self::$consoleInstance; + } + + /** + * Getter for an instance of this class + * + * @return $consoleInstance An instance of this class + */ + public static final function getInstance() { + // Is the self-instance already set? + if (is_null(self::$consoleInstance)) { + $contentType = FrameworkConfiguration::getSelfInstance()->getConfigEntry('web_content_type'); + self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType); + } // END - if + + // Return the instance + return self::$consoleInstance; + } + + /** + * Output the code + * + * @param $outStream Something we shall sent to the console + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function output ($outStream = FALSE, $stripTags = FALSE) { + print trim($outStream) . PHP_EOL; + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/debug/.htaccess b/inc/main/classes/output/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/debug/class_BaseDebugOutput.php b/inc/main/classes/output/debug/class_BaseDebugOutput.php new file mode 100644 index 00000000..9440e384 --- /dev/null +++ b/inc/main/classes/output/debug/class_BaseDebugOutput.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseDebugOutput extends BaseOutput { + /** + * Class name for this output class is being used for logging + */ + private $loggerClassName = FALSE; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for logger class name + * + * @param $loggerClassName Class name this output class is being used for logging + * @return void + */ + public final function setLoggerClassName ($loggerClassName) { + $this->loggerClassName = $loggerClassName; + } + + /** + * Getter for logger class name + * + * @return $loggerClassName Class name this output class is being used for logging + */ + public final function getLoggerClassName () { + return $this->loggerClassName; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/debug/console/.htaccess b/inc/main/classes/output/debug/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/debug/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/debug/console/class_DebugConsoleOutput.php b/inc/main/classes/output/debug/console/class_DebugConsoleOutput.php new file mode 100644 index 00000000..3598cc18 --- /dev/null +++ b/inc/main/classes/output/debug/console/class_DebugConsoleOutput.php @@ -0,0 +1,136 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStreamer, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $debugInstance The prepared debug instance + */ + public static final function createDebugConsoleOutput () { + // Get a new instance + $debugInstance = new DebugConsoleOutput(); + + // Return it + return $debugInstance; + } + + /** + * Outputs the given data without HTML tags + * + * @param $output The HTML'ed output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function outputStream ($output, $stripTags = FALSE) { + // Strip HTML tags out? + if ($stripTags === TRUE) { + // Prepare the output without HTML tags + $output = trim(html_entity_decode(strip_tags(stripslashes($output)))); + } else { + // Prepare the output with HTML tags + $output = trim(stripslashes($output)); + } + + // Are debug times enabled? + if ($this->getConfigInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_output_timings') == 'Y') { + // Output it first + $output = $this->getPrintableExecutionTime() . $output; + } // END - if + + // And print it out... + printf('%s%s', $output, chr(10)); + } + + /** + * Output the code + * + * @param $outStream Stream to output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function output ($outStream = FALSE, $stripTags = FALSE) { + // Empty output will be silently ignored + if ($outStream !== FALSE) { + $this->outputStream($outStream, $stripTags); + } // END - if + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/debug/error/.htaccess b/inc/main/classes/output/debug/error/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/debug/error/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/debug/error/class_DebugErrorLogOutput.php b/inc/main/classes/output/debug/error/class_DebugErrorLogOutput.php new file mode 100644 index 00000000..7124250c --- /dev/null +++ b/inc/main/classes/output/debug/error/class_DebugErrorLogOutput.php @@ -0,0 +1,133 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugErrorLogOutput extends BaseDebugOutput implements Debugger, OutputStreamer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $debugInstance The prepared debug instance + */ + public static final function createDebugErrorLogOutput () { + // Get a new instance + $debugInstance = new DebugErrorLogOutput(); + + // Return it + return $debugInstance; + } + + /** + * Outputs the given data without HTML tags, ignores $stripTags + * + * @param $output The HTML'ed output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function outputStream ($output, $stripTags = FALSE) { + // Split multiple lines into and array to put them out line-by-line + $errorLines = explode(chr(10), $output); + + // "Walk" through all lines + foreach ($errorLines as $err) { + // Trim any spaces, \n, \r etc. out + $err = trim($err); + + // Log only none-empty lines + if (!empty($err)) { + // Log this line + error_log(html_entity_decode(strip_tags($err)), 0); + } // END - if + } // END - foreach + } + + /** + * Output the code + * + * @param $outStream Stream to output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function output ($outStream = FALSE, $stripTags = FALSE) { + // Empty output will be silently ignored + if ($outStream !== FALSE) { + $this->outputStream($outStream); + } + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Determines for seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/debug/web/.htaccess b/inc/main/classes/output/debug/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/debug/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/debug/web/class_DebugWebOutput.php b/inc/main/classes/output/debug/web/class_DebugWebOutput.php new file mode 100644 index 00000000..b8c34cb6 --- /dev/null +++ b/inc/main/classes/output/debug/web/class_DebugWebOutput.php @@ -0,0 +1,122 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugWebOutput extends BaseDebugOutput implements Debugger, OutputStreamer { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $debugInstance The prepared debug instance + */ + public static final function createDebugWebOutput () { + // Get a new instance + $debugInstance = new DebugWebOutput(); + + // Return it + return $debugInstance; + } + + /** + * Outputs the given data directly, ignores $stripTags + * + * @param $output The HTML output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function outputStream ($output, $stripTags = FALSE) { + // Strip out
    + $output = str_replace('
    ', '', $output); + print(stripslashes($output)."
    \n"); + } + + /** + * Output the code + * + * @param $outStream Stream to output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function output ($outStream = FALSE, $stripTags = FALSE) { + // Empty output will be silently ignored + if ($outStream !== FALSE) { + $this->outputStream($outStream, $stripTags); + } // END - if + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/output/log_file/.htaccess b/inc/main/classes/output/log_file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/log_file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/web/.htaccess b/inc/main/classes/output/web/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/output/web/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/output/web/class_WebOutput.php b/inc/main/classes/output/web/class_WebOutput.php new file mode 100644 index 00000000..76f9be52 --- /dev/null +++ b/inc/main/classes/output/web/class_WebOutput.php @@ -0,0 +1,113 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WebOutput extends BaseOutput implements OutputStreamer, Registerable { + /** + * The instance for the singleton design pattern + */ + private static $webInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Create a new web output system and set the content type + * + * @param $applicationInstance An instance of a ManageableApplication class + * @return $debugInstance An instance of this middleware class + */ + public static final function createWebOutput (ManageableApplication $applicationInstance) { + // Is the self-instance already set? + if (is_null(self::$webInstance)) { + // Get a new instance and set it + self::$webInstance = new WebOutput(); + + // Get the content type + $contentType = self::$webInstance->getConfigInstance()->getConfigEntry('web_content_type'); + + // Set the content type + if (!empty($contentType)) { + // Set the header + $applicationInstance->getResponseInstance()->addHeader('Content-type', $contentType); + } // END - if + } // END - if + + // Return instance + return self::$webInstance; + } + + /** + * Output the code + * + * @param $outStream Stream to output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function output ($outStream = FALSE, $stripTags = FALSE) { + print(stripslashes($outStream)); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @throws UnsupportedOperationException If this method is called + */ + public function determineSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + * @throws UnsupportedOperationException If this method is called + */ + public function seek ($offset, $whence = SEEK_SET) { + self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] offset=' . $offset . ',whence=' . $whence); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + * @throws UnsupportedOperationException If this method is called + */ + public function size () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/parser/.htaccess b/inc/main/classes/parser/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/parser/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/parser/class_ b/inc/main/classes/parser/class_ new file mode 100644 index 00000000..3fe153d8 --- /dev/null +++ b/inc/main/classes/parser/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Parser extends BaseParser implements Parseable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class Parser and prepares it for usage + * + * @param $templateInstance A CompileableTemplate instance + * @return $parserInstance An instance of this parser + public final static function create???Parser (CompileableTemplate $templateInstance) { + // Get a new instance + $parserInstance = new ???Parser(); + + // Set the template instance + $parserInstance->setTemplateInstance($templateInstance); + + // Return the prepared instance + return $parserInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/parser/class_BaseParser.php b/inc/main/classes/parser/class_BaseParser.php new file mode 100644 index 00000000..23bb8051 --- /dev/null +++ b/inc/main/classes/parser/class_BaseParser.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseParser extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/parser/xml/.htaccess b/inc/main/classes/parser/xml/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/parser/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/parser/xml/class_XmlParser.php b/inc/main/classes/parser/xml/class_XmlParser.php new file mode 100644 index 00000000..82d0d15a --- /dev/null +++ b/inc/main/classes/parser/xml/class_XmlParser.php @@ -0,0 +1,115 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlParser extends BaseParser implements Parseable { + // Exception constants + const EXCEPTION_XML_PARSER_ERROR = 0x1e0; + const EXCEPTION_XML_NODE_UNKNOWN = 0x1e1; + const EXCEPTION_XML_NODE_MISMATCH = 0x1e2; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class Parser and prepares it for usage + * + * @param $templateInstance A CompileableTemplate instance + * @return $parserInstance An instance of this parser + */ + public static final function createXmlParser (CompileableTemplate $templateInstance) { + // Get a new instance + $parserInstance = new XmlParser(); + + // Set the template instance + $parserInstance->setTemplateInstance($templateInstance); + + // Return the prepared instance + return $parserInstance; + } + + /** + * Parses the given XML content + * + * @param $content Valid XML content + * @return void + * @throws XmlParserException If an XML error was found + */ + public function parseXmlContent ($content) { + // Convert all to UTF8 + if (empty($content)) { + // No empty content! + self::createDebugInstance(__CLASS__)->debugOutput('Empty content! Backtrace:
    ');
    +			debug_print_backtrace();
    +			self::createDebugInstance(__CLASS__)->debugOutput('
    '); + exit(); + } elseif (function_exists('recode')) { + // Recode found, so use it + $content = recode('html..utf8', $content); + } elseif (function_exists('mb_convert_encoding')) { + // Use mb_convert_encoding() + $content = mb_convert_encoding($content, 'UTF-8', 'auto'); + } else { + // @TODO We need to find a fallback solution here + $this->partialStub('Cannot find recode/mbstring extension!'); + } // END - if + + // Get an XML parser + $xmlParser = xml_parser_create(); + + // Force case-folding to on + xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, TRUE); + + // Set UTF-8 + xml_parser_set_option($xmlParser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); + + // Get instance (we need this :( ) + $templateInstance = $this->getTemplateInstance(); + + // Set object + xml_set_object($xmlParser, $templateInstance); + + // Set handler call-backs + xml_set_element_handler($xmlParser, 'startElement', 'finishElement'); + xml_set_character_data_handler($xmlParser, 'characterHandler'); + + // Now parse the XML tree + if (!xml_parse($xmlParser, $content)) { + // Error found in XML! + //* DEBUG: */ exit(__METHOD__ . ':
    '.htmlentities($content).'
    '); + throw new XmlParserException(array($this, $xmlParser), self::EXCEPTION_XML_PARSER_ERROR); + } // END - if + + // Free the parser + xml_parser_free($xmlParser); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/points/.htaccess b/inc/main/classes/points/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/points/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/points/class_UserPoints.php b/inc/main/classes/points/class_UserPoints.php new file mode 100644 index 00000000..428868d8 --- /dev/null +++ b/inc/main/classes/points/class_UserPoints.php @@ -0,0 +1,183 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePoints { + /** + * Amount of points + */ + private $amount = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this points class + * + * @param $userInstance An instance of a user class + * @return $pointsInstance An instance of this class + */ + public static final function createUserPoints (ManageableAccount $userInstance) { + // Get a new instance + $pointsInstance = new UserPoints(); + + // Set user instance + $pointsInstance->setUserInstance($userInstance); + + // Get a critieria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add search criteria + $searchInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $userInstance->getUserId()); + $searchInstance->setLimit(1); + + // Get a wrapper instance + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('user_points_db_wrapper_class'); + + // Get result back + $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance); + + // Advance to first entry by default + $resultInstance->next(); + + // Set it in this instance + $pointsInstance->setResultInstance($resultInstance); + + // Return instance + return $pointsInstance; + } + + /** + * Setter for amount + * + * @param $amount Amount of points to store + * @return void + */ + public final function setAmount ($amount) { + $this->amount = (float) $amount; + } + + /** + * Getter for amount + * + * @return $amount Amount of points to store + */ + public final function getAmount () { + return $this->amount; + } + + /** + * Checks whether the user has the required amount of points left for the specified action + * + * @param $action The action or configuration entry plus prefix the user wants to perform + * @return $hasRequired Whether the user has the required points + * @todo Finish loading part of points + */ + public function ifUserHasRequiredPoints ($action) { + // Default is that everyone is poor... ;-) + $hasRequired = FALSE; + + // Get the required points entry + $requiredPoints = $this->getConfigInstance()->getConfigEntry($action . '_action_points'); + + // Rewind always + $this->getResultInstance()->rewind(); + + // Do we have an entry? + if ($this->getResultInstance()->next()) { + // Get the entry + $currEntry = $this->getResultInstance()->current(); + + // Has he enought points? + $hasRequired = ($currEntry['points'] >= $requiredPoints); + } // END - if + + // Return the result + return $hasRequired; + } + + /** + * "Books" the given points amount on the current user's account + * + * @param $amount Amount of points we shall book + * @return void + */ + public function bookPointsDirectly ($amount) { + // Rewind always + $this->getResultInstance()->rewind(); + + // Do we have an entry? + if ($this->getResultInstance()->next()) { + // Get the entry + $entry = $this->getResultInstance()->current(); + + // Add the points + $amount += $entry[UserPointsDatabaseWrapper::DB_COLUMN_POINTS]; + + // Now get another criteria + $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); + + // And add our both entries + $updateInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $amount); + + // Add the search criteria for searching for the right entry + $updateInstance->setSearchInstance($searchInstance); + + // Set wrapper class name + $updateInstance->setWrapperConfigEntry('user_points_db_wrapper_class'); + + // Remember the update in database result + $this->getResultInstance()->add2UpdateQueue($updateInstance); + } else { + // Set the amount in class + $this->setAmount($amount); + + // Create the new entry + $wrapperInstance->insertUserPoints($this); + } + } + + /** + * Adds registration elements to a given dataset instance + * + * @param $criteriaInstance An instance of a StoreableCriteria class + * @param $requestInstance An instance of a Requestable class + * @return void + */ + public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL) { + // Add user id + $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS_UID, $this->getUserInstance()->getUserId()); + + // Add amount + $criteriaInstance->addCriteria(UserPointsDatabaseWrapper::DB_COLUMN_POINTS, $this->getAmount()); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/reader/.htaccess b/inc/main/classes/reader/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/reader/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/reader/class_ConsoleNewsReader.php b/inc/main/classes/reader/class_ConsoleNewsReader.php new file mode 100644 index 00000000..1aa4b615 --- /dev/null +++ b/inc/main/classes/reader/class_ConsoleNewsReader.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this reader by a provided request instance + * + * @param $requestInstance An instance of a Requestable class + * @return $readerInstance An instance of this reader class + */ + public static final function createConsoleNewsReader (Requestable $requestInstance) { + // Get a new instance + $readerInstance = new ConsoleNewsReader(); + + // Set request instance + $readerInstance->setRequestInstance($requestInstance); + + // Return prepared instance + return $readerInstance; + } + + /** + * Initializes this reader class by pre-fetching news depending on 'command' + * (outside or login area), which amount of news and how much to skip + * + * @return void + */ + public function initializeReader () { + // Get 'command' for saving some calls + $command = $this->getRequestInstance()->getRequestElement('command'); + + // First get a wrapper instance + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class'); + + // Next create a searchable criteria instance + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the command as criteria to it at lease + $criteriaInstance->addCriteria('command', $command); + + // Add limitation from config + $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit'); + + // Get a resultInstance back from the database + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Save that resultInstance in this class + $this->setResultInstance($resultInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/reader/class_DefaultNewsReader.php b/inc/main/classes/reader/class_DefaultNewsReader.php new file mode 100644 index 00000000..95354828 --- /dev/null +++ b/inc/main/classes/reader/class_DefaultNewsReader.php @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this reader by a provided request instance + * + * @param $requestInstance An instance of a Requestable class + * @return $readerInstance An instance of this reader class + */ + public static final function createDefaultNewsReader (Requestable $requestInstance) { + // Get a new instance + $readerInstance = new DefaultNewsReader(); + + // Set request instance + $readerInstance->setRequestInstance($requestInstance); + + // Return prepared instance + return $readerInstance; + } + + /** + * Initializes this reader class by pre-fetching news depending on 'command' + * (outside or login area), which amount of news and how much to skip + * + * @return void + */ + public function initializeReader () { + // Get 'command' for saving some calls + $command = $this->getRequestInstance()->getRequestElement('command'); + + // First get a wrapper instance + $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('news_db_wrapper_class'); + + // Next create a searchable criteria instance + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the page as criteria to it at lease + $criteriaInstance->addCriteria('command', $command); + + // Add limitation from config + $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit'); + + // Get a resultInstance back from the database + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Save that resultInstance in this class + $this->setResultInstance($resultInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/registration/.htaccess b/inc/main/classes/registration/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/registration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/registration/class_BaseRegistration.php b/inc/main/classes/registration/class_BaseRegistration.php new file mode 100644 index 00000000..0a516f89 --- /dev/null +++ b/inc/main/classes/registration/class_BaseRegistration.php @@ -0,0 +1,101 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseRegistration extends BaseFrameworkSystem { + /** + * Pre-registration filter chain + */ + private $preRegistrationFilter = NULL; + + /** + * Pre-registration filter chain + */ + private $postRegistrationFilter = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initialize filters. This must be done before you can use them + * + * @return void + */ + protected function initFilterChains () { + // Pre/post-registration filters + $this->preRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + $this->postRegistrationFilter = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + } + + /** + * Adds a filter to the pre filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPreFilter (Filterable $filterInstance) { + // Add the pre filter + $this->preRegistrationFilter->addFilter($filterInstance); + } + + /** + * Adds a filter to the post filter chain + * + * @param $filterInstance An instance of a filter + * @return void + */ + public function addPostFilter (Filterable $filterInstance) { + // Add the post filter + $this->postRegistrationFilter->addFilter($filterInstance); + } + + /** + * Executes all pre filters + * + * @return void + */ + protected function executePreFilters () { + // Execute all pre filters + $this->preRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance()); + } + + /** + * Executes all post filters + * + * @return void + */ + protected function executePostFilters () { + // Execute all post filters + $this->postRegistrationFilter->processFilters($this->getRequestInstance(), $this->getResponseInstance()); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/registry/.htaccess b/inc/main/classes/registry/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/registry/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/registry/class_ b/inc/main/classes/registry/class_ new file mode 100644 index 00000000..db836926 --- /dev/null +++ b/inc/main/classes/registry/class_ @@ -0,0 +1,59 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Registry extends BaseRegistry implements Register { + /** + * Instance of this class + */ + private static $registryInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton getter for self instance. This class has no factory pattern + * because here is no need for special parameters. + * + * @return $registryInstance Instance of this class + */ + public final static function getRegistry () { + // Is an instance there? + if (is_null(self::$registryInstance)) { + // Not yet, so create one + self::$registryInstance = new ???Registry(); + } // END - if + + // Return the instance + return self::$registryInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/registry/class_BaseRegistry.php b/inc/main/classes/registry/class_BaseRegistry.php new file mode 100644 index 00000000..34f4a892 --- /dev/null +++ b/inc/main/classes/registry/class_BaseRegistry.php @@ -0,0 +1,224 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseRegistry extends BaseFrameworkSystem implements Registerable { + /** + * Glue for generating a registry key + */ + const REGISTRY_KEY_GLUE = '_'; + + /** + * Instance of this class + */ + private static $registryInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init raw array + $this->initGenericArrayGroup('raw', 'generic'); + } + + /** + * Checks whether an instance key was found + * + * @param $instanceKey The key holding an instance in registry + * @return $exists Whether the key exists in registry + */ + public function instanceExists ($instanceKey) { + // Does this key exists? + $exists = $this->isGenericArrayKeySet('registry', 'instance', $instanceKey); + + // Return the result + return $exists; + } + + /** + * Adds/overwrites a new instance to the registry at the given key + * + * @param $instanceKey The key to identify the instance + * @param $objectInstance An instance we shall store + * @return void + */ + public function addInstance ($instanceKey, Registerable $objectInstance) { + $this->setGenericArrayKey('registry', 'instance', $instanceKey, $objectInstance); + } + + /** + * Getter for whole instance registry + * + * @return $instanceRegistry The whole instance registry array + */ + public final function getInstanceRegistry () { + return $this->getGenericSubArray('registry', 'instance'); + } + + /** + * Adds a new entry to the given list name. If you want to add objects + * please use addInstance() and getInstance() instead. + * + * @param $key The key to identify the whole list + * @param $value The value to be stored + * @return void + */ + public final function addEntry ($key, $value) { + // Key must not be an array + assert(!is_array($key)); + + // Push it + $this->pushValueToGenericArrayKey('raw', 'generic', $key, $value); + } + + /** + * Getter for entries or "sub entries" + * + * @return $entries An array with entries from this registry + */ + public final function getEntries ($key = NULL) { + // Key must not be an array + assert(!is_array($key)); + + // Default is whole array + $entries = $this->getGenericArray('raw'); + + // Is $key set? + if (!is_null($key)) { + // Then use this entry + $entries = $this->getGenericArrayKey('raw', 'generic', $key); + } // END - if + + // Return the array + return $entries; + } + + /** + * "Getter" for an array of all entries for given key + * + * @param $arrayKey The array (key) to look in + * @param $lookFor The key to look for + * @return $entry An array with all keys + */ + public function getArrayFromKey ($arrayKey, $lookFor) { + // Key must not be an array + assert(!is_array($arrayKey)); + + // Init array + $entry = array(); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking arrayKey=' . $arrayKey . ',lookFor=' . $lookFor); + + // "Walk" over all entries + foreach ($this->getEntries($arrayKey) as $key => $value) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key=' . $key . ',value=' . $value . ',lookFor=' . $lookFor); + + // If $value matches the $lookFor, we need to look for more entries for this! + if ($lookFor == $value) { + // Look for more entries + foreach ($this->getEntries() as $key2 => $value2) { + // Now "walk" through all entries, if an array is returned + if (is_array($value2)) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key2=' . $key2 . ',value2()=' . count($value2) . ',lookFor=' . $lookFor); + + // "Walk" through all of them + foreach ($value2 as $key3 => $value3) { + // $value3 needs to be an array + assert(is_array($value3)); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Checking key=' . $key . ',key3=' . $key3 . ',isset()=' . isset($value3[$key]) . ' ...'); + + // Both keys must match! + if (($key == $key3) || (isset($value3[$key]))) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . $value3[$key] . ' ...'); + + // Then add it + $entry[$key3] = $value3[$key]; + } // END - if + } // END - foreach + } // END - if + } // END - foreach + + // Skip further lookups + break; + } // END - if + } // END - foreach + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Returning entry(' . count($entry) . ')=' . print_r($entry, TRUE)); + + // Return it + return $entry; + } + + /** + * Gets a registered instance or null if not found + * + * @param $instanceKey The key to identify the instance + * @return $objectInstance An instance we shall store + * @throws NullPointerException If the requested key is not found + */ + public function getInstance ($instanceKey) { + // Is the instance there? + if (!$this->instanceExists($instanceKey)) { + // This might happen if a non-registered key was requested + throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the instance + $objectInstance = $this->getGenericArrayKey('registry', 'instance', $instanceKey); + + // Return the result + return $objectInstance; + } + + /** + * "Getter" for a registry key for given prefix and array. This method + * calls implode() to get a suitable key. This method does not care about + * the indexes. + * + * @param $prefix Prefix for the key + * @param $data An array with data + * @return $registryKey A registry key + */ + public static function getRegistryKeyFromArray ($prefix, array $data) { + // "Generate" the key + $registryKey = $prefix . self::REGISTRY_KEY_GLUE . implode(self::REGISTRY_KEY_GLUE, $data); + + // Return it + return $registryKey; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/registry/generic/.htaccess b/inc/main/classes/registry/generic/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/registry/generic/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/registry/generic/class_Registry.php b/inc/main/classes/registry/generic/class_Registry.php new file mode 100644 index 00000000..d998ac83 --- /dev/null +++ b/inc/main/classes/registry/generic/class_Registry.php @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Registry extends BaseRegistry implements Register { + /** + * Instance of this class + */ + private static $registryInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Singleton getter for self instance. This class has no factory pattern + * because here is no need for special parameters. + * + * @return $registryInstance Instance of this class + */ + public static final function getRegistry () { + // Is an instance there? + if (is_null(self::$registryInstance)) { + // Not yet, so create one + self::$registryInstance = new Registry(); + } // END - if + + // Return the instance + return self::$registryInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/registry/sub/.htaccess b/inc/main/classes/registry/sub/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/registry/sub/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/registry/sub/class_SubRegistry.php b/inc/main/classes/registry/sub/class_SubRegistry.php new file mode 100644 index 00000000..96c9eac3 --- /dev/null +++ b/inc/main/classes/registry/sub/class_SubRegistry.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SubRegistry extends BaseRegistry implements Register { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance (non-singleton, of course) of this registry class + * + * @return $registryInstance An instance of this registry class + */ + public static final function createSubRegistry () { + // Just get a new instance ... + $registryInstance = new SubRegistry(); + + // ... and return it + return $registryInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/request/.htaccess b/inc/main/classes/request/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/request/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/request/class_ b/inc/main/classes/request/class_ new file mode 100644 index 00000000..ac05147e --- /dev/null +++ b/inc/main/classes/request/class_ @@ -0,0 +1,93 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Request extends BaseRequest implements Requestable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class and prepares it a little + * + * @return $httpInstance An instance of this class + */ + public final static function create???Request () { + // Create an instance + $httpInstance = new ???Request(); + + // Prepare the HTTP request data for usage + $httpInstance->prepareRequestData(); + + // Return the prepared instance + return $httpInstance; + } + + /** + * Prepares the request data for usage + * + * @return void + * @todo Needs to be implemented + */ + public function prepareRequestData () { + $this->partialStub("Please implement this method."); + } + + /** + * Getter for a header element or 'null' if header was not found + * + * @param $headerName Name of the header + * @return $headerValue Value of the header or 'null' if not found + */ + public function getHeaderElement ($headerName) { + $this->partialStub("Please implement this method."); + } + + /** + * Getter for request method. This getter might be useful for security filters + * + * @return $requestMethod Used request method + */ + public final function getRequestMethod () { + $this->partialStub("Please implement this method."); + return $_SERVER['REQUEST_METHOD']; + } + + /** + * Reads a cookie and returns it's value or null if not found + * + * @param $cookieName Name of cookie we shall read + * @return $cookieValue Value of cookie or null if not found + */ + public final function readCookie ($cookieName) { + $this->partialStub("Please implement this method."); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/request/class_BaseRequest.php b/inc/main/classes/request/class_BaseRequest.php new file mode 100644 index 00000000..0069bc47 --- /dev/null +++ b/inc/main/classes/request/class_BaseRequest.php @@ -0,0 +1,136 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseRequest extends BaseFrameworkSystem { + /** + * Array for the request data + */ + private $requestData = array(); + + /** + * Whether this request is valid and can be further processed. The default is + * valid so make sure your intercepting filters sets this attribute to FALSE + * when they need to intercept the data flow. + */ + private $requestIsValid = TRUE; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Checks whether a request element is set + * @param $element Name of the request element we want to check + * @return $isSet Whether the request element is set + */ + public function isRequestElementSet ($element) { + // Is this element found? + $isSet = isset($this->requestData[$element]); + + // Return result + return $isSet; + } + + /** + * Getter for request element or 'null' if element was not found + * + * @param $element Name of the request element we want to check + * @return $value Value of the found request element or 'null' if the + * element was not found + */ + public function getRequestElement ($element) { + // Initialize value + $value = NULL; + + // Is the element set? + if ($this->isRequestElementSet($element)) { + // Get the bare value + $value = $this->requestData[$element]; + + // Secure it against attacks + $value = htmlentities(strip_tags($value), ENT_QUOTES); + } // END - if + + // Return the element's value + return $value; + } + + /** + * Setter for request elements + * + * @param $element Request element to se + * @param $value Value to set + * @return void + */ + public function setRequestElement ($element, $value) { + $this->requestData[$element] = $value; + } + + /** + * Setter for request data array + * + * @param $requestData Request element to se + * @return void + */ + public function setRequestData (array $requestData) { + $this->requestData = $requestData; + } + + /** + * Wrapper method for array_key() function for the request data array + * + * @return $array An array containing all array keys to return + */ + public function getParameterNames () { + return array_keys($this->requestData); + } + + /** + * Sets whether the request was valid (default: TRUE) + * + * @param $isValid Whether the request is valid + * @return void + */ + public final function requestIsValid ($isValid = TRUE) { + $this->requestIsValid = (bool) $isValid; + } + + /** + * Returns whether this request is valid + * + * @return $requestIsValid Whether this request is valid + */ + public final function isRequestValid () { + return $this->requestIsValid; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/request/console/.htaccess b/inc/main/classes/request/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/request/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/request/console/class_ConsoleRequest.php b/inc/main/classes/request/console/class_ConsoleRequest.php new file mode 100644 index 00000000..c5e070ed --- /dev/null +++ b/inc/main/classes/request/console/class_ConsoleRequest.php @@ -0,0 +1,157 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleRequest extends BaseRequest implements Requestable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class and prepares it a little + * + * @return $httpInstance An instance of this class + */ + public static final function createConsoleRequest () { + // Create an instance + $httpInstance = new ConsoleRequest(); + + // Prepare the console request data for usage + $httpInstance->prepareRequestData(); + + // Return the prepared instance + return $httpInstance; + } + + /** + * Prepares the request data for usage + * + * @return void + */ + public function prepareRequestData () { + // Get the "request data" from the command-line argument list + $args = $_SERVER['argv']; + + // Are there less than two parameters? + if ($_SERVER['argc'] < 2) { + // Skip this + return; + } // END - if + + // Is the first element "index.php" ? + if ($args[0] == 'index.php') { + // Then remove it + array_shift($args); + } // END - if + + // Try to determine next parameters + foreach ($args as $arg) { + // Seperate arguemnt name from value + $argArray = explode('=', $arg); + + // Is the second one set? + if (!isset($argArray[1])) { + // Add it likewise, but empty value + $this->setRequestElement($argArray[0], ''); + } else { + // Set a name=value pair escaped and secured + $this->setRequestElement($argArray[0], escapeshellcmd($argArray[1])); + } + } // END - foreach + } + + /** + * Getter for a header element or 'null' if header was not found + * + * @param $headerName Name of the header + * @return $headerValue Value of the header or 'null' if not found + * @throws UnsupportedOperationException This method should never be called + */ + public function getHeaderElement ($headerName) { + // Console doesn't have any headers + throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for request method. This getter might be useful for security filters + * + * @return $requestMethod Used request method + */ + public final function getRequestMethod () { + // @TODO Can't this be 'CONSOLE' ? + return 'LOCAL'; + } + + /** + * Reads a cookie and returns it's value or null if not found + * + * @param $cookieName Name of cookie we shall read + * @return $cookieValue Value of cookie or null if not found + * @throws UnsupportedOperationException This method should never be called + */ + public final function readCookie ($cookieName) { + // There are no cookies on console + throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks if the request method is GET. + * + * @return $isGet Whether the request method is GET + * @throws UnsupportedOperationException This method should never be called + */ + public function isGetRequestMethod () { + // Not support method + throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks if the request method is HEAD. + * + * @return $isHead Whether the request method is HEAD + * @throws UnsupportedOperationException This method should never be called + */ + public function isHeadRequestMethod () { + // Not support method + throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks if the request method is POST. + * + * @return $isPost Whether the request method is POST + * @throws UnsupportedOperationException This method should never be called + */ + public function isPostRequestMethod () { + // Not support method + throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/request/html/.htaccess b/inc/main/classes/request/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/request/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/request/html/class_HtmlRequest.php b/inc/main/classes/request/html/class_HtmlRequest.php new file mode 100644 index 00000000..edf9c9a4 --- /dev/null +++ b/inc/main/classes/request/html/class_HtmlRequest.php @@ -0,0 +1,147 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Move out the cookie part to a seperate class, e.g. Cookie + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlRequest extends BaseRequest implements Requestable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class and prepares it a little + * + * @return $requestInstance An instance of this class + */ + public static final function createHtmlRequest () { + // Create an instance + $requestInstance = new HtmlRequest(); + + // Prepare the HTML request data for usage + $requestInstance->prepareRequestData(); + + // Return the prepared instance + return $requestInstance; + } + + /** + * Checks if the request method is GET. + * + * @return $isGet Whether the request method is GET + */ + public function isGetRequestMethod () { + // Check it + return ($this->getRequestMethod() == 'GET'); + } + + /** + * Checks if the request method is HEAD. + * + * @return $isHead Whether the request method is HEAD + */ + public function isHeadRequestMethod () { + // Check it + return ($this->getRequestMethod() == 'HEAD'); + } + + /** + * Checks if the request method is POST. + * + * @return $isPost Whether the request method is POST + */ + public function isPostRequestMethod () { + // Check it + return ($this->getRequestMethod() == 'POST'); + } + + /** + * Prepares the HTML request data for usage by currently copying + * $_REQUEST into a private attribute. Later on we can add more + * things for initialization here. + * + * @return void + */ + public function prepareRequestData () { + // Copy GET then POST data + $this->setRequestData(array_merge($_GET, $_POST)); + } + + /** + * Getter for a header element or 'null' if header was not found + * + * @param $headerName Name of the header + * @return $headerValue Value of the header or 'null' if not found + */ + public function getHeaderElement ($headerName) { + // Default return value on error + $headerValue = NULL; + + // Construct the name + $name = 'HTTP_' . strtoupper(self::convertDashesToUnderscores($headerName)); + + // Does this header exist? + if (isset($_SERVER[$name])) { + $headerValue = $_SERVER[$name]; + } // END - if + + // Return the value + return $headerValue; + } + + /** + * Getter for request method. This getter might be useful for security filters + * + * @return $requestMethod Used request method + */ + public final function getRequestMethod () { + return $_SERVER['REQUEST_METHOD']; + } + + /** + * Reads a cookie and returns it's value or null if not found + * + * @param $cookieName Name of cookie we shall read + * @return $cookieValue Value of cookie or null if not found + */ + public final function readCookie ($cookieName) { + // Default is no cookie with that name found + $cookieValue = NULL; + + // Is the cookie set? + if (isset($_COOKIE[$cookieName])) { + // Then get it + $cookieValue = $_COOKIE[$cookieName]; + } // END - if + + // Return the value + return $cookieValue; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/.htaccess b/inc/main/classes/resolver/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/action/.htaccess b/inc/main/classes/resolver/action/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/action/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/action/class_BaseActionResolver.php b/inc/main/classes/resolver/action/class_BaseActionResolver.php new file mode 100644 index 00000000..44836e9d --- /dev/null +++ b/inc/main/classes/resolver/action/class_BaseActionResolver.php @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseActionResolver extends BaseResolver { + /** + * Validated action name + */ + private $actionName = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for action name + * + * @param $actionName Last validated action name + * @return void + */ + protected final function setActionName ($actionName) { + $this->actionName = (string) $actionName; + } + + /** + * Getter for action name + * + * @return $actionName Last validated action name + */ + public final function getActionName () { + return $this->actionName; + } + + /** + * Checks whether the given action is valid + * + * @param $actionName The default action we shall execute + * @return $isValid Whether the given action is valid + * @throws EmptyVariableException Thrown if given action is not set + */ + public function isActionValid ($actionName) { + // By default nothing shall be valid + $isValid = FALSE; + + // Is a action set? + if (empty($actionName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($this, 'actionName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Create class name + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($actionName) . 'Action'; + + // Now, let us create the full name of the action class + $this->setClassName($className); + + // Is this class already loaded? + if (class_exists($this->getClassName())) { + // This class does exist. :-) + $isValid = TRUE; + } // END - if + + // Set action name + $this->setActionName($actionName); + + // Return the result + return $isValid; + } + + /** + * "Loads" current action and instances it if not yet cached + * + * @return $actionInstance A loaded action instance + */ + protected function loadAction () { + // Init action instance + $actionInstance = NULL; + + // Create action class name + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($this->getActionName()) . 'Action'; + + // ... and set it + $this->setClassName($className); + + // Initiate the action + $actionInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $actionInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/action/html/.htaccess b/inc/main/classes/resolver/action/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/action/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/action/html/class_HtmlActionResolver.php b/inc/main/classes/resolver/action/html/class_HtmlActionResolver.php new file mode 100644 index 00000000..e6d8bb37 --- /dev/null +++ b/inc/main/classes/resolver/action/html/class_HtmlActionResolver.php @@ -0,0 +1,151 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlActionResolver extends BaseActionResolver implements ActionResolver { + /** + * Last successfull resolved action + */ + private $lastActionInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'html' + $this->setClassPrefix('html'); + } + + /** + * Creates an instance of a Html action resolver with a given default action + * + * @param $actionName The default action we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared action resolver instance + * @throws EmptyVariableException Thrown if default action is not set + * @throws InvalidActionException Thrown if default action is invalid + */ + public static final function createHtmlActionResolver ($actionName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HtmlActionResolver(); + + // Is the variable $actionName set and the action is valid? + if (empty($actionName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isActionValid($actionName) === FALSE) { + // Invalid action found + throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an action instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $actionInstance An instance of the resolved action + * @throws InvalidActionException Thrown if $actionName is + * invalid + * @throws InvalidActionInstanceException Thrown if $actionInstance + * is an invalid instance + */ + public function resolveActionByRequest (Requestable $requestInstance) { + // Init variables + $actionName = ''; + $actionInstance = NULL; + + // This goes fine so let's resolve the action + $actionName = $requestInstance->getRequestElement('action'); + + // Is the action empty? Then fall back to default action + if (empty($actionName)) { + $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->isActionValid($actionName) === FALSE) { + // This action is invalid! + throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $actionInstance = $this->loadAction(); + + // And validate it + if ((!is_object($actionInstance)) || (!$actionInstance instanceof Actionable)) { + // This action has an invalid instance! + throw new InvalidActionInstanceException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Set last action + $this->setResolvedInstance($actionInstance); + + // Return the resolved action instance + return $actionInstance; + } + + /** + * Resolves the action by its direct name and returns an instance of its class + * + * @return $actionInstance An instance of the action class + * @throws InvalidActionException Thrown if $actionName is invalid + */ + public function resolveAction () { + // Initiate the instance variable + $actionInstance = NULL; + + // Get action name + $actionName = $this->getActionName(); + + // Is the action empty? Then fall back to default action + if (empty($actionName)) { + $actionName = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->isActionValid($actionName) === FALSE) { + // This action is invalid! + throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $actionInstance = $this->loadAction(); + + // Return the instance + return $actionInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/class_ b/inc/main/classes/resolver/class_ new file mode 100644 index 00000000..5cdfd089 --- /dev/null +++ b/inc/main/classes/resolver/class_ @@ -0,0 +1,577 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Resolver extends BaseResolver implements Resolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to '???' + $this->setClassPrefix('???'); + } + + /** + * Creates an instance of a Html action resolver with a given default action + * + * @param $!!!Name The default action we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared action resolver instance + * @throws EmptyVariableException Thrown if default action is not set + * @throws Invalid|||Exception Thrown if default action is invalid + */ + public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new ???Resolver(); + + // Is the variable $!!!Name set and the action is valid? + if (empty($!!!Name)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { + // Invalid action found + throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an action instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $!!!Instance An instance of the resolved action + * @throws Invalid|||Exception Thrown if $!!!Name is + * invalid + * @throws Invalid|||InstanceException Thrown if $!!!Instance + * is an invalid instance + */ + public function resolve|||ByRequest (Requestable $requestInstance) { + // Init variables + $!!!Name = ''; + $!!!Instance = null; + + // This goes fine so let's resolve the action + $!!!Name = $requestInstance->getRequestElement('action'); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // And validate it + if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { + // This action has an invalid instance! + throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Set last action + $this->setResolvedInstance($!!!Instance); + + // Return the resolved action instance + return $!!!Instance; + } + + /** + * Resolves the action by its direct name and returns an instance of its class + * + * @return $!!!Instance An instance of the action class + * @throws Invalid|||Exception Thrown if $!!!Name is invalid + */ + public function resolve||| () { + // Initiate the instance variable + $!!!Instance = null; + + // Get action name + $!!!Name = $this->get|||Name(); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) { + $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // Return the instance + return $!!!Instance; + } +} + +// [EOF] +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Resolver extends BaseResolver implements Resolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to '???' + $this->setClassPrefix('???'); + } + + /** + * Creates an instance of a Html action resolver with a given default action + * + * @param $!!!Name The default action we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared action resolver instance + * @throws EmptyVariableException Thrown if default action is not set + * @throws Invalid|||Exception Thrown if default action is invalid + */ + public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new ???Resolver(); + + // Is the variable $!!!Name set and the action is valid? + if (empty($!!!Name)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { + // Invalid action found + throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an action instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $!!!Instance An instance of the resolved action + * @throws Invalid|||Exception Thrown if $!!!Name is + * invalid + * @throws Invalid|||InstanceException Thrown if $!!!Instance + * is an invalid instance + */ + public function resolve|||ByRequest (Requestable $requestInstance) { + // Init variables + $!!!Name = ''; + $!!!Instance = null; + + // This goes fine so let's resolve the action + $!!!Name = $requestInstance->getRequestElement('action'); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // And validate it + if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { + // This action has an invalid instance! + throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Set last action + $this->setResolvedInstance($!!!Instance); + + // Return the resolved action instance + return $!!!Instance; + } + + /** + * Resolves the action by its direct name and returns an instance of its class + * + * @return $!!!Instance An instance of the action class + * @throws Invalid|||Exception Thrown if $!!!Name is invalid + */ + public function resolve||| () { + // Initiate the instance variable + $!!!Instance = null; + + // Get action name + $!!!Name = $this->get|||Name(); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) { + $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // Return the instance + return $!!!Instance; + } +} + +// [EOF] +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Resolver extends BaseResolver implements Resolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to '???' + $this->setClassPrefix('???'); + } + + /** + * Creates an instance of a Html action resolver with a given default action + * + * @param $!!!Name The default action we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared action resolver instance + * @throws EmptyVariableException Thrown if default action is not set + * @throws Invalid|||Exception Thrown if default action is invalid + */ + public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new ???Resolver(); + + // Is the variable $!!!Name set and the action is valid? + if (empty($!!!Name)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { + // Invalid action found + throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an action instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $!!!Instance An instance of the resolved action + * @throws Invalid|||Exception Thrown if $!!!Name is + * invalid + * @throws Invalid|||InstanceException Thrown if $!!!Instance + * is an invalid instance + */ + public function resolve|||ByRequest (Requestable $requestInstance) { + // Init variables + $!!!Name = ''; + $!!!Instance = null; + + // This goes fine so let's resolve the action + $!!!Name = $requestInstance->getRequestElement('action'); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // And validate it + if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { + // This action has an invalid instance! + throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Set last action + $this->setResolvedInstance($!!!Instance); + + // Return the resolved action instance + return $!!!Instance; + } + + /** + * Resolves the action by its direct name and returns an instance of its class + * + * @return $!!!Instance An instance of the action class + * @throws Invalid|||Exception Thrown if $!!!Name is invalid + */ + public function resolve||| () { + // Initiate the instance variable + $!!!Instance = null; + + // Get action name + $!!!Name = $this->get|||Name(); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) { + $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // Return the instance + return $!!!Instance; + } +} + +// [EOF] +?> + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Resolver extends BaseResolver implements Resolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to '???' + $this->setClassPrefix('???'); + } + + /** + * Creates an instance of a ??? resolver with a given default action + * + * @param $!!!Name The default action we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared action resolver instance + * @throws EmptyVariableException Thrown if default action is not set + * @throws Invalid|||Exception Thrown if default action is invalid + */ + public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new ???Resolver(); + + // Is the variable $!!!Name set and the action is valid? + if (empty($!!!Name)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->is|||Valid($!!!Name) === FALSE) { + // Invalid action found + throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } + + /** + * Returns an action instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $!!!Instance An instance of the resolved action + * @throws Invalid|||Exception Thrown if $!!!Name is + * invalid + * @throws Invalid|||InstanceException Thrown if $!!!Instance + * is an invalid instance + */ + public function resolve|||ByRequest (Requestable $requestInstance) { + // Init variables + $!!!Name = ''; + $!!!Instance = null; + + // This goes fine so let's resolve the action + $!!!Name = $requestInstance->getRequestElement('action'); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // And validate it + if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) { + // This action has an invalid instance! + throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Set last action + $this->setResolvedInstance($!!!Instance); + + // Return the resolved action instance + return $!!!Instance; + } + + /** + * Resolves the action by its direct name and returns an instance of its class + * + * @return $!!!Instance An instance of the action class + * @throws Invalid|||Exception Thrown if $!!!Name is invalid + */ + public function resolve||| () { + // Initiate the instance variable + $!!!Instance = null; + + // Get action name + $!!!Name = $this->get|||Name(); + + // Is the action empty? Then fall back to default action + if (empty($!!!Name)) { + $!!!Name = $this->getConfigInstance()->getConfigEntry('default_action'); + } // END - if + + // Check if action is valid + if ($this->is|||Valid($!!!Name) === FALSE) { + // This action is invalid! + throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION); + } // END - if + + // Get the action + $!!!Instance = $this->load|||(); + + // Return the instance + return $!!!Instance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/class_BaseResolver.php b/inc/main/classes/resolver/class_BaseResolver.php new file mode 100644 index 00000000..e6582f1a --- /dev/null +++ b/inc/main/classes/resolver/class_BaseResolver.php @@ -0,0 +1,132 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseResolver extends BaseFrameworkSystem { + /** + * Class name + */ + private $className = ''; + + /** + * Prefix for class + */ + private $classPrefix = ''; + + /** + * (Last) resolved instance + */ + private $resolvedInstance = NULL; + + // Exception constants + const EXCEPTION_INVALID_COMMAND = 0x1d0; + const EXCEPTION_INVALID_CONTROLLER = 0x1d1; + const EXCEPTION_INVALID_ACTION = 0x1d2; + const EXCEPTION_INVALID_STATE = 0x1d3; + + /** + * Protected constructor + * + * @param $className Real name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for class name + * + * @return $className Name of the class + */ + public final function getClassName () { + return $this->className; + } + + /** + * "Getter" for class name (useable for an object factory) + * + * @return $className Capitalized class name + */ + protected function getCapitalizedClassPrefix () { + // Get class name + $className = $this->getClassPrefix(); + + // And capitalize it + $className = self::convertToClassName($className); + + // Return it + return $className; + } + + /** + * Setter for class name + * + * @param $className Name of the class + * @return void + */ + protected final function setClassName ($className) { + $this->className = (string) $className; + } + + /** + * Getter for class prefix + * + * @return $classPrefix Last validated classPrefix + */ + protected final function getClassPrefix () { + return $this->classPrefix; + } + + /** + * Setter for class prefix + * + * @param $classPrefix Last validated classPrefix + * @return void + */ + protected final function setClassPrefix ($classPrefix) { + $this->classPrefix = (string) $classPrefix; + } + + /** + * Getter for (last) resolved instance + * + * @return $resolvedInstance Last validated resolvedInstance + */ + protected final function getResolvedInstance () { + return $this->resolvedInstance; + } + + /** + * Setter for (last) resolved instance + * + * @param $resolvedInstance (Last) validated resolved instance + * @return void + */ + protected final function setResolvedInstance (FrameworkInterface $resolvedInstance) { + $this->resolvedInstance = $resolvedInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/command/.htaccess b/inc/main/classes/resolver/command/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/command/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/command/class_BaseCommandResolver.php b/inc/main/classes/resolver/command/class_BaseCommandResolver.php new file mode 100644 index 00000000..ff444fd7 --- /dev/null +++ b/inc/main/classes/resolver/command/class_BaseCommandResolver.php @@ -0,0 +1,180 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseCommandResolver extends BaseResolver { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * "Loads" a given command and instances it if not yet cached + * + * @param $commandName A command name we shall look for + * @return $commandInstance A loaded command instance + * @throws InvalidCommandException Thrown if even the default + * command class is missing (bad!) + */ + protected function loadCommand ($commandName) { + // Init command instance + $commandInstance = NULL; + + // Create class name + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($commandName) . 'Command'; + + // Create command class name + $this->setClassName($className); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Class not found, so throw an exception + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Initiate the command + $commandInstance = ObjectFactory::createObjectByName($this->getClassName(), array($this)); + + // Return the result + return $commandInstance; + } + + /** + * Returns an command instance for a given request class or null if + * it was not found + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + * @throws InvalidCommandException Thrown if $commandName is + * invalid + * @throws InvalidCommandInstanceException Thrown if $commandInstance + * is an invalid instance + */ + public function resolveCommandByRequest (Requestable $requestInstance) { + // Init variables + $commandName = ''; + $commandInstance = NULL; + + // This goes fine so let's resolve the command + $commandName = $requestInstance->getRequestElement('command'); + + // Is the command empty? Then fall back to default command + if (empty($commandName)) { + $commandName = $this->getConfigInstance()->getConfigEntry('default_' . self::getResponseTypeFromSystem() . '_command'); + } // END - if + + // Check if command is valid + if ($this->isCommandValid($commandName) === FALSE) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // And validate it + if ((!is_object($commandInstance)) || (!$commandInstance instanceof Commandable)) { + // This command has an invalid instance! + throw new InvalidCommandInstanceException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Set last command + $this->setResolvedInstance($commandInstance); + + // Return the resolved command instance + return $commandInstance; + } + + /** + * Resolves the command by its direct name and returns an instance of its class + * + * @param $commandName The direct command name we shall resolve + * @return $commandInstance An instance of the command class + * @throws InvalidCommandException Thrown if $commandName is invalid + */ + public function resolveCommand ($commandName) { + // Initiate the instance variable + $commandInstance = NULL; + + // Is the command empty? Then fall back to default command + if (empty($commandName)) { + $commandName = $this->getConfigInstance()->getConfigEntry('default_' . self::getResponseTypeFromSystem() . '_command'); + } // END - if + + // Check if command is valid + if ($this->isCommandValid($commandName) === FALSE) { + // This command is invalid! + throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND); + } // END - if + + // Get the command + $commandInstance = $this->loadCommand($commandName); + + // Return the instance + return $commandInstance; + } + + /** + * Checks whether the given command is valid + * + * @param $commandName The default command we shall execute + * @return $isValid Whether the given command is valid + * @throws EmptyVariableException Thrown if given command is not set + */ + public function isCommandValid ($commandName) { + // By default nothing shall be valid + $isValid = FALSE; + + // Is a command set? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($this, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Create the full class name + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($commandName) . 'Command'; + + // Now, let us create the full name of the command class + $this->setClassName($className); + + // Is this class already loaded? + if (class_exists($this->getClassName())) { + // This class does exist. :-) + $isValid = TRUE; + } // END - if + + // Set command name + $this->setCommandName($commandName); + + // Return the result + return $isValid; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/command/console/.htaccess b/inc/main/classes/resolver/command/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/command/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/command/console/class_ConsoleCommandResolver.php b/inc/main/classes/resolver/command/console/class_ConsoleCommandResolver.php new file mode 100644 index 00000000..2b1582c8 --- /dev/null +++ b/inc/main/classes/resolver/command/console/class_ConsoleCommandResolver.php @@ -0,0 +1,69 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Console" + $this->setClassPrefix('console'); + } + + /** + * Creates an instance of a Console command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public static final function createConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new ConsoleCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/command/html/.htaccess b/inc/main/classes/resolver/command/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/command/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/command/html/class_Html b/inc/main/classes/resolver/command/html/class_Html new file mode 100644 index 00000000..42b09af4 --- /dev/null +++ b/inc/main/classes/resolver/command/html/class_Html @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Html???CommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = null; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'html' + $this->setCommandPrefix('html'); + } + + /** + * Creates an instance of a Html command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $appInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if the default command is not set + * @throws InvalidCommandException Thrown if the default command is invalid + */ + public final static function createHtml???CommandResolver ($commandName, ManageableApplication $appInstance) { + // Create the new instance + $resolverInstance = new Html???CommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($appInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/command/html/class_HtmlCommandResolver.php b/inc/main/classes/resolver/command/html/class_HtmlCommandResolver.php new file mode 100644 index 00000000..db1e6ac7 --- /dev/null +++ b/inc/main/classes/resolver/command/html/class_HtmlCommandResolver.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "html" + $this->setClassPrefix('html'); + } + + /** + * Creates an instance of a Html command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public static final function createHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HtmlCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/command/image/.htaccess b/inc/main/classes/resolver/command/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/command/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/command/image/class_ImageCommandResolver.php b/inc/main/classes/resolver/command/image/class_ImageCommandResolver.php new file mode 100644 index 00000000..80a84dc9 --- /dev/null +++ b/inc/main/classes/resolver/command/image/class_ImageCommandResolver.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageCommandResolver extends BaseCommandResolver implements CommandResolver { + /** + * Last successfull resolved command + */ + private $lastCommandInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Image" + $this->setClassPrefix('image'); + } + + /** + * Creates an instance of a Image command resolver with a given default command + * + * @param $commandName The default command we shall execute + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared command resolver instance + * @throws EmptyVariableException Thrown if default command is not set + * @throws InvalidCommandException Thrown if default command is invalid + */ + public static final function createImageCommandResolver ($commandName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new ImageCommandResolver(); + + // Is the variable $commandName set and the command is valid? + if (empty($commandName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) { + // Invalid command found + throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/controller/.htaccess b/inc/main/classes/resolver/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/controller/class_BaseControllerResolver.php b/inc/main/classes/resolver/controller/class_BaseControllerResolver.php new file mode 100644 index 00000000..5615515a --- /dev/null +++ b/inc/main/classes/resolver/controller/class_BaseControllerResolver.php @@ -0,0 +1,179 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseControllerResolver extends BaseResolver { + /** + * Protected constructor + * + * @param $className Name of the real class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * "Loads" a given controller and instances it if not yet cached. If the + * controller was not found one of the default controllers will be used + * depending on whether news shall be displayed. + * + * @param $controllerName A controller name we shall look for + * @return $controllerInstance A loaded controller instance + * @throws InvalidControllerException Thrown if even the requested + * controller class is missing (bad!) + */ + protected function loadController ($controllerName) { + // Cache default controller + $defaultController = $this->getConfigInstance()->getConfigEntry('default_' . strtolower($this->getClassPrefix()) . '_controller'); + + // Init controller instance + $controllerInstance = NULL; + + // Default controller + $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); + + // Generate the class name + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BEFORE: controller=' . $controllerName); + if ($controllerName != $defaultController) { + // Create controller class name + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($controllerName) . 'Controller'; + + // ... and set it + $this->setClassName($className); + } else { + // No news at main controller or non-news controller + $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); + } + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('AFTER: controller=' . $this->getClassName()); + + // Is this class loaded? + if (!class_exists($this->getClassName())) { + // Throw an exception here + throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set default resolver config name + $resolverConfigEntry = ''; + + // Try to read a config entry for our resolver including controller name... ;-) + $resolverConfigEntry = sprintf('%s_cmd_%s_resolver_class', strtolower($this->getClassPrefix()), strtolower($controllerName)); + + // Get the config, this will throw an exception if there is no special controller resolver + $resolverClass = $this->getConfigInstance()->getConfigEntry($resolverConfigEntry); + + // Initiate the resolver and controller + $resolverInstance = ObjectFactory::createObjectByConfiguredName( + $resolverConfigEntry, + array( + $controllerName, + $this->getApplicationInstance() + ) + ); + $controllerInstance = ObjectFactory::createObjectByName( + $this->getClassName(), + array($resolverInstance) + ); + + // Return the result + return $controllerInstance; + } + + /** + * Checks whether the given controller is valid + * + * @param $controllerName The default controller we shall execute + * @return $isValid Whether the given controller is valid + * @throws EmptyVariableException Thrown if given controller is not set + * @throws DefaultControllerException Thrown if default controller was not found + */ + public function isControllerValid ($controllerName) { + // By default nothing shall be valid + $isValid = FALSE; + + // Is a controller set? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($this, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // Create class name + $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($controllerName) . 'Controller'; + + // Now, let us create the full name of the controller class + $this->setClassName($className); + + // Try it hard to get an controller + while ($isValid === FALSE) { + // Is this class already loaded? + if (class_exists($this->getClassName())) { + // This class does exist. :-) + $isValid = TRUE; + } elseif ($this->getClassName() != $this->getCapitalizedClassPrefix() . 'DefaultNewsController') { + // Set default controller + $this->setClassName($this->getCapitalizedClassPrefix() . 'DefaultNewsController'); + } else { + // All is tried, give it up here + throw new DefaultControllerException($this, self::EXCEPTION_DEFAULT_CONTROLLER_GONE); + } + } // END - while + + // Return the result + return $isValid; + } + + /** + * Resolves the default controller of the given controller + * + * @return $controllerInstance A controller instance for the default + * controller + * @throws InvalidControllerInstanceException Thrown if $controllerInstance + * is invalid + */ + public function resolveController () { + // Init variables + $controllerName = ''; + $controllerInstance = NULL; + + // Get the controller name + $controllerName = $this->getControllerName(); + + // Get the controller + $controllerInstance = $this->loadController($controllerName); + + // And validate it + if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) { + // This controller has an invalid instance! + throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } // END - if + + // Set last controller + $this->setResolvedInstance($controllerInstance); + + // Return the maybe resolved instance + return $controllerInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/controller/console/.htaccess b/inc/main/classes/resolver/controller/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/controller/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php b/inc/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php new file mode 100644 index 00000000..d0e5280d --- /dev/null +++ b/inc/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to "Console" + $this->setClassPrefix('console'); + } + + /** + * Creates an instance of a resolver class with a given controller + * + * @param $controllerName The controller we shall resolve + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default controller is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public static final function createConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new ConsoleControllerResolver(); + + // Is the variable $controllerName set and the controller is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { + // Invalid controller found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Set controller name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/controller/html/.htaccess b/inc/main/classes/resolver/controller/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/controller/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/controller/html/class_HtmlControllerResolver.php b/inc/main/classes/resolver/controller/html/class_HtmlControllerResolver.php new file mode 100644 index 00000000..c50f32a7 --- /dev/null +++ b/inc/main/classes/resolver/controller/html/class_HtmlControllerResolver.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'Html' + $this->setClassPrefix('html'); + } + + /** + * Creates an instance of a resolver class with a given controller + * + * @param $controllerName The controller we shall resolve + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default controller is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public static final function createHtmlControllerResolver ($controllerName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new HtmlControllerResolver(); + + // Is the variable $controllerName set and the controller is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { + // Invalid controller found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Set controller name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/resolver/controller/image/.htaccess b/inc/main/classes/resolver/controller/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/resolver/controller/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/resolver/controller/image/class_ImageControllerResolver.php b/inc/main/classes/resolver/controller/image/class_ImageControllerResolver.php new file mode 100644 index 00000000..8a14a722 --- /dev/null +++ b/inc/main/classes/resolver/controller/image/class_ImageControllerResolver.php @@ -0,0 +1,72 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageControllerResolver extends BaseControllerResolver implements ControllerResolver { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set prefix to 'image' + $this->setClassPrefix('image'); + } + + /** + * Creates an instance of a resolver class with a given controller + * + * @param $controllerName The controller we shall resolve + * @param $applicationInstance An instance of a manageable application helper class + * @return $resolverInstance The prepared controller resolver instance + * @throws EmptyVariableException Thrown if default controller is not set + * @throws InvalidControllerException Thrown if default controller is invalid + */ + public static final function createImageControllerResolver ($controllerName, ManageableApplication $applicationInstance) { + // Create the new instance + $resolverInstance = new ImageControllerResolver(); + + // Is the variable $controllerName set and the controller is valid? + if (empty($controllerName)) { + // Then thrown an exception here + throw new EmptyVariableException(array($resolverInstance, 'controllerName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) { + // Invalid controller found + throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); + } + + // Set the application instance + $resolverInstance->setApplicationInstance($applicationInstance); + + // Set controller name + $resolverInstance->setControllerName($controllerName); + + // Return the prepared instance + return $resolverInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/response/.htaccess b/inc/main/classes/response/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/response/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/response/class_BaseResponse.php b/inc/main/classes/response/class_BaseResponse.php new file mode 100644 index 00000000..0becb582 --- /dev/null +++ b/inc/main/classes/response/class_BaseResponse.php @@ -0,0 +1,249 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class BaseResponse extends BaseFrameworkSystem { + /** + * Response status + */ + private $responseStatus = '200 OK'; + + /** + * Array with all headers + */ + private $responseHeaders = array(); + + /** + * Cookies we shall sent out + */ + private $cookies = array(); + + /** + * Body of the response + */ + private $responseBody = ''; + + /** + * Instance of the template engine + */ + private $templateInstance = NULL; + + /** + * Response type + */ + private $responseType = 'invalid'; + + /** + * Protected constructor + * + * @param $className Name of the concrete response + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for status + * + * @param $status New response status + * @return void + */ + public final function setResponseStatus ($status) { + $this->responseStatus = (string) $status; + } + + /** + * Add header element + * + * @param $name Name of header element + * @param $value Value of header element + * @return void + */ + public final function addHeader ($name, $value) { + $this->responseHeaders[$name] = $value; + } + + /** + * Reset the header array + * + * @return void + */ + public final function resetResponseHeaders () { + $this->responseHeaders = array(); + } + + /** + * "Writes" data to the response body + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + public final function writeToBody ($output) { + $this->responseBody .= $output; + } + + /** + * Sets the response body to something new + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + public final function setResponseBody ($output) { + $this->responseBody = $output; + } + + /** + * Setter for response type + * + * @param $responseType Response type + * @return void + */ + protected final function setResponseType ($responseType) { + $this->responseType = $responseType; + } + + /** + * Getter for response type + * + * @param $responseType Response type + * @return void + */ + public final function getResponseType () { + return $this->responseType; + } + + /** + * Adds a fatal message id to the response. The added messages can then be + * processed and outputed to the world + * + * @param $messageId The message id we shall add + * @return void + */ + public final function addFatalMessage ($messageId) { + // Adds the resolved message id to the fatal message list + $this->addFatalMessagePlain($this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId)); + } + + /** + * Adds a plain fatal message id to the response + * + * @param $message The plain message we shall add + * @return void + */ + public final function addFatalMessagePlain ($message) { + // Adds the resolved message id to the fatal message list + $this->pushValueToGenericArrayKey('fatal_messages', 'generic', 'message', $message); + } + + /** + * Flushs the cached HTTP response to the outer world + * + * @param $force Whether we shall force the output or abort if headers are + * already sent with an exception + * @return void + * @throws ResponseHeadersAlreadySentException Thrown if headers are + * already sent + */ + public function flushBuffer ($force = FALSE) { + if ((headers_sent()) && ($force === FALSE)) { + // Headers are already sent! + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } elseif (!headers_sent()) { + // Send headers out + header('HTTP/1.1 ' . $this->responseStatus); + + // Used later + $now = gmdate('D, d M Y H:i:s') . ' GMT'; + + // General header for no caching + $this->addHeader('Expired', $now); // RFC2616 - Section 14.21 + $this->addHeader('Last-Modified', $now); + $this->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 + $this->addHeader('Pragma', 'no-cache'); // HTTP/1.0 + + // Define the charset to be used + //$this->addHeader('Content-type:', sprintf("text/html; charset=%s", $this->getConfigInstance()->getConfigEntry('header_charset'))); + + // Send all headers + foreach ($this->responseHeaders as $name => $value) { + header($name . ': ' . $value); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('name=' . $name . ',value=' . $value); + } // END - foreach + + // Send cookies out? + if (count($this->cookies) > 0) { + // Send all cookies + $cookieString = implode(' ', $this->cookies); + header('Set-Cookie: ' . $cookieString); + + // Remove them all + $this->cookies = array(); + } // END - if + } + + // Are there some error messages? + if ((!$this->isValidGenericArrayKey('fatal_messages', 'generic', 'message')) || ($this->countGenericArrayElements('fatal_messages', 'generic', 'message') == 0)) { + // Flush the output to the world + $this->getWebOutputInstance()->output($this->responseBody); + } else { + // Display all error messages + $this->getApplicationInstance()->handleFatalMessages($this->getGenericArrayKey('fatal_messages', 'generic', 'message')); + + // Send the error messages out to the world + $this->getWebOutputInstance()->output($this->responseBody); + } + + // Clear response header and body + $this->setResponseBody(''); + $this->resetResponseHeaders(); + } + + /** + * "Getter" for default command + * + * @return $defaultCommand Default command for this response + */ + public function determineDefaultCommand () { + // Get application instance + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Generate config key + $configKey = sprintf('default_%s_%s_command', + $applicationInstance->getAppShortName(), + $this->getResponseType() + ); + + // Get default command response + $defaultCommand = $this->getConfigInstance()->getConfigEntry($configKey); + + // Return it + return $defaultCommand; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/response/console/.htaccess b/inc/main/classes/response/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/response/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/response/console/class_ConsoleResponse.php b/inc/main/classes/response/console/class_ConsoleResponse.php new file mode 100644 index 00000000..000ecfef --- /dev/null +++ b/inc/main/classes/response/console/class_ConsoleResponse.php @@ -0,0 +1,136 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class ConsoleResponse extends BaseResponse implements Responseable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set response type + $this->setResponseType('console'); + } + + /** + * Creates an object of this class + * + * @param $applicationInstance An instance of a manageable application + * @return $responseInstance A prepared instance of this class + */ + public static final function createConsoleResponse (ManageableApplication $applicationInstance) { + // Get a new instance + $responseInstance = new ConsoleResponse(); + + // Set the application instance + $responseInstance->setApplicationInstance($applicationInstance); + + // Initialize the template engine here + $responseInstance->initTemplateEngine($applicationInstance); + + // Init web output instance + $responseInstance->initWebOutputInstance(); + + // Return the prepared instance + return $responseInstance; + } + + /** + * Initializes the template engine instance + * + * @param $applicationInstance An instance of a manageable application + * @return void + */ + public final function initTemplateEngine (ManageableApplication $applicationInstance) { + $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance)); + } + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @param $expires Timestamp of expiration (default: configured) + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + public function addCookie ($cookieName, $cookieValue, $encrypted = FALSE, $expires = NULL) { + //* DEBUG: */ echo $cookieName.'='.$cookieValue."
    \n"; + $this->partialStub('Naturally unimplemented in console response.'); + } + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + public function redirectToConfiguredUrl ($configEntry) { + $this->partialStub('Naturally unimplemented in console response.'); + } + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + public function expireCookie ($cookieName) { + $this->partialStub('Naturally unimplemented in console response.'); + } + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + public function refreshCookie ($cookieName) { + $this->partialStub('Naturally unimplemented in console response.'); + } + + /** + * Flushs the cached console response to the console + * + * @param $force Whether we shall force the output or abort if headers are + * already sent with an exception + * @return void + * @throws ResponseHeadersAlreadySentException Thrown if headers are + * already sent + */ + public function flushBuffer ($force = FALSE) { + $this->partialStub('Please implement this class.'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/response/html/.htaccess b/inc/main/classes/response/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/response/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/response/html/class_HtmlResponse.php b/inc/main/classes/response/html/class_HtmlResponse.php new file mode 100644 index 00000000..ec5924b0 --- /dev/null +++ b/inc/main/classes/response/html/class_HtmlResponse.php @@ -0,0 +1,211 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class HtmlResponse extends BaseResponse implements Responseable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set response type + $this->setResponseType('html'); + } + + /** + * Creates an object of this class + * + * @param $applicationInstance An instance of a manageable application + * @return $responseInstance A prepared instance of this class + */ + public static final function createHtmlResponse (ManageableApplication $applicationInstance) { + // Get a new instance + $responseInstance = new HtmlResponse(); + + // Set the application instance + $responseInstance->setApplicationInstance($applicationInstance); + + // Initialize the template engine here + $responseInstance->initTemplateEngine($applicationInstance); + + // Init web output instance + $responseInstance->initWebOutputInstance(); + + // Return the prepared instance + return $responseInstance; + } + + /** + * Initializes the template engine instance + * + * @param $applicationInstance An instance of a manageable application + * @return void + */ + public final function initTemplateEngine (ManageableApplication $applicationInstance) { + $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance)); + } + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @param $expires Timestamp of expiration (default: configured) + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + * @todo Encryption of cookie data not yet supported. + * @todo Why are these parameters conflicting? + * @todo If the return statement is removed and setcookie() commented out, + * @todo this will send only one cookie out, the first one. + */ + public function addCookie ($cookieName, $cookieValue, $encrypted = FALSE, $expires = NULL) { + //* DEBUG: */ echo $cookieName.'='.$cookieValue."
    \n"; + // Are headers already sent? + if (headers_sent()) { + // Throw an exception here + //* DEBUG: */ return; + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Shall we encrypt the cookie? + if ($encrypted === TRUE) { + // Unsupported at the moment + $this->partialStub('Encryption is unsupported at the moment.'); + } // END - if + + // For slow browsers set the cookie array element first + $_COOKIE[$cookieName] = $cookieValue; + + // Get all config entries + if (is_null($expires)) { + $expires = (time() + $this->getConfigInstance()->getConfigEntry('cookie_expire')); + } // END - if + + $path = $this->getConfigInstance()->getConfigEntry('cookie_path'); + $domain = $this->getConfigInstance()->getConfigEntry('cookie_domain'); + + setcookie($cookieName, $cookieValue, $expires); + //, $path, $domain, (isset($_SERVER['HTTPS'])) + return; + + // Now construct the full header + $cookieString = $cookieName . '=' . $cookieValue . '; '; + $cookieString .= 'expires=' . date('D, d-F-Y H:i:s', $expires) . ' GMT'; + // $cookieString .= "; path=".$path."; domain=".$domain; + + // Set the cookie as a header + $this->cookies[$cookieName] = $cookieString; + } + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + public function redirectToConfiguredUrl ($configEntry) { + // Is the header not yet sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Assign application data + $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance()); + + // Get the url from config + $url = $this->getConfigInstance()->getConfigEntry($configEntry . '_url'); + + // Compile the URL + $url = $this->getTemplateInstance()->compileRawCode($url); + + // Do we have a 'http' in front of the URL? + if (substr(strtolower($url), 0, 4) != 'http') { + // Is there a / in front of the relative URL? + if (substr($url, 0, 1) == '/') { + $url = substr($url, 1); + } // END - if + + // No, then extend it with our base URL + $url = $this->getConfigInstance()->getConfigEntry('base_url') . '/' . $url; + } // END - if + + // Add redirect header + $this->addHeader('Location', str_replace('&', '&', $url)); + + // Set correct response status + $this->setResponseStatus('301 Moved Permanently'); + + // Clear the body + $this->setResponseBody(''); + + // Flush the result + $this->flushBuffer(); + + // All done here... + exit(); + } + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + public function expireCookie ($cookieName) { + // Is the cookie there? + if (isset($_COOKIE[$cookieName])) { + // Then expire it with 20 minutes past + $this->addCookie($cookieName, '', FALSE, (time() - 1200)); + + // Remove it from array + unset($_COOKIE[$cookieName]); + } // END - if + } + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + public function refreshCookie ($cookieName) { + // Only update existing cookies + if (isset($_COOKIE[$cookieName])) { + // Update the cookie + $this->addCookie($cookieName, $_COOKIE[$cookieName], FALSE); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/response/image/.htaccess b/inc/main/classes/response/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/response/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/response/image/class_ImageResponse.php b/inc/main/classes/response/image/class_ImageResponse.php new file mode 100644 index 00000000..e6c5190d --- /dev/null +++ b/inc/main/classes/response/image/class_ImageResponse.php @@ -0,0 +1,243 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * The extended headers are taken from phpMyAdmin setup tool, written by + * Michal Cihar , licensed under GNU GPL 2.0. + */ +class ImageResponse extends BaseResponse implements Responseable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set response type + $this->setResponseType('image'); + } + + /** + * Creates an object of this class + * + * @param $applicationInstance An instance of a manageable application + * @return $responseInstance A prepared instance of this class + */ + public static final function createImageResponse (ManageableApplication $applicationInstance) { + // Get a new instance + $responseInstance = new ImageResponse(); + + // Set the application instance + $responseInstance->setApplicationInstance($applicationInstance); + + // Initialize the template engine here + $responseInstance->initTemplateEngine($applicationInstance); + + // Init web output instance + $responseInstance->initWebOutputInstance(); + + // Return the prepared instance + return $responseInstance; + } + + /** + * Initializes the template engine instance + * + * @param $applicationInstance An instance of a manageable application + * @return void + */ + public final function initTemplateEngine (ManageableApplication $applicationInstance) { + // Get config instance + $cfg = $this->getConfigInstance(); + + // Set new template engine + $cfg->setConfigEntry('html_template_class' , $cfg->getConfigEntry('image_template_class')); + $cfg->setConfigEntry('raw_template_extension' , '.img'); + $cfg->setConfigEntry('code_template_extension', '.xml'); + $cfg->setConfigEntry('tpl_base_path' , 'templates/images/'); + // @TODO Please fix this + $cfg->setConfigEntry('code_template_type' , 'image'); + + // Get a prepared instance + $this->setTemplateInstance($this->prepareTemplateInstance($applicationInstance)); + } + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @param $expires Timestamp of expiration (default: configured) + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + * @todo Encryption of cookie data not yet supported. + * @todo Why are these parameters conflicting? + * @todo If the return statement is removed and setcookie() commented out, + * @todo this will send only one cookie out, the first one. + */ + public function addCookie ($cookieName, $cookieValue, $encrypted = FALSE, $expires = NULL) { + // Are headers already sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Shall we encrypt the cookie? + if ($encrypted === TRUE) { + // Unsupported at the moment + $this->partialStub('Encryption is unsupported at the moment.'); + } // END - if + + // For slow browsers set the cookie array element first + $_COOKIE[$cookieName] = $cookieValue; + + // Get all config entries + if (is_null($expires)) { + $expires = (time() + $this->getConfigInstance()->getConfigEntry('cookie_expire')); + } // END - if + + $path = $this->getConfigInstance()->getConfigEntry('cookie_path'); + $domain = $this->getConfigInstance()->getConfigEntry('cookie_domain'); + + setcookie($cookieName, $cookieValue, $expires); + //, $path, $domain, (isset($_SERVER['HTTPS'])) + return; + + // Now construct the full header + $cookieString = $cookieName . '=' . $cookieValue . '; '; + $cookieString .= 'expires=' . date('D, d-F-Y H:i:s', $expires) . ' GMT'; + // TODO Why is this not always working? $cookieString .= '; path=' . $path . '; domain=' . $domain; + + // Set the cookie as a header + $this->cookies[$cookieName] = $cookieString; + } + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + public function redirectToConfiguredUrl ($configEntry) { + // Is the header not yet sent? + if (headers_sent()) { + // Throw an exception here + throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT); + } // END - if + + // Assign application data + $this->getTemplateInstance()->assignApplicationData($this->getApplicationInstance()); + + // Get the url from config + $url = $this->getConfigInstance()->getConfigEntry($configEntry . '_url'); + + // Compile the URL + $url = $this->getTemplateInstance()->compileRawCode($url); + + // Do we have a 'http' in front of the URL? + if (substr(strtolower($url), 0, 4) != 'http') { + // Is there a / in front of the relative URL? + if (substr($url, 0, 1) == '/') $url = substr($url, 1); + + // No, then extend it with our base URL + $url = $this->getConfigInstance()->getConfigEntry('base_url') . '/' . $url; + } // END - if + + // Add redirect header + $this->addHeader('Location', str_replace('&', '&', $url)); + + // Set correct response status + $this->setResponseStatus('301 Moved Permanently'); + + // Clear the body + $this->setResponseBody(''); + + // Flush the result + $this->flushBuffer(); + + // All done here... + exit(); + } + + /** + * Flushs the cached HTTP response to the outer world + * + * @param $force Whether we shall force the output or abort if headers are + * already sent with an exception + * @return void + */ + public function flushBuffer ($force = FALSE) { + // Finish the image + $this->getImageInstance()->finishImage(); + + // Get image content + $content = $this->getImageInstance()->getContent(); + + // Set it as response body + $this->setResponseBody($content); + + // Set content type + $this->addHeader('Content-type', 'image/' . $this->getImageInstance()->getImageType()); + + // Call parent method + parent::flushBuffer($force); + } + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + public function expireCookie ($cookieName) { + // Is the cookie there? + if (isset($_COOKIE[$cookieName])) { + // Then expire it with 20 minutes past + $this->addCookie($cookieName, '', FALSE, (time() - 1200)); + + // Remove it from array + unset($_COOKIE[$cookieName]); + } // END - if + } + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + public function refreshCookie ($cookieName) { + // Only update existing cookies + if (isset($_COOKIE[$cookieName])) { + // Update the cookie + $this->addCookie($cookieName, $_COOKIE[$cookieName], FALSE); + } // END - if + } +} + +// [EOF] +?> diff --git a/inc/main/classes/rng/.htaccess b/inc/main/classes/rng/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/rng/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/rng/class_RandomNumberGenerator.php b/inc/main/classes/rng/class_RandomNumberGenerator.php new file mode 100644 index 00000000..a30fb0dd --- /dev/null +++ b/inc/main/classes/rng/class_RandomNumberGenerator.php @@ -0,0 +1,219 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class RandomNumberGenerator extends BaseFrameworkSystem { + /** + * Prime number for better pseudo random numbers + */ + private $prime = 0; + + /** + * Add this calculated number to the rng + */ + private $extraNumber = 0; + + /** + * Extra salt for secured hashing + */ + private $extraSalt = ''; + + /** + * Fixed salt for secured hashing + */ + private $fixedSalt = ''; + + /** + * Maximum length for random string + */ + private $rndStrLen = 0; + + /** + * Self instance + */ + private static $selfInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of this class + * @return void + */ + protected function __construct ($className = __CLASS__) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Creates an instance of this class + * + * @param $extraInstance An extra instance for more salt (default: null) + * @return $rngInstance An instance of this random number generator + */ + public static final function createRandomNumberGenerator (FrameworkInterface $extraInstance = NULL) { + // Is self instance set? + if (is_null(self::$selfInstance)) { + // Get a new instance + $rngInstance = new RandomNumberGenerator(); + + // Initialize the RNG now + $rngInstance->initRng($extraInstance); + + // Set it "self" + self::$selfInstance = $rngInstance; + } else { + // Use from self instance + $rngInstance = self::$selfInstance; + } + + // Return the instance + return $rngInstance; + } + + /** + * Initializes the random number generator + * + * @param $extraInstance An extra instance for more salt (default: null) + * @return void + * @todo Add site key for stronger salt! + */ + protected function initRng ($extraInstance) { + // Get the prime number from config + $this->prime = $this->getConfigInstance()->getConfigEntry('math_prime'); + + // Calculate the extra number which is always the same unless you give + // a better prime number + $this->extraNumber = ($this->prime * $this->prime / pow(pi(), 2)); + + // Seed mt_rand() + mt_srand((double) sqrt(microtime(TRUE) * 100000000 * $this->extraNumber)); + + // Set the server IP to cluster + $serverIp = 'cluster'; + + // Do we have a single server? + if ($this->getConfigInstance()->getConfigEntry('is_single_server') == 'Y') { + // Then use that IP for extra security + $serverIp = $this->getConfigInstance()->detectServerAddress(); + } // END - if + + // Yet-another fixed salt. This is not dependend on server software or date + if ($extraInstance instanceof FrameworkInterface) { + // With extra instance information + $this->fixedSalt = sha1( + $serverIp . ':' . + $extraInstance->__toString() . ':' . + json_encode($this->getDatabaseInstance()->getConnectionData()) + ); + } else { + // Without extra information + $this->fixedSalt = sha1($serverIp . ':' . json_encode($this->getDatabaseInstance()->getConnectionData())); + } + + // One-way data we need for "extra-salting" the random number + $this->extraSalt = sha1( + $this->fixedSalt . ':' . + getenv('SERVER_SOFTWARE') . ':' . + $this->getConfigInstance()->getConfigEntry('date_key') . ':' . + $this->getConfigInstance()->getConfigEntry('base_url') + ); + + // Get config entry for max salt length + $this->rndStrLen = $this->getConfigInstance()->getConfigEntry('rnd_str_length'); + } + + /** + * Makes a pseudo-random string useable for salts + * + * @param $length Length of the string, default: 128 + * @return $randomString The pseudo-random string + */ + public function randomString ($length = -1) { + // Is the number <1, then fix it to default length + if ($length < 1) { + $length = $this->rndStrLen; + } // END - if + + // Initialize the string + $randomString = ''; + + // And generate it + for ($idx = 0; $idx < $length; $idx++) { + // Add a random character and add it to our string + $randomString .= chr($this->randomNumber(0, 255)); + } // END - for + + // Return the random string a little mixed up + return str_shuffle($randomString); + } + + /** + * Generate a pseudo-random integer number in a given range + * + * @param $min Min value to generate + * @param $max Max value to generate + * @return $num Pseudo-random number + * @todo I had a better random number generator here but now it is somewhere lost :( + */ + public function randomNumber ($min, $max) { + return mt_rand($min, $max); + } + + /** + * Getter for extra salt + * + * @return $extraSalt + */ + public final function getExtraSalt () { + return $this->extraSalt; + } + + /** + * Getter for fixed salt + * + * @return $fixedSalt + */ + public final function getFixedSalt () { + return $this->fixedSalt; + } + + /** + * Generates a key based on if we have extra (default) or fixed salt enabled + * + * @return $key The generated key for encryption + */ + public function generateKey () { + // Default is extra salt + $key = md5($this->getExtraSalt()); + + // Get key + if ($this->getConfigInstance()->getConfigEntry('crypt_fixed_salt') == 'Y') { + $key = md5($this->getFixedSalt()); + } // END - if + + // Return it + return $key; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/scrypt/.htaccess b/inc/main/classes/scrypt/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/scrypt/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/scrypt/class_Scrypt.php b/inc/main/classes/scrypt/class_Scrypt.php new file mode 100644 index 00000000..6fabd03f --- /dev/null +++ b/inc/main/classes/scrypt/class_Scrypt.php @@ -0,0 +1,235 @@ + + * @license http://www.opensource.org/licenses/BSD-2-Clause BSD 2-Clause License + * @link http://github.com/DomBlack/php-scrypt + */ + +/** + * This class abstracts away from scrypt module, allowing for easy use. + * + * You can create a new hash for a password by calling Scrypt:hashScrypt($password) + * + * You can check a password by calling Scrypt:checkScrypt($password, $hash) + * + * @category Security + * @package Scrypt + * @author Dominic Black + * @author Roland Haeder + * @license http://www.opensource.org/licenses/BSD-2-Clause BSD 2-Clause License + * @link http://github.com/DomBlack/php-scrypt + */ +abstract class Scrypt extends BaseFrameworkSystem +{ + + /** + * + * @var int The key length + */ + private static $_keyLength = 32; + + /** + * Get the byte-length of the given string + * + * @param string $str Input string + * + * @return int + */ + protected static function strlen ($str) { + static $isShadowed = null; + + if ($isShadowed === null) { + $isShadowed = extension_loaded('mbstring') && + ini_get('mbstring.func_overload') & 2; + } + + if ($isShadowed) { + return mb_strlen($str, '8bit'); + } else { + return strlen($str); + } + } + + /** + * Generates a random salt + * + * @param int $length The length of the salt + * + * @return string The salt + */ + public static function generateScryptSalt ($length = 8) + { + $buffer = ''; + $buffer_valid = false; + if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { + $buffer = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); + if ($buffer) { + $buffer_valid = true; + } + } + if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { + $cryptoStrong = false; + $buffer = openssl_random_pseudo_bytes($length, $cryptoStrong); + if ($buffer && $cryptoStrong) { + $buffer_valid = true; + } + } + if (!$buffer_valid && BaseFrameworkSystem::isReadableFile('/dev/urandom')) { + $f = fopen('/dev/urandom', 'r'); + $read = static::strlen($buffer); + while ($read < $length) { + $buffer .= fread($f, $length - $read); + $read = static::strlen($buffer); + } + fclose($f); + if ($read >= $length) { + $buffer_valid = true; + } + } + if (!$buffer_valid || static::strlen($buffer) < $length) { + $bl = static::strlen($buffer); + for ($i = 0; $i < $length; $i++) { + if ($i < $bl) { + $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); + } else { + $buffer .= chr(mt_rand(0, 255)); + } + } + } + $salt = str_replace(array('+', '$'), array('.', ''), base64_encode($buffer)); + + return $salt; + } + + /** + * Create a password hash + * + * @param string $password The clear text password + * @param string $salt The salt to use, or null to generate a random one + * @param int $N The CPU difficultly (must be a power of 2, > 1) + * @param int $r The memory difficultly + * @param int $p The parallel difficultly + * + * @return string The hashed password + */ + public static function hashScrypt ($password, $salt = false, $N = 16384, $r = 8, $p = 1) + { + if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { + // Feature has been disabled + throw new \InvalidArgumentException('Feature "scrypt" disabled.'); + } + + if ($N == 0 || ($N & ($N - 1)) != 0) { + throw new \InvalidArgumentException('N must be > 0 and a power of 2'); + } + + if ($N > PHP_INT_MAX / 128 / $r) { + throw new \InvalidArgumentException('Parameter N is too large'); + } + + if ($r > PHP_INT_MAX / 128 / $p) { + throw new \InvalidArgumentException('Parameter r is too large'); + } + + if ($salt === false) { + $salt = self::generateScryptSalt(); + } else { + // Remove dollar signs from the salt, as we use that as a separator. + $salt = str_replace(array('+', '$'), array('.', ''), base64_encode($salt)); + } + + $hash = scrypt($password, $salt, $N, $r, $p, self::$_keyLength); + + return $N . '$' . $r . '$' . $p . '$' . $salt . '$' . $hash; + } + + /** + * Check a clear text password against a hash + * + * @param string $password The clear text password + * @param string $hash The hashed password + * + * @return boolean If the clear text matches + */ + public static function checkScrypt ($password, $hash) + { + // Is there actually a hash? + if (!$hash) { + return false; + } + + if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { + // Feature has been disabled + throw new \InvalidArgumentException('Feature "scrypt" disabled.'); + } + + list ($N, $r, $p, $salt, $hash) = explode('$', $hash); + + // No empty fields? + if (empty($N) or empty($r) or empty($p) or empty($salt) or empty($hash)) { + return false; + } + + // Are numeric values numeric? + if (!is_numeric($N) or !is_numeric($r) or !is_numeric($p)) { + return false; + } + + $calculated = scrypt($password, $salt, $N, $r, $p, self::$_keyLength); + + // Use compareScryptHashes to avoid timeing attacks + return self::compareScryptHashes($hash, $calculated); + } + + /** + * Zend Framework (http://framework.zend.com/) + * + * @link http://github.com/zendframework/zf2 for the canonical source repository + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * + * Compare two strings to avoid timing attacks + * + * C function memcmp() internally used by PHP, exits as soon as a difference + * is found in the two buffers. That makes possible of leaking + * timing information useful to an attacker attempting to iteratively guess + * the unknown string (e.g. password). + * + * @param string $expected + * @param string $actual + * + * @return boolean If the two strings match. + */ + public static function compareScryptHashes ($expected, $actual) + { + $expected = (string) $expected; + $actual = (string) $actual; + $lenExpected = static::strlen($expected); + $lenActual = static::strlen($actual); + $len = min($lenExpected, $lenActual); + + $result = 0; + for ($i = 0; $i < $len; $i ++) { + $result |= ord($expected[$i]) ^ ord($actual[$i]); + } + $result |= $lenExpected ^ $lenActual; + + return ($result === 0); + } +} diff --git a/inc/main/classes/stacker/.htaccess b/inc/main/classes/stacker/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/stacker/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/stacker/class_ b/inc/main/classes/stacker/class_ new file mode 100644 index 00000000..a72a14fb --- /dev/null +++ b/inc/main/classes/stacker/class_ @@ -0,0 +1,90 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Stacker extends BaseStacker implements Stackable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class Stacker and prepares it for usage + * + * @param $appInstance A manageable application + * @return $stackInstance An instance of ???Stacker + */ + public final static function create???Stacker (ManageableApplication $appInstance) { + // Get a new instance + $stackInstance = new ???Stacker(); + + // Init generic stacker + $stackInstance->initStack('generic'); + + // Return the prepared instance + return $stackInstance; + } + + /** + * Pushs a value on a named stacker + * + * @param $stackerName Name of the stack + * @param $value Value to push on it + * @return void + * @throws StackerFullException If the stack is full + */ + public function pushNamed ($stackerName, $value) { + $this->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value); + } + + /** + * 'Pops' a value from a named stacker + * + * @param $stackerName Name of the stack + * @return void + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function popNamed ($stackerName) { + $this->partialStub('stackerName=' . $stackerName); + } + + /** + * Get value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function getNamed ($stackerName) { + $this->partialStub('stackerName=' . $stackerName); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/stacker/class_BaseStacker.php b/inc/main/classes/stacker/class_BaseStacker.php new file mode 100644 index 00000000..0deeeda2 --- /dev/null +++ b/inc/main/classes/stacker/class_BaseStacker.php @@ -0,0 +1,269 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseStacker extends BaseFrameworkSystem { + // Exception codes + const EXCEPTION_STACKER_ALREADY_INITIALIZED = 0x050; + const EXCEPTION_STACKER_IS_FULL = 0x051; + const EXCEPTION_NO_STACKER_FOUND = 0x052; + const EXCEPTION_STACKER_IS_EMPTY = 0x053; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Initializes given stacker + * + * @param $stackerName Name of the stack + * @param $forceReInit Force re-initialization + * @return void + * @throws AlreadyInitializedStackerException If the stack is already initialized + */ + public function initStack ($stackerName, $forceReInit = FALSE) { + // Is the stack already initialized? + if (($forceReInit === FALSE) && ($this->isStackInitialized($stackerName))) { + // Then throw the exception + throw new AlreadyInitializedStackerException(array($this, $stackerName, $forceReInit), self::EXCEPTION_STACKER_ALREADY_INITIALIZED); + } // END - if + + // Initialize the given stack + $this->initGenericArrayKey('stacks', $stackerName, 'entries', $forceReInit); + } + + /** + * Initializes all stacks + * + * @return void + */ + public function initStacks (array $stacks, $forceReInit = FALSE) { + // "Walk" through all (more will be added as needed + foreach ($stacks as $stackerName) { + // Init this stack + $this->initStack($stackerName, $forceReInit); + } // END - foreach + } + + /** + * Checks whether the given stack is initialized (set in array $stackers) + * + * @param $stackerName Name of the stack + * @return $isInitialized Whether the stack is initialized + */ + public function isStackInitialized ($stackerName) { + // Is is there? + $isInitialized = ($this->isValidGenericArrayKey('stacks', $stackerName, 'entries')); + + // Return result + return $isInitialized; + } + + /** + * Checks whether the given stack is full + * + * @param $stackerName Name of the stack + * @return $isFull Whether the stack is full + * @throws NoStackerException If given stack is missing + */ + protected function isStackFull ($stackerName) { + // Is the stack not yet initialized? + if (!$this->isStackInitialized($stackerName)) { + // Throw an exception + throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + } // END - if + + // So, is the stack full? + $isFull = (($this->getStackCount($stackerName)) == $this->getConfigInstance()->getConfigEntry('stacker_' . $stackerName . '_max_size')); + + // Return result + return $isFull; + } + + /** + * Checks whether the given stack is empty + * + * @param $stackerName Name of the stack + * @return $isEmpty Whether the stack is empty + * @throws NoStackerException If given stack is missing + */ + public function isStackEmpty ($stackerName) { + // Is the stack not yet initialized? + if (!$this->isStackInitialized($stackerName)) { + // Throw an exception + throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + } // END - if + + // So, is the stack empty? + $isEmpty = (($this->getStackCount($stackerName)) == 0); + + // Return result + return $isEmpty; + } + + /** + * Getter for size of given stack (array count) + * + * @param $stackerName Name of the stack + * @return $count Size of stack (array count) + * @throws NoStackerException If given stack is missing + */ + public function getStackCount ($stackerName) { + // Is the stack not yet initialized? + if (!$this->isStackInitialized($stackerName)) { + // Throw an exception + throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + } // END - if + + // Now, count the array of entries + $count = $this->countGenericArrayElements('stacks', $stackerName, 'entries'); + + // Return result + return $count; + } + + /** + * Adds a value to given stack + * + * @param $stackerName Name of the stack + * @param $value Value to add to this stacker + * @return void + * @throws FullStackerException Thrown if the stack is full + */ + protected function addValue ($stackerName, $value) { + // Is the stack not yet initialized or full? + if (!$this->isStackInitialized($stackerName)) { + // Then do it here + $this->initStack($stackerName); + } elseif ($this->isStackFull($stackerName)) { + // Stacker is full + throw new FullStackerException(array($this, $stackerName, $value), self::EXCEPTION_STACKER_IS_FULL); + } + + // Now add the value to the stack + $this->pushValueToGenericArrayKey('stacks', $stackerName, 'entries', $value); + } + + /** + * Get last value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + protected function getLastValue ($stackerName) { + // Is the stack not yet initialized or full? + if (!$this->isStackInitialized($stackerName)) { + // Throw an exception + throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + } elseif ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } + + // Now get the last value + $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1); + + // Return it + return $value; + } + + /** + * Get first value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + protected function getFirstValue ($stackerName) { + // Is the stack not yet initialized or full? + if (!$this->isStackInitialized($stackerName)) { + // Throw an exception + throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + } elseif ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } + + // Now get the first value + $value = $this->getGenericArrayElement('stacks', $stackerName, 'entries', 0); + + // Return it + return $value; + } + + /** + * "Pops" last entry from stack + * + * @param $stackerName Name of the stack + * @return $value Value "poped" from array + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + protected function popLast ($stackerName) { + // Is the stack not yet initialized or full? + if (!$this->isStackInitialized($stackerName)) { + // Throw an exception + throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + } elseif ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } + + // Now, remove the last entry, we don't care about the return value here, see elseif() block above + return $this->popGenericArrayElement('stacks', $stackerName, 'entries'); + } + + /** + * "Pops" first entry from stack + * + * @param $stackerName Name of the stack + * @return $value Value "shifted" from array + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + protected function popFirst ($stackerName) { + // Is the stack not yet initialized or full? + if (!$this->isStackInitialized($stackerName)) { + // Throw an exception + throw new NoStackerException(array($this, $stackerName), self::EXCEPTION_NO_STACKER_FOUND); + } elseif ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } + + // Now, remove the last entry, we don't care about the return value here, see elseif() block above + return $this->shiftGenericArrayElement('stacks', $stackerName, 'entries'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/stacker/fifo/.htaccess b/inc/main/classes/stacker/fifo/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/stacker/fifo/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/stacker/fifo/class_FiFoStacker.php b/inc/main/classes/stacker/fifo/class_FiFoStacker.php new file mode 100644 index 00000000..e9a64035 --- /dev/null +++ b/inc/main/classes/stacker/fifo/class_FiFoStacker.php @@ -0,0 +1,98 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FiFoStacker extends BaseStacker implements Stackable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class Stacker and prepares it for usage + * + * @return $stackInstance An instance of FiFoStacker + */ + public static final function createFiFoStacker () { + // Get a new instance + $stackInstance = new FiFoStacker(); + + // Init generic stacker + $stackInstance->initStack('generic'); + + // Return the prepared instance + return $stackInstance; + } + + /** + * Pushs a value on a named stacker + * + * @param $stackerName Name of the stack + * @param $value Value to push on it + * @return void + * @throws StackerFullException If the stack is full + */ + public function pushNamed ($stackerName, $value) { + // Call the protected method + parent::addValue($stackerName, $value); + } + + /** + * 'Pops' a value from a named stacker and returns it's value + * + * @param $stackerName Name of the stack + * @return $value Value of the current stack entry + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function popNamed ($stackerName) { + // Get the value + $value = $this->getNamed($stackerName); + + // Call the protected method + parent::popFirst($stackerName); + + // Return the value + return $value; + } + + /** + * Get value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function getNamed ($stackerName) { + // Call the protected method + return parent::getFirstValue($stackerName); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/stacker/file/.htaccess b/inc/main/classes/stacker/file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/stacker/file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/stacker/file/class_ b/inc/main/classes/stacker/file/class_ new file mode 100644 index 00000000..38970b39 --- /dev/null +++ b/inc/main/classes/stacker/file/class_ @@ -0,0 +1,109 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???FileStack extends BaseFileStack implements StackableFile, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $fileName Absolute Name of stack file + * @return $stackInstance An instance of a Stackable class + */ + public final static function create???FileStack ($fileName) { + // Get new instance + $stackInstance = new ???FileStack(); + + // Init this stack + $stackInstance->initStack($fileName); + + // Return the prepared instance + return $stackInstance; + } + + /** + * Pushs a value on a named stacker + * + * @param $stackerName Name of the stack + * @param $value Value to push on it + * @return void + * @throws StackerFullException If the stack is full + */ + public function pushNamed ($stackerName, $value) { + $this->partialStub('stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . $value); + } + + /** + * 'Pops' a value from a named stacker + * + * @param $stackerName Name of the stack + * @return void + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function popNamed ($stackerName) { + $this->partialStub('stackerName=' . $stackerName); + } + + /** + * Get value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function getNamed ($stackerName) { + $this->partialStub('stackerName=' . $stackerName); + } + + /** + * Seeks to given position + * + * @param $seekPosition Seek position in file + * @return void + */ + public function seek ($seekPosition) { + $this->partialStub('seekPosition=' . $seekPosition); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + public function size () { + $this->partialStub(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/stacker/file/class_BaseFileStack.php b/inc/main/classes/stacker/file/class_BaseFileStack.php new file mode 100644 index 00000000..03242694 --- /dev/null +++ b/inc/main/classes/stacker/file/class_BaseFileStack.php @@ -0,0 +1,616 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseFileStack extends BaseStacker { + /** + * Magic for this stack + */ + const STACK_MAGIC = 'STACKv0.1'; + + /** + * Name of array index for gap position + */ + const ARRAY_INDEX_GAP_POSITION = 'gap'; + + /** + * Name of array index for hash + */ + const ARRAY_INDEX_HASH = 'hash'; + + /** + * Name of array index for length of raw data + */ + const ARRAY_INDEX_DATA_LENGTH = 'length'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Reads the file header + * + * @return void + * @todo To hard assertions here, better rewrite them to exceptions + */ + public function readFileHeader () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // First rewind to beginning as the header sits at the beginning ... + $this->getIteratorInstance()->rewind(); + + // Then read it (see constructor for calculation) + $data = $this->getIteratorInstance()->read($this->getIteratorInstance()->getHeaderSize()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getIteratorInstance()->getHeaderSize())); + + // Have all requested bytes been read? + assert(strlen($data) == $this->getIteratorInstance()->getHeaderSize()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Last character must be the separator + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] data(-1)=%s', __METHOD__, __LINE__, dechex(ord(substr($data, -1, 1))))); + assert(substr($data, -1, 1) == chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Okay, then remove it + $data = substr($data, 0, -1); + + // And update seek position + $this->getIteratorInstance()->updateSeekPosition(); + + /* + * Now split it: + * + * 0 => magic + * 1 => total entries + * 2 => current seek position + */ + $header = explode(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), $data); + + // Set header here + $this->getIteratorInstance()->setHeader($header); + + // Check if the array has only 3 elements + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] header(%d)=%s', __METHOD__, __LINE__, count($header), print_r($header, TRUE))); + assert(count($header) == 3); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Check magic + assert($header[0] == self::STACK_MAGIC); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Check length of count and seek position + assert(strlen($header[1]) == BaseBinaryFile::LENGTH_COUNT); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + assert(strlen($header[2]) == BaseBinaryFile::LENGTH_POSITION); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__)); + + // Decode count and seek position + $header[1] = hex2bin($header[1]); + $header[2] = hex2bin($header[2]); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Flushes the file header + * + * @return void + */ + public function flushFileHeader () { + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__)); + + // Put all informations together + $header = sprintf('%s%s%s%s%s%s', + // Magic + self::STACK_MAGIC, + + // Separator magic<->count + chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), + + // Total entries (will be zero) and pad it to 20 chars + str_pad($this->dec2hex($this->getIteratorInstance()->getCounter()), BaseBinaryFile::LENGTH_COUNT, '0', STR_PAD_LEFT), + + // Separator count<->seek position + chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), + + // Position (will be zero) + str_pad($this->dec2hex($this->getIteratorInstance()->getSeekPosition(), 2), BaseBinaryFile::LENGTH_POSITION, '0', STR_PAD_LEFT), + + // Separator position<->entries + chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES) + ); + + // Write it to disk (header is always at seek position 0) + $this->getIteratorInstance()->writeData(0, $header, FALSE); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); + } + + /** + * Initializes this file-based stack. + * + * @param $fileName File name of this stack + * @param $type Type of this stack (e.g. url_source for URL sources) + * @return void + * @todo Currently the stack file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole stack file. + */ + protected function initFileStack ($fileName, $type) { + // Get a stack file instance + $fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileName, $this)); + + // Get iterator instance + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_iterator_class', array($fileInstance)); + + // Is the instance implementing the right interface? + assert($iteratorInstance instanceof SeekableWritableFileIterator); + + // Set iterator here + $this->setIteratorInstance($iteratorInstance); + + // Calculate header size + $this->getIteratorInstance()->setHeaderSize( + strlen(self::STACK_MAGIC) + + strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) + + BaseBinaryFile::LENGTH_COUNT + + strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) + + BaseBinaryFile::LENGTH_POSITION + + strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)) + ); + + // Init counters and gaps array + $this->getIteratorInstance()->initCountersGapsArray(); + + // Is the file's header initialized? + if (!$this->getIteratorInstance()->isFileHeaderInitialized()) { + // No, then create it (which may pre-allocate the stack) + $this->getIteratorInstance()->createFileHeader(); + + // And pre-allocate a bit + $this->getIteratorInstance()->preAllocateFile('file_stack'); + } // END - if + + // Load the file header + $this->readFileHeader(); + + // Count all entries in file + $this->getIteratorInstance()->analyzeFile(); + + /* + * Get stack index instance. This can be used for faster + * "defragmentation" and startup. + */ + $indexInstance = FileStackIndexFactory::createFileStackIndexInstance($fileName, $type); + + // And set it here + $this->setIndexInstance($indexInstance); + } + + /** + * Adds a value to given stack + * + * @param $stackerName Name of the stack + * @param $value Value to add to this stacker + * @return void + * @throws FullStackerException If the stack is full + */ + protected function addValue ($stackerName, $value) { + // Do some tests + if ($this->isStackFull($stackerName)) { + // Stacker is full + throw new FullStackerException(array($this, $stackerName, $value), self::EXCEPTION_STACKER_IS_FULL); + } // END - if + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName . ',value[' . gettype($value) . ']=' . print_r($value, TRUE)); + + // No objects/resources are allowed as their serialization takes to long + assert(!is_object($value)); + assert(!is_resource($value)); + + /* + * Now add the value to the file stack which returns gap position, a + * hash and length of the raw data. + */ + $data = $this->getIteratorInstance()->writeValueToFile($stackerName, $value); + + // Add the hash and gap position to the index + $this->getIndexInstance()->addHashToIndex($stackerName, $data); + } + + /** + * Get last value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws EmptyStackerException If the stack is empty + */ + protected function getLastValue ($stackerName) { + // Is the stack not yet initialized or full? + if ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } // END - if + + // Now get the last value + /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); + $value = NULL; + + // Return it + return $value; + } + + /** + * Get first value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws EmptyStackerException If the stack is empty + */ + protected function getFirstValue ($stackerName) { + // Is the stack not yet initialized or full? + if ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } // END - if + + // Now get the first value + /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); + $value = NULL; + + // Return it + return $value; + } + + /** + * "Pops" last entry from stack + * + * @param $stackerName Name of the stack + * @return $value Value "poped" from array + * @throws EmptyStackerException If the stack is empty + */ + protected function popLast ($stackerName) { + // Is the stack not yet initialized or full? + if ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } // END - if + + // Now, remove the last entry, we don't care about the return value here, see elseif() block above + /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); + return NULL; + } + + /** + * "Pops" first entry from stack + * + * @param $stackerName Name of the stack + * @return $value Value "shifted" from array + * @throws EmptyStackerException If the named stacker is empty + */ + protected function popFirst ($stackerName) { + // Is the stack not yet initialized or full? + if ($this->isStackEmpty($stackerName)) { + // Throw an exception + throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY); + } // END - if + + // Now, remove the last entry, we don't care about the return value here, see elseif() block above + /* NOISY-DEBUG: */ $this->partialStub('[' . __METHOD__ . ':' . __LINE__ . '] stackerName=' . $stackerName); + return NULL; + } + + /** + * Checks whether the given stack is full + * + * @param $stackerName Name of the stack + * @return $isFull Whether the stack is full + */ + protected function isStackFull ($stackerName) { + // File-based stacks will only run full if the disk space is low. + // @TODO Please implement this, returning FALSE + $isFull = FALSE; + + // Return result + return $isFull; + } + + /** + * Checks whether the given stack is empty + * + * @param $stackerName Name of the stack + * @return $isEmpty Whether the stack is empty + * @throws NoStackerException If given stack is missing + */ + public function isStackEmpty ($stackerName) { + // So, is the stack empty? + $isEmpty = (($this->getStackCount($stackerName)) == 0); + + // Return result + return $isEmpty; + } + + /** + * Initializes given stacker + * + * @param $stackerName Name of the stack + * @param $forceReInit Force re-initialization + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function initStack ($stackerName, $forceReInit = FALSE) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Initializes all stacks + * + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function initStacks (array $stacks, $forceReInit = FALSE) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks whether the given stack is initialized (set in array $stackers) + * + * @param $stackerName Name of the stack + * @return $isInitialized Whether the stack is initialized + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function isStackInitialized ($stackerName) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function isEndOfFileReached () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for file name + * + * @return $fileName The current file name + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function getFileName () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for size of given stack (array count) + * + * @param $stackerName Name of the stack + * @return $count Size of stack (array count) + */ + public function getStackCount ($stackerName) { + // Now, simply return the found count value, this must be up-to-date then! + return $this->getIteratorInstance()->getCounter(); + } + + /** + * Calculates minimum length for one entry/block + * + * @return $length Minimum length for one entry/block + */ + public function calculateMinimumBlockLength () { + // Calulcate it + $length = + // Length of entry group + BaseBinaryFile::LENGTH_GROUP + strlen(chr(BaseBinaryFile::SEPARATOR_GROUP_HASH)) + + // Hash + value + self::getHashLength() + strlen(chr(BaseBinaryFile::SEPARATOR_HASH_VALUE)) + 1 + + // Final separator + strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES)); + + // Return it + return $length; + } + + /** + * Initializes counter for valid entries, arrays for damaged entries and + * an array for gap seek positions. If you call this method on your own, + * please re-analyze the file structure. So you are better to call + * analyzeFile() instead of this method. + * + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function initCountersGapsArray () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for header size + * + * @return $totalEntries Size of file header + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getHeaderSize () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for header size + * + * @param $headerSize Size of file header + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function setHeaderSize ($headerSize) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for header array + * + * @return $totalEntries Size of file header + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getHeader () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for header + * + * @param $header Array for a file header + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function setHeader (array $header) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Updates seekPosition attribute from file to avoid to much access on file. + * + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function updateSeekPosition () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public final function getCounter () { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Writes data at given position + * + * @param $seekPosition Seek position + * @param $data Data to be written + * @param $flushHeader Whether to flush the header (default: flush) + * @return void + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function writeData ($seekPosition, $data, $flushHeader = TRUE) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s,data[]=%s,flushHeader=%d', __METHOD__, __LINE__, $seekPosition, gettype($data), intval($flushHeader))); + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Writes given value to the file and returns a hash and gap position for it + * + * @param $groupId Group identifier + * @param $value Value to be added to the stack + * @return $data Hash and gap position + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function writeValueToFile ($groupId, $value) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,value[%s]=%s', __METHOD__, __LINE__, $groupId, gettype($value), print_r($value, TRUE))); + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Searches for next suitable gap the given length of data can fit in + * including padding bytes. + * + * @param $length Length of raw data + * @return $seekPosition Found next gap's seek position + * @throws UnsupportedOperationException This method is not (and maybe never will be) supported + */ + public function searchNextGap ($length) { + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] length=%s', __METHOD__, __LINE__, $length)); + throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * "Getter" for file size + * + * @return $fileSize Size of currently loaded file + */ + public function getFileSize () { + // Call iterator's method + return $this->getIteratorInstance()->getFileSize(); + } + + /** + * Writes given raw data to the file and returns a gap position and length + * + * @param $groupId Group identifier + * @param $hash Hash from encoded value + * @param $encoded Encoded value to be written to the file + * @return $data Gap position and length of the raw data + */ + public function writeDataToFreeGap ($groupId, $hash, $encoded) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,encoded()=%d - CALLED!', __METHOD__, __LINE__, $groupId, $hash, strlen($encoded))); + + // Raw data been written to the file + $rawData = sprintf('%s%s%s%s%s', + $groupId, + BaseBinaryFile::SEPARATOR_GROUP_HASH, + hex2bin($hash), + BaseBinaryFile::SEPARATOR_HASH_VALUE, + $encoded + ); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d', __METHOD__, __LINE__, $groupId, $hash, strlen($rawData))); + + // Search for next free gap + $gapPosition = $this->getIteratorInstance()->searchNextGap(strlen($rawData)); + + // Gap position cannot be smaller than header length + 1 + assert($gapPosition > $this->getIteratorInstance()->getHeaderSize()); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,gapPosition=%s', __METHOD__, __LINE__, $groupId, $hash, $gapPosition)); + + // Then write the data at that gap + $this->getIteratorInstance()->writeData($gapPosition, $rawData); + + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] groupId=%s,hash=%s,rawData()=%d - EXIT!', __METHOD__, __LINE__, $groupId, $hash, strlen($rawData))); + + // Return gap position, hash and length of raw data + return array( + self::ARRAY_INDEX_GAP_POSITION => $gapPosition, + self::ARRAY_INDEX_HASH => $hash, + self::ARRAY_INDEX_DATA_LENGTH => strlen($rawData) + ); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/stacker/file/fifo/.htaccess b/inc/main/classes/stacker/file/fifo/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/stacker/file/fifo/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/stacker/file/fifo/class_FiFoFileStack.php b/inc/main/classes/stacker/file/fifo/class_FiFoFileStack.php new file mode 100644 index 00000000..fc7edf43 --- /dev/null +++ b/inc/main/classes/stacker/file/fifo/class_FiFoFileStack.php @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FiFoFileStack extends BaseFileStack implements StackableFile, CalculatableBlock, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $fileName Absolute Name of stack file + * @param $type Type of this stack (e.g. url_source for URL sources) + * @return $stackInstance An instance of a Stackable class + */ + public final static function createFiFoFileStack ($fileName, $type) { + // Get new instance + $stackInstance = new FiFoFileStack(); + + // Init this stack + $stackInstance->initFileStack($fileName, $type); + + // Return the prepared instance + return $stackInstance; + } + + /** + * Pushs a value on a named stacker + * + * @param $stackerName Name of the stack + * @param $value Value to push on it + * @return void + * @throws StackerFullException If the stack is full + */ + public function pushNamed ($stackerName, $value) { + // Call the protected method + parent::addValue($stackerName, $value); + } + + /** + * 'Pops' a value from a named stacker and returns it's value + * + * @param $stackerName Name of the stack + * @return $value Value of the current stack entry + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function popNamed ($stackerName) { + // Get the value + $value = $this->getNamed($stackerName); + + // Call the protected method + parent::popFirst($stackerName); + + // Return the value + return $value; + } + + /** + * Get value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function getNamed ($stackerName) { + // Call the protected method + return parent::getFirstValue($stackerName); + } + + /** + * Seeks to given position + * + * @param $seekPosition Seek position in file + * @return $status Status of this operation + */ + public function seek ($seekPosition) { + $this->partialStub('seekPosition=' . $seekPosition); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + public function size () { + // Call the iterator instance + return $this->getIteratorInstance()->size(); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/stacker/filo/.htaccess b/inc/main/classes/stacker/filo/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/stacker/filo/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/stacker/filo/class_FiLoStacker.php b/inc/main/classes/stacker/filo/class_FiLoStacker.php new file mode 100644 index 00000000..ba7c09c3 --- /dev/null +++ b/inc/main/classes/stacker/filo/class_FiLoStacker.php @@ -0,0 +1,98 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FiLoStacker extends BaseStacker implements Stackable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class Stacker and prepares it for usage + * + * @return $stackInstance An instance of FiLoStacker + */ + public static final function createFiLoStacker () { + // Get a new instance + $stackInstance = new FiLoStacker(); + + // Init the generic stacker + $stackInstance->initStack('generic'); + + // Return the prepared instance + return $stackInstance; + } + + /** + * Pushs a value on a named stacker + * + * @param $stackerName Name of the stack + * @param $value Value to push on it + * @return void + * @throws StackerFullException If the stack is full + */ + public function pushNamed ($stackerName, $value) { + // Call the protected method + parent::addValue($stackerName, $value); + } + + /** + * 'Pops' a value from a named stacker and returns it's value + * + * @param $stackerName Name of the stack + * @return $value Value of the current stack entry + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function popNamed ($stackerName) { + // Get the value + $value = $this->getNamed($stackerName); + + // Call the protected method + parent::popLast($stackerName); + + // Return the value + return $value; + } + + /** + * Get value from named stacker + * + * @param $stackerName Name of the stack + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + public function getNamed ($stackerName) { + // Call the protected method + return parent::getLastValue($stackerName); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/states/.htaccess b/inc/main/classes/states/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/states/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/states/class_ b/inc/main/classes/states/class_ new file mode 100644 index 00000000..b2505a4e --- /dev/null +++ b/inc/main/classes/states/class_ @@ -0,0 +1,40 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???State extends BaseState implements ??Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/states/class_BaseState.php b/inc/main/classes/states/class_BaseState.php new file mode 100644 index 00000000..73970992 --- /dev/null +++ b/inc/main/classes/states/class_BaseState.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseState extends BaseFrameworkSystem implements Stateable { + // Exception code constants + const EXCEPTION_INVALID_STATE = 0xc00; + + /** + * State name for printing out (except debug output where you want to use + * $stateInstance->__toString() instead of this). + */ + private $stateName = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for state name + * + * @return $stateName Name of this state in a printable maner + */ + public final function getStateName () { + return $this->stateName; + } + + /** + * Setter for state name + * + * @param $stateName Name of this state in a printable maner + * @return void + */ + protected final function setStateName ($stateName) { + $this->stateName = $stateName; + } + + /** + * Executes the state with given Executor instance + * + * @param $executorInstance An instance of a Executor class + * @return void + * @throws UnsupportedOperationException This method should be overwritten + */ + public function executeState (Executor $executorInstance) { + throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/streams/.htaccess b/inc/main/classes/streams/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/streams/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/streams/class_ b/inc/main/classes/streams/class_ new file mode 100644 index 00000000..d7e24e2d --- /dev/null +++ b/inc/main/classes/streams/class_ @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Stream extends BaseStream implements Stream { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this node class + * + * @return $streamInstance An instance of this node class + */ + public final static function create???Stream (Requestable $requestInstance) { + // Get a new instance + $streamInstance = new ???Stream(); + + // Return the instance + return $streamInstance; + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/streams/class_BaseStream.php b/inc/main/classes/streams/class_BaseStream.php new file mode 100644 index 00000000..435479e0 --- /dev/null +++ b/inc/main/classes/streams/class_BaseStream.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseStream extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/streams/crypto/.htaccess b/inc/main/classes/streams/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/streams/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/streams/crypto/class_McryptStream.php b/inc/main/classes/streams/crypto/class_McryptStream.php new file mode 100644 index 00000000..2a60fe23 --- /dev/null +++ b/inc/main/classes/streams/crypto/class_McryptStream.php @@ -0,0 +1,175 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class McryptStream extends BaseStream implements EncryptableStream { + /** + * Separator on many places + */ + const DATA_PAYLOAD_SEPARATOR = '|'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this node class + * + * @param $rngInstance An RNG instance + * @return $streamInstance An instance of this node class + */ + public static final function createMcryptStream (RandomNumberGenerator $rngInstance) { + // Get a new instance + $streamInstance = new McryptStream(); + + // Set the RNG instance + $streamInstance->setRngInstance($rngInstance); + + // Return the instance + return $streamInstance; + } + + /** + * Encrypt the string with fixed salt + * + * @param $str The unencrypted string + * @param $key Optional key, if none provided, a random key will be generated + * @return $encrypted Encrypted string + */ + public function encryptStream ($str, $key = NULL) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: key[' . gettype($key) . ']=' . $key); + + // Init crypto module + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + + // Generate key, if none provided + if (is_null($key)) { + // None provided + $key = $this->getRngInstance()->generateKey(); + } // END - if + + // Add some "payload" to the string + switch ($this->getRngInstance()->randomNumber(0, 8)) { + case 0: + $payloadString = crc32($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20)); + break; + + case 1: + $payloadString = crc32($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20)); + break; + + case 2: + $payloadString = crc32($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20)); + break; + + case 3: + $payloadString = md5($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20)); + break; + + case 4: + $payloadString = md5($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20)); + break; + + case 5: + $payloadString = md5($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20)); + break; + + case 6: + $payloadString = sha1($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . crc32($this->getRngInstance()->randomString(20)); + break; + + case 7: + $payloadString = sha1($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . md5($this->getRngInstance()->randomString(20)); + break; + + case 8: + $payloadString = sha1($this->getRngInstance()->randomString(10)) . self::DATA_PAYLOAD_SEPARATOR . base64_encode($str) . self::DATA_PAYLOAD_SEPARATOR . sha1($this->getRngInstance()->randomString(20)); + break; + } + + // Encrypt the string + $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $payloadString, MCRYPT_MODE_ECB, $iv); + + // Return the string + return $encrypted; + } + + /** + * Decrypt the string with fixed salt + * + * @param $encrypted Encrypted string + * @param $key Optional key, if none provided, a random key will be generated + * @return $str The unencrypted string + */ + public function decryptStream ($encrypted, $key = NULL) { + // Init crypto module + $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + + // Shall we use a default key or custom? + if (is_null($key)) { + // Generate (default) key + $key = $this->getRngInstance()->generateKey(); + } // END - if + + // Decrypt the string + $payloadString = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB, $iv); + + // Get the real string out + $strArray = explode(self::DATA_PAYLOAD_SEPARATOR, $payloadString); + + // Does the element count match? + assert(count($strArray) == 3); + + // Decode the string + $str = base64_decode($strArray[1]); + + // Trim trailing nulls away + $str = rtrim($str, "\0"); + + // Return the string + return $str; + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called (which is a mistake) + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/streams/crypto/class_NullCryptoStream.php b/inc/main/classes/streams/crypto/class_NullCryptoStream.php new file mode 100644 index 00000000..c42e6d1f --- /dev/null +++ b/inc/main/classes/streams/crypto/class_NullCryptoStream.php @@ -0,0 +1,92 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NullCryptoStream extends BaseStream implements EncryptableStream { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this node class + * + * @return $streamInstance An instance of this node class + */ + public static final function createNullCryptoStream () { + // Get a new instance + $streamInstance = new NullCryptoStream(); + + // Return the instance + return $streamInstance; + } + + /** + * Encrypt the string with fixed salt + * + * @param $str The unencrypted string + * @param $key Optional key, if none provided, a random key will be generated + * @return $encrypted Encrypted string + */ + public function encryptStream ($str, $key = NULL) { + // Just handle it over + $encrypted = (string) $str; + + // Return it + return $encrypted; + } + + /** + * Decrypt the string with fixed salt + * + * @param $encrypted Encrypted string + * @return $str The unencrypted string + */ + public function decryptStream ($encrypted) { + // Just handle it over + $str = (string) $encrypted; + + // Return it + return $str; + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called (which is a mistake) + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/streams/input/.htaccess b/inc/main/classes/streams/input/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/streams/input/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/streams/input/class_ b/inc/main/classes/streams/input/class_ new file mode 100644 index 00000000..0bae09ff --- /dev/null +++ b/inc/main/classes/streams/input/class_ @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???InputStream extends BaseStream implements InputStream { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this node class + * + * @return $streamInstance An instance of this node class + */ + public final static function create???InputStream () { + // Get a new instance + $streamInstance = new ???InputStream(); + + // Return the instance + return $streamInstance; + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/streams/output/.htaccess b/inc/main/classes/streams/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/streams/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/streams/output/class_ b/inc/main/classes/streams/output/class_ new file mode 100644 index 00000000..10b3c722 --- /dev/null +++ b/inc/main/classes/streams/output/class_ @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???OutputStream extends BaseStream implements OutputStream { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this node class + * + * @return $streamInstance An instance of this node class + */ + public final static function create???OutputStream () { + // Get a new instance + $streamInstance = new ???OutputStream(); + + // Return the instance + return $streamInstance; + } + + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + * @throws UnsupportedOperationException If this method is called + */ + public function streamData ($data) { + self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/tasks/.htaccess b/inc/main/classes/tasks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/tasks/class_ b/inc/main/classes/tasks/class_ new file mode 100644 index 00000000..1bbb87e2 --- /dev/null +++ b/inc/main/classes/tasks/class_ @@ -0,0 +1,82 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class !!!???Task extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function create!!!???Task () { + // Get new instance + $taskInstance = new !!!???Task(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo Maybe visit some sub-objects + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + * @todo 0% + */ + public function executeTask () { + $this->partialStub('Unimplemented task.'); + } + + /** + * Shuts down the task + * + * @return void + * @todo 0% done + */ + public function doShutdown () { + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/tasks/class_BaseTask.php b/inc/main/classes/tasks/class_BaseTask.php new file mode 100644 index 00000000..c7bbe68b --- /dev/null +++ b/inc/main/classes/tasks/class_BaseTask.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseTask extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/tasks/idle/.htaccess b/inc/main/classes/tasks/idle/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/tasks/idle/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/tasks/idle/class_IdleLoopTask.php b/inc/main/classes/tasks/idle/class_IdleLoopTask.php new file mode 100644 index 00000000..20d394be --- /dev/null +++ b/inc/main/classes/tasks/idle/class_IdleLoopTask.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class IdleLoopTask extends BaseTask implements Taskable, Visitable { + /** + * Idle loop time + */ + private $idleTime = 0; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init idle loop time from config ("cache" it here) + $this->idleTime = $this->getConfigInstance()->getConfigEntry('idle_loop_time'); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Taskable/Visitable class + */ + public static final function createIdleLoopTask () { + // Get new instance + $taskInstance = new IdleLoopTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Idle here a little + $this->idle($this->idleTime); + } + + /** + * Shutdown this task, this does nothing here, just supply the method. + * + * @return void + */ + public function doShutdown () { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...'); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/template/.htaccess b/inc/main/classes/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/template/class_ b/inc/main/classes/template/class_ new file mode 100644 index 00000000..e27e3215 --- /dev/null +++ b/inc/main/classes/template/class_ @@ -0,0 +1,85 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???TemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $applicationInstance A manageable application + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public final static function create???TemplateEngine (ManageableApplication $applicationInstance) { + // Get a new instance + $templateInstance = new ???TemplateEngine(); + + // Determine base path + $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; + + // Is the base path valid? + if (empty($templateBasePath)) { + // Base path is empty + throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($templateBasePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($templateBasePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($templateBasePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $templateInstance->setTemplateBasePath($templateBasePath); + + // Set template extensions + $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); + $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); + + // Absolute output path for compiled templates + $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); + + // Return the prepared instance + return $templateInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/template/class_BaseTemplateEngine.php b/inc/main/classes/template/class_BaseTemplateEngine.php new file mode 100644 index 00000000..543bd88f --- /dev/null +++ b/inc/main/classes/template/class_BaseTemplateEngine.php @@ -0,0 +1,1641 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseTemplateEngine extends BaseFrameworkSystem { + /** + * The local path name where all templates and sub folders for special + * templates are stored. We will internally determine the language plus + * "html" for web templates or "emails" for email templates + */ + private $templateBasePath = ''; + + /** + * Template type + */ + private $templateType = 'html'; + + /** + * The extension for web and email templates (not compiled templates) + */ + private $templateExtension = '.tpl'; + + /** + * The extension for code templates (not compiled templates) + */ + private $codeExtension = '.ctp'; + + /** + * Path relative to $templateBasePath and language code for compiled code-templates + */ + private $compileOutputPath = 'templates/_compiled/'; + + /** + * The path name for all templates + */ + private $genericBasePath = 'templates/'; + + /** + * The raw (maybe uncompiled) template + */ + private $rawTemplateData = ''; + + /** + * Template data with compiled-in variables + */ + private $compiledData = ''; + + /** + * The last loaded template's FQFN for debugging the engine + */ + private $lastTemplate = ''; + + /** + * The variable stack for the templates + */ + private $varStack = array(); + + /** + * Loaded templates for recursive protection and detection + */ + private $loadedTemplates = array(); + + /** + * Compiled templates for recursive protection and detection + */ + private $compiledTemplates = array(); + + /** + * Loaded raw template data + */ + private $loadedRawData = NULL; + + /** + * Raw templates which are linked in code templates + */ + private $rawTemplates = NULL; + + /** + * A regular expression for variable=value pairs + */ + private $regExpVarValue = '/([\w_]+)(="([^"]*)"|=([\w_]+))?/'; + + /** + * A regular expression for filtering out code tags + * + * E.g.: {?template:variable=value;var2=value2;[...]?} + */ + private $regExpCodeTags = '/\{\?([a-z_]+)(:("[^"]+"|[^?}]+)+)?\?\}/'; + + /** + * A regular expression to find template comments like + */ + private $regExpComments = '//'; + + /** + * Loaded helpers + */ + private $helpers = array(); + + /** + * Current variable group + */ + private $currGroup = 'general'; + + /** + * All template groups except "general" + */ + private $variableGroups = array(); + + /** + * Code begin + */ + private $codeBegin = ''; + + /** + * Language support is enabled by default + */ + private $languageSupport = TRUE; + + /** + * XML compacting is disabled by default + */ + private $xmlCompacting = FALSE; + + // Exception codes for the template engine + const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x110; + const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111; + const EXCEPTION_INVALID_VIEW_HELPER = 0x112; + const EXCEPTION_VARIABLE_IS_MISSING = 0x113; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + + // Init file I/O instance + $ioInstance = ObjectFactory::createObjectByConfiguredName('file_io_class'); + + // Set it + $this->setFileIoInstance($ioInstance); + } + + /** + * Search for a variable in the stack + * + * @param $variableName The variable we are looking for + * @param $variableGroup Optional variable group to look in + * @return $index FALSE means not found, >=0 means found on a specific index + */ + private function getVariableIndex ($variableName, $variableGroup = NULL) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // First everything is not found + $found = FALSE; + + // If the stack is NULL, use the current group + if (is_null($variableGroup)) { + // Use current group + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); + $variableGroup = $this->currGroup; + } // END - if + + // Is the group there? + if ($this->isVarStackSet($variableGroup)) { + // Now search for it + foreach ($this->getVarStack($variableGroup) as $index => $currEntry) { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':currGroup=' . $variableGroup . ',idx=' . $index . ',currEntry=' . $currEntry['name'] . ',variableName=' . $variableName); + // Is the entry found? + if ($currEntry['name'] == $variableName) { + // Found! + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.':FOUND!'); + $found = $index; + break; + } // END - if + } // END - foreach + } // END - if + + // Return the current position + return $found; + } + + /** + * Checks whether the given variable group is set + * + * @param $variableGroup Variable group to check + * @return $isSet Whether the given variable group is set + */ + protected final function isVarStackSet ($variableGroup) { + // Check it + $isSet = isset($this->varStack[$variableGroup]); + + // Return result + return $isSet; + } + + /** + * Getter for given variable group + * + * @param $variableGroup Variable group to check + * @return $varStack Found variable group + */ + public final function getVarStack ($variableGroup) { + return $this->varStack[$variableGroup]; + } + + /** + * Setter for given variable group + * + * @param $variableGroup Variable group to check + * @param $varStack Variable stack to check + * @return void + */ + protected final function setVarStack ($variableGroup, array $varStack) { + $this->varStack[$variableGroup] = $varStack; + } + + /** + * Return a content of a variable or null if not found + * + * @param $variableName The variable we are looking for + * @param $variableGroup Optional variable group to look in + * @return $content Content of the variable or null if not found + */ + protected function readVariable ($variableName, $variableGroup = NULL) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // First everything is not found + $content = NULL; + + // If the stack is NULL, use the current group + if (is_null($variableGroup)) { + // Use current group + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.' currGroup=' . $this->currGroup . ' set as stack!'); + $variableGroup = $this->currGroup; + } // END - if + + // Get variable index + $found = $this->getVariableIndex($variableName, $variableGroup); + + // Is the variable found? + if ($found !== FALSE) { + // Read it + $content = $this->getVariableValue($variableGroup, $found); + } // END - if + + // Return the current position + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': variableGroup=' . $variableGroup . ',variableName=' . $variableName . ', content[' . gettype($content) . ']=' . $content); + return $content; + } + + /** + * Add a variable to the stack + * + * @param $variableName Name of variable to add + * @param $value Value we want to store in the variable + * @return void + */ + private function addVariable ($variableName, $value) { + // Set general variable group + $this->setVariableGroup('general'); + + // Add it to the stack + $this->addGroupVariable($variableName, $value); + } + + /** + * Returns all variables of current group or empty array + * + * @return $result Whether array of found variables or empty array + */ + private function readCurrentGroup () { + // Default is not found + $result = array(); + + // Is the group there? + if ($this->isVarStackSet($this->currGroup)) { + // Then use it + $result = $this->getVarStack($this->currGroup); + } // END - if + + // Return result + return $result; + } + + /** + * Settter for variable group + * + * @param $groupName Name of variable group + * @param $add Whether add this group + * @return void + */ + public function setVariableGroup ($groupName, $add = TRUE) { + // Set group name + //* DEBIG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': currGroup=' . $groupName); + $this->currGroup = $groupName; + + // Skip group 'general' + if (($groupName != 'general') && ($add === TRUE)) { + $this->variableGroups[$groupName] = 'OK'; + } // END - if + } + + + /** + * Adds a variable to current group + * + * @param $variableName Variable to set + * @param $value Value to store in variable + * @return void + */ + public function addGroupVariable ($variableName, $value) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': group=' . $this->currGroup . ', variableName=' . $variableName . ', value=' . $value); + + // Get current variables in group + $currVars = $this->readCurrentGroup(); + + // Append our variable + array_push($currVars, $this->generateVariableArray($variableName, $value)); + + // Add it to the stack + $this->setVarStack($this->currGroup, $currVars); + } + + /** + * Getter for variable value, throws a NoVariableException if the variable is not found + * + * @param $variableGroup Variable group to use + * @param $index Index in variable array + * @return $value Value to set + */ + private function getVariableValue ($variableGroup, $index) { + // Return it + return $this->varStack[$variableGroup][$index]['value']; + } + + /** + * Modify an entry on the stack + * + * @param $variableName The variable we are looking for + * @param $value The value we want to store in the variable + * @return void + * @throws NoVariableException If the given variable is not found + */ + private function modifyVariable ($variableName, $value) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // Get index for variable + $index = $this->getVariableIndex($variableName); + + // Is the variable set? + if ($index === FALSE) { + // Unset variables cannot be modified + throw new NoVariableException(array($this, $variableName, $value), self::EXCEPTION_VARIABLE_IS_MISSING); + } // END - if + + // Then modify it + $this->setVariableValue($this->currGroup, $index, $value); + } + + /** + * Sets a variable value for given variable group and index + * + * @param $variableGroup Variable group to use + * @param $index Index in variable array + * @param $value Value to set + * @return void + */ + private function setVariableValue ($variableGroup, $index, $value) { + $this->varStack[$variableGroup][$index]['value'] = $value; + } + + /** + * Sets a variable within given group. This method does detect if the + * variable is already set. If so, the variable got modified, otherwise + * added. + * + * @param $variableGroup Variable group to use + * @param $variableName Variable to set + * @param $value Value to set + * @return void + */ + protected function setVariable ($variableGroup, $variableName, $value) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // Get index for variable + $index = $this->getVariableIndex($variableName); + + // Is the variable set? + if ($index === FALSE) { + // Is the stack there? + if (!isset($this->varStack[$variableGroup])) { + // Then initialize it here + $this->varStack[$variableGroup] = array(); + } // END - if + + // Not found, add it + array_push($this->varStack[$variableGroup], $this->generateVariableArray($variableName, $value)); + } else { + // Then modify it + $this->setVariableValue($this->currGroup, $index, $value); + } + } + + /** + * "Generates" (better returns) an array for all variables for given + * variable/value pay. + * + * @param $variableName Variable to set + * @param $value Value to set + * @return $varData Variable data array + */ + private function generateVariableArray ($variableName, $value) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // Generate the temporary array + $varData = array( + 'name' => $variableName, + 'value' => $value + ); + + // And return it + return $varData; + } + + /** + * Setter for template type. Only 'html', 'emails' and 'compiled' should + * be sent here + * + * @param $templateType The current template's type + * @return void + */ + protected final function setTemplateType ($templateType) { + $this->templateType = (string) $templateType; + } + + /** + * Getter for template type + * + * @return $templateType The current template's type + */ + public final function getTemplateType () { + return $this->templateType; + } + + /** + * Setter for the last loaded template's FQFN + * + * @param $template The last loaded template + * @return void + */ + private final function setLastTemplate ($template) { + $this->lastTemplate = (string) $template; + } + + /** + * Getter for the last loaded template's FQFN + * + * @return $template The last loaded template + */ + private final function getLastTemplate () { + return $this->lastTemplate; + } + + /** + * Setter for base path + * + * @param $templateBasePath The relative base path for all templates + * @return void + */ + protected final function setTemplateBasePath ($templateBasePath) { + // And set it + $this->templateBasePath = (string) $templateBasePath; + } + + /** + * Getter for base path + * + * @return $templateBasePath The relative base path for all templates + */ + public final function getTemplateBasePath () { + // And set it + return $this->templateBasePath; + } + + /** + * Getter for generic base path + * + * @return $templateBasePath The relative base path for all templates + */ + public final function getGenericBasePath () { + // And set it + return $this->genericBasePath; + } + + /** + * Setter for template extension + * + * @param $templateExtension The file extension for all uncompiled + * templates + * @return void + */ + protected final function setRawTemplateExtension ($templateExtension) { + // And set it + $this->templateExtension = (string) $templateExtension; + } + + /** + * Setter for code template extension + * + * @param $codeExtension The file extension for all uncompiled + * templates + * @return void + */ + protected final function setCodeTemplateExtension ($codeExtension) { + // And set it + $this->codeExtension = (string) $codeExtension; + } + + /** + * Getter for template extension + * + * @return $templateExtension The file extension for all uncompiled + * templates + */ + public final function getRawTemplateExtension () { + // And set it + return $this->templateExtension; + } + + /** + * Getter for code-template extension + * + * @return $codeExtension The file extension for all code- + * templates + */ + public final function getCodeTemplateExtension () { + // And set it + return $this->codeExtension; + } + + /** + * Setter for path of compiled templates + * + * @param $compileOutputPath The local base path for all compiled + * templates + * @return void + */ + protected final function setCompileOutputPath ($compileOutputPath) { + // And set it + $this->compileOutputPath = (string) $compileOutputPath; + } + + /** + * Unsets the given offset in the variable group + * + * @param $index Index to unset + * @param $variableGroup Variable group (default: currGroup) + * @return void + */ + protected final function unsetVariableStackOffset ($index, $variableGroup = NULL) { + // Is the variable group not set? + if (is_null($variableGroup)) { + // Then set it to current + $variableGroup = $this->currGroup; + } // END - if + + // Is the entry there? + if (!isset($this->varStack[$variableGroup][$index])) { + // Abort here, we need fixing! + $this->debugInstance(); + } // END - if + + // Remove it + unset($this->varStack[$variableGroup][$index]); + } + + /** + * Private setter for raw template data + * + * @param $rawTemplateData The raw data from the template + * @return void + */ + protected final function setRawTemplateData ($rawTemplateData) { + // And store it in this class + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . strlen($rawTemplateData) . ' Bytes set.'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__.': ' . $this->currGroup . ' variables: ' . count($this->getVarStack($this->currGroup)) . ', groups=' . count($this->varStack)); + $this->rawTemplateData = (string) $rawTemplateData; + } + + /** + * Getter for raw template data + * + * @return $rawTemplateData The raw data from the template + */ + public final function getRawTemplateData () { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: ' . strlen($this->rawTemplateData) . ' Bytes read.'); + return $this->rawTemplateData; + } + + /** + * Private setter for compiled templates + * + * @return void + */ + private final function setCompiledData ($compiledData) { + // And store it in this class + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: ' . strlen($compiledData) . ' Bytes set.'); + $this->compiledData = (string) $compiledData; + } + + /** + * Getter for compiled templates, must be public for e.g. Mailer classes. + * + * @return $compiledData Compiled template data + */ + public final function getCompiledData () { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: ' . strlen($this->compiledData) . ' Bytes read.'); + return $this->compiledData; + } + + /** + * Private loader for all template types + * + * @param $template The template we shall load + * @param $extOther An other extension to use + * @return void + * @throws FileNotFoundException If the template was not found + */ + protected function loadTemplate ($template, $extOther = '') { + // Get extension for the template if empty + if (empty($extOther)) { + // None provided, so get the raw one + $ext = $this->getRawTemplateExtension(); + } else { + // Then use it! + $ext = (string) $extOther; + } + + // Is language support enabled? + if ($this->isLanguageSupportEnabled()) { + // Construct the FQFN for the template by honoring the current language + $fqfn = sprintf('%s%s%s%s/%s/%s%s', + $this->getConfigInstance()->getConfigEntry('base_path'), + $this->getTemplateBasePath(), + $this->getGenericBasePath(), + $this->getLanguageInstance()->getLanguageCode(), + $this->getTemplateType(), + (string) $template, + $ext + ); + } else { + // Construct the FQFN for the template without language + $fqfn = sprintf('%s%s%s%s/%s%s', + $this->getConfigInstance()->getConfigEntry('base_path'), + $this->getTemplateBasePath(), + $this->getGenericBasePath(), + $this->getTemplateType(), + (string) $template, + $ext + ); + } + + // First try this + try { + // Load the raw template data + $this->loadRawTemplateData($fqfn); + } catch (FileNotFoundException $e) { + // If we shall load a code-template we need to switch the file extension + if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('html_template_type')) && (empty($extOther))) { + // Switch over to the code-template extension and try it again + $ext = $this->getCodeTemplateExtension(); + + // Try it again... + $this->loadTemplate($template, $ext); + } else { + // Throw it again + throw new FileNotFoundException($fqfn, self::EXCEPTION_FILE_NOT_FOUND); + } + } + + } + + /** + * A private loader for raw template names + * + * @param $fqfn The full-qualified file name for a template + * @return void + */ + private function loadRawTemplateData ($fqfn) { + // Some debug code to look on the file which is being loaded + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: FQFN=' . $fqfn); + + // Load the raw template + $rawTemplateData = $this->getFileIoInstance()->loadFileContents($fqfn); + + // Store the template's contents into this class + $this->setRawTemplateData($rawTemplateData); + + // Remember the template's FQFN + $this->setLastTemplate($fqfn); + } + + /** + * Try to assign an extracted template variable as a "content" or 'config' + * variable. + * + * @param $variableName The variable's name (shall be content or config) + * by default + * @param $variableName The variable we want to assign + * @return void + */ + private function assignTemplateVariable ($variableName, $var) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: variableName=' . $variableName . ',variableName=' . $variableName); + + // Is it not a config variable? + if ($variableName != 'config') { + // Regular template variables + $this->assignVariable($variableName, ''); + } else { + // Configuration variables + $this->assignConfigVariable($var); + } + } + + /** + * Extract variables from a given raw data stream + * + * @param $rawData The raw template data we shall analyze + * @return void + */ + private function extractVariablesFromRawData ($rawData) { + // Cast to string + $rawData = (string) $rawData; + + // Search for variables + preg_match_all('/\$(\w+)(\[(\w+)\])?/', $rawData, $variableMatches); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:rawData(' . strlen($rawData) . ')=' . $rawData . ',variableMatches=' . print_r($variableMatches, TRUE)); + + // Did we find some variables? + if ((is_array($variableMatches)) && (count($variableMatches) == 4) && (count($variableMatches[0]) > 0)) { + // Initialize all missing variables + foreach ($variableMatches[3] as $key => $var) { + // Variable name + $variableName = $variableMatches[1][$key]; + + // Workarround: Do not assign empty variables + if (!empty($var)) { + // Try to assign it, empty strings are being ignored + $this->assignTemplateVariable($variableName, $var); + } // END - if + } // END - foreach + } // END - if + } + + /** + * Main analysis of the loaded template + * + * @param $templateMatches Found template place-holders, see below + * @return void + * + *--------------------------------- + * Structure of $templateMatches: + *--------------------------------- + * [0] => Array - An array with all full matches + * [1] => Array - An array with left part (before the ':') of a match + * [2] => Array - An array with right part of a match including ':' + * [3] => Array - An array with right part of a match excluding ':' + */ + private function analyzeTemplate (array $templateMatches) { + // Backup raw template data + $backup = $this->getRawTemplateData(); + + // Initialize some arrays + if (is_null($this->loadedRawData)) { + // Initialize both + $this->loadedRawData = array(); + $this->rawTemplates = array(); + } // END - if + + // Load all requested templates + foreach ($templateMatches[1] as $template) { + // Load and compile only templates which we have not yet loaded + // RECURSIVE PROTECTION! BE CAREFUL HERE! + if ((!isset($this->loadedRawData[$template])) && (!in_array($template, $this->loadedTemplates))) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:template=' . $template); + + // Template not found, but maybe variable assigned? + if ($this->getVariableIndex($template) !== FALSE) { + // Use that content here + $this->loadedRawData[$template] = $this->readVariable($template); + + // Recursive protection: + array_push($this->loadedTemplates, $template); + } else { + // Then try to search for code-templates + try { + // Load the code template and remember it's contents + $this->loadCodeTemplate($template); + $this->loadedRawData[$template] = $this->getRawTemplateData(); + + // Remember this template for recursion detection + // RECURSIVE PROTECTION! + array_push($this->loadedTemplates, $template); + } catch (FileNotFoundException $e) { + // Even this is not done... :/ + array_push($this->rawTemplates, $template); + } + } + } // END - if + } // END - foreach + + // Restore the raw template data + $this->setRawTemplateData($backup); + } + + /** + * Compile a given raw template code and remember it for later usage + * + * @param $code The raw template code + * @param $template The template's name + * @return void + */ + private function compileCode ($code, $template) { + // Is this template already compiled? + if (in_array($template, $this->compiledTemplates)) { + // Abort here... + return; + } // END - if + + // Remember this template being compiled + array_push($this->compiledTemplates, $template); + + // Compile the loaded code in five steps: + // + // 1. Backup current template data + $backup = $this->getRawTemplateData(); + + // 2. Set the current template's raw data as the new content + $this->setRawTemplateData($code); + + // 3. Compile the template data + $this->compileTemplate(); + + // 4. Remember it's contents + $this->loadedRawData[$template] = $this->getRawTemplateData(); + + // 5. Restore the previous raw content from backup variable + $this->setRawTemplateData($backup); + } + + /** + * Insert all given and loaded templates by running through all loaded + * codes and searching for their place-holder in the main template + * + * @param $templateMatches See method analyzeTemplate() + * @return void + */ + private function insertAllTemplates (array $templateMatches) { + // Run through all loaded codes + foreach ($this->loadedRawData as $template => $code) { + + // Search for the template + $foundIndex = array_search($template, $templateMatches[1]); + + // Lookup the matching template replacement + if (($foundIndex !== FALSE) && (isset($templateMatches[0][$foundIndex]))) { + + // Get the current raw template + $rawData = $this->getRawTemplateData(); + + // Replace the space holder with the template code + $rawData = str_replace($templateMatches[0][$foundIndex], $code, $rawData); + + // Set the new raw data + $this->setRawTemplateData($rawData); + } // END - if + } // END - foreach + } + + /** + * Load all extra raw templates + * + * @return void + */ + private function loadExtraRawTemplates () { + // Are there some raw templates we need to load? + if (count($this->rawTemplates) > 0) { + // Try to load all raw templates + foreach ($this->rawTemplates as $key => $template) { + try { + // Load the template + $this->loadHtmlTemplate($template); + + // Remember it's contents + $this->rawTemplates[$template] = $this->getRawTemplateData(); + + // Remove it from the loader list + unset($this->rawTemplates[$key]); + + // Remember this template for recursion detection + // RECURSIVE PROTECTION! + array_push($this->loadedTemplates, $template); + } catch (FileNotFoundException $e) { + // This template was never found. We silently ignore it + unset($this->rawTemplates[$key]); + } + } // END - foreach + } // END - if + } + + /** + * Assign all found template variables + * + * @param $varMatches An array full of variable/value pairs. + * @return void + * @todo Unfinished work or don't die here. + */ + private function assignAllVariables (array $varMatches) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:varMatches()=' . count($varMatches)); + + // Search for all variables + foreach ($varMatches[1] as $key => $var) { + // Replace all dashes to underscores to match variables with configuration entries + $var = trim(self::convertDashesToUnderscores($var)); + + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:key=' . $key . ',var=' . $var); + + // Detect leading equals + if (substr($varMatches[2][$key], 0, 1) == '=') { + // Remove and cast it + $varMatches[2][$key] = (string) substr($varMatches[2][$key], 1); + } // END - if + + // Do we have some quotes left and right side? Then it is free text + if ((substr($varMatches[2][$key], 0, 1) == '"') && (substr($varMatches[2][$key], -1, 1) == '"')) { + // Free string detected! Which we can assign directly + $this->assignVariable($var, $varMatches[3][$key]); + } elseif (!empty($varMatches[2][$key])) { + // @TODO Non-string found so we need some deeper analysis... + ApplicationEntryPoint::app_exit('Deeper analysis not yet implemented!'); + } + } // END - foreach + } + + /** + * Compiles all loaded raw templates + * + * @param $templateMatches See method analyzeTemplate() for details + * @return void + */ + private function compileRawTemplateData (array $templateMatches) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:loadedRawData()= ' .count($this->loadedRawData)); + + // Are some code-templates found which we need to compile? + if (count($this->loadedRawData) > 0) { + // Then compile all! + foreach ($this->loadedRawData as $template => $code) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:template=' . $template . ',code(' . strlen($code) . ')=' . $code); + + // Is this template already compiled? + if (in_array($template, $this->compiledTemplates)) { + // Then skip it + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: Template ' . $template . ' already compiled. SKIPPED!'); + continue; + } // END - if + + // Search for the template + $foundIndex = array_search($template, $templateMatches[1]); + + // Lookup the matching variable data + if (($foundIndex !== FALSE) && (isset($templateMatches[3][$foundIndex]))) { + // Split it up with another reg. exp. into variable=value pairs + preg_match_all($this->regExpVarValue, $templateMatches[3][$foundIndex], $varMatches); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:varMatches=' . print_r($varMatches, TRUE)); + + // Assign all variables + $this->assignAllVariables($varMatches); + } // END - if (isset($templateMatches ... + + // Compile the loaded template + $this->compileCode($code, $template); + } // END - foreach ($this->loadedRawData ... + + // Insert all templates + $this->insertAllTemplates($templateMatches); + } // END - if (count($this->loadedRawData) ... + } + + /** + * Inserts all raw templates into their respective variables + * + * @return void + */ + private function insertRawTemplates () { + // Load all templates + foreach ($this->rawTemplates as $template => $content) { + // Set the template as a variable with the content + $this->assignVariable($template, $content); + } + } + + /** + * Finalizes the compilation of all template variables + * + * @return void + */ + private function finalizeVariableCompilation () { + // Get the content + $content = $this->getRawTemplateData(); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: content before=' . strlen($content) . ' (' . md5($content) . ')'); + + // Do we have the stack? + if (!$this->isVarStackSet('general')) { + // Abort here silently + // @TODO This silent abort should be logged, maybe. + return; + } // END - if + + // Walk through all variables + foreach ($this->getVarStack('general') as $currEntry) { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: name=' . $currEntry['name'] . ', value=
    ' . htmlentities($currEntry['value']) . '
    '); + // Replace all [$var] or {?$var?} with the content + // @TODO Old behaviour, will become obsolete! + $content = str_replace('$content[' . $currEntry['name'] . ']', $currEntry['value'], $content); + + // @TODO Yet another old way + $content = str_replace('[' . $currEntry['name'] . ']', $currEntry['value'], $content); + + // The new behaviour + $content = str_replace('{?' . $currEntry['name'] . '?}', $currEntry['value'], $content); + } // END - for + + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: content after=' . strlen($content) . ' (' . md5($content) . ')'); + + // Set the content back + $this->setRawTemplateData($content); + } + + /** + * Load a specified HTML template into the engine + * + * @param $template The web template we shall load which is located in + * 'html' by default + * @return void + */ + public function loadHtmlTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('html_template_type')); + + // Load the special template + $this->loadTemplate($template); + } + + /** + * Assign (add) a given variable with a value + * + * @param $variableName The variable we are looking for + * @param $value The value we want to store in the variable + * @return void + * @throws EmptyVariableException If the variable name is left empty + */ + public final function assignVariable ($variableName, $value) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // Empty variable found? + if (empty($variableName)) { + // Throw an exception + throw new EmptyVariableException(array($this, 'variableName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } // END - if + + // First search for the variable if it was already added + $index = $this->getVariableIndex($variableName); + + // Was it found? + if ($index === FALSE) { + // Add it to the stack + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value); + $this->addVariable($variableName, $value); + } elseif (!empty($value)) { + // Modify the stack entry + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value); + $this->modifyVariable($variableName, $value); + } + } + + /** + * Removes a given variable + * + * @param $variableName The variable we are looking for + * @param $variableGroup Name of variable group (default: 'general') + * @return void + */ + public final function removeVariable ($variableName, $variableGroup = 'general') { + // First search for the variable if it was already added + $index = $this->getVariableIndex($variableName, $variableGroup); + + // Was it found? + if ($index !== FALSE) { + // Remove this variable + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:UNSET: variableGroup=' . $variableGroup . ',variableName=' . $variableName . ',index=' . $index); + $this->unsetVariableStackOffset($index, $variableGroup); + } // END - if + } + + /** + * Assigns the last loaded raw template content with a given variable + * + * @param $templateName Name of the template we want to assign + * @param $variableName Name of the variable we want to assign + * @return void + */ + public function assignTemplateWithVariable ($templateName, $variableName) { + // Get the content from last loaded raw template + $content = $this->getRawTemplateData(); + + // Assign the variable + $this->assignVariable($variableName, $content); + + // Purge raw content + $this->setRawTemplateData(''); + } + + /** + * Assign a given congfiguration variable with a value + * + * @param $variableName The configuration variable we want to assign + * @return void + */ + public function assignConfigVariable ($variableName) { + // Replace all dashes to underscores to match variables with configuration entries + $variableName = trim(self::convertDashesToUnderscores($variableName)); + + // Sweet and simple... + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: variableName=' . $variableName . ',getConfigEntry()=' . $this->getConfigInstance()->getConfigEntry($variableName)); + $this->assignVariable($variableName, $this->getConfigInstance()->getConfigEntry($variableName)); + } + + /** + * Assigns a lot variables into the stack of currently loaded template. + * This method should only be used in very rare circumstances, e.g. when + * you have to copy a whole set of variables into the template engine. + * Before you use this method, please make sure you have considered all + * other possiblities. + * + * @param $variables An array with variables to be assigned + * @return void + */ + public function assignMultipleVariables (array $variables) { + // "Inject" all + foreach ($variables as $name => $value) { + // Set variable with name for 'config' group + $this->assignVariable($name, $value); + } // END - foreach + } + + /** + * Assigns all the application data with template variables + * + * @param $applicationInstance A manageable application instance + * @return void + */ + public function assignApplicationData (ManageableApplication $applicationInstance) { + // Get long name and assign it + $this->assignVariable('app_full_name' , $applicationInstance->getAppName()); + + // Get short name and assign it + $this->assignVariable('app_short_name', $applicationInstance->getAppShortName()); + + // Get version number and assign it + $this->assignVariable('app_version' , $applicationInstance->getAppVersion()); + + // Assign extra application-depending data + $applicationInstance->assignExtraTemplateData($this); + } + + /** + * Load a specified code template into the engine + * + * @param $template The code template we shall load which is + * located in 'code' by default + * @return void + */ + public function loadCodeTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('code_' . self::getResponseTypeFromSystem() . '_template_type')); + + // Load the special template + $this->loadTemplate($template); + } + + /** + * Load a specified email template into the engine + * + * @param $template The email template we shall load which is + * located in 'emails' by default + * @return void + */ + public function loadEmailTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('email_template_type')); + + // Load the special template + $this->loadTemplate($template); + } + + /** + * Compiles configuration place-holders in all variables. This 'walks' + * through the variable group 'general'. It interprets all values from that + * variables as configuration entries after compiling them. + * + * @return void + */ + public final function compileConfigInVariables () { + // Do we have the stack? + if (!$this->isVarStackSet('general')) { + // Abort here silently + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: Aborted, variable stack general not found!'); + return; + } // END - if + + // Iterate through all general variables + foreach ($this->getVarStack('general') as $index => $currVariable) { + // Compile the value + $value = $this->compileRawCode($this->readVariable($currVariable['name']), TRUE); + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: name=' . $currVariable['name'] . ',value=' . $value); + + // Remove it from stack + $this->removeVariable($currVariable['name'], 'general'); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: value='. $value . ',name=' . $currVariable['name'] . ',index=' . $index); + + // Is it a configuration key? + if ($this->getConfigInstance()->isConfigurationEntrySet($value)) { + // The value itself is a configuration entry + $this->assignConfigVariable($value); + } else { + // Re-assign the value directly + $this->assignVariable($currVariable['name'], $value); + } + } // END - foreach + } + + /** + * Compile all variables by inserting their respective values + * + * @return void + * @todo Make this code some nicer... + */ + public final function compileVariables () { + // Initialize the $content array + $validVar = $this->getConfigInstance()->getConfigEntry('tpl_valid_var'); + $dummy = array(); + + // Iterate through all general variables + foreach ($this->getVarStack('general') as $currVariable) { + // Transfer it's name/value combination to the $content array + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:' . $currVariable['name'] . '=
    ' . htmlentities($currVariable['value']).'
    '); + $dummy[$currVariable['name']] = $currVariable['value']; + }// END - if + + // Set the new variable (don't remove the second dollar!) + $$validVar = $dummy; + + // Remove some variables + unset($index); + unset($currVariable); + + // Run the compilation three times to get content from helper classes in + $cnt = 0; + while ($cnt < 3) { + // Finalize the compilation of template variables + $this->finalizeVariableCompilation(); + + // Prepare the eval() command for comiling the template + $eval = sprintf('$result = "%s";', + addslashes($this->getRawTemplateData()) + ); + + // This loop does remove the backslashes (\) in PHP parameters + while (strpos($eval, $this->codeBegin) !== FALSE) { + // Get left part before "codeBegin)); + + // Get all from right of "codeBegin) + 5)); + + // Cut middle part out and remove escapes + $evalMiddle = trim(substr($evalRight, 0, strpos($evalRight, $this->codeEnd))); + $evalMiddle = stripslashes($evalMiddle); + + // Remove the middle part from right one + $evalRight = substr($evalRight, (strpos($evalRight, $this->codeEnd) + 2)); + + // And put all together + $eval = sprintf('%s<%%php %s %%>%s', $evalLeft, $evalMiddle, $evalRight); + } // END - while + + // Prepare PHP code for eval() command + $eval = str_replace( + '<%php', '";', + str_replace( + '%>', + "\n\$result .= \"", + $eval + ) + ); + + // Run the constructed command. This will "compile" all variables in + eval($eval); + + // Goes something wrong? + if ((!isset($result)) || (empty($result))) { + // Output eval command + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('Failed eval() code:
    %s
    ', $this->markupCode($eval, TRUE)), TRUE); + + // Output backtrace here + $this->debugBackTrace(); + } // END - if + + // Set raw template data + $this->setRawTemplateData($result); + $cnt++; + } // END - while + + // Final variable assignment + $this->finalizeVariableCompilation(); + + // Set the new content + $this->setCompiledData($this->getRawTemplateData()); + } + + /** + * Compile all required templates into the current loaded one + * + * @return void + * @throws UnexpectedTemplateTypeException If the template type is + * not "code" + * @throws InvalidArrayCountException If an unexpected array + * count has been found + */ + public function compileTemplate () { + // Get code type to make things shorter + $codeType = $this->getConfigInstance()->getConfigEntry('code_' . self::getResponseTypeFromSystem() . '_template_type'); + + // We will only work with template type "code" from configuration + if (substr($this->getTemplateType(), 0, strlen($codeType)) != $codeType) { + // Abort here + throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->getConfigEntry('code_' . self::getResponseTypeFromSystem() . '_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED); + } // END - if + + // Get the raw data. + $rawData = $this->getRawTemplateData(); + + // Remove double spaces and trim leading/trailing spaces + $rawData = trim(str_replace(' ', ' ', $rawData)); + + // Search for raw variables + $this->extractVariablesFromRawData($rawData); + + // Search for code-tags which are {? ?} + preg_match_all($this->regExpCodeTags, $rawData, $templateMatches); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:templateMatches=' . print_r($templateMatches , TRUE)); + + // Analyze the matches array + if ((is_array($templateMatches)) && (count($templateMatches) == 4) && (count($templateMatches[0]) > 0)) { + // Entries are found: + // + // The main analysis + $this->analyzeTemplate($templateMatches); + + // Compile raw template data + $this->compileRawTemplateData($templateMatches); + + // Are there some raw templates left for loading? + $this->loadExtraRawTemplates(); + + // Are some raw templates found and loaded? + if (count($this->rawTemplates) > 0) { + // Insert all raw templates + $this->insertRawTemplates(); + + // Remove the raw template content as well + $this->setRawTemplateData(''); + } // END - if + } // END - if($templateMatches ... + } + + /** + * Loads a given view helper (by name) + * + * @param $helperName The helper's name + * @return void + */ + protected function loadViewHelper ($helperName) { + // Is this view helper loaded? + if (!isset($this->helpers[$helperName])) { + // Create a class name + $className = self::convertToClassName($helperName) . 'ViewHelper'; + + // Generate new instance + $this->helpers[$helperName] = ObjectFactory::createObjectByName($className); + } // END - if + + // Return the requested instance + return $this->helpers[$helperName]; + } + + /** + * Transfers the content of this template engine to a given response instance + * + * @param $responseInstance An instance of a response class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + // Get the content and set it in response class + $responseInstance->writeToBody($this->getCompiledData()); + } + + /** + * "Compiles" a variable by replacing {?var?} with it's content + * + * @param $rawCode Raw code to compile + * @param $setMatchAsCode Sets $match if readVariable() returns empty result + * @return $rawCode Compile code with inserted variable value + */ + public function compileRawCode ($rawCode, $setMatchAsCode=FALSE) { + // Find the variables + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:rawCode=
    ' . htmlentities($rawCode) . '
    '); + preg_match_all($this->regExpVarValue, $rawCode, $varMatches); + + // Compile all variables + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:
    ' . print_r($varMatches, TRUE) . '
    '); + foreach ($varMatches[0] as $match) { + // Add variable tags around it + $varCode = '{?' . $match . '?}'; + + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:varCode=' . $varCode); + + // Is the variable found in code? (safes some calls) + if (strpos($rawCode, $varCode) !== FALSE) { + // Debug message + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: match=' . $match . ',rawCode[' . gettype($rawCode) . ']=' . $rawCode); + + // Use $match as new value or $value from read variable? + if ($setMatchAsCode === TRUE) { + // Insert match + $rawCode = str_replace($varCode, $match, $rawCode); + } else { + // Read the variable + $value = $this->readVariable($match); + + // Insert value + $rawCode = str_replace($varCode, $value, $rawCode); + } + } // END - if + } // END - foreach + + // Return the compiled data + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:rawCode=
    ' . htmlentities($rawCode) . '
    '); + return $rawCode; + } + + /** + * Getter for variable group array + * + * @return $variableGroups All variable groups + */ + public final function getVariableGroups () { + return $this->variableGroups; + } + + /** + * Renames a variable in code and in stack + * + * @param $oldName Old name of variable + * @param $newName New name of variable + * @return void + */ + public function renameVariable ($oldName, $newName) { + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']: oldName=' . $oldName . ', newName=' . $newName); + // Get raw template code + $rawData = $this->getRawTemplateData(); + + // Replace it + $rawData = str_replace($oldName, $newName, $rawData); + + // Set the code back + $this->setRawTemplateData($rawData); + } + + /** + * Renders the given XML content + * + * @param $content Valid XML content or if not set the current loaded raw content + * @return void + * @throws XmlParserException If an XML error was found + */ + public function renderXmlContent ($content = NULL) { + // Is the content set? + if (is_null($content)) { + // Get current content + $content = $this->getRawTemplateData(); + } // END - if + + // Get a XmlParser instance + $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this)); + + // Check if XML compacting is enabled + if ($this->isXmlCompactingEnabled()) { + // Yes, so get a decorator class for transparent compacting + $parserInstance = ObjectFactory::createObjectByConfiguredName('deco_compacting_xml_parser_class', array($parserInstance)); + } // END - if + + // Parse the XML document + $parserInstance->parseXmlContent($content); + } + + /** + * Enables or disables language support + * + * @param $languageSupport New language support setting + * @return void + */ + public final function enableLanguageSupport ($languageSupport = TRUE) { + $this->languageSupport = (bool) $languageSupport; + } + + /** + * Checks whether language support is enabled + * + * @return $languageSupport Whether language support is enabled or disabled + */ + public final function isLanguageSupportEnabled () { + return $this->languageSupport; + } + + /** + * Enables or disables XML compacting + * + * @param $xmlCompacting New XML compacting setting + * @return void + */ + public final function enableXmlCompacting ($xmlCompacting = TRUE) { + $this->xmlCompacting = (bool) $xmlCompacting; + } + + /** + * Checks whether XML compacting is enabled + * + * @return $xmlCompacting Whether XML compacting is enabled or disabled + */ + public final function isXmlCompactingEnabled () { + return $this->xmlCompacting; + } + + /** + * Removes all commentd, tabs and new-line characters to compact the content + * + * @param $uncompactedContent The uncompacted content + * @return $compactedContent The compacted content + */ + public function compactContent ($uncompactedContent) { + // First, remove all tab/new-line/revert characters + $compactedContent = str_replace(chr(9), '', str_replace(chr(10), '', str_replace(chr(13), '', $uncompactedContent))); + + // Then regex all comments like away + preg_match_all($this->regExpComments, $compactedContent, $matches); + + // Do we have entries? + if (isset($matches[0][0])) { + // Remove all + foreach ($matches[0] as $match) { + // Remove the match + $compactedContent = str_replace($match, '', $compactedContent); + } // END - foreach + } // END - if + + // Set the content again + $this->setRawTemplateData($compactedContent); + + // Return compacted content + return $compactedContent; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/template/console/.htaccess b/inc/main/classes/template/console/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/template/console/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/template/console/class_ConsoleTemplateEngine.php b/inc/main/classes/template/console/class_ConsoleTemplateEngine.php new file mode 100644 index 00000000..4a55c273 --- /dev/null +++ b/inc/main/classes/template/console/class_ConsoleTemplateEngine.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createConsoleTemplateEngine () { + // Get a new instance + $templateInstance = new ConsoleTemplateEngine(); + + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Determine base path + $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; + + // Is the base path valid? + if (empty($templateBasePath)) { + // Base path is empty + throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($templateBasePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($templateBasePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($templateBasePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $templateInstance->setTemplateBasePath($templateBasePath); + + // Set template extensions + $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); + $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); + + // Absolute output path for compiled templates + $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); + + // Return the prepared instance + return $templateInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/template/html/.htaccess b/inc/main/classes/template/html/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/template/html/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/template/html/class_HtmlTemplateEngine.php b/inc/main/classes/template/html/class_HtmlTemplateEngine.php new file mode 100644 index 00000000..f1d758a5 --- /dev/null +++ b/inc/main/classes/template/html/class_HtmlTemplateEngine.php @@ -0,0 +1,88 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HtmlTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createHtmlTemplateEngine () { + // Get a new instance + $templateInstance = new HtmlTemplateEngine(); + + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Determine base path + $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; + + // Is the base path valid? + if (empty($templateBasePath)) { + // Base path is empty + throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($templateBasePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($templateBasePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($templateBasePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $templateInstance->setTemplateBasePath($templateBasePath); + + // Set template extensions + $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); + $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); + + // Absolute output path for compiled templates + $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); + + // Return the prepared instance + return $templateInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/template/image/.htaccess b/inc/main/classes/template/image/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/template/image/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/template/image/class_ImageTemplateEngine.php b/inc/main/classes/template/image/class_ImageTemplateEngine.php new file mode 100644 index 00000000..3b7b8da0 --- /dev/null +++ b/inc/main/classes/template/image/class_ImageTemplateEngine.php @@ -0,0 +1,505 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Main nodes in the XML tree ('image' is ignored) + */ + private $mainNodes = array( + 'base', + 'type', + 'resolution', + 'background-color', + 'foreground-color', + 'image-string' + ); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array( + 'name', + 'string-name', + 'x', + 'y', + 'font-size', + 'width', + 'height', + 'red', + 'green', + 'blue', + 'text' + ); + + /** + * Current main node + */ + private $currMainNode = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createImageTemplateEngine () { + // Get a new instance + $templateInstance = new ImageTemplateEngine(); + + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Determine base path + $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; + + // Is the base path valid? + if (empty($templateBasePath)) { + // Base path is empty + throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($templateBasePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($templateBasePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($templateBasePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $templateInstance->setTemplateBasePath($templateBasePath); + + // Set template extensions + $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); + $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); + + // Absolute output path for compiled templates + $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->currMainNode; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + public function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = 'initImage'; + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + //* DEBUG: */ echo "START: >".$element."<
    \n"; + if (in_array($element, $this->mainNodes)) { + // Okay, main node found! + $methodName = 'setImage' . self::convertToClassName($element); + } elseif (in_array($element, $this->subNodes)) { + // Sub node found + $methodName = 'setImageProperty' . self::convertToClassName($element); + } elseif ($element != 'image') { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + //* DEBUG: */ echo "call: ".$methodName."
    \n"; + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + public function finishElement ($resource, $nodeName) { + // Make all lower-case + $nodeName = strtolower($nodeName); + + // Does this match with current main node? + //* DEBUG: */ echo "END: >".$nodeName."<
    \n"; + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { + // Did not match! + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); + } elseif (in_array($nodeName, $this->getSubNodes())) { + // Silently ignore sub nodes + return; + } + + // Construct method name + $methodName = 'finish' . self::convertToClassName($nodeName); + + // Call the corresponding method + call_user_func_array(array($this->getImageInstance(), $methodName), array()); + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something usefull with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Unfinished work! + $this->partialStub('Handling extra characters is not yet supported!'); + } + + /** + * Intializes the image + * + * @return void + * @todo Add cache creation here + */ + private function initImage () { + // Unfinished work! + } + + /** + * Set the image type + * + * @param $imageType Code fragment or direct value holding the image type + * @return void + */ + private function setImageType ($imageType) { + // Set group to general + $this->setVariableGroup('general'); + + // Try to compile it first to get the value from variable stack + $imageType = $this->compileRawCode($imageType); + + // Now make a class name of it + $className = self::convertToClassName($imageType.'_image'); + + // And try to initiate it + $this->setImageInstance(ObjectFactory::createObjectByName($className, array($this))); + + // Set current main node to type + $this->currMainNode = 'type'; + } + + /** + * "Setter" for resolution, we first need to collect the resolution from the + * sub-nodes. So first, this method will prepare an array for it + * + * @return void + */ + private function setImageResolution () { + // Call the image class + $this->getImageInstance()->initResolution(); + + // Current main node is resolution + $this->currMainNode = 'resolution'; + } + + /** + * "Setter" for base information. For more details see above method! + * + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageBase () { + // Call the image class + $this->getImageInstance()->initBase(); + + // Current main node is resolution + $this->currMainNode = 'base'; + } + + /** + * "Setter" for background-color. For more details see above method! + * + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageBackgroundColor () { + // Call the image class + $this->getImageInstance()->initBackgroundColor(); + + // Current main node is background-color + $this->currMainNode = 'background-color'; + } + + /** + * "Setter" for foreground-color. For more details see above method! + * + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageForegroundColor () { + // Call the image class + $this->getImageInstance()->initForegroundColor(); + + // Current main node is foreground-color + $this->currMainNode = 'foreground-color'; + } + + /** + * "Setter" for image-string. For more details see above method! + * + * @param $groupable Whether this image string is groupable + * @return void + * @see ImageTemplateEngine::setImageResolution + */ + private function setImageImageString ($groupable = 'single') { + // Call the image class + $this->getImageInstance()->initImageString($groupable); + + // Current main node is foreground-color + $this->currMainNode = 'image-string'; + } + + /** + * Setter for image name + * + * @param $imageName Name of the image + * @return void + */ + private function setImagePropertyName ($imageName) { + // Call the image class + $this->getImageInstance()->setImageName($imageName); + } + + /** + * Setter for image width + * + * @param $width Width of the image or variable + * @return void + */ + private function setImagePropertyWidth ($width) { + // Call the image class + $this->getImageInstance()->setWidth($width); + } + + /** + * Setter for image height + * + * @param $height Height of the image or variable + * @return void + */ + private function setImagePropertyHeight ($height) { + // Call the image class + $this->getImageInstance()->setHeight($height); + } + + /** + * Setter for image red color + * + * @param $red Red color value + * @return void + */ + private function setImagePropertyRed ($red) { + // Call the image class + $this->getImageInstance()->setRed($red); + } + + /** + * Setter for image green color + * + * @param $green Green color value + * @return void + */ + private function setImagePropertyGreen ($green) { + // Call the image class + $this->getImageInstance()->setGreen($green); + } + + /** + * Setter for image blue color + * + * @param $blue Blue color value + * @return void + */ + private function setImagePropertyBlue ($blue) { + // Call the image class + $this->getImageInstance()->setBlue($blue); + } + + /** + * Setter for string name (identifier) + * + * @param $stringName String name (identifier) + * @return void + */ + private function setImagePropertyStringName ($stringName) { + // Call the image class + $this->getImageInstance()->setStringName($stringName); + } + + /** + * Setter for font size + * + * @param $fontSize Size of the font + * @return void + */ + private function setImagePropertyFontSize ($fontSize) { + // Call the image class + $this->getImageInstance()->setFontSize($fontSize); + } + + /** + * Setter for image string + * + * @param $imageString Image string to set + * @return void + */ + private function setImagePropertyText ($imageString) { + // Call the image class + $this->getImageInstance()->setString($imageString); + } + + /** + * Setter for X coordinate + * + * @param $x X coordinate + * @return void + */ + private function setImagePropertyX ($x) { + // Call the image class + $this->getImageInstance()->setX($x); + } + + /** + * Setter for Y coordinate + * + * @param $y Y coordinate + * @return void + */ + private function setImagePropertyY ($y) { + // Call the image class + $this->getImageInstance()->setY($y); + } + + /** + * Getter for image cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the image cache + */ + public function getImageCacheFqfn () { + // Get the FQFN ready + $fqfn = sprintf('%s%s%s/%s.%s', + $this->getConfigInstance()->getConfigEntry('base_path'), + $this->getGenericBasePath(), + 'images/_cache', + md5( + $this->getImageInstance()->getImageName() . ':' . $this->__toString() . ':' . $this->getImageInstance()->__toString() + ), + $this->getImageInstance()->getImageType() + ); + + // Return it + return $fqfn; + } + + /** + * Outputs the image to the world + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + // Set the image instance + $responseInstance->setImageInstance($this->getImageInstance()); + } + + /** + * Load a specified image template into the engine + * + * @param $template The image template we shall load which is + * located in 'image' by default + * @return void + */ + public function loadImageTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('image_template_type')); + + // Load the special template + $this->loadTemplate($template); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/template/mail/.htaccess b/inc/main/classes/template/mail/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/template/mail/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/template/mail/class_MailTemplateEngine.php b/inc/main/classes/template/mail/class_MailTemplateEngine.php new file mode 100644 index 00000000..90ae7ccd --- /dev/null +++ b/inc/main/classes/template/mail/class_MailTemplateEngine.php @@ -0,0 +1,359 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MailTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Main nodes in the XML tree + */ + private $mainNodes = array( + 'mail-data' + ); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array( + 'subject-line', + 'sender-address', + 'recipient-address', + 'message' + ); + + /** + * Mailer instance + */ + private $mailerInstance = NULL; + + /** + * Current main node + */ + private $currMainNode = ''; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createMailTemplateEngine () { + // Get a new instance + $templateInstance = new MailTemplateEngine(); + + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Determine base path + $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; + + // Is the base path valid? + if (empty($templateBasePath)) { + // Base path is empty + throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($templateBasePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($templateBasePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($templateBasePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $templateInstance->setTemplateBasePath($templateBasePath); + + // Set template extensions + $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); + $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension')); + + // Absolute output path for compiled templates + $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->currMainNode; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + public function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = 'initEmail'; + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + //* DEBUG: */ echo "START: >".$element."<
    \n"; + if (in_array($element, $this->getMainNodes())) { + // Okay, main node found! + $methodName = 'setEmail' . self::convertToClassName($element); + } elseif (in_array($element, $this->getSubNodes())) { + // Sub node found + $methodName = 'setEmailProperty' . self::convertToClassName($element); + } elseif ($element != 'text-mail') { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + //* DEBUG: */ echo "call: ".$methodName."
    \n"; + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + public function finishElement ($resource, $nodeName) { + // Make all lower-case + $nodeName = strtolower($nodeName); + + // Does this match with current main node? + //* DEBUG: */ echo "END: >".$nodeName."<
    \n"; + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { + // Did not match! + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); + } elseif (in_array($nodeName, $this->getSubNodes())) { + // Silently ignore sub nodes + return; + } + + // Construct method name + $methodName = 'finish' . self::convertToClassName($nodeName); + + // Call the corresponding method + call_user_func_array(array($this, $methodName), array()); + } + + /** + * Adds the message text to the template engine + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Add the message now + $this->assignVariable('message', $characters); + } + + /** + * Intializes the mail + * + * @return void + * @todo Add cache creation here + */ + private function initEmail () { + // Unfinished work! + } + + /** + * Setter for mail data node + * + * @return void + * @todo Should we call back the mailer class here? + */ + private function setEmailMailData () { + // Set current main node + $this->currMainNode = 'mail-data'; + } + + /** + * Setter for sender address property + * + * @param $senderAddress Sender address to set in email + * @return void + */ + private function setEmailPropertySenderAddress ($senderAddress) { + // Set the template variable + $this->assignVariable('sender', $senderAddress); + } + + /** + * Setter for recipient address property + * + * @param $recipientAddress Recipient address to set in email + * @return void + */ + private function setEmailPropertyRecipientAddress ($recipientAddress) { + // Set the template variable + $this->assignVariable('recipient', $recipientAddress); + } + + /** + * Setter for subject line property + * + * @return void + */ + private function setEmailPropertySubjectLine () { + // Empty for now + } + + /** + * Method stub to avoid output + * + * @return void + */ + private function setEmailPropertyMessage () { + // Empty for now + } + + /** + * Gets the template variable "message", stores it back as raw template data + * and compiles all variables so the mail message got prepared for output + * + * @return void + */ + private function finishMailData () { + // Get the message and set it as new raw template data back + $message = $this->readVariable('message'); + $this->setRawTemplateData($message); + + // Get some variables to compile + //$sender = $this->compileRawCode($this->readVariable('sender')); + //$this->assignVariable('sender', $sender); + + // Then compile all variables + $this->compileVariables(); + } + + /** + * Invokes the final mail process + * + * @return void + */ + private function finishTextMail () { + $this->getMailerInstance()->invokeMailDelivery(); + } + + /** + * Getter for image cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the image cache + * @todo 0% done + */ + public function getMailCacheFqfn () { + // Initialize FQFN + $fqfn = ''; + $this->debugBackTrace('Unfinished area!'); + + // Return it + return $fqfn; + } + + /** + * Setter for mailer instance + * + * @param $mailerInstance A mailer instance + * @return void + */ + public final function setMailerInstance (DeliverableMail $mailerInstance) { + $this->mailerInstance = $mailerInstance; + } + + /** + * Getter for mailer instance + * + * @return $mailerInstance A mailer instance + */ + protected final function getMailerInstance () { + return $this->mailerInstance; + } + + /** + * Outputs the mail to the world. This should only the mailer debug class do! + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + public function transferToResponse (Responseable $responseInstance) { + $responseInstance->writeToBody($this->getCompiledData()); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/template/menu/.htaccess b/inc/main/classes/template/menu/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/template/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/template/menu/class_MenuTemplateEngine.php b/inc/main/classes/template/menu/class_MenuTemplateEngine.php new file mode 100644 index 00000000..f0237b1e --- /dev/null +++ b/inc/main/classes/template/menu/class_MenuTemplateEngine.php @@ -0,0 +1,877 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTemplate { + /** + * Main nodes in the XML tree ('menu' is ignored) + */ + private $mainNodes = array( + 'block-list', + ); + + /** + * Sub nodes in the XML tree + */ + private $subNodes = array( + 'entry-list', + 'entry', + 'entry-id', + 'entries-content', + 'block-header', + 'block-footer', + 'footer-id', + 'footer-class', + 'footer-text', + 'block', + 'title', + 'title-id', + 'title-class', + 'title-text', + 'design', + 'text', + 'advert', + 'anchor', + 'anchor-id', + 'anchor-text', + 'anchor-title', + 'anchor-href', + ); + + /** + * Variables for a menu entry + */ + private $menuEntryVariables = array( + // List entry + 'entry_id', + // Anchor + 'anchor-id', + 'anchor-text', + 'anchor-title', + 'anchor-href', + ); + + /** + * Variables for a menu block + */ + private $menuBlockVariables = array( + // Title + 'title_id', + 'title_class', + 'title_text', + // Content is taken from menuEntries + // Footer + 'footer_id', + 'footer_class', + 'footer_text', + ); + + /** + * Rendered menu entries + */ + private $menuEntries = array(); + + /** + * Rendered menu blocks + */ + private $menuBlocks = array(); + + /** + * Menu instance + */ + private $menuInstance = NULL; + + /** + * Current main node + */ + private $curr = array(); + + /** + * Content from dependency + */ + private $dependencyContent = array(); + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @param $menuInstance A RenderableMenu instance + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createMenuTemplateEngine (RenderableMenu $menuInstance) { + // Get a new instance + $templateInstance = new MenuTemplateEngine(); + + // Get the application instance from registry + $applicationInstance = Registry::getRegistry()->getInstance('app'); + + // Determine base path + $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; + + // Is the base path valid? + if (empty($templateBasePath)) { + // Base path is empty + throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING); + } elseif (!is_string($templateBasePath)) { + // Is not a string + throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING); + } elseif (!is_dir($templateBasePath)) { + // Is not a path + throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME); + } elseif (!is_readable($templateBasePath)) { + // Is not readable + throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH); + } + + // Set the base path + $templateInstance->setTemplateBasePath($templateBasePath); + + // Set template extensions + $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension')); + $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('menu_template_extension')); + + // Absolute output path for compiled templates + $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path')); + + // Set the menu instance + $templateInstance->setMenuInstance($menuInstance); + + // Init a variable stacker + $stackInstance = ObjectFactory::createObjectByConfiguredName('menu_stacker_class'); + + // Set it + $templateInstance->setStackInstance($stackInstance); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Load a specified menu template into the engine + * + * @param $template The menu template we shall load which is + * located in 'menu' by default + * @return void + */ + public function loadMenuTemplate ($template) { + // Set template type + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('menu_template_type')); + + // Load the special template + $this->loadTemplate($template); + } + + /** + * Getter for current main node + * + * @return $currMainNode Current main node + */ + public final function getCurrMainNode () { + return $this->curr['main_node']; + } + + /** + * Setter for current main node + * + * @param $element Element name to set as current main node + * @return $currMainNode Current main node + */ + private final function setCurrMainNode ($element) { + $this->curr['main_node'] = (string) $element; + } + + /** + * Getter for main node array + * + * @return $mainNodes Array with valid main node names + */ + public final function getMainNodes () { + return $this->mainNodes; + } + + /** + * Getter for sub node array + * + * @return $subNodes Array with valid sub node names + */ + public final function getSubNodes () { + return $this->subNodes; + } + + /** + * Handles the start element of an XML resource + * + * @param $resource XML parser resource (currently ignored) + * @param $element The element we shall handle + * @param $attributes All attributes + * @return void + * @throws InvalidXmlNodeException If an unknown/invalid XML node name was found + */ + public function startElement ($resource, $element, array $attributes) { + // Initial method name which will never be called... + $methodName = 'initMenu'; + + // Make the element name lower-case + $element = strtolower($element); + + // Is the element a main node? + //* DEBUG: */ echo "START: >".$element."<
    \n"; + if (in_array($element, $this->getMainNodes())) { + // Okay, main node found! + $methodName = 'start' . self::convertToClassName($element); + + // Set it + $this->setCurrMainNode($element); + } elseif (in_array($element, $this->getSubNodes())) { + // Sub node found + $methodName = 'start' . self::convertToClassName($element); + } elseif ($element != 'menu') { + // Invalid node name found + throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN); + } + + // Call method + //* DEBUG: */ echo "call: ".$methodName."
    \n"; + call_user_func_array(array($this, $methodName), $attributes); + } + + /** + * Ends the main or sub node by sending out the gathered data + * + * @param $resource An XML resource pointer (currently ignored) + * @param $nodeName Name of the node we want to finish + * @return void + * @throws XmlNodeMismatchException If current main node mismatches the closing one + */ + public function finishElement ($resource, $nodeName) { + // Make all lower-case + $nodeName = strtolower($nodeName); + + // Does this match with current main node? + //* DEBUG: */ echo "END: >".$nodeName."<
    \n"; + if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) { + // Did not match! + throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH); + } // END - if + + // Construct method name + $methodName = 'finish' . self::convertToClassName($nodeName); + + // Call the corresponding method + //* DEBUG: */ echo "call: ".$methodName."
    \n"; + call_user_func_array(array($this, $methodName), array()); + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + * @todo Find something useful with this! + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return; + } // END - if + + // Assign the found characters to variable and use the last entry from + // stack as the name + parent::assignVariable($this->getStackInstance()->getNamed('current_node'), $characters); + } + + /** + * Handles the template dependency for given node + * + * @param $node The node we should load a dependency template + * @param $templateDependency A template to load to satisfy dependencies + * @return void + */ + private function handleTemplateDependency ($node, $templateDependency) { + // Is the template dependency set? + if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) { + // Get a temporay menu template instance + $templateInstance = ObjectFactory::createObjectByConfiguredName('menu_template_class', array($this->getMenuInstance())); + + // Then load it + $templateInstance->loadMenuTemplate($templateDependency); + + // Parse the XML content + $templateInstance->renderXmlContent(); + + // Save the parsed raw content in our dependency array + $this->dependencyContent[$node] = $templateInstance->getRawTemplateData(); + } // END - if + } + + /** + * Intializes the menu + * + * @param $templateDependency A template to load to satisfy dependencies + * @return void + * @todo Add cache creation here + */ + private function initMenu ($templateDependency = '') { + // Get web template engine + $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array($this->getApplicationInstance()))); + + // Handle the dependency template + $this->handleTemplateDependency('menu', $templateDependency); + + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'menu'); + } + + /** + * Starts the menu entries + * + * @param $templateDependency A template to load to satisfy dependencies + * @return void + */ + private function startEntryList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'entry-list'); + } + + /** + * Starts the menu block header + * + * @return void + */ + private function startBlockHeader () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'block-header'); + } + + /** + * Starts the menu block footer + * + * @return void + */ + private function startBlockFooter () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'block-footer'); + } + + /** + * Starts the menu property 'block-list' + * + * @return void + */ + private function startBlockList () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'block-list'); + } + + /** + * Starts the menu property 'block' + * + * @return void + */ + private function startBlock () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'block'); + } + + /** + * Starts the menu property 'title' + * + * @return void + */ + private function startTitle () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'title'); + } + + /** + * Starts the menu property 'title-id' + * + * @return void + */ + private function startTitleId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'title-id'); + } + + /** + * Starts the menu property 'title-class' + * + * @return void + */ + private function startTitleClass () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'title-class'); + } + + /** + * Starts the menu property 'title-text' + * + * @return void + */ + private function startTitleText () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'title-text'); + } + + /** + * Starts the menu property 'entry' + * + * @return void + */ + private function startEntry () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'entry'); + } + + /** + * Starts the menu property 'entry-id' + * + * @return void + */ + private function startEntryId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'entry-id'); + } + + /** + * Starts the menu property 'anchor' + * + * @return void + */ + private function startAnchor () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'anchor'); + } + + /** + * Starts the menu property 'anchor-id' + * + * @return void + */ + private function startAnchorId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'anchor-id'); + } + + /** + * Starts the menu property 'anchor-text' + * + * @return void + */ + private function startAnchorText () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'anchor-text'); + } + + /** + * Starts the menu property 'anchor-title' + * + * @return void + */ + private function startAnchorTitle () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'anchor-title'); + } + + /** + * Starts the menu property 'anchor-href' + * + * @return void + */ + private function startAnchorHref () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'anchor-href'); + } + + /** + * Starts the menu property 'footer-id' + * + * @return void + */ + private function startFooterId () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'footer-id'); + } + + /** + * Starts the menu property 'footer-class' + * + * @return void + */ + private function startFooterClass () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'footer-class'); + } + + /** + * Starts the menu property 'footer-text' + * + * @return void + */ + private function startFooterText () { + // Push the node name on the stacker + $this->getStackInstance()->pushNamed('current_node', 'footer-text'); + } + + /** + * Finishes the title node by added another template to the menu + * + * @return void + */ + private function finishTitle () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the title-id node by + * + * @return void + */ + private function finishTitleId () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the title-class node + * + * @return void + */ + private function finishTitleClass () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the title-class node + * + * @return void + */ + private function finishTitleText () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the footer-text node + * + * @return void + */ + private function finishFooterText () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the footer-class node + * + * @return void + */ + private function finishFooterClass () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the footer-id node + * + * @return void + */ + private function finishFooterId () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the anchor-href node + * + * @return void + */ + private function finishAnchorHref () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the anchor-title node + * + * @return void + */ + private function finishAnchorTitle () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the anchor-text node + * + * @return void + */ + private function finishAnchorText () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the anchor-id node + * + * @return void + */ + private function finishAnchorId () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the anchor node + * + * @return void + */ + private function finishAnchor () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the entry-id node + * + * @return void + */ + private function finishEntryId () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the entry node + * + * @return void + */ + private function finishEntry () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + + // Render this menu entry + $this->renderMenuEntry(); + } + + /** + * Finishes the block node + * + * @return void + */ + private function finishBlock () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + + // Render this menu block + $this->renderMenuBlock(); + } + + /** + * Finishes the block-list node + * + * @return void + */ + private function finishBlockList () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the menu entries + * + * @return void + */ + private function finishEntryList () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the menu block header + * + * @return void + */ + private function finishBlockHeader () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the menu block footer + * + * @return void + */ + private function finishBlockFooter () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Finishes the menu + * + * @return void + */ + private function finishMenu () { + // Pop the last entry + $this->getStackInstance()->popNamed('current_node'); + } + + /** + * Renders this menu entry, as every block all variables got overwritten + * with data from next entry. + * + * @return void + */ + private function renderMenuEntry () { + // Prepare template engine + $templateInstance = $this->prepareTemplateInstance(); + + // Load menu entry template + $templateInstance->loadCodeTemplate('menu_entry'); + + // Copy all variables over to it + foreach ($this->menuEntryVariables as $variableName) { + // Copy variable + $variableValue = $this->readVariable($variableName); + + // Is the key 'anchor-href'? + if ($variableName == 'anchor-href') { + // Expand variable with URL then + $variableValue = '{?base_url?}/' . $variableValue; + } // END - if + + // ... into the instance + $templateInstance->assignVariable($variableName, $variableValue); + } // END - foreach + + // Compile template + variables + $templateInstance->compileTemplate(); + $templateInstance->compileVariables(); + + // Remember it here + $this->menuEntries[$this->readVariable('entry_id')] = $templateInstance->getRawTemplateData(); + } + + /** + * Renders this menu block, as next block all data is overwritten with + * next block. + * + * @return void + */ + private function renderMenuBlock () { + // Init block content + $blockContent = implode('', $this->menuEntries); + + // Prepare template engine + $templateInstance = $this->prepareTemplateInstance(); + + // Load menu entry template + $templateInstance->loadCodeTemplate('menu_block'); + + // Copy all variables over to it + foreach ($this->menuBlockVariables as $variableName) { + // Copy variable + $variableValue = $this->readVariable($variableName); + + // ... into the instance + $templateInstance->assignVariable($variableName, $variableValue); + } // END - foreach + + // Assign block content + $templateInstance->assignVariable('block_content', $blockContent); + + // Compile template + variables + $templateInstance->compileTemplate(); + $templateInstance->compileVariables(); + + // Remember it here + array_push($this->menuBlocks, $templateInstance->getRawTemplateData()); + + // Reset rendered menu entries array + $this->menuEntries = array(); + } + + /** + * "Getter" for menu content + * + * @return $menuContent Returned menu content + */ + public function getMenuContent () { + // Implode menuBlocks + $menuContent = implode('', $this->menuBlocks); + + // Clean variable + $this->menuBlocks = array(); + + // And return it + return $menuContent; + } + + /** + * Getter for menu cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + // Get the FQFN ready + $fqfn = sprintf('%s%s%s/%s.%s', + $this->getConfigInstance()->getConfigEntry('base_path'), + $this->getGenericBasePath(), + 'menus/_cache', + md5( + $this->getMenuInstance()->getMenuName() . ':' . + $this->__toString() . ':' . + $this->getMenuInstance()->__toString() + ), + $this->getMenuInstance()->getMenuType() + ); + + // Return it + return $fqfn; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/user/.htaccess b/inc/main/classes/user/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/user/class_BaseUser.php b/inc/main/classes/user/class_BaseUser.php new file mode 100644 index 00000000..bc7988a4 --- /dev/null +++ b/inc/main/classes/user/class_BaseUser.php @@ -0,0 +1,363 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseUser extends BaseFrameworkSystem implements Updateable { + // Exception constances + const EXCEPTION_USERNAME_NOT_FOUND = 0x150; + const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151; + const EXCEPTION_USER_PASS_MISMATCH = 0x152; + const EXCEPTION_USER_IS_GUEST = 0x153; + + /** + * Username of current user + */ + private $userName = ''; + + /** + * User id of current user + */ + private $userId = 0; + + /** + * Email of current user + */ + private $email = ''; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for username + * + * @param $userName The username to set + * @return void + */ + public final function setUserName ($userName) { + $this->userName = (string) $userName; + } + + /** + * Getter for username + * + * @return $userName The username to get + */ + public final function getUserName () { + return $this->userName; + } + + /** + * Setter for user id + * + * @param $userId The user id to set + * @return void + * @todo Find a way of casting here. "(int)" might destroy the user id > 32766 + */ + public final function setUserId ($userId) { + $this->userId = $userId; + } + + /** + * Getter for user id + * + * @return $userId The user id to get + */ + public final function getUserId () { + return $this->userId; + } + + /** + * Setter for email + * + * @param $email The email to set + * @return void + */ + protected final function setEmail ($email) { + $this->email = (string) $email; + } + + /** + * Getter for email + * + * @return $email The email to get + */ + public final function getEmail () { + return $this->email; + } + + /** + * Determines whether the username exists or not + * + * @return $exists Whether the username exists + */ + public function ifUsernameExists () { + // By default the username does not exist + $exists = FALSE; + + // Is a previous result there? + if (!$this->getResultInstance() instanceof SearchableResult) { + // Get a UserDatabaseWrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Create a search criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the username as a criteria and set limit to one entry + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->setLimit(1); + + // Get a search result + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Set the index "solver" + $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + + // And finally set it + $this->setResultInstance($resultInstance); + } // END - if + + // Rewind it + $this->getResultInstance()->rewind(); + + // Search for it + if ($this->getResultInstance()->next()) { + // Entry found + $exists = TRUE; + } // END - if + + // Return the status + return $exists; + } + + /** + * Determines whether the email exists or not + * + * @return $exists Whether the email exists + */ + public function ifEmailAddressExists () { + // By default the email does not exist + $exists = FALSE; + + // Is a previous result there? + if (!$this->getResultInstance() instanceof SearchableResult) { + // Get a UserDatabaseWrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Create a search criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the username as a criteria and set limit to one entry + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail()); + $criteriaInstance->setLimit(1); + + // Get a search result + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Set the index "solver" + $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + + // And finally set it + $this->setResultInstance($resultInstance); + } // END - if + + // Rewind it + $this->getResultInstance()->rewind(); + + // Search for it + if ($this->getResultInstance()->next()) { + // Entry found + $exists = TRUE; + + // Is the username set? + if ($this->getUserName() == '') { + // Get current entry + $currEntry = $this->getResultInstance()->current(); + + // Set the username + $this->setUserName($currEntry['username']); + } // END - if + } // END - if + + // Return the status + return $exists; + } + + /** + * Checks if supplied password hash in request matches with the stored in + * database. + * + * @param $requestInstance A requestable class instance + * @return $matches Whether the supplied password hash matches + */ + public function ifPasswordHashMatches (Requestable $requestInstance) { + // By default nothing matches... ;) + $matches = FALSE; + + // Is a previous result there? + if ((!$this->getResultInstance() instanceof SearchableResult) || ($this->getResultInstance()->count() == 0)) { + // Get a UserDatabaseWrapper instance + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Create a search criteria + $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add the username as a criteria and set limit to one entry + $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $criteriaInstance->setLimit(1); + + // Get a search result + $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance); + + // Set the index "solver" + $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId')); + + // And finally set it + $this->setResultInstance($resultInstance); + } // END - if + + // Rewind it and advance to first entry + $this->getResultInstance()->rewind(); + + // This call set the result instance to a clean state + $this->getResultInstance()->next(); + + // Search for it + if ($this->getResultInstance()->find('pass_hash')) { + // So does the hashes match? + //* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash') . '
    ' . $this->getResultInstance()->getFoundValue() . '
    '; + $matches = ($requestInstance->getRequestElement('pass_hash') === $this->getResultInstance()->getFoundValue()); + } // END - if + + // Return the status + return $matches; + } + + /** + * "Getter" for user's password hash + * + * @return $passHash User's password hash from database result + */ + public final function getPasswordHash () { + // Default is missing password hash + $passHash = NULL; + + // Get a database entry + $entry = $this->getDatabaseEntry(); + + // Is the password hash there? + if (isset($entry['pass_hash'])) { + // Get it + $passHash = $entry['pass_hash']; + } // END - if + + // And return the hash + return $passHash; + } + + /** + * Getter for primary key value + * + * @return $primaryValue Value of the primary key based on database type + */ + public final function getPrimaryKey () { + // Get a user database wrapper + $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class'); + + // Get the primary key back from the wrapper + $primaryKey = $wrapperInstance->getPrimaryKeyValue(); + + // Get that field + $primaryValue = $this->getField($primaryKey); + + // Return the value + return $primaryValue; + } + + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem + */ + public function updateDatabaseField ($fieldName, $fieldValue) { + // Get a critieria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add search criteria + $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $searchInstance->setLimit(1); + + // Now get another criteria + $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); + + // Add criteria entry which we shall update + $updateInstance->addCriteria($fieldName, $fieldValue); + + // Add the search criteria for searching for the right entry + $updateInstance->setSearchInstance($searchInstance); + + // Set wrapper class name + $updateInstance->setWrapperConfigEntry('user_db_wrapper_class'); + + // Remember the update in database result + $this->getResultInstance()->add2UpdateQueue($updateInstance); + } + + /** + * Checks whether the user status is 'confirmed' + * + * @return $isConfirmed Whether the user status is 'confirmed' + */ + public function isConfirmed () { + // Determine it + $isConfirmed = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == $this->getConfigInstance()->getConfigEntry('user_status_confirmed')); + + // Return it + return $isConfirmed; + } + + /** + * Checks whether the user status is 'guest' + * + * @return $isGuest Whether the user status is 'guest' + */ + public function isGuest () { + // Determine it + $isGuest = ($this->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) == $this->getConfigInstance()->getConfigEntry('user_status_guest')); + + // Return it + return $isGuest; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/user/guest/.htaccess b/inc/main/classes/user/guest/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/user/guest/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/user/guest/class_Guest.php b/inc/main/classes/user/guest/class_Guest.php new file mode 100644 index 00000000..6fdefc7f --- /dev/null +++ b/inc/main/classes/user/guest/class_Guest.php @@ -0,0 +1,138 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Guest extends BaseUser implements ManageableGuest, Registerable { + // Exceptions + const EXCEPTION_USERNAME_NOT_FOUND = 0x170; + const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171; + const EXCEPTION_USER_PASS_MISMATCH = 0x172; + const EXCEPTION_USER_NOT_GUEST = 0x173; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates a user by a given request instance + * + * @param $requestInstance An instance of a Requestable class + * @return $userInstance An instance of this user class + * @todo Add more ways over creating user classes + */ + public static final function createGuestByRequest (Requestable $requestInstance) { + // Determine if by email or username + if (!is_null($requestInstance->getRequestElement('username'))) { + // Username supplied + $userInstance = self::createGuestByUserName($requestInstance->getRequestElement('username')); + } elseif (!is_null($requestInstance->getRequestElement('email'))) { + // Email supplied + $userInstance = self::createGuestByEmail($requestInstance->getRequestElement('email')); + } else { + // Unsupported mode + $userInstance = new Guest(); + $userInstance->debugBackTrace('More ways of creating user classes are needed here.'); + exit(); + } + + // Return the prepared instance + return $userInstance; + } + + /** + * Creates an instance of this user class by a provided username. This + * factory method will check if username is already taken and if not so it + * will throw an exception. + * + * @param $userName Username we need a class instance for + * @return $userInstance An instance of this user class + * @throws UsernameMissingException If the username does not exist + * @throws UserNoGuestException If the user is no guest account + */ + public static final function createGuestByUsername ($userName) { + // Get a new instance + $userInstance = new Guest(); + + // Set the username + $userInstance->setUserName($userName); + + // Check if username exists + if ($userInstance->ifUsernameExists() === FALSE) { + // Throw an exception here + throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); + } elseif ($userInstance->isGuest() === FALSE) { + // Sanity check on 'guest' status failed + throw new UserNoGuestException(array($userInstance, $userName), self::EXCEPTION_USER_NOT_GUEST_STATUS); + } + + // Return the instance + return $userInstance; + } + + /** + * Creates an instance of this user class by a provided email address. This + * factory method will not check if email address is there. + * + * @param $email Email address of the user + * @return $userInstance An instance of this user class + */ + public static final function createGuestByEmail ($email) { + // Get a new instance + $userInstance = new Guest(); + + // Set the username + $userInstance->setEmail($email); + + // Return the instance + return $userInstance; + } + + /** + * Updates the last activity timestamp and last performed action in the + * database result. You should call flushPendingUpdates() to flush these updates + * to the database layer. + * + * @param $requestInstance A requestable class instance + * @return void + */ + public function updateLastActivity (Requestable $requestInstance) { + // No activity will be logged for guest accounts + } + + /** + * Flushs all pending updates to the database layer + * + * @return void + */ + public function flushPendingUpdates () { + // No updates will be flushed to database! + } +} + +// [EOF] +?> diff --git a/inc/main/classes/user/member/.htaccess b/inc/main/classes/user/member/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/user/member/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/user/member/class_Member.php b/inc/main/classes/user/member/class_Member.php new file mode 100644 index 00000000..1e4a9696 --- /dev/null +++ b/inc/main/classes/user/member/class_Member.php @@ -0,0 +1,152 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Member extends BaseUser implements ManageableMember, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this user class by a provided username. This + * factory method will check if username is already taken and if not so it + * will throw an exception. + * + * @param $userName Username we need a class instance for + * @return $userInstance An instance of this user class + * @throws UsernameMissingException If the username does not exist + * @throws UnexpectedGuestAccountException If the user status is 'guest' + */ + public static final function createMemberByUsername ($userName) { + // Get a new instance + $userInstance = new Member(); + + // Set the username + $userInstance->setUserName($userName); + + // Check if username exists + if ($userInstance->ifUsernameExists() === FALSE) { + // Throw an exception here + throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND); + } elseif ($userInstance->isGuest() === TRUE) { + // User should not be a guest here + throw new UnexpectedGuestAccountException(array($userInstance, $userName), self::EXCEPTION_USER_IS_GUEST); + } + + // Return the instance + return $userInstance; + } + + /** + * Creates an instance of this user class by a provided email address. This + * factory method will not check if email address is there. + * + * @param $email Email address of the user + * @return $userInstance An instance of this user class + */ + public static final function createMemberByEmail ($email) { + // Get a new instance + $userInstance = new Member(); + + // Set the username + $userInstance->setEmail($email); + + // Return the instance + return $userInstance; + } + + /** + * Creates a user by a given request instance + * + * @param $requestInstance An instance of a Requestable class + * @return $userInstance An instance of this user class + * @todo Add more ways over creating user classes + */ + public static final function createMemberByRequest (Requestable $requestInstance) { + // Determine if by email or username + if (!is_null($requestInstance->getRequestElement('username'))) { + // Username supplied + $userInstance = self::createMemberByUserName($requestInstance->getRequestElement('username')); + } elseif (!is_null($requestInstance->getRequestElement('email'))) { + // Email supplied + $userInstance = self::createMemberByEmail($requestInstance->getRequestElement('email')); + } else { + // Unsupported mode + $userInstance = new Member(); + $userInstance->debugBackTrace('More ways of creating user classes are needed here.'); + exit(); + } + + // Return the prepared instance + return $userInstance; + } + + /** + * Updates the last activity timestamp and last performed action in the + * database result. You should call flushPendingUpdates() to flush these updates + * to the database layer. + * + * @param $requestInstance A requestable class instance + * @return void + */ + public function updateLastActivity (Requestable $requestInstance) { + // Set last action + $lastAction = $requestInstance->getRequestElement('action'); + + // If there is no action use the default on + if (is_null($lastAction)) { + $lastAction = $this->getConfigInstance()->getConfigEntry('login_default_action'); + } // END - if + + // Get a critieria instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add search criteria + $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName()); + $searchInstance->setLimit(1); + + // Now get another criteria + $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class'); + + // And add our both entries + $updateInstance->addCriteria('last_activity', date('Y-m-d H:i:s', time())); + $updateInstance->addCriteria('last_action', $lastAction); + + // Add the search criteria for searching for the right entry + $updateInstance->setSearchInstance($searchInstance); + + // Set wrapper class name + $updateInstance->setWrapperConfigEntry('user_db_wrapper_class'); + + // Remember the update in database result + $this->getResultInstance()->add2UpdateQueue($updateInstance); + } +} + +// [EOF] +?> diff --git a/inc/main/classes/visitor/.htaccess b/inc/main/classes/visitor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/visitor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/visitor/class_ b/inc/main/classes/visitor/class_ new file mode 100644 index 00000000..e1ccf277 --- /dev/null +++ b/inc/main/classes/visitor/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Visitor extends BaseVisitor implements Visitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('!!!'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function create???Visitor () { + // Get new instance + $visitorInstance = new ???Visitor(); + + // Return the prepared instance + return $visitorInstance; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/visitor/class_BaseVisitor.php b/inc/main/classes/visitor/class_BaseVisitor.php new file mode 100644 index 00000000..185588fd --- /dev/null +++ b/inc/main/classes/visitor/class_BaseVisitor.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseVisitor extends BaseFrameworkSystem { + /** + * Mode of the visitor (the first word of the concrete class' name) + */ + private $visitorMode = 'invalid'; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for visitor mode + * + * @param $visitorMode New visitor mode to set + * @return void + */ + protected final function setVisitorMode ($visitorMode) { + $this->visitorMode = (string) $visitorMode; + } + + /** + * Getter for visitor mode + * + * @return $visitorMode New visitor mode to set + */ + public final function getVisitorMode () { + return $this->visitorMode; + } +} + +// [EOF] +?> diff --git a/inc/main/classes/visitor/tasks/.htaccess b/inc/main/classes/visitor/tasks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/visitor/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/classes/visitor/tasks/class_ActiveTaskVisitor.php b/inc/main/classes/visitor/tasks/class_ActiveTaskVisitor.php new file mode 100644 index 00000000..ec348674 --- /dev/null +++ b/inc/main/classes/visitor/tasks/class_ActiveTaskVisitor.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('task'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public static final function createActiveTaskVisitor () { + // Get new instance + $visitorInstance = new ActiveTaskVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given task instance + * + * @param $taskInstance A Taskable instance + * @return void + */ + public function visitTask (Taskable $taskInstance) { + // Execute the task from this visitor + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting task ' . $taskInstance->__toString() . ' - CALLED!'); + $taskInstance->executeTask(); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting task ' . $taskInstance->__toString() . ' - EXIT!'); + } + + /** + * Pool visitor method for active tasks + * + * @param $poolInstance A Poolable instance + * @return void + */ + public function visitPool (Poolable $poolInstance) { + /** + * We don't need to visit a pool as an active task because a pool can + * never become a task. Instead e.g. by a listener pool we should visit + * all listeners one by one + */ + } + + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + public function visitListener (Listenable $listenerInstance) { + // Do "listen" here + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - CALLED!'); + $listenerInstance->doListen(); + //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ' ]: Visiting ' . $listenerInstance->__toString() . ' - FINISH'); + } + + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A decorator instance + * @return void + */ + public function visitDecorator (BaseDecorator $decoratorInstance) { + // A decorator itself can never become an active task so this method + // remains empty. + } +} + +// [EOF] +?> diff --git a/inc/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php b/inc/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php new file mode 100644 index 00000000..4fc037e3 --- /dev/null +++ b/inc/main/classes/visitor/tasks/class_ShutdownTaskVisitor.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ShutdownTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('task'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public static final function createShutdownTaskVisitor () { + // Get new instance + $visitorInstance = new ShutdownTaskVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given task instance + * + * @param $taskInstance A Taskable instance + * @return void + */ + public function visitTask (Taskable $taskInstance) { + // Shutdown the task instance + $taskInstance->doShutdown(); + } + + /** + * Pool visitor method for active tasks + * + * @param $poolInstance A Poolable instance + * @return void + */ + public function visitPool (Poolable $poolInstance) { + // Shutdown the pool instance + $poolInstance->doShutdown(); + } + + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + public function visitListener (Listenable $listenerInstance) { + // Shutdown the listener instance + $listenerInstance->doShutdown(); + } + + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A decorator instance + * @return void + */ + public function visitDecorator (BaseDecorator $decoratorInstance) { + // Shutdown the decorator instance + $decoratorInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/.htaccess b/inc/main/exceptions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/actions/.htaccess b/inc/main/exceptions/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/actions/class_InvalidActionException.php b/inc/main/exceptions/actions/class_InvalidActionException.php new file mode 100644 index 00000000..dcb79f50 --- /dev/null +++ b/inc/main/exceptions/actions/class_InvalidActionException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidActionException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray An array with message parts + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code) { + // Prepare the message + $message = sprintf('[%s:%d] Cannot resolve action %s (%s).', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getClassName() + ); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/auth/.htaccess b/inc/main/exceptions/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/auth/class_UserAuthorizationException.php b/inc/main/exceptions/auth/class_UserAuthorizationException.php new file mode 100644 index 00000000..dfb06e10 --- /dev/null +++ b/inc/main/exceptions/auth/class_UserAuthorizationException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserAuthorizationException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $filterInstance An instance of the filter throwing this exception + * @param $code Error code + * @return void + */ + public function __construct (Filterable $filterInstance, $code) { + // Construct the message + $message = sprintf('[%s:%d] Authorization has failed. Error code %s', + $filterInstance->__toString(), + $this->getLine(), + $this->getHexCode($code) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/base64/.htaccess b/inc/main/exceptions/base64/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/base64/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/base64/class_Base64EncodingBadException.php b/inc/main/exceptions/base64/class_Base64EncodingBadException.php new file mode 100644 index 00000000..a0f2fb71 --- /dev/null +++ b/inc/main/exceptions/base64/class_Base64EncodingBadException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Base64EncodingBadException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Raw data %s contains invalid characters for BASE64-encoding.', + $messageArray[0]->__toString(), + $this->getLine(), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/base64/class_Base64EncodingModuloException.php b/inc/main/exceptions/base64/class_Base64EncodingModuloException.php new file mode 100644 index 00000000..39531410 --- /dev/null +++ b/inc/main/exceptions/base64/class_Base64EncodingModuloException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Base64EncodingModuloException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Data length %s modulo 4 is not zero: data=%s', + $messageArray[0]->__toString(), + $this->getLine(), + strlen($messageArray[1]), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/class_ b/inc/main/exceptions/class_ new file mode 100644 index 00000000..156e7c9e --- /dev/null +++ b/inc/main/exceptions/class_ @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Exception extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct ($message, $code) { + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/class_FrameworkException.php b/inc/main/exceptions/class_FrameworkException.php new file mode 100644 index 00000000..8862e934 --- /dev/null +++ b/inc/main/exceptions/class_FrameworkException.php @@ -0,0 +1,207 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class FrameworkException extends ReflectionException { + /** + * Array for the backtrace + */ + private $backTrace = array(); + + /** + * Extra data + */ + private $extraData = ''; + + /** + * The super constructor for all exceptions + * + * @param $message The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct ($message, $code = 0) { + // Make sure everything is assigned properly + parent::__construct($message, $code); + + // Extract backtrace + $this->saveBackTrace(); + + // Cast all data + $message = (string) $message; + $code = (int) $code; + + // In emergency exit? + if (defined('EMERGENCY_EXIT_CALLED')) { + // Output message + printf("[%s:] Message: %s, Backtrace:
    %s
    ", + $this->__toString(), + $message, + $this->getPrintableBackTrace() + ); + + // End here + exit(); + } // END - if + + // Should we log exceptions? (bad implementation) + if (defined('LOG_EXCEPTIONS')) { + // Log the error + error_log(sprintf("[%s:] %s (%s)", + $this->__toString(), + $message, + $this->getHexCode() + )); + } // END - if + } + + /** + * Save the current backtrace + * + * @return void + */ + private final function saveBackTrace () { + // Get full backtrace + $this->backTrace = debug_backtrace(); + + // Remove this call + $dummy = array_shift($this->backTrace); + + // resort the array + ksort($this->backTrace); + } + + /** + * Get saved backtrace + * + * @return $backTrace The full backtrace in an array + */ + public final function getBackTrace () { + return $this->backTrace; + } + + /** + * Getter for printable backtrace + * + * @return $backTrace Backtrace for web pages + */ + public final function getPrintableBackTrace () { + // Get the backtrace + $dbgTrace = $this->getBackTrace(); + + // Taken from de.php.net user comments + $dbgMsg = "
    \nDebug backtrace begin:
    \n"; + foreach ($dbgTrace as $dbgIndex => $dbgInfo) { + // No info by default + $info = 'NULL'; + + // Are there arguments? + if ((isset($dbgInfo['args'])) && (is_array($dbgInfo['args'])) && (isset($dbgInfo['args'][0]))) { + //* DEBUG: */ echo $dbgIndex.":
    ".htmlentities(print_r($dbgInfo['args'], TRUE))."
    "; + $info = ''; + foreach ($dbgInfo['args'] as $debug) { + // Add only non-array elements + if (!is_array($debug)) { + $info .= $debug . ', '; + } // END - if + } // END - foreach + + // Remove last chars (commata, space) + $info = substr($info, 0, -2); + } // END - if + + // Prepare argument infos + $info = '' . $info . ''; + + // File detection + $file = 'Unknown file'; + if (isset($dbgInfo['file'])) { + $file = basename($dbgInfo['file']); + } // END - if + + // Line detection + $line = 'Unknown line'; + if (isset($dbgInfo['line'])) { + $line = 'line ' . $dbgInfo['line']; + } // END - if + + // The message + $dbgMsg .= "\t at ".$dbgIndex." ".$file." (".$line.") -> ".$dbgInfo['function'].'('.$info.")
    \n"; + } // END - if + + // Add end-message + $dbgMsg .= "Debug backtrace end
    \n"; + + // Return full debug message + return $dbgMsg; + } + + /** + * Returns the name of the thrown exception + * + * @return $toString The name of the thrown exception + */ + public function __toString() { + return get_class($this); + } + + /** + * Getter for hex-decimal code + * + * @param $code Integer code to encode in hex + * @return $hexCode The exception code in hex-decimal format + */ + public final function getHexCode ($code = NULL) { + // Get the decimal code + if (is_null($code)) $code = $this->getCode(); + + // Format it to hex-decimal, 0x as prefix and 3 chars + $hexCode = sprintf("0x%03s", dechex($code)); + + // Return it + return $hexCode; + } + + /** + * Setter for extra data + * + * @param $extraData Extra data to store + * @return void + */ + protected final function setExtraData ($extraData) { + $this->extraData = $extraData; + } + + /** + * Getter for extra data + * + * @return $extraData Extra data to store + */ + public final function getExtraData () { + return $this->extraData; + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/compressor/.htaccess b/inc/main/exceptions/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/compressor/class_MismatchingCompressorsException.php b/inc/main/exceptions/compressor/class_MismatchingCompressorsException.php new file mode 100644 index 00000000..d089c28d --- /dev/null +++ b/inc/main/exceptions/compressor/class_MismatchingCompressorsException.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MismatchingCompressorsException extends FrameworkException { + /** + * The constructor + * + * @param $array Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $array, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Der Kompressor %s zu den geladenen Daten aus %s und der aktuell verwendete Kompressor %s stimmen nicht überein!', + $array[0]->__toString(), + $this->getLine(), + strtoupper($array[1]), + sprintf('%s:%s', + basename(dirname($array[2])), + basename($array[2]) + ), + strtoupper($array[3]) + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/config/.htaccess b/inc/main/exceptions/config/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/config/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/config/class_ConfigEntryIsEmptyException.php b/inc/main/exceptions/config/class_ConfigEntryIsEmptyException.php new file mode 100644 index 00000000..862e0fbb --- /dev/null +++ b/inc/main/exceptions/config/class_ConfigEntryIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfigEntryIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkConfiguration $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Empty configuration entry provided.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/config/class_ConfigValueTypeUnsupportedException.php b/inc/main/exceptions/config/class_ConfigValueTypeUnsupportedException.php new file mode 100644 index 00000000..b39fc811 --- /dev/null +++ b/inc/main/exceptions/config/class_ConfigValueTypeUnsupportedException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConfigValueTypeUnsupportedException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Message data array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Configuration key %s has unspported value type %s.', + $messageArray[0]->__toString(), + $this->getLine(), + $messageArray[1], + gettype($messageArray[2]) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/config/class_NoConfigEntryException.php b/inc/main/exceptions/config/class_NoConfigEntryException.php new file mode 100644 index 00000000..d33d492d --- /dev/null +++ b/inc/main/exceptions/config/class_NoConfigEntryException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Rename this class to NoFoundEntryException + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoConfigEntryException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Configuration entry %s not found.', + $classArray[0], + $this->getLine(), + $classArray[1] + ); + + // Set extra data + $this->setExtraData($classArray[1].':'.$this->getLine()); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/connection/.htaccess b/inc/main/exceptions/connection/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/connection/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/connection/class_ConnectionAlreadyRegisteredException.php b/inc/main/exceptions/connection/class_ConnectionAlreadyRegisteredException.php new file mode 100644 index 00000000..99b357c5 --- /dev/null +++ b/inc/main/exceptions/connection/class_ConnectionAlreadyRegisteredException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ConnectionAlreadyRegisteredException extends AbstractConnectionException { + /** + * A Constructor for this exception + * + * @param $messageData An array with all relevant data for the exception + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Connection with socket %s is already registered.', + $messageData[0]->__toString(), + $messageData[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/controller/.htaccess b/inc/main/exceptions/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/controller/class_DefaultControllerException.php b/inc/main/exceptions/controller/class_DefaultControllerException.php new file mode 100644 index 00000000..922762c0 --- /dev/null +++ b/inc/main/exceptions/controller/class_DefaultControllerException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DefaultControllerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $resolverInstance An instance of a resolver class + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (ControllerResolver $resolverInstance, $code) { + // Prepare the message + $message = sprintf('[%s:%d] Cannot resolve default controller (%s). Maybe missing?', + $resolverInstance->__toString(), + $this->getLine(), + $resolverInstance->getClassName() + ); + + // Set extra data + $this->setExtraData($resolverInstance->getClassName() . ':' . $this->getLine()); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/controller/class_InvalidControllerException.php b/inc/main/exceptions/controller/class_InvalidControllerException.php new file mode 100644 index 00000000..e29b1f6d --- /dev/null +++ b/inc/main/exceptions/controller/class_InvalidControllerException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidControllerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray An array with message parts + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code) { + // Prepare the message + $message = sprintf('[%s:%d] Cannot resolve controller %s (class name: %s).', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getClassName() + ); + + // Set extra data + $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/criteria/.htaccess b/inc/main/exceptions/criteria/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/criteria/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/crypto/.htaccess b/inc/main/exceptions/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/crypto/class_EncryptInvalidLengthException.php b/inc/main/exceptions/crypto/class_EncryptInvalidLengthException.php new file mode 100644 index 00000000..9ecb93fa --- /dev/null +++ b/inc/main/exceptions/crypto/class_EncryptInvalidLengthException.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class 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()->getConfigEntry('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/main/exceptions/crypto/class_EncryptMissingException.php b/inc/main/exceptions/crypto/class_EncryptMissingException.php new file mode 100644 index 00000000..ded067f5 --- /dev/null +++ b/inc/main/exceptions/crypto/class_EncryptMissingException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EncryptMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $message Error message + * @param $code Error code + * @return void + */ + public function __construct (Filterable $filterInstance, $code) { + // Construct message + $message = sprintf('[%s:%d] Encrypt string is missing.', + $filterInstance->__toString(), + $this->getLine() + ); + + // Set extra data + $this->setExtraData($filterInstance->__toString()); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/.htaccess b/inc/main/exceptions/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/database/class_ b/inc/main/exceptions/database/class_ new file mode 100644 index 00000000..4aa413e1 --- /dev/null +++ b/inc/main/exceptions/database/class_ @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Exception extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Just call the parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/class_DatabaseException.php b/inc/main/exceptions/database/class_DatabaseException.php new file mode 100644 index 00000000..c7488588 --- /dev/null +++ b/inc/main/exceptions/database/class_DatabaseException.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Just call the parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/general/.htaccess b/inc/main/exceptions/database/general/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/database/general/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/database/general/class_SqlException.php b/inc/main/exceptions/database/general/class_SqlException.php new file mode 100644 index 00000000..6991b0f7 --- /dev/null +++ b/inc/main/exceptions/database/general/class_SqlException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SqlException extends DatabaseException { + /** + * The constructor + * + * @param $msgArray Message array + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Construct the message + $message = sprintf('[%s:%d] SQL error detected. Message from database: %s, code: %s.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $this->getHexCode($msgArray[2]) + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/local_file/.htaccess b/inc/main/exceptions/database/local_file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/database/local_file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/database/local_file/class_SavePathIsEmptyException.php b/inc/main/exceptions/database/local_file/class_SavePathIsEmptyException.php new file mode 100644 index 00000000..742558ee --- /dev/null +++ b/inc/main/exceptions/database/local_file/class_SavePathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathIsEmptyException extends DatabaseException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Save path is empty.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php b/inc/main/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php new file mode 100644 index 00000000..c6d66bc2 --- /dev/null +++ b/inc/main/exceptions/database/local_file/class_SavePathIsNoDirectoryException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathIsNoDirectoryException extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf('Save path %s is no directory.', $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/local_file/class_SavePathReadProtectedException.php b/inc/main/exceptions/database/local_file/class_SavePathReadProtectedException.php new file mode 100644 index 00000000..c46affd4 --- /dev/null +++ b/inc/main/exceptions/database/local_file/class_SavePathReadProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathReadProtectedException extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf('Path %s is not readable. Please fix your file access rights.', $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/local_file/class_SavePathWriteProtectedException.php b/inc/main/exceptions/database/local_file/class_SavePathWriteProtectedException.php new file mode 100644 index 00000000..818e3357 --- /dev/null +++ b/inc/main/exceptions/database/local_file/class_SavePathWriteProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SavePathWriteProtectedException extends DatabaseException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf('Save path %s is write-protected. Please fix your file permissions.', $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/database/wrapper/.htaccess b/inc/main/exceptions/database/wrapper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/database/wrapper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/feature/.htaccess b/inc/main/exceptions/feature/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/feature/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/feature/class_FeatureMethodNotCallableException.php b/inc/main/exceptions/feature/class_FeatureMethodNotCallableException.php new file mode 100644 index 00000000..5a7224b7 --- /dev/null +++ b/inc/main/exceptions/feature/class_FeatureMethodNotCallableException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FeatureMethodNotCallableException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Method %s cannot be called.', + $messageArray[0], + $this->getLine(), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/.htaccess b/inc/main/exceptions/file_directory/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/file_directory/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/file_directory/class_DirPointerNotOpenedException.php b/inc/main/exceptions/file_directory/class_DirPointerNotOpenedException.php new file mode 100644 index 00000000..0c734c80 --- /dev/null +++ b/inc/main/exceptions/file_directory/class_DirPointerNotOpenedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DirPointerNotOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $path Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf('Für den Pfad %s konnte kein Pointer initialisiert werden.', $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_FileIoException.php b/inc/main/exceptions/file_directory/class_FileIoException.php new file mode 100644 index 00000000..85744cbc --- /dev/null +++ b/inc/main/exceptions/file_directory/class_FileIoException.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIoException extends FrameworkException { + /** + * The constructor + * + * @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('A problem has been detected reading or writing to/from %s.', $fqfn); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_FileIsEmptyException.php b/inc/main/exceptions/file_directory/class_FileIsEmptyException.php new file mode 100644 index 00000000..9e5e97c6 --- /dev/null +++ b/inc/main/exceptions/file_directory/class_FileIsEmptyException.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $fqfn Ignored + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fqfn, $code) { + // Call parent constructor + parent::__construct('No file name provided.', $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_FileNotFoundException.php b/inc/main/exceptions/file_directory/class_FileNotFoundException.php new file mode 100644 index 00000000..3117bfaf --- /dev/null +++ b/inc/main/exceptions/file_directory/class_FileNotFoundException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileNotFoundException extends FrameworkException { + /** + * The constructor + * + * @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('File %s not found.', $fqfn); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_FileReadProtectedException.php b/inc/main/exceptions/file_directory/class_FileReadProtectedException.php new file mode 100644 index 00000000..b70a58ae --- /dev/null +++ b/inc/main/exceptions/file_directory/class_FileReadProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $fileName File which cannot be read from + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fileName, $code) { + // Add a message around the missing class + $message = sprintf('File %s is read-protected. Please set read access rights (CHMOD).', $fileName); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_FileWriteProtectedException.php b/inc/main/exceptions/file_directory/class_FileWriteProtectedException.php new file mode 100644 index 00000000..47ea7948 --- /dev/null +++ b/inc/main/exceptions/file_directory/class_FileWriteProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileWriteProtectedException extends FrameworkException { + /** + * The constructor + * + * @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('File %s cannot be written. Please check file and/or directory permissions.', $fqfn); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_InvalidDataLengthException.php b/inc/main/exceptions/file_directory/class_InvalidDataLengthException.php new file mode 100644 index 00000000..fb240163 --- /dev/null +++ b/inc/main/exceptions/file_directory/class_InvalidDataLengthException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidDataLengthException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Unexpected data length of %s bytes has been detected, %s bytes were expected.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_InvalidMD5ChecksumException.php b/inc/main/exceptions/file_directory/class_InvalidMD5ChecksumException.php new file mode 100644 index 00000000..fcc37efd --- /dev/null +++ b/inc/main/exceptions/file_directory/class_InvalidMD5ChecksumException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidMD5ChecksumException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] MD5 hashes %s and %s doesnt match.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_InvalidResourceException.php b/inc/main/exceptions/file_directory/class_InvalidResourceException.php new file mode 100644 index 00000000..fba3fd86 --- /dev/null +++ b/inc/main/exceptions/file_directory/class_InvalidResourceException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidResourceException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Has an invalid resource.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_PathIsEmptyException.php b/inc/main/exceptions/file_directory/class_PathIsEmptyException.php new file mode 100644 index 00000000..a324f06e --- /dev/null +++ b/inc/main/exceptions/file_directory/class_PathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PathIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Directory path is empty.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_PathIsNoDirectoryException.php b/inc/main/exceptions/file_directory/class_PathIsNoDirectoryException.php new file mode 100644 index 00000000..94a3e1ad --- /dev/null +++ b/inc/main/exceptions/file_directory/class_PathIsNoDirectoryException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PathIsNoDirectoryException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf('Der angegebene Pfad %s ist ungütig (kein Pfad).', $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_PathReadProtectedException.php b/inc/main/exceptions/file_directory/class_PathReadProtectedException.php new file mode 100644 index 00000000..6d6268d4 --- /dev/null +++ b/inc/main/exceptions/file_directory/class_PathReadProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class PathReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($path, $code) { + // Add a message around the missing class + $message = sprintf('The path %s appears to be read-protected. Please fix your CHMOD rights.', $path); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/file_directory/class_PathWriteProtectedException.php b/inc/main/exceptions/file_directory/class_PathWriteProtectedException.php new file mode 100644 index 00000000..67b8bf0e --- /dev/null +++ b/inc/main/exceptions/file_directory/class_PathWriteProtectedException.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileWriteProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $fqfn Full-qualified file name + * @param $code Code number for the exception + * @return void + */ + public function __construct ($fqfn, $code) { + // Add a message around the missing class + $message = sprintf('Path %s cannot be written to. Please check permissions.', dirname($fqfn)); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/filter/.htaccess b/inc/main/exceptions/filter/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/filter/class_FilterChainException.php b/inc/main/exceptions/filter/class_FilterChainException.php new file mode 100644 index 00000000..ee14c2e9 --- /dev/null +++ b/inc/main/exceptions/filter/class_FilterChainException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FilterChainException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $filterInstance Instance of a filter class + * @param $code Exception code for better debugging + * @return void + */ + public function __construct (Filterable $filterInstance, $code) { + // Construct the message + $message = sprintf('[%s:%d] Filter chain interruppted by fatal error in filter.', + $filterInstance->__toString(), + $this->getLine() + ); + + // Call the parent exception + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/filter/class_InvalidFilterChainException.php b/inc/main/exceptions/filter/class_InvalidFilterChainException.php new file mode 100644 index 00000000..5ee49100 --- /dev/null +++ b/inc/main/exceptions/filter/class_InvalidFilterChainException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidFilterChainException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $filterInstance Instance of a filter class + * @param $code Exception code for better debugging + * @return void + */ + public function __construct (array $filterArray, $code) { + // Construct the message + $message = sprintf('[%s:%d] Filter chain %s is not initialized.', + $filterArray[0]->__toString(), + $this->getLine(), + $filterArray[1] + ); + + // Call the parent exception + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/.htaccess b/inc/main/exceptions/helper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/helper/class_FormClosedException.php b/inc/main/exceptions/helper/class_FormClosedException.php new file mode 100644 index 00000000..049e76da --- /dev/null +++ b/inc/main/exceptions/helper/class_FormClosedException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FormClosedException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Could not add form element %s because form is closed.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_FormGroupClosedException.php b/inc/main/exceptions/helper/class_FormGroupClosedException.php new file mode 100644 index 00000000..61fa90cd --- /dev/null +++ b/inc/main/exceptions/helper/class_FormGroupClosedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FormGroupClosedException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Could not add sub group %s because no form group has been opened before.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_FormOpenedException.php b/inc/main/exceptions/helper/class_FormOpenedException.php new file mode 100644 index 00000000..a0986ab6 --- /dev/null +++ b/inc/main/exceptions/helper/class_FormOpenedException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FormOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $helperInstance Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (BaseHelper $helperInstance, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Form is not yet closed. Close it with method %s::addFormTag() and add no parameters.', + $helperInstance->__toString(), + $this->getLine(), + $helperInstance->__toString() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_HelperGroupAlreadyCreatedException.php b/inc/main/exceptions/helper/class_HelperGroupAlreadyCreatedException.php new file mode 100644 index 00000000..040cb55d --- /dev/null +++ b/inc/main/exceptions/helper/class_HelperGroupAlreadyCreatedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HelperGroupAlreadyCreatedException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Group %s already opened before.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php b/inc/main/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php new file mode 100644 index 00000000..7d8e1e93 --- /dev/null +++ b/inc/main/exceptions/helper/class_HelperNoPreviousOpenedSubGroupException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HelperNoPreviousOpenedSubGroupException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Sub group not opened before. Raw text follows: %s', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php b/inc/main/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php new file mode 100644 index 00000000..b2e0ec1b --- /dev/null +++ b/inc/main/exceptions/helper/class_HelperSubGroupAlreadyCreatedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class HelperSubGroupAlreadyCreatedException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Sub group %s already opened before.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_InvalidFormNameException.php b/inc/main/exceptions/helper/class_InvalidFormNameException.php new file mode 100644 index 00000000..badede76 --- /dev/null +++ b/inc/main/exceptions/helper/class_InvalidFormNameException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidFormNameException extends FrameworkException { + /** + * The constructor + * + * @param $helperInstance Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (BaseHelper $helperInstance, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Form name not set.', + $helperInstance->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_NoGroupOpenedException.php b/inc/main/exceptions/helper/class_NoGroupOpenedException.php new file mode 100644 index 00000000..39fcc2c4 --- /dev/null +++ b/inc/main/exceptions/helper/class_NoGroupOpenedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoGroupOpenedException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Array containing exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Group not opened before. Raw text follows: %s', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/helper/class_UserInstanceMissingException.php b/inc/main/exceptions/helper/class_UserInstanceMissingException.php new file mode 100644 index 00000000..4e5162a9 --- /dev/null +++ b/inc/main/exceptions/helper/class_UserInstanceMissingException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserInstanceMissingException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with class instance and registry key + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Registry key %s does not include a class with implemented interface Manageable(User|Guest).', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/language/.htaccess b/inc/main/exceptions/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/language/class_InvalidLanguagePathStringException.php b/inc/main/exceptions/language/class_InvalidLanguagePathStringException.php new file mode 100644 index 00000000..68be0a4d --- /dev/null +++ b/inc/main/exceptions/language/class_InvalidLanguagePathStringException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidLanguagePathStringException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] %s is not a string with path.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/language/class_LanguagePathIsEmptyException.php b/inc/main/exceptions/language/class_LanguagePathIsEmptyException.php new file mode 100644 index 00000000..e100a29f --- /dev/null +++ b/inc/main/exceptions/language/class_LanguagePathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguagePathIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Language base path is empty.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/language/class_LanguagePathIsNoDirectoryException.php b/inc/main/exceptions/language/class_LanguagePathIsNoDirectoryException.php new file mode 100644 index 00000000..dc37609a --- /dev/null +++ b/inc/main/exceptions/language/class_LanguagePathIsNoDirectoryException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguagePathIsNoDirectoryException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Language base path %s does not exist or is not a directory.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/language/class_LanguagePathReadProtectedException.php b/inc/main/exceptions/language/class_LanguagePathReadProtectedException.php new file mode 100644 index 00000000..dbba52d1 --- /dev/null +++ b/inc/main/exceptions/language/class_LanguagePathReadProtectedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class LanguagePathReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $class Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Base language path %s is read-protected. Please change access rights (CHMOD).', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/.htaccess b/inc/main/exceptions/main/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/main/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/main/class_AssertionException.php b/inc/main/exceptions/main/class_AssertionException.php new file mode 100644 index 00000000..f7eb89aa --- /dev/null +++ b/inc/main/exceptions/main/class_AssertionException.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AssertionException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_ClassMismatchException.php b/inc/main/exceptions/main/class_ClassMismatchException.php new file mode 100644 index 00000000..c347e0d0 --- /dev/null +++ b/inc/main/exceptions/main/class_ClassMismatchException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ClassMismatchException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding the exception informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('The class %s does not match class %s.', + $classArray[0], + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_DimNotFoundInArrayException.php b/inc/main/exceptions/main/class_DimNotFoundInArrayException.php new file mode 100644 index 00000000..dba31aa9 --- /dev/null +++ b/inc/main/exceptions/main/class_DimNotFoundInArrayException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DimNotFoundInArrayException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + if (is_object($class)) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Dimensions not found in array, array is invalid!', + $class->__toString(), + $this->getLine() + ); + } else { + // No class given + $message = sprintf('Please provide a class for %s', __CLASS__); + } + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_EmptyVariableException.php b/inc/main/exceptions/main/class_EmptyVariableException.php new file mode 100644 index 00000000..2741d41d --- /dev/null +++ b/inc/main/exceptions/main/class_EmptyVariableException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmptyVariableException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message array holding all needed data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Variable %s is not set.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_FatalErrorException.php b/inc/main/exceptions/main/class_FatalErrorException.php new file mode 100644 index 00000000..e0ca7594 --- /dev/null +++ b/inc/main/exceptions/main/class_FatalErrorException.php @@ -0,0 +1,39 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FatalErrorException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_IndexOutOfBoundsException.php b/inc/main/exceptions/main/class_IndexOutOfBoundsException.php new file mode 100644 index 00000000..458e70f0 --- /dev/null +++ b/inc/main/exceptions/main/class_IndexOutOfBoundsException.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class IndexOutOfBoundsException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($message, $code) { + // Add a message around the missing class + $message = sprintf('%s is out of bounds.', + $message + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_InvalidArrayCountException.php b/inc/main/exceptions/main/class_InvalidArrayCountException.php new file mode 100644 index 00000000..ee2c3880 --- /dev/null +++ b/inc/main/exceptions/main/class_InvalidArrayCountException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidArrayCountException extends FrameworkException { + /** + * The constructor + * + * @param $array Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $array, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] %s has %d elements, expected arre %d.', + $array[0]->__toString(), + $this->getLine(), + $array[1], + $array[2], + $array[3] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_InvalidCommandException.php b/inc/main/exceptions/main/class_InvalidCommandException.php new file mode 100644 index 00000000..64cbd6c1 --- /dev/null +++ b/inc/main/exceptions/main/class_InvalidCommandException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidCommandException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Invalid command %s (class %s) detected.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getClassName() + ); + + // Set extra data + $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_InvalidCommandInstanceException.php b/inc/main/exceptions/main/class_InvalidCommandInstanceException.php new file mode 100644 index 00000000..82de3c73 --- /dev/null +++ b/inc/main/exceptions/main/class_InvalidCommandInstanceException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidCommandInstanceException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Invalid command %s detected.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_InvalidInterfaceException.php b/inc/main/exceptions/main/class_InvalidInterfaceException.php new file mode 100644 index 00000000..bfb4cd03 --- /dev/null +++ b/inc/main/exceptions/main/class_InvalidInterfaceException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidInterfaceException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Object does not implement expected interface %s.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_InvalidObjectException.php b/inc/main/exceptions/main/class_InvalidObjectException.php new file mode 100644 index 00000000..09b917ae --- /dev/null +++ b/inc/main/exceptions/main/class_InvalidObjectException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidObjectException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Object is not allowed here.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_MissingArrayElementsException.php b/inc/main/exceptions/main/class_MissingArrayElementsException.php new file mode 100644 index 00000000..22ab7be1 --- /dev/null +++ b/inc/main/exceptions/main/class_MissingArrayElementsException.php @@ -0,0 +1,57 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingArrayElementsException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array with exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Extract all elements + $elements = ''; + if ((isset($classArray[2])) && (is_array($classArray[2]))) { + // Convert into strings + $elements = implode('
    , ', $classArray[2]); + } else { + // Invalid data + $elements = 'invalid_data'; + } + + // Add a message around the missing class + $message = sprintf('[%s:%d] Array %s() Does not have these elements: %s', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $elements + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_MissingDecimalsThousandsSeparatorException.php b/inc/main/exceptions/main/class_MissingDecimalsThousandsSeparatorException.php new file mode 100644 index 00000000..e3c5c9af --- /dev/null +++ b/inc/main/exceptions/main/class_MissingDecimalsThousandsSeparatorException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingDecimalsThousandsSeparatorException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct ($instance, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Decimal and thousand seperators are missing.', + $instance->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_MissingMethodException.php b/inc/main/exceptions/main/class_MissingMethodException.php new file mode 100644 index 00000000..6ad4bb49 --- /dev/null +++ b/inc/main/exceptions/main/class_MissingMethodException.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Try to rewrite user/guest login classes and mark this exception as deprecated + * @deprecated Please do no longer use this exception + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class MissingMethodException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding the exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] This class has no method %s().', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_NoClassException.php b/inc/main/exceptions/main/class_NoClassException.php new file mode 100644 index 00000000..212befcc --- /dev/null +++ b/inc/main/exceptions/main/class_NoClassException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoClassException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Class %s not found.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Set extra data + $this->setExtraData($msgArray[1]); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_NullPointerException.php b/inc/main/exceptions/main/class_NullPointerException.php new file mode 100644 index 00000000..5b2665ca --- /dev/null +++ b/inc/main/exceptions/main/class_NullPointerException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NullPointerException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] An object instance is set to null.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_ResponseHeadersAlreadySentException.php b/inc/main/exceptions/main/class_ResponseHeadersAlreadySentException.php new file mode 100644 index 00000000..f85ac4ed --- /dev/null +++ b/inc/main/exceptions/main/class_ResponseHeadersAlreadySentException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ResponseHeadersAlreadySentException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Headers are already sent.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_UnsupportedOperationException.php b/inc/main/exceptions/main/class_UnsupportedOperationException.php new file mode 100644 index 00000000..fd2465dc --- /dev/null +++ b/inc/main/exceptions/main/class_UnsupportedOperationException.php @@ -0,0 +1,57 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnsupportedOperationException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding the exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Init extra class name + $extraClassName = ''; + + // Do we have an extra instance? + if ((isset($classArray[2])) && ($classArray[2] instanceof FrameworkInterface)) { + // Get the class name + $extraClassName = $classArray[2]->__toString(); + } // END - if + + // Add a message around the missing class + $message = sprintf('[%s:%d] Method %s() is unsupported or should not be called. extraInstance=%s', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $extraClassName + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/main/class_VariableIsNotSetException.php b/inc/main/exceptions/main/class_VariableIsNotSetException.php new file mode 100644 index 00000000..2f2e3d60 --- /dev/null +++ b/inc/main/exceptions/main/class_VariableIsNotSetException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class VariableIsNotSetException extends FrameworkException { + /** + * The constructor + * + * @param $array Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $array, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] While the application %s was initialized, a variable %s was not created.', + $array[0]->__toString(), + $this->getLine(), + $array[1], + $array[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/result/.htaccess b/inc/main/exceptions/result/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/result/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/result/class_InvalidDatabaseResultException.php b/inc/main/exceptions/result/class_InvalidDatabaseResultException.php new file mode 100644 index 00000000..7695a8c3 --- /dev/null +++ b/inc/main/exceptions/result/class_InvalidDatabaseResultException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidDatabaseResultException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $msgArray, $code) { + // Construct the message + $message = sprintf('[%s:%d] Database instance %s contains invalid entries.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1]->__toString() + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/result/class_ResultUpdateException.php b/inc/main/exceptions/result/class_ResultUpdateException.php new file mode 100644 index 00000000..0a41b677 --- /dev/null +++ b/inc/main/exceptions/result/class_ResultUpdateException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ResultUpdateException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $resultInstance Instance of the failed result update + * @param $code Error code + * @return void + */ + public function __construct (UpdateableResult $resultInstance, $code) { + // Construct the message + $message = sprintf('[%s:%d] Update of result instance has nothing changed.', + $resultInstance->__toString(), + $this->getLine() + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/.htaccess b/inc/main/exceptions/socket/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/socket/class_AbstractSocketException.php b/inc/main/exceptions/socket/class_AbstractSocketException.php new file mode 100644 index 00000000..4f61282e --- /dev/null +++ b/inc/main/exceptions/socket/class_AbstractSocketException.php @@ -0,0 +1,30 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +abstract class AbstractSocketException extends FrameworkException { + // This abstract exception is currently kept empty +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_InvalidServerSocketException.php b/inc/main/exceptions/socket/class_InvalidServerSocketException.php new file mode 100644 index 00000000..fb50a52e --- /dev/null +++ b/inc/main/exceptions/socket/class_InvalidServerSocketException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidServerSocketException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Socket resource %s is not a server socket.', + $messageData[0]->__toString(), + $messageData[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_InvalidSocketException.php b/inc/main/exceptions/socket/class_InvalidSocketException.php new file mode 100644 index 00000000..572394cb --- /dev/null +++ b/inc/main/exceptions/socket/class_InvalidSocketException.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidSocketException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Is it a resource? + if (is_resource($messageData[1])) { + // Get last error + $lastError = socket_last_error($messageData[1]); + + // Construct the message + $message = sprintf('[%s:] Invalid socket, type=%s, errno=%s, errstr=%s', + $messageData[0]->__toString(), + gettype($messageData[1]), + $lastError, + socket_strerror($lastError) + ); + } else { + // Construct the message + $message = sprintf('[%s:] Invalid socket, type=%s(%s), errno=%s, errstr=%s', + $messageData[0]->__toString(), + $messageData[1], + gettype($messageData[1]), + $messageData[2], + $messageData[3] + ); + } + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_NoSocketErrorDetectedException.php b/inc/main/exceptions/socket/class_NoSocketErrorDetectedException.php new file mode 100644 index 00000000..d9e6d0fa --- /dev/null +++ b/inc/main/exceptions/socket/class_NoSocketErrorDetectedException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoSocketErrorDetectedException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Socket %s has no error reported.', + $messageData[0]->__toString(), + $messageData[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_NoSocketRegisteredException.php b/inc/main/exceptions/socket/class_NoSocketRegisteredException.php new file mode 100644 index 00000000..701a0ff3 --- /dev/null +++ b/inc/main/exceptions/socket/class_NoSocketRegisteredException.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoSocketRegisteredException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $protocolInstance An instance of a HandleableProtocol class + * @param $code Error code + * @return void + */ + public function __construct (HandleableProtocol $protocolInstance, $code) { + // Construct the message + $message = sprintf('[%s:] Requested socket is not yet registered.', + $protocolInstance->__toString() + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_SocketAlreadyRegisteredException.php b/inc/main/exceptions/socket/class_SocketAlreadyRegisteredException.php new file mode 100644 index 00000000..9445a889 --- /dev/null +++ b/inc/main/exceptions/socket/class_SocketAlreadyRegisteredException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketAlreadyRegisteredException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageData An array with all relevant data for the exception + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Socket %s is already registered.', + $messageData[0]->__toString(), + $messageData[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_SocketConnectionException.php b/inc/main/exceptions/socket/class_SocketConnectionException.php new file mode 100644 index 00000000..dd9c8839 --- /dev/null +++ b/inc/main/exceptions/socket/class_SocketConnectionException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketConnectionException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Could not make a connection, type=%s, errno=%s, errstr=%s', + $messageData[0]->__toString(), + gettype($messageData[1]), + $messageData[2], + $messageData[3] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_SocketCreationException.php b/inc/main/exceptions/socket/class_SocketCreationException.php new file mode 100644 index 00000000..0ad42f94 --- /dev/null +++ b/inc/main/exceptions/socket/class_SocketCreationException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketCreationException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Cannot create socket, type=%s, errno=%s, errstr=%s', + $messageData[0]->__toString(), + $messageData[1], + $messageData[2], + $messageData[3] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_SocketOptionException.php b/inc/main/exceptions/socket/class_SocketOptionException.php new file mode 100644 index 00000000..f863a833 --- /dev/null +++ b/inc/main/exceptions/socket/class_SocketOptionException.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketOptionException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Changing option on socket failed, type=%s, errno=%s, errstr=%s', + $messageData[0]->__toString(), + gettype($messageData[1]), + $messageData[2], + $messageData[3] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_SocketShutdownException.php b/inc/main/exceptions/socket/class_SocketShutdownException.php new file mode 100644 index 00000000..42ed51ff --- /dev/null +++ b/inc/main/exceptions/socket/class_SocketShutdownException.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class SocketShutdownException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $helperInstance An instance of a ConnectionHelper class + * @param $code Error code + * @return void + */ + public function __construct (ConnectionHelper $helperInstance, $code) { + // Get socket resource + $socketResource = $helperInstance->getSocketResource(); + + // Construct the message + $message = sprintf('[%s:] Socket %s cannot be shutdown down. errNo=%s, errStr=%s', + $helperInstance->__toString(), + $socketResource, + socket_last_error($socketResource), + socket_strerror(socket_last_error($socketResource)) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/socket/class_UnsupportedSocketErrorHandlerException.php b/inc/main/exceptions/socket/class_UnsupportedSocketErrorHandlerException.php new file mode 100644 index 00000000..5072dbc3 --- /dev/null +++ b/inc/main/exceptions/socket/class_UnsupportedSocketErrorHandlerException.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnsupportedSocketErrorHandlerException extends AbstractSocketException { + /** + * A Constructor for this exception + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageData, $code) { + // Construct the message + $message = sprintf('[%s:] Socket error handler %s is not yet implemented, errorCode=%s, message=%s', + $messageData[0]->__toString(), + $messageData[1], + $messageData[2], + socket_strerror($messageData[2]) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/stacker/.htaccess b/inc/main/exceptions/stacker/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/stacker/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/stacker/class_AlreadyInitializedStackerException.php b/inc/main/exceptions/stacker/class_AlreadyInitializedStackerException.php new file mode 100644 index 00000000..dd0a38de --- /dev/null +++ b/inc/main/exceptions/stacker/class_AlreadyInitializedStackerException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AlreadyInitializedStackerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Stacker %s already initialized, forceReInit=%d.', + $messageArray[0]->__toString(), + $this->getLine(), + $messageArray[1], + intval($messageArray[2]) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/stacker/class_EmptyStackerException.php b/inc/main/exceptions/stacker/class_EmptyStackerException.php new file mode 100644 index 00000000..7c0cd8f2 --- /dev/null +++ b/inc/main/exceptions/stacker/class_EmptyStackerException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class EmptyStackerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Stacker %s is empty.', + $messageArray[0]->__toString(), + $this->getLine(), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/stacker/class_FullStackerException.php b/inc/main/exceptions/stacker/class_FullStackerException.php new file mode 100644 index 00000000..2e04309b --- /dev/null +++ b/inc/main/exceptions/stacker/class_FullStackerException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FullStackerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Stacker %s is full.', + $messageArray[0]->__toString(), + $this->getLine(), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/stacker/class_NoStackerException.php b/inc/main/exceptions/stacker/class_NoStackerException.php new file mode 100644 index 00000000..4ba59cd0 --- /dev/null +++ b/inc/main/exceptions/stacker/class_NoStackerException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoStackerException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (array $messageArray, $code) { + // Construct message + $message = sprintf('[%s:%d] Stacker %s is not initialized.', + $messageArray[0]->__toString(), + $this->getLine(), + $messageArray[1] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/state/.htaccess b/inc/main/exceptions/state/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/state/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/state/class_InvalidStateInstanceException.php b/inc/main/exceptions/state/class_InvalidStateInstanceException.php new file mode 100644 index 00000000..fc6883ab --- /dev/null +++ b/inc/main/exceptions/state/class_InvalidStateInstanceException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidStateInstanceException extends FrameworkException { + /** + * The constructor + * + * @param $message Message from the exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Invalid state %s of type %s detected.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + gettype($mgArray[2]) + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/state/class_UnexpectedStateException.php b/inc/main/exceptions/state/class_UnexpectedStateException.php new file mode 100644 index 00000000..25114dd0 --- /dev/null +++ b/inc/main/exceptions/state/class_UnexpectedStateException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnexpectedStateException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $messageArray Error message array + * @param $code Error code + * @return void + */ + public function __construct (Stateable $stateInstance, $code) { + // Construct the message + $message = sprintf('[%s:%d] Unexpected state detected.', + $stateInstance->__toString(), + $this->getLine() + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/state/class_UnresolveableStateException.php b/inc/main/exceptions/state/class_UnresolveableStateException.php new file mode 100644 index 00000000..f025e18c --- /dev/null +++ b/inc/main/exceptions/state/class_UnresolveableStateException.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnresolveableStateException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray An array with message parts + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code) { + // Prepare the message + $message = sprintf('[%s:%d] Cannot resolve state %s (class name: %s).', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getClassName() + ); + + // Set extra data + $this->setExtraData($msgArray[0]->getClassName() . ':' . $this->getLine()); + + // Call parent contructor with message + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/template/.htaccess b/inc/main/exceptions/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/template/class_BasePathIsEmptyException.php b/inc/main/exceptions/template/class_BasePathIsEmptyException.php new file mode 100644 index 00000000..51a5f842 --- /dev/null +++ b/inc/main/exceptions/template/class_BasePathIsEmptyException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePathIsEmptyException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this exception + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Template path is empty.', + $class->__toString(), + $this->getLine() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/template/class_BasePathIsNoDirectoryException.php b/inc/main/exceptions/template/class_BasePathIsNoDirectoryException.php new file mode 100644 index 00000000..28677ea1 --- /dev/null +++ b/inc/main/exceptions/template/class_BasePathIsNoDirectoryException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePathIsNoDirectoryException extends FrameworkException { + /** + * The constructor + * + * @param $classArray An array holding our informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Template base path %s does not exist.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/template/class_BasePathReadProtectedException.php b/inc/main/exceptions/template/class_BasePathReadProtectedException.php new file mode 100644 index 00000000..440ccd01 --- /dev/null +++ b/inc/main/exceptions/template/class_BasePathReadProtectedException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BasePathReadProtectedException extends FrameworkException { + /** + * The constructor + * + * @param $classArray An array holding our informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Der Template-Basispfad %s ist lesegeschützt! Bitte Zugriffsrechte (CHMOD) ändern.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/template/class_InvalidBasePathStringException.php b/inc/main/exceptions/template/class_InvalidBasePathStringException.php new file mode 100644 index 00000000..10b0dc04 --- /dev/null +++ b/inc/main/exceptions/template/class_InvalidBasePathStringException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidBasePathStringException extends FrameworkException { + /** + * The constructor + * + * @param $classArray Array holding exception data + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $classArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] %s is not a string with a base path.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/template/class_NoVariableException.php b/inc/main/exceptions/template/class_NoVariableException.php new file mode 100644 index 00000000..52b22615 --- /dev/null +++ b/inc/main/exceptions/template/class_NoVariableException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NoVariableException extends FrameworkException { + /** + * The constructor + * + * @param $messageArray Data for the message + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $messageArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Variable %s is not set, cannot modify(?) its value to %s.', + $messageArray[0]->__toString(), + $this->getLine(), + $messageArray[1], + $messageArray[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/template/class_UnexpectedTemplateTypeException.php b/inc/main/exceptions/template/class_UnexpectedTemplateTypeException.php new file mode 100644 index 00000000..66b77128 --- /dev/null +++ b/inc/main/exceptions/template/class_UnexpectedTemplateTypeException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnexpectedTemplateTypeException extends FrameworkException { + /** + * The constructor + * + * @param $msgArray An array holding our informations + * @param $code Code number for the exception + * @return void + */ + public function __construct (array $msgArray, $code) { + // Add a message around the missing class + $message = sprintf('[%s:%d] Der Template-Typ %s entspricht nicht dem erwartetem Template-Typ %s.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[2] + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/template/class_UnsupportedTemplateEngineException.php b/inc/main/exceptions/template/class_UnsupportedTemplateEngineException.php new file mode 100644 index 00000000..e0042073 --- /dev/null +++ b/inc/main/exceptions/template/class_UnsupportedTemplateEngineException.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnsupportedTemplateEngineException extends FrameworkException { + /** + * The constructor + * + * @param $class Class throwing this class + * @param $code Code number for the exception + * @return void + */ + public function __construct (FrameworkInterface $class, $code) { + // Add a message around the missing class + $message = sprintf('Template-Engine %s not (yet) supported.', + $class->__toString() + ); + + // Call parent constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/user/.htaccess b/inc/main/exceptions/user/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/user/class_AccountPasswordMismatchException.php b/inc/main/exceptions/user/class_AccountPasswordMismatchException.php new file mode 100644 index 00000000..647ab230 --- /dev/null +++ b/inc/main/exceptions/user/class_AccountPasswordMismatchException.php @@ -0,0 +1,45 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class AccountPasswordMismatchException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $filterInstance A filterable class instance + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (Filterable $filterInstance, $code) { + // Create the message + $message = sprintf('[%s:%d] Supplied account password did not match with stored.', + $filterInstance->__toString(), + $this->getLine() + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/user/class_UnexpectedGuestAccountException.php b/inc/main/exceptions/user/class_UnexpectedGuestAccountException.php new file mode 100644 index 00000000..9100f1dd --- /dev/null +++ b/inc/main/exceptions/user/class_UnexpectedGuestAccountException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UnexpectedGuestAccountException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code = 0) { + // Create the message + $message = sprintf('[%s:%d] User %s is a guest account.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/user/class_UserEmailMissingException.php b/inc/main/exceptions/user/class_UserEmailMissingException.php new file mode 100644 index 00000000..37a01393 --- /dev/null +++ b/inc/main/exceptions/user/class_UserEmailMissingException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserEmailMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code = 0) { + // Create the message + $message = sprintf('[%s:%d] User email %s was not found.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/user/class_UserNoGuestException.php b/inc/main/exceptions/user/class_UserNoGuestException.php new file mode 100644 index 00000000..515431a7 --- /dev/null +++ b/inc/main/exceptions/user/class_UserNoGuestException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserNoGuestException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code = 0) { + // Create the message + $message = sprintf('[%s:%d] User %s is not a guest account: %s', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1], + $msgArray[0]->getField(UserDatabaseWrapper::DB_COLUMN_USER_STATUS) + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/user/class_UserPasswordMismatchException.php b/inc/main/exceptions/user/class_UserPasswordMismatchException.php new file mode 100644 index 00000000..2a422390 --- /dev/null +++ b/inc/main/exceptions/user/class_UserPasswordMismatchException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UserPasswordMismatchException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code = 0) { + // Create the message + $message = sprintf('[%s:%d] Supplied password for user %s did not match with stored password.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1]->getUserName() + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/user/class_UsernameMissingException.php b/inc/main/exceptions/user/class_UsernameMissingException.php new file mode 100644 index 00000000..2ea69048 --- /dev/null +++ b/inc/main/exceptions/user/class_UsernameMissingException.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class UsernameMissingException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $msgArray The non-optional message for the exception + * @param $code An optional code for better debugging + * @return void + */ + public function __construct (array $msgArray, $code = 0) { + // Create the message + $message = sprintf('[%s:%d] Username %s was not found.', + $msgArray[0]->__toString(), + $this->getLine(), + $msgArray[1] + ); + + // Make sure everything is assigned properly + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/xml/.htaccess b/inc/main/exceptions/xml/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/exceptions/xml/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/exceptions/xml/class_InvalidXmlNodeException.php b/inc/main/exceptions/xml/class_InvalidXmlNodeException.php new file mode 100644 index 00000000..6e8f81e9 --- /dev/null +++ b/inc/main/exceptions/xml/class_InvalidXmlNodeException.php @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class InvalidXmlNodeException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Extract attributes + $attributes = 'None'; + if ((is_array($classArray[2])) && (count($classArray[2]) > 0)) { + $attributes = implode(', ', $classArray[2]); + } // END - if + + // Construct our message + $message = sprintf('[%s:%d] Invalid XML node found: %s, attributes: %s.', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $attributes + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/xml/class_XmlNodeMismatchException.php b/inc/main/exceptions/xml/class_XmlNodeMismatchException.php new file mode 100644 index 00000000..92fe138f --- /dev/null +++ b/inc/main/exceptions/xml/class_XmlNodeMismatchException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlNodeMismatchException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Construct our message + $message = sprintf('[%s:%d] XML nodes mismatch. Given: %s, Expected: %s', + $classArray[0]->__toString(), + $this->getLine(), + $classArray[1], + $classArray[2] + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/exceptions/xml/class_XmlParserException.php b/inc/main/exceptions/xml/class_XmlParserException.php new file mode 100644 index 00000000..b5532695 --- /dev/null +++ b/inc/main/exceptions/xml/class_XmlParserException.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlParserException extends FrameworkException { + /** + * The super constructor for all exceptions + * + * @param $classArray Array holding the exception data + * @param $code Error code + * @return void + */ + public function __construct (array $classArray, $code) { + // Construct our message + $message = sprintf('[%s:%d] XML Error: %s at line %d.', + $classArray[0]->__toString(), + $this->getLine(), + xml_error_string(xml_get_error_code($classArray[1])), + xml_get_current_line_number($classArray[1]) + ); + + // Call parent exception constructor + parent::__construct($message, $code); + } +} + +// [EOF] +?> diff --git a/inc/main/interfaces/.htaccess b/inc/main/interfaces/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/actions/.htaccess b/inc/main/interfaces/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/actions/class_PerformableAction.php b/inc/main/interfaces/actions/class_PerformableAction.php new file mode 100644 index 00000000..2a6f506f --- /dev/null +++ b/inc/main/interfaces/actions/class_PerformableAction.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface PerformableAction extends FrameworkInterface { + /** + * Executes the command with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + */ + function execute (Requestable $requestInstance, Responseable $responseInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/actions/commands/.htaccess b/inc/main/interfaces/actions/commands/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/actions/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/actions/commands/class_Commandable.php b/inc/main/interfaces/actions/commands/class_Commandable.php new file mode 100644 index 00000000..1d9138d2 --- /dev/null +++ b/inc/main/interfaces/actions/commands/class_Commandable.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Commandable extends PerformableAction { + /** + * 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 + */ + function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/application/.htaccess b/inc/main/interfaces/application/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/application/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/application/class_ManageableApplication.php b/inc/main/interfaces/application/class_ManageableApplication.php new file mode 100644 index 00000000..65b98650 --- /dev/null +++ b/inc/main/interfaces/application/class_ManageableApplication.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableApplication extends FrameworkInterface { + /** + * Launches the application + * + * @return void + */ + function entryPoint (); + + /** + * Handle the indexed array of fatal messages and puts them out in an + * acceptable fasion + * + * @param $messageList An array of fatal messages + * @return void + */ + function handleFatalMessages (array $messageList); + + /** + * Builds the master template's name + * + * @return $masterTemplateName Name of the master template + */ + function buildMasterTemplateName(); + + /** + * Assigns extra application-depending data + * + * @param $templateInstance An instance of a CompileableTemplate + * @return void + * @todo Nothing to add? + */ + function assignExtraTemplateData (CompileableTemplate $templateInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/auth/.htaccess b/inc/main/interfaces/auth/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/auth/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/auth/class_Authorizeable.php b/inc/main/interfaces/auth/class_Authorizeable.php new file mode 100644 index 00000000..f10eaac5 --- /dev/null +++ b/inc/main/interfaces/auth/class_Authorizeable.php @@ -0,0 +1,41 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Authorizeable extends FrameworkInterface { + /** + * Destroy the authorization data + * + * @return void + */ + function destroyAuthData(); + + /** + * Updates the authorization data and/or sets additional tracking data + * + * @return void + */ + function updateAuthData (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/block/.htaccess b/inc/main/interfaces/block/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/block/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/block/calculatable/.htaccess b/inc/main/interfaces/block/calculatable/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/block/calculatable/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/block/calculatable/class_CalculatableBlock.php b/inc/main/interfaces/block/calculatable/class_CalculatableBlock.php new file mode 100644 index 00000000..289f0790 --- /dev/null +++ b/inc/main/interfaces/block/calculatable/class_CalculatableBlock.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface CalculatableBlock extends Block { + /** + * Calculates minimum length for one entry/block + * + * @return $length Minimum length for one entry/block + */ + function calculateMinimumBlockLength (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/block/class_Block.php b/inc/main/interfaces/block/class_Block.php new file mode 100644 index 00000000..12c99f0f --- /dev/null +++ b/inc/main/interfaces/block/class_Block.php @@ -0,0 +1,154 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface Block extends FrameworkInterface { + /** + * Reads the file header + * + * @return void + */ + function readFileHeader (); + + /** + * Flushes the file header + * + * @return void + */ + function flushFileHeader (); + + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + */ + function isEndOfFileReached (); + + /** + * Getter for file name + * + * @return $fileName The current file name + */ + function getFileName (); + + /** + * Initializes counter for valid entries, arrays for damaged entries and + * an array for gap seek positions. If you call this method on your own, + * please re-analyze the file structure. So you are better to call + * analyzeFile() instead of this method. + * + * @return void + */ + function initCountersGapsArray (); + + /** + * Getter for header size + * + * @return $totalEntries Size of file header + */ + function getHeaderSize (); + + /** + * Setter for header size + * + * @param $headerSize Size of file header + * @return void + */ + function setHeaderSize ($headerSize); + + /** + * Getter for header array + * + * @return $totalEntries Size of file header + */ + function getHeader (); + + /** + * Setter for header + * + * @param $header Array for a file header + * @return void + */ + function setHeader (array $header); + + /** + * Updates seekPosition attribute from file to avoid to much access on file. + * + * @return void + */ + function updateSeekPosition (); + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + function getCounter (); + + /** + * "Getter" for file size + * + * @return $fileSize Size of currently loaded file + */ + function getFileSize (); + + /** + * Writes given value to the file and returns a hash and gap position for it + * + * @param $groupId Group identifier + * @param $value Value to be added to the stack + * @return $data Hash and gap position + */ + function writeValueToFile ($groupId, $rawData); + + /** + * Writes given raw data to the file and returns a gap position and length + * + * @param $groupId Group identifier + * @param $hash Hash from encoded value + * @param $encoded Encoded value to be written to the file + * @return $data Gap position and length of the raw data + */ + function writeDataToFreeGap ($groupId, $hash, $encoded); + + /** + * Writes data at given position + * + * @param $seekPosition Seek position + * @param $data Data to be written + * @param $flushHeader Whether to flush the header (default: flush) + * @return void + */ + function writeData ($seekPosition, $data, $flushHeader = TRUE); + + /** + * Searches for next suitable gap the given length of data can fit in + * including padding bytes. + * + * @param $length Length of raw data + * @return $seekPosition Found next gap's seek position + */ + function searchNextGap ($length); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/cache/.htaccess b/inc/main/interfaces/cache/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/cache/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/cache/class_Cacheable.php b/inc/main/interfaces/cache/class_Cacheable.php new file mode 100644 index 00000000..ae1d03ed --- /dev/null +++ b/inc/main/interfaces/cache/class_Cacheable.php @@ -0,0 +1,62 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Cacheable extends FrameworkInterface { + /** + * Does the specified offset exist in cache? + * + * @param $offset The offset we are looking for + * @param $arrayElement If type is array, then this element must be found + * @param $minimumCount If array element is found then this count must at least match + * @return $exists Whether the offset exists + */ + function offsetExists($offset, $arrayElement = NULL, $minimumCount = 0); + + /** + * Setter for cache offset + * + * @param $offset The offset we shall set + * @param $data Data to store in cache + * @return void + */ + function offsetSet($offset, $data); + + /** + * Getter for cache offset or "null" if not found + * + * @param $offset The offset we shall set + * @return $data Data to store in cache + */ + function offsetGet($offset); + + /** + * Purges the given cache entry + * + * @param $offset The offset we shall set + * @return void + */ + function purgeOffset($offset); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/captcha/.htaccess b/inc/main/interfaces/captcha/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/captcha/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/captcha/class_SolveableCaptcha.php b/inc/main/interfaces/captcha/class_SolveableCaptcha.php new file mode 100644 index 00000000..9916e590 --- /dev/null +++ b/inc/main/interfaces/captcha/class_SolveableCaptcha.php @@ -0,0 +1,41 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface SolveableCaptcha extends FrameworkInterface { + /** + * Initiates the CAPTCHA + * + * @return void + */ + function initiateCaptcha (); + + /** + * Render the CAPTCHA code + * + * @return void + */ + function renderCode (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/class_ b/inc/main/interfaces/class_ new file mode 100644 index 00000000..b3a5c087 --- /dev/null +++ b/inc/main/interfaces/class_ @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface ??? extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/class_FrameworkInterface.php b/inc/main/interfaces/class_FrameworkInterface.php new file mode 100644 index 00000000..724e57d7 --- /dev/null +++ b/inc/main/interfaces/class_FrameworkInterface.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Find a better name for this interface + * + * 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 . + */ +interface FrameworkInterface { + /** + * Getter for field name + * + * @param $fieldName Field name which we shall get + * @return $fieldValue Field value from the user + * @throws NullPointerException If the result instance is null + */ + function getField ($fieldName); + + /** + * Checks if given field is set + * + * @param $fieldName Field name to check + * @return $isSet Whether the given field name is set + * @throws NullPointerException If the result instance is null + */ + function isFieldSet ($fieldName); + + /** + * Checks whether an object equals this object. You should overwrite this + * method to implement own equality checks + * + * @param $objectInstance An instance of a FrameworkInterface object + * @return $equals Whether both objects equals + */ + function equals (FrameworkInterface $objectInstance); + + /** + * Generates a code for hashes from this class + * + * @return $hashCode The hash code respresenting this class + */ + function hashCode (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/client/.htaccess b/inc/main/interfaces/client/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/client/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/client/class_Client.php b/inc/main/interfaces/client/class_Client.php new file mode 100644 index 00000000..de441385 --- /dev/null +++ b/inc/main/interfaces/client/class_Client.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface Client extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/compressor/.htaccess b/inc/main/interfaces/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/compressor/class_Compressor.php b/inc/main/interfaces/compressor/class_Compressor.php new file mode 100644 index 00000000..b80a6c8d --- /dev/null +++ b/inc/main/interfaces/compressor/class_Compressor.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Compressor extends FrameworkInterface { + /** + * A compression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The compressed stream data + * @throws InvalidObjectException If the stream is an object + */ + function compressStream ($streamData); + + /** + * A decompression stream + * + * @param $streamData Mixed non-object stream data + * @return $streamData The decompressed stream data + * @throws InvalidObjectException If the stream is an object + */ + function decompressStream ($streamData); + + /** + * Getter for the file extension of this compressor + * + * @return $string The compressor's file extension + */ + function getCompressorExtension (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/controller/.htaccess b/inc/main/interfaces/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/controller/class_Controller.php b/inc/main/interfaces/controller/class_Controller.php new file mode 100644 index 00000000..c4debd47 --- /dev/null +++ b/inc/main/interfaces/controller/class_Controller.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Controller extends FrameworkInterface { + /** + * Handles the given request and response + * + * @param $requestInstance An instance of a request class + * @param $responseInstance An instance of a response class + * @return void + */ + function handleRequest (Requestable $requestInstance, Responseable $responseInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/criteria/.htaccess b/inc/main/interfaces/criteria/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/criteria/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/criteria/class_Criteria.php b/inc/main/interfaces/criteria/class_Criteria.php new file mode 100644 index 00000000..9609302f --- /dev/null +++ b/inc/main/interfaces/criteria/class_Criteria.php @@ -0,0 +1,249 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Criteria extends FrameworkInterface { + /** + * Setter for wrapper class name + * + * @param $wrapperConfigEntry Configuration entry which hold the wrapper class' name + * @return void + */ + function setWrapperConfigEntry ($wrapperConfigEntry); + + /** + * Getter for wrapper class name + * + * @return $wrapperConfigEntry Configuration entry which hold the wrapper class' name + */ + function getWrapperConfigEntry (); + + /** + * Checks whether given key is set + * + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + function isKeySet ($criteriaType, $criteriaKey); + + /** + * Checks whether given key is set for 'choice' type + * + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + function isChoiceKeySet ($criteriaKey); + + /** + * Checks whether given key is set for 'exclude' type + * + * @param $criteriaKey Criteria key + * @return $isSet Whether key is set + */ + function isExcludeKeySet ($criteriaKey); + + /** + * Getter for criteria array + * + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $criteria + */ + function getCriteriaArray ($criteriaType = 'default'); + + /** + * Getter for criteria array 'choice' type + * + * @return $criteria + */ + function getCriteriaChoiceArray (); + + /** + * Getter for criteria array 'exclude' type + * + * @return $criteria + */ + function getCriteriaExcludeArray (); + + /** + * Unsets a criteria key from all criteria types + * + * @param $criteriaKey Criteria key to unset + * @return void + */ + function unsetCriteria ($criteriaKey); + + /** + * Add criteria, this method converts dashes to underscores because dashes + * are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return void + */ + function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default'); + + /** + * Sets criteria, this method converts dashes to underscores because dashes + * are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return void + */ + function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default'); + + /** + * Add "choice" criteria, this method converts dashes to underscores because + * dashes are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + function addChoiceCriteria ($criteriaKey, $criteriaValue); + + /** + * Add "exclude" criteria, this method converts dashes to underscores because + * dashes are not valid for criteria keys. + * + * @param $criteriaKey Criteria key + * @param $criteriaValue Criteria value + * @return void + */ + function addExcludeCriteria ($criteriaKey, $criteriaValue); + + /** + * Add configured criteria + * + * @param $criteriaKey Criteria key + * @param $configEntry Configuration entry + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return void + */ + function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default'); + + /** + * Get criteria element or FALSE if not found + * + * @param $criteriaKey The requested criteria key + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $value Whether the value of the critera or FALSE + */ + function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default'); + + /** + * Get criteria element or FALSE if not found for 'choice' type + * + * @param $criteriaKey The requested criteria key + * @return $value Whether the value of the critera or FALSE + */ + function getCriteriaChoiceElemnent ($criteriaKey); + + /** + * Get criteria element or FALSE if not found for 'exclude' type + * + * @param $criteriaKey The requested criteria key + * @return $value Whether the value of the critera or FALSE + */ + function getCriteriaExcludeElemnent ($criteriaKey); + + /** + * Checks whether given array entry matches + * + * @param $entryArray Array with the entries to find + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $matches Whether the entry matches or not + */ + function ifEntryMatches (array $entryArray, $criteriaType = 'default'); + + /** + * Checks whether given array 'choice' entry matches + * + * @param $entryArray Array with the entries to find + * @return $matches Whether the entry matches or not + */ + function ifChoiceMatches (array $entryArray); + + /** + * Checks whether given array 'exclude' entry matches + * + * @param $entryArray Array with the entries to find + * @return $matches Whether the entry matches or not + */ + function ifExcludeMatches (array $entryArray); + + /** + * "Getter" for a cache key + * + * @param $onlyKeys Only use these keys for a cache key + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $cacheKey The key suitable for the cache system + */ + function getCacheKey ($onlyKeys = array(), $criteriaType = 'default'); + + /** + * "Getter" for a cache key ('choice' type) + * + * @param $onlyKeys Only use these keys for a cache key + * @return $cacheKey The key suitable for the cache system + */ + function getCacheKeyChoice ($onlyKeys = array()); + + /** + * "Getter" for a cache key ('exclude' type) + * + * @param $onlyKeys Only use these keys for a cache key + * @return $cacheKey The key suitable for the cache system + */ + function getCacheKeyExclude ($onlyKeys = array()); + + /** + * Count the criteria, e.g. useful to find out if a database query has no + * limitation (search criteria). + * + * @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude' + * @return $count Count of all criteria entries + */ + function count ($criteriaType = 'default'); + + /** + * Count 'choice' criteria, e.g. useful to find out if a database query + * has no limitation (search criteria). + * + * @return $count Count of all criteria entries + */ + function countChoice (); + + /** + * Count 'exclude' criteria, e.g. useful to find out if a database query + * has no limitation (search criteria). + * + * @return $count Count of all criteria entries + */ + function countExclude (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/criteria/extended/.htaccess b/inc/main/interfaces/criteria/extended/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/criteria/extended/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/criteria/extended/class_AddableCriteria.php b/inc/main/interfaces/criteria/extended/class_AddableCriteria.php new file mode 100644 index 00000000..e1254b23 --- /dev/null +++ b/inc/main/interfaces/criteria/extended/class_AddableCriteria.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface AddableCriteria extends FrameworkInterface { + /** + * Adds registration elements to a given dataset instance + * + * @param $criteriaInstance An instance of a StoreableCriteria class + * @param $requestInstance An instance of a Requestable class + * @return void + */ + function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance = NULL); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/criteria/extended/class_LocalSearchCriteria.php b/inc/main/interfaces/criteria/extended/class_LocalSearchCriteria.php new file mode 100644 index 00000000..e0920c86 --- /dev/null +++ b/inc/main/interfaces/criteria/extended/class_LocalSearchCriteria.php @@ -0,0 +1,78 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface LocalSearchCriteria extends Criteria { + /** + * Setter for limit + * + * @param $limit Search limit + * @return void + * @todo Find a nice casting here. (int) allows until and including 32766. + */ + function setLimit ($limit); + + /** + * "Setter" for limit from a configuration entry + * + * @param $configEntry The configuration entry which hold a number as limit + * @return void + */ + function setConfiguredLimit ($configEntry); + + /** + * Getter for limit + * + * @return $limit Search limit + */ + function getLimit (); + + /** + * Setter for skip + * + * @param $skip Search skip + * @return void + * @todo Find a nice casting here. (int) allows until and including 32766. + */ + function setSkip ($skip); + + /** + * Getter for skip + * + * @return $skip Search skip + */ + function getSkip (); + + /** + * Checks whether the given key/value pair is matching with 'default' and one of 'choice' and + * never with in 'exclude'. + * + * @param $key Key element to check + * @param $value Value to check + * @param $separator Separator for "exploding" $value (default: ',') + * @return $isMatching Whether the key/value is matching or excluded + */ + function isCriteriaMatching ($key, $value, $separator = ','); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/criteria/extended/class_LocalUpdateCriteria.php b/inc/main/interfaces/criteria/extended/class_LocalUpdateCriteria.php new file mode 100644 index 00000000..5b627e93 --- /dev/null +++ b/inc/main/interfaces/criteria/extended/class_LocalUpdateCriteria.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface LocalUpdateCriteria extends Criteria { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/criteria/extended/class_StoreableCriteria.php b/inc/main/interfaces/criteria/extended/class_StoreableCriteria.php new file mode 100644 index 00000000..faa6c89e --- /dev/null +++ b/inc/main/interfaces/criteria/extended/class_StoreableCriteria.php @@ -0,0 +1,94 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface StoreableCriteria extends Criteria { + /** + * Setter for table name + * + * @param $tableName Name of the table to set + * @return void + */ + function setTableName ($tableName); + + /** + * Getter for table name + * + * @return $tableName Name of the table to set + */ + function getTableName (); + + /** + * Setter for unique key + * + * @param $uniqueKey Column to use as unique key + * @return void + */ + function setUniqueKey ($uniqueKey); + + /** + * Getter for unique key + * + * @return $uniqueKey Column to use as unique key + */ + function getUniqueKey (); + + /** + * Getter for unique key value + * + * @return $uniqueValue Value of the unique key + */ + function getUniqueValue (); + + /** + * Getter for primary key or unique key if not set + * + * @return $primaryKey Primary key or unique key if not set + */ + function getPrimaryKey (); + + /** + * Setter for primary key + * + * @param $primaryKey Primary key to set + * @return void + */ + function setPrimaryKey ($primaryKey); + + /** + * Setter for primary key array + * + * @param $primaryKeys Primary key array to set + * @return void + */ + function setPrimaryKeyCombined (array $primaryKeys); + + /** + * Getter for primary keys + * + * @return $primaryKeys Primary key array + */ + function getPrimaryKeys (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/crypto/.htaccess b/inc/main/interfaces/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/crypto/class_Cryptable.php b/inc/main/interfaces/crypto/class_Cryptable.php new file mode 100644 index 00000000..5f30f5a8 --- /dev/null +++ b/inc/main/interfaces/crypto/class_Cryptable.php @@ -0,0 +1,57 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Cryptable extends FrameworkInterface { + /** + * Hashes a string with salt and returns the hash. If an old previous hash + * is supplied the method will use the first X chars of that hash for hashing + * the password. This is useful if you want to check if password is identical + * for authorization purposes. + * + * @param $str Unhashed string + * @param $oldHash A hash from previous hashed string + * @param $withFixed Whether to include a fixed salt (not recommended in p2p applications) + * @return $hashed The hashed and salted string + */ + function hashString ($str, $oldHash = '', $withFixed = TRUE); + + /** + * Encrypt the string with fixed salt + * + * @param $str The unencrypted string + * @param $key Optional key, if none provided, a random key will be generated + * @return $encrypted Encrypted string + */ + function encryptString ($str, $key = NULL); + + /** + * Decrypt the string with fixed salt + * + * @param $encrypted Encrypted string + * @return $str The unencrypted string + */ + function decryptString ($encrypted); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/database/.htaccess b/inc/main/interfaces/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/database/backend/.htaccess b/inc/main/interfaces/database/backend/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/database/backend/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/database/backend/class_DatabaseBackend.php b/inc/main/interfaces/database/backend/class_DatabaseBackend.php new file mode 100644 index 00000000..e040e8cb --- /dev/null +++ b/inc/main/interfaces/database/backend/class_DatabaseBackend.php @@ -0,0 +1,123 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DatabaseBackend extends FrameworkDatabase { + /** + * Getter for last read file + * + * @return $lastFile The last read file's name with full path + */ + function getLastFile (); + + /** + * Getter for last read file's content as an array + * + * @return $lastContent The array with elements 'header' and 'data'. + */ + function getLastContents (); + + /** + * Getter for file extension + * + * @return $fileExtension The array with elements 'header' and 'data'. + */ + function getFileExtension (); + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + function getIndexKey (); + + /** + * Makes sure that the database connection is alive + * + * @return void + * @todo Do some checks on the database directory and files here + */ + function connectToDatabase (); + + /** + * Starts a SELECT query on the database by given return type, table name + * and search criteria + * + * @param $tableName Name of the database table + * @param $searchInstance Local search criteria class + * @return $resultData Result data of the query + * @throws UnsupportedCriteriaException If the criteria is unsupported + * @throws SqlException If an 'SQL error' occurs + */ + function querySelect ($tableName, LocalSearchCriteria $searchInstance); + + /** + * "Inserts" a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + function queryInsertDataSet (StoreableCriteria $dataSetInstance); + + /** + * "Updates" a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @return void + * @throws SqlException If an SQL error occurs + */ + function queryUpdateDataSet (StoreableCriteria $dataSetInstance); + + /** + * Getter for primary key of specified table or if not found null will be + * returned. This must be database-specific. + * + * @param $tableName Name of the table we need the primary key from + * @return $primaryKey Primary key column of the given table + */ + function getPrimaryKeyOfTable ($tableName); + + /** + * Removes non-data from given array. + * + * @param $data An array with possible non-data that needs to be removed. + * @return $data A cleaned up array with only data. + * @todo Add more generic non-data for removal + */ + function removeNonPublicDataFromArray (array $data); + + /** + * Counts total rows of given table + * + * @param $tableName Table name + * @return $count Total rows of given table + */ + function countTotalRows($tableName); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/database/class_DatabaseWrapper.php b/inc/main/interfaces/database/class_DatabaseWrapper.php new file mode 100644 index 00000000..03962256 --- /dev/null +++ b/inc/main/interfaces/database/class_DatabaseWrapper.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DatabaseWrapper extends FrameworkInterface { + /** + * Getter for index key + * + * @return $indexKey Index key + */ + function getIndexKey(); + + /** + * Getter for last exception + * + * @return $lastException Last exception or NULL if none occured + */ + function getLastException(); + + /** + * Do a "select" query on the current table with the given search criteria and + * store it in cache for later usage + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $resultInstance An instance of a database result class + */ + function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = array()); + + /** + * Count the numbers of rows we shall receive + * + * @param $criteriaInstance An instance of a Criteria class + * @param $onlyKeys Only use these keys for a cache key + * @return $numRows Numbers of rows of database entries + */ + function doSelectCountByCriteria(Criteria $criteriaInstance, $onlyKeys = array()); + + /** + * Getter for primary key used in wrapped table + * + * @return $primaryKey Primary key used in wrapped table + */ + function getPrimaryKeyValue(); + + /** + * Counts total rows of this table + * + * @return $count Total rows of this table + */ + function countTotalRows(); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/database/class_FrameworkDatabase.php b/inc/main/interfaces/database/class_FrameworkDatabase.php new file mode 100644 index 00000000..8b7c72c4 --- /dev/null +++ b/inc/main/interfaces/database/class_FrameworkDatabase.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FrameworkDatabase extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/database/class_Updateable.php b/inc/main/interfaces/database/class_Updateable.php new file mode 100644 index 00000000..1887b357 --- /dev/null +++ b/inc/main/interfaces/database/class_Updateable.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Updateable extends FrameworkInterface { + /** + * Updates a given field with new value + * + * @param $fieldName Field to update + * @param $fieldValue New value to store + * @return void + */ + function updateDatabaseField ($fieldName, $fieldValue); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/database/frontend/.htaccess b/inc/main/interfaces/database/frontend/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/database/frontend/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/database/middleware/.htaccess b/inc/main/interfaces/database/middleware/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/database/middleware/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/database/middleware/class_DatabaseConnector.php b/inc/main/interfaces/database/middleware/class_DatabaseConnector.php new file mode 100644 index 00000000..86acb923 --- /dev/null +++ b/inc/main/interfaces/database/middleware/class_DatabaseConnector.php @@ -0,0 +1,123 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DatabaseConnector extends FrameworkDatabase { + /** + * Get an instance of this class (Singleton) + * + * @return $selfInstance An instance of this class + */ + static function getSelfInstance (); + + /** + * Setter for database connection + * + * @param $login Login to database + * @param $pass Password (plain) + * @param $dbase Database to choose + * @param $host Hostname to use + * @return void + */ + function setConnectionData ($login, $pass, $dbase, $host='localhost'); + + /** + * Getter for connection data + * + * @return $connectData Connection data stored with this clas + */ + function getConnectionData (); + + /** + * Setter for the real database layer + * @param $dbLayer An instance of the real database layer + * @return void + */ + function setDatabaseLayer (DatabaseBackend $dbLayer); + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + function getIndexKey (); + + /** + * Runs a 'select' statement on the database layer with given table name + * and criteria. If this doesn't fail the result will be returned + * + * @param $tableName Name of the 'table' we shall query + * @param $criteriaInstance An instance of a Criteria class + * @return $result The result as an array + */ + function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance); + + /** + * Getter for last exception + * + * @return $exceptionInstance Last thrown exception + */ + function getLastException (); + + /** + * 'Inserts' a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @return void + */ + function queryInsertDataSet (StoreableCriteria $dataSetInstance); + + /** + * 'Updates' a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @return void + */ + function queryUpdateDataSet (StoreableCriteria $dataSetInstance); + + /** + * Getter for primary key column of specified table name + * + * @param $tableName Name of table we need the primary key column from + * @return $primaryKey Primary key column of requested table + */ + function getPrimaryKeyOfTable ($tableName); + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + function removeNonPublicDataFromArray (array $data); + + /** + * Counts total rows of given table + * + * @param $tableName Table name + * @return $count Total rows of given table + */ + function countTotalRows($tableName); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/database/wrapper/.htaccess b/inc/main/interfaces/database/wrapper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/database/wrapper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/database/wrapper/class_BookablePointsWrapper.php b/inc/main/interfaces/database/wrapper/class_BookablePointsWrapper.php new file mode 100644 index 00000000..eaeb13e8 --- /dev/null +++ b/inc/main/interfaces/database/wrapper/class_BookablePointsWrapper.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface BookablePointsWrapper extends DatabaseWrapper { + /** + * Inserts the given points for the given user in the database + * + * @param $pointsInstance An instance of a user class + * @return void + */ + function insertUserPoints (BookablePoints $pointsInstance); + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a Updateable database result + * @return void + */ + function doUpdateByResult (UpdateableResult $resultInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/database/wrapper/class_ManageableAccountWrapper.php b/inc/main/interfaces/database/wrapper/class_ManageableAccountWrapper.php new file mode 100644 index 00000000..ec9126dd --- /dev/null +++ b/inc/main/interfaces/database/wrapper/class_ManageableAccountWrapper.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableAccountWrapper extends DatabaseWrapper { + /** + * Handles inserting the registration data from a registration instance into the database + * + * @param $registrationInstance An instance of a registration class + * @return void + */ + function insertRegistrationObject (UserRegister $registrationInstance); + + /** + * Updates an user database entry with given result + * + * @param $resultInstance An instance of a Updateable database result + * @return void + */ + function doUpdateByResult (UpdateableResult $resultInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/debug/.htaccess b/inc/main/interfaces/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/debug/class_Debugger.php b/inc/main/interfaces/debug/class_Debugger.php new file mode 100644 index 00000000..a8925403 --- /dev/null +++ b/inc/main/interfaces/debug/class_Debugger.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Debugger extends FrameworkInterface { + /** + * Outputs the given data + * + * @param $output Debug text for output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + function outputStream ($output, $stripTags = FALSE); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/discovery/.htaccess b/inc/main/interfaces/discovery/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/discovery/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/discovery/class_Discoverable.php b/inc/main/interfaces/discovery/class_Discoverable.php new file mode 100644 index 00000000..d9a13ffc --- /dev/null +++ b/inc/main/interfaces/discovery/class_Discoverable.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Discoverable extends FrameworkInterface { + /** + * Discovers the request + * + * @param $requestInstance An instance of a Requestable class + * @return void + */ + function discover (Requestable $requestInstance); + + /** + * Adds the database result in a human-readable format to the helper class + * + * @param $helperInstance An instance of a helper class + * @return void + */ + function addResultsToHelper (HelpableTemplate $helperInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/feature/.htaccess b/inc/main/interfaces/feature/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/feature/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/feature/class_Feature.php b/inc/main/interfaces/feature/class_Feature.php new file mode 100644 index 00000000..9fa497fe --- /dev/null +++ b/inc/main/interfaces/feature/class_Feature.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface Feature extends FrameworkInterface { + /** + * Checks whether this feature can be made available to other classes. + * + * @return $isAvailable Whether this feature is available + */ + function isFeatureAvailable (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/filter/.htaccess b/inc/main/interfaces/filter/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/filter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/filter/class_Filterable.php b/inc/main/interfaces/filter/class_Filterable.php new file mode 100644 index 00000000..9d9e3a4a --- /dev/null +++ b/inc/main/interfaces/filter/class_Filterable.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Filterable extends FrameworkInterface { + /** + * 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 + */ + function execute (Requestable $requestInstance, Responseable $responseInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/handler/.htaccess b/inc/main/interfaces/handler/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/handler/class_Handleable.php b/inc/main/interfaces/handler/class_Handleable.php new file mode 100644 index 00000000..cc2539cf --- /dev/null +++ b/inc/main/interfaces/handler/class_Handleable.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Handleable extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/handler/class_HandleableDataSet.php b/inc/main/interfaces/handler/class_HandleableDataSet.php new file mode 100644 index 00000000..26e12f91 --- /dev/null +++ b/inc/main/interfaces/handler/class_HandleableDataSet.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HandleableDataSet extends Handleable { + /** + * Adds all required elements from given array into data set instance + * + * @param $dataSetInstance An instance of a StoreableCriteria class + * @param $messageData An array with all message data + * @return void + */ + function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/handler/protocol/.htaccess b/inc/main/interfaces/handler/protocol/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/handler/protocol/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/handler/protocol/class_HandleableProtocol.php b/inc/main/interfaces/handler/protocol/class_HandleableProtocol.php new file mode 100644 index 00000000..a4918ab6 --- /dev/null +++ b/inc/main/interfaces/handler/protocol/class_HandleableProtocol.php @@ -0,0 +1,58 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HandleableProtocol extends Handleable { + /** + * Getter for port number to satify HandleableProtocol + * + * @return $port The port number + */ + function getPort (); + + /** + * Getter for protocol name + * + * @return $protocol Name of used protocol + */ + function getProtocolName (); + + /** + * Validates given 'recipient' if it is a valid UNL. This means that the UNL + * can be parsed by the protocol handler. + * + * @param $packageData Valid raw package data + * @return $isValid Whether the UNL can be validated + */ + function isValidUniversalNodeLocatorByPackageData (array $packageData); + + /** + * If the found UNL (address) matches own external or internal address + * + * @param $unl UNL to test + * @return $ifMatches Whether the found UNL matches own addresss + */ + function isOwnAddress ($unl); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/handler/task/.htaccess b/inc/main/interfaces/handler/task/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/handler/task/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/handler/task/class_HandleableTask.php b/inc/main/interfaces/handler/task/class_HandleableTask.php new file mode 100644 index 00000000..67969ac9 --- /dev/null +++ b/inc/main/interfaces/handler/task/class_HandleableTask.php @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo HandleableDataSet looks strange here + * + * 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 . + */ +interface HandleableTask extends HandleableDataSet { + /** + * Searches a task by given instance + * + * @param $taskInstanc An instanceof a Taskable class + * @return $taskName Name of the task as used while registration + */ + function searchTask (Taskable $taskInstance); + + /** + * Registers a task with a task handler. + * + * @param $taskName A task name to register the task on + * @param $taskInstance The instance we should register as a task + * @return void + */ + function registerTask ($taskName, Visitable $taskInstance); + + /** + * Checks whether tasks are left including idle task + * + * @return $tasksLeft Whether there are tasks left to handle + */ + function hasTasksLeft (); + + /** + * Handles all tasks by checking if they should startup or if it is their + * turn to run. You should use this method in a while() loop in conjuntion + * with hasTasksLeft() so you can e.g. shutdown by adding a ShutdownTask + * which will attempt to remove all tasks from the task handler. + * + * @return void + */ + function handleTasks (); + + /** + * Shuts down all tasks and the task handler itself. This method should be + * called from a corresponding filter class. + * + * @return void + */ + function doShutdown (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/helper/.htaccess b/inc/main/interfaces/helper/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/helper/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/helper/class_Helper.php b/inc/main/interfaces/helper/class_Helper.php new file mode 100644 index 00000000..427f3813 --- /dev/null +++ b/inc/main/interfaces/helper/class_Helper.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Helper extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/helper/login/.htaccess b/inc/main/interfaces/helper/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/helper/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/helper/login/class_HelpableLogin.php b/inc/main/interfaces/helper/login/class_HelpableLogin.php new file mode 100644 index 00000000..90a1717e --- /dev/null +++ b/inc/main/interfaces/helper/login/class_HelpableLogin.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HelpableLogin extends Helper { + /** + * Execute the login request by given response instance. This instance can + * be used for sending cookies or at least the session id out. + * + * @param $responseInstance An instance of a Responseable class + * @return void + */ + function executeLogin (Responseable $responseInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/helper/template/.htaccess b/inc/main/interfaces/helper/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/helper/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/helper/template/class_HelpableTemplate.php b/inc/main/interfaces/helper/template/class_HelpableTemplate.php new file mode 100644 index 00000000..54462567 --- /dev/null +++ b/inc/main/interfaces/helper/template/class_HelpableTemplate.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HelpableTemplate extends Helper { + /** + * Flush the content out,e g. to a template variable + * + * @return void + */ + function flushContent (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/index/.htaccess b/inc/main/interfaces/index/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/index/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/index/class_Indexable b/inc/main/interfaces/index/class_Indexable new file mode 100644 index 00000000..d3dfbc13 --- /dev/null +++ b/inc/main/interfaces/index/class_Indexable @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface Indexable??? extends Indexable { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/index/class_Indexable.php b/inc/main/interfaces/index/class_Indexable.php new file mode 100644 index 00000000..079d0368 --- /dev/null +++ b/inc/main/interfaces/index/class_Indexable.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface Indexable extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/index/stack/.htaccess b/inc/main/interfaces/index/stack/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/index/stack/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/index/stack/class_IndexableStack.php b/inc/main/interfaces/index/stack/class_IndexableStack.php new file mode 100644 index 00000000..64b88056 --- /dev/null +++ b/inc/main/interfaces/index/stack/class_IndexableStack.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface IndexableStack extends Indexable, CalculatableBlock { + /** + * Adds given hash to an index file + * + * @param $stackName Name of stack to add hash + * @param $data Hash and gap position to be added to the index + * @return void + */ + function addHashToIndex ($stackName, array $data); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/.htaccess b/inc/main/interfaces/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/class_FilePointer.php b/inc/main/interfaces/io/class_FilePointer.php new file mode 100644 index 00000000..20a3c375 --- /dev/null +++ b/inc/main/interfaces/io/class_FilePointer.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FilePointer extends FrameworkInterface { + /** + * Getter for the file pointer + * + * @return $filePointer The file pointer which shall be a valid file resource + */ + function getPointer (); + + /** + * Getter for file name + * + * @return $fileName The current file name + */ + function getFileName (); + + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + */ + function isEndOfFileReached (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/class_Streamable.php b/inc/main/interfaces/io/class_Streamable.php new file mode 100644 index 00000000..2c143932 --- /dev/null +++ b/inc/main/interfaces/io/class_Streamable.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Streamable extends FrameworkInterface { + /** + * Determines seek position + * + * @return $seekPosition Current seek position + */ + function determineSeekPosition (); + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + */ + function seek ($offset, $whence = SEEK_SET); + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + function size (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/class_StreamableInput.php b/inc/main/interfaces/io/class_StreamableInput.php new file mode 100644 index 00000000..5b36bb9b --- /dev/null +++ b/inc/main/interfaces/io/class_StreamableInput.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface StreamableInput extends Streamable { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/class_StreamableOutput.php b/inc/main/interfaces/io/class_StreamableOutput.php new file mode 100644 index 00000000..2798e50c --- /dev/null +++ b/inc/main/interfaces/io/class_StreamableOutput.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface StreamableOutput extends Streamable { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/directory/.htaccess b/inc/main/interfaces/io/directory/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/directory/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/directory/class_FrameworkDirectory.php b/inc/main/interfaces/io/directory/class_FrameworkDirectory.php new file mode 100644 index 00000000..bc06c093 --- /dev/null +++ b/inc/main/interfaces/io/directory/class_FrameworkDirectory.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FrameworkDirectory extends FrameworkInterface { + /** + * Read raw lines of data from a directory pointer and return the data + * + * @return $currentEntry Current entry from encapsulated iterator + */ + function readRawDirectory (); + + /** + * Read lines from the current directory pointer except some parts + * + * @param $except Some parts of a directory we want to ignore. Valid: directory and file names, other values will be silently ignored + * @return string Directory and/or file names read from the current directory pointer + */ + function readDirectoryExcept (array $except = array()); + + /** + * Close a directory source and set it's instance to null and the path name + * to empty + * + * @return void + */ + function closeDirectory (); + + /** + * Getter for the directory pointer + * + * @return $iteratorInstance The directory pointer which shall be a valid directory resource + */ + function getDirectoryIteratorInstance (); + + /** + * Getter for path name + * + * @return $pathName The current path name + */ + function getPathName (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/file/.htaccess b/inc/main/interfaces/io/file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/file/class_FileInputStreamer.php b/inc/main/interfaces/io/file/class_FileInputStreamer.php new file mode 100644 index 00000000..34bb1217 --- /dev/null +++ b/inc/main/interfaces/io/file/class_FileInputStreamer.php @@ -0,0 +1,37 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FileInputStreamer extends StreamableInput { + /** + * Reads from a local or remote file + * + * @param $fqfn The file's FQFN we shall load + * @return $array An array containing all read lines + * @throws InvalidArrayCountException If an array has not the expected size + * @throws InvalidMD5ChecksumException If two MD5 hashes did not match + */ + function loadFileContents ($fqfn); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/file/class_FileOutputStreamer.php b/inc/main/interfaces/io/file/class_FileOutputStreamer.php new file mode 100644 index 00000000..ee9f2a25 --- /dev/null +++ b/inc/main/interfaces/io/file/class_FileOutputStreamer.php @@ -0,0 +1,37 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface FileOutputStreamer extends StreamableOutput { + /** + * Saves streamed (that are mostly serialized objects) data to files or + * external servers. + * + * @param $fileName The local file's name including full path + * @param $dataArray Array containing the compressor's extension and streamed data + * @return void + */ + function saveFile ($fileName, array $dataArray); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/file/csv/.htaccess b/inc/main/interfaces/io/file/csv/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/file/csv/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/file/csv/class_CsvInputStreamer.php b/inc/main/interfaces/io/file/csv/class_CsvInputStreamer.php new file mode 100644 index 00000000..558dd725 --- /dev/null +++ b/inc/main/interfaces/io/file/csv/class_CsvInputStreamer.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface CsvInputStreamer extends FileInputStreamer { + /** + * Reads a line from CSV file and returns it as an indexed array + * + * @param $columnSeparator Character to use separting columns + * @return $lineArray An index array with the read line + */ + function readCsvFileLine ($columnSeparator); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/file/handler/.htaccess b/inc/main/interfaces/io/file/handler/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/file/handler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/file/handler/class_IoHandler.php b/inc/main/interfaces/io/file/handler/class_IoHandler.php new file mode 100644 index 00000000..6348cc9a --- /dev/null +++ b/inc/main/interfaces/io/file/handler/class_IoHandler.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface IoHandler extends FileInputStreamer, FileOutputStreamer { + /** + * Setter for the *real* file input instance + * + * @param $inputStream The *real* file-input class + * @return void + */ + function setInputStream (FileInputStreamer $inputStream); + + /** + * Getter for the *real* file input instance + * + * @return $inputStream The *real* file-input class + */ + function getInputStream (); + + /** + * Setter for the *real* file output instance + * + * @param $outputStream The *real* file-output class + * @return void + */ + function setOutputStream (FileOutputStreamer $outputStream); + + /** + * Getter for the *real* file output instance + * + * @return $outputStream The *real* file-output class + */ + function getOutputStream (); + + /** + * Saves a file with data by using the current output stream + * + * @param $fileName Name of the file + * @param $dataStream File data stream + * @param $objectInstance An instance of a FrameworkInterface class (default: NULL) + * @return void + */ + function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/output/.htaccess b/inc/main/interfaces/io/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/output/class_OutputStreamer.php b/inc/main/interfaces/io/output/class_OutputStreamer.php new file mode 100644 index 00000000..1d2f89c5 --- /dev/null +++ b/inc/main/interfaces/io/output/class_OutputStreamer.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface OutputStreamer extends StreamableOutput { + /** + * Output the code + * + * @param $outStream Stream to output + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + function output ($outStream = FALSE, $stripTags = FALSE); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/pointer/.htaccess b/inc/main/interfaces/io/pointer/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/pointer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/pointer/class_InputPointer.php b/inc/main/interfaces/io/pointer/class_InputPointer.php new file mode 100644 index 00000000..a4567af0 --- /dev/null +++ b/inc/main/interfaces/io/pointer/class_InputPointer.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface InputPointer extends StreamableInput, FilePointer { + /** + * Read data a file pointer + * + * @return $data Read data from file + */ + function readFromFile (); + + /** + * Reads a line, maximum 4096 Bytes from current file pointer + * + * @return $data Read data from file + */ + function readLine (); + + /** + * Reads given amount of bytes from file. + * + * @param $bytes Amount of bytes to read or whole line (only text files) + * @return $data Data read from file + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + */ + function read ($bytes = NULL); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/pointer/class_OutputPointer.php b/inc/main/interfaces/io/pointer/class_OutputPointer.php new file mode 100644 index 00000000..4ac2fe94 --- /dev/null +++ b/inc/main/interfaces/io/pointer/class_OutputPointer.php @@ -0,0 +1,48 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface OutputPointer extends StreamableOutput, FilePointer { + /** + * Write data to a file pointer + * + * @param $dataStream The data stream we shall write to the file + * @return mixed Number of writes bytes or FALSE on error + * @throws NullPointerException If the file pointer instance + * is not set by setPointer() + * @throws InvalidResourceException If there is being set + * an invalid file resource + */ + function writeToFile ($dataStream); + + /** + * Writes at given position by seeking to it. + * + * @param $seekPosition Seek position in file + * @param $data Data to be written + * @return mixed Number of writes bytes or FALSE on error + */ + function writeAtPosition ($seedPosition, $data); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/io/pointer/io/.htaccess b/inc/main/interfaces/io/pointer/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/io/pointer/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/io/pointer/io/class_InputOutputPointer.php b/inc/main/interfaces/io/pointer/io/class_InputOutputPointer.php new file mode 100644 index 00000000..8d4500b2 --- /dev/null +++ b/inc/main/interfaces/io/pointer/io/class_InputOutputPointer.php @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface InputOutputPointer extends InputPointer, OutputPointer { + /** + * Rewinds to the beginning of the file + * + * @return $status Status of this operation + */ + function rewind (); + + /** + * Advances to next "block" of bytes + * + * @return void + */ + function next (); + + /** + * Checks wether the current entry is valid (not at the end of the file). + * This method will return TRUE if an emptied (nulled) entry has been found. + * + * @return $isValid Whether the next entry is valid + */ + function valid (); + + /** + * Gets current seek position ("key"). + * + * @return $key Current key in iteration + */ + function key (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/iterator/.htaccess b/inc/main/interfaces/iterator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/iterator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/iterator/class_SeekableWritableFileIterator.php b/inc/main/interfaces/iterator/class_SeekableWritableFileIterator.php new file mode 100644 index 00000000..26ed97dd --- /dev/null +++ b/inc/main/interfaces/iterator/class_SeekableWritableFileIterator.php @@ -0,0 +1,188 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @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 . + */ +interface SeekableWritableFileIterator extends SeekableIterator { + /** + * Seeks to given position + * + * @param $seekPosition Seek position in file + * @return $status Status of this operation + */ + function seek ($seekPosition); + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + function size (); + + /** + * Reads given amount of bytes from file. + * + * @param $bytes Amount of bytes to read + * @return $data Data read from file + */ + function read ($bytes); + + /** + * Analyzes entries in index file. This will count all found (and valid) + * entries, mark invalid as damaged and count gaps ("fragmentation"). If + * only gaps are found, the file is considered as "virgin" (no entries). + * + * @return void + */ + function analyzeFile (); + + /** + * Checks whether the file header is initialized + * + * @return $isInitialized Whether the file header is initialized + */ + function isFileHeaderInitialized (); + + /** + * Creates the assigned file + * + * @return void + */ + function createFileHeader (); + + /** + * Pre-allocates file (if enabled) with some space for later faster write access. + * + * @param $type Type of the file + * @return void + */ + function preAllocateFile ($type); + + /** + * Initializes counter for valid entries, arrays for damaged entries and + * an array for gap seek positions. If you call this method on your own, + * please re-analyze the file structure. So you are better to call + * analyzeFile() instead of this method. + * + * @return void + */ + function initCountersGapsArray (); + + /** + * Getter for header size + * + * @return $totalEntries Size of file header + */ + function getHeaderSize (); + + /** + * Setter for header size + * + * @param $headerSize Size of file header + * @return void + */ + function setHeaderSize ($headerSize); + + /** + * Getter for header array + * + * @return $totalEntries Size of file header + */ + function getHeader (); + + /** + * Setter for header + * + * @param $header Array for a file header + * @return void + */ + function setHeader (array $header); + + /** + * Updates seekPosition attribute from file to avoid to much access on file. + * + * @return void + */ + function updateSeekPosition (); + + /** + * Getter for total entries + * + * @return $totalEntries Total entries in this file + */ + function getCounter (); + + /** + * "Getter" for file size + * + * @return $fileSize Size of currently loaded file + */ + function getFileSize (); + + /** + * Writes data at given position + * + * @param $seekPosition Seek position + * @param $data Data to be written + * @param $flushHeader Whether to flush the header (default: flush) + * @return void + */ + function writeData ($seekPosition, $data, $flushHeader = TRUE); + + /** + * Getter for seek position + * + * @return $seekPosition Current seek position (stored here in object) + */ + function getSeekPosition (); + + /** + * Writes given value to the file and returns a hash and gap position for it + * + * @param $groupId Group identifier + * @param $value Value to be added to the stack + * @return $data Hash and gap position + */ + function writeValueToFile ($groupId, $value); + + /** + * Writes given raw data to the file and returns a gap position and length + * + * @param $groupId Group identifier + * @param $hash Hash from encoded value + * @param $encoded Encoded value to be written to the file + * @return $data Gap position and length of the raw data + */ + function writeDataToFreeGap ($groupId, $hash, $encoded); + + /** + * Searches for next suitable gap the given length of data can fit in + * including padding bytes. + * + * @param $length Length of raw data + * @return $seekPosition Found next gap's seek position + */ + function searchNextGap ($length); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/language/.htaccess b/inc/main/interfaces/language/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/language/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/language/class_ManageableLanguage.php b/inc/main/interfaces/language/class_ManageableLanguage.php new file mode 100644 index 00000000..ceffb104 --- /dev/null +++ b/inc/main/interfaces/language/class_ManageableLanguage.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableLanguage extends FrameworkInterface { + /** + * Initialize the array-object for all later language strings + * + * @return void + */ + function initLanguageStrings(); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/lists/.htaccess b/inc/main/interfaces/lists/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/lists/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/lists/class_Listable.php b/inc/main/interfaces/lists/class_Listable.php new file mode 100644 index 00000000..f3a60f92 --- /dev/null +++ b/inc/main/interfaces/lists/class_Listable.php @@ -0,0 +1,89 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Listable extends FrameworkInterface, IteratorAggregate { + /** + * Checks whether the given group is set + * + * @param $groupName Group to check if found in list + * @return $isset Whether the group is valid + */ + function isGroupSet ($groupName); + + /** + * Adds the given group or if already added issues a ListGroupAlreadyAddedException + * + * @param $groupName Group to add + * @return void + * @throws ListGroupAlreadyAddedException If the given group is already added + */ + function addGroup ($groupName); + + /** + * Adds the given instance to list group and sub group + * + * @param $groupName Group to add instance to + * @param $subGroup Sub group to add instance to + * @param $visitableInstance An instance of Visitable + * @return void + * @throws NoListGroupException If the given group is not found + */ + function addInstance ($groupName, $subGroup, Visitable $visitableInstance); + + /** + * Adds the given entry to list group + * + * @param $groupName Group to add instance to + * @param $entry An entry of any type + * @return void + * @throws NoListGroupException If the given group is not found + */ + function addEntry ($groupName, $entry); + + /** + * Updates the given entry by hash with given array + * + * @param $hash Hash for this entry + * @param $entryArray Array with entry we should update + * @return void + * @throws InvalidListHashException If the solved hash index is invalid + */ + function updateCurrentEntryByHash ($hash, array $entryArray); + + /** + * "Getter" for an iterator instance of this list + * + * @return $iteratorInstance An instance of a Iterator class + */ + function getListIterator (); + + /** + * Clears this list (mostly by clearing all groups together) + * + * @return void + */ + function clearList (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/login/.htaccess b/inc/main/interfaces/login/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/login/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/login/class_LoginableUser.php b/inc/main/interfaces/login/class_LoginableUser.php new file mode 100644 index 00000000..d1c26b32 --- /dev/null +++ b/inc/main/interfaces/login/class_LoginableUser.php @@ -0,0 +1,47 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface LoginableUser extends FrameworkInterface { + /** + * Logins the user with the given request containing the credential. The + * result of the login can be thrown by exception or, if prefered stored + * in a boolean attribute which is then readable by a matching getter. + * + * @param $requestInstance An instance of a Requestable class + * @param $responseInstance An instance of a Responseable class + * @return void + */ + function doLogin (Requestable $requestInstance, Responseable $responseInstance); + + /** + * Check if the implementation is correct. Only the request instance is + * needed as no redirect is done here. + * + * @param $requestInstance An instance of a Requestable class + * @return + */ + function testLogin (Requestable $requestInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/mailer/.htaccess b/inc/main/interfaces/mailer/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/mailer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/mailer/class_DeliverableMail.php b/inc/main/interfaces/mailer/class_DeliverableMail.php new file mode 100644 index 00000000..2e03b4ea --- /dev/null +++ b/inc/main/interfaces/mailer/class_DeliverableMail.php @@ -0,0 +1,56 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DeliverableMail extends FrameworkInterface { + /** + * Adds a user class to the recipient list for current template + * + * @param $userInstance An instance of a user class + * @return void + */ + function addRecipientByUserInstance (ManageableMember $userInstance); + + /** + * Use subject line provided by the (XML) template otherwise a subject line must be set + * + * @return void + */ + function useSubjectFromTemplate (); + + /** + * Deliver email to the recipient(s) + * + * @return void + */ + function deliverEmail (); + + /** + * Send notification to the admin + * + * @return void + */ + function sendAdminNotification (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/menu/.htaccess b/inc/main/interfaces/menu/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/menu/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/menu/class_RenderableMenu.php b/inc/main/interfaces/menu/class_RenderableMenu.php new file mode 100644 index 00000000..8b0281c2 --- /dev/null +++ b/inc/main/interfaces/menu/class_RenderableMenu.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface RenderableMenu extends FrameworkInterface { + /** + * Renders the menu by loading the base template and a menu-specific + * template. + * + * @return void + */ + function renderMenu (); + + /** + * Transfers the rendered menu to a given template engine by assigning + * the rendered content with a template variable. + * + * @2param $templateInstance An instance of a CompileableTemplate class + * @return void + */ + function transferContentToTemplateEngine (CompileableTemplate $templateInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/parser/.htaccess b/inc/main/interfaces/parser/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/parser/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/parser/class_Parseable.php b/inc/main/interfaces/parser/class_Parseable.php new file mode 100644 index 00000000..c3bcb3ea --- /dev/null +++ b/inc/main/interfaces/parser/class_Parseable.php @@ -0,0 +1,36 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Parseable extends FrameworkInterface { + /** + * Parses the given XML content + * + * @param $content Valid XML content + * @return void + * @throws XmlParserException If an XML error was found + */ + function parseXmlContent ($content); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/points/.htaccess b/inc/main/interfaces/points/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/points/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/points/class_BookablePoints.php b/inc/main/interfaces/points/class_BookablePoints.php new file mode 100644 index 00000000..eba95cdf --- /dev/null +++ b/inc/main/interfaces/points/class_BookablePoints.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface BookablePoints extends AddableCriteria { + /** + * Checks whether the user has the required amount of points left for the specified action + * + * @param $action The action or configuration entry plus prefix the user wants to perform + * @return $hasRequired Whether the user has the required points + */ + function ifUserHasRequiredPoints ($action); + + /** + * "Books" the given points amount on the current user's account + * + * @param $amount Amount of points we shall book + * @return void + */ + function bookPointsDirectly ($amount); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/reader/.htaccess b/inc/main/interfaces/reader/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/reader/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/reader/class_ReadableNews.php b/inc/main/interfaces/reader/class_ReadableNews.php new file mode 100644 index 00000000..44af0ee0 --- /dev/null +++ b/inc/main/interfaces/reader/class_ReadableNews.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ReadableNews extends FrameworkInterface { + /** + * Initializes the news reader class. This is very reader-dependent + * + * @return void + */ + function initializeReader(); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/registration/.htaccess b/inc/main/interfaces/registration/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/registration/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/registration/class_UserRegister.php b/inc/main/interfaces/registration/class_UserRegister.php new file mode 100644 index 00000000..ad4bf56a --- /dev/null +++ b/inc/main/interfaces/registration/class_UserRegister.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface UserRegister extends AddableCriteria { + /** + * Encrypt given request key or throws an exception if key was not found in + * request. + * + * @param $requestKey Key in request class + * @return void + */ + function encryptPassword ($requestKey); + + /** + * Perform things like informing assigned affilates about new registration + * before registration + * + * @return void + */ + function doPreRegistration (); + + /** + * Registers the new user account by insterting the request data into the + * database and paying some start credits or throw exceptions if this fails + * + * @return void + */ + function registerNewUser (); + + /** + * Perform things like notifying partner websites after registration is done + * + * @return void + */ + function doPostRegistration (); + + /** + * Do the action which is required after all registration steps are done. + * This can be a simple redirect to another webpage or displaying a message + * to the user. Or this can be a login step into the newly created account. + * + * @return void + */ + function doPostAction (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/registry/.htaccess b/inc/main/interfaces/registry/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/registry/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/registry/class_Register.php b/inc/main/interfaces/registry/class_Register.php new file mode 100644 index 00000000..222e7c10 --- /dev/null +++ b/inc/main/interfaces/registry/class_Register.php @@ -0,0 +1,52 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Register extends FrameworkInterface { + /** + * Checks whether an instance key was found + * + * @param $instanceKey The key holding an instance in registry + * @return $exists Whether the key exists in registry + */ + function instanceExists ($instanceKey); + + /** + * Adds/overwrites a new instance to the registry at the given key + * + * @param $instanceKey The key to identify the instance + * @param $objectInstance An instance we shall store + * @return void + */ + function addInstance ($instanceKey, Registerable $objectInstance); + + /** + * Gets a registered instance or null if not found + * + * @param $instanceKey The key to identify the instance + * @return $objectInstance An instance we shall store + */ + function getInstance ($instanceKey); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/registry/class_Registerable.php b/inc/main/interfaces/registry/class_Registerable.php new file mode 100644 index 00000000..213a562a --- /dev/null +++ b/inc/main/interfaces/registry/class_Registerable.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Registerable extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/registry/socket/.htaccess b/inc/main/interfaces/registry/socket/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/registry/socket/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/registry/socket/class_RegisterableSocket.php b/inc/main/interfaces/registry/socket/class_RegisterableSocket.php new file mode 100644 index 00000000..efe266a8 --- /dev/null +++ b/inc/main/interfaces/registry/socket/class_RegisterableSocket.php @@ -0,0 +1,64 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface RegisterableSocket extends Registerable { + /** + * Checks whether given socket resource is registered. If $socketResource is + * FALSE only the instance will be checked. + * + * @param $infoInstance An instance of a ShareableInfo class + * @param $socketResource A valid socket resource + * @return $isRegistered Whether the given socket resource is registered + */ + function isSocketRegistered (ShareableInfo $infoInstance, $socketResource); + + /** + * Registeres given socket for listener or throws an exception if it is already registered + * + * @param $infoInstance An instance of a ShareableInfo class + * @param $socketResource A valid socket resource + * @return void + * @throws SocketAlreadyRegisteredException If the given socket is already registered + */ + function registerSocket (ShareableInfo $infoInstance, $socketResource); + + /** + * Getter for given listener's socket resource + * + * @param $listenerInstance An instance of a Listenable class + * @return $socketResource A valid socket resource + * @throws NoSocketRegisteredException If the requested socket is not registered + */ + function getRegisteredSocketResource (Listenable $listenerInstance); + + /** + * "Getter" for info instance from given package data + * + * @param $packageData Raw package data + * @return $infoInstance An instance of a ShareableInfo class + */ + function getInfoInstanceFromPackageData (array $packageData); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/request/.htaccess b/inc/main/interfaces/request/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/request/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/request/class_Requestable.php b/inc/main/interfaces/request/class_Requestable.php new file mode 100644 index 00000000..5a9ef492 --- /dev/null +++ b/inc/main/interfaces/request/class_Requestable.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Requestable extends FrameworkInterface { + /** + * Prepares the request data for usage + * + * @return void + */ + function prepareRequestData (); + + /** + * Checks whether a request element is set + * + * @param $element Name of the request element we want to check + * @return $isSet Whether the request element is set + * @throws MissingArrayElementsException Thrown if a request element is not set + */ + function isRequestElementSet ($element); + + /** + * Getter for request element or 'null' if element was not found + * + * @param $element Name of the request element we want to check + * @return $value Value of the found request element or 'null' if the + * element was not found + */ + function getRequestElement ($element); + + /** + * Wrapper method for array_key() function for the request data array + * + * @return $array An array containing all array keys to return + */ + function getParameterNames (); + + /** + * Getter for a header element or 'null' if header was not found + * + * @param $headerName Name of the header + * @return $headerValue Value of the header or 'null' if not found + */ + function getHeaderElement ($headerName); + + /** + * Sets whether the request was valid (default: TRUE) + * + * @param $isValid Whether the request is valid + * @return void + */ + function requestIsValid ($isValid = TRUE); + + /** + * Reads a cookie and returns it's value or null if not found + * + * @param $cookieName Name of cookie we shall read + * @return $cookieValue Value of cookie or null if not found + */ + function readCookie ($cookieName); + + /** + * Checks if the request method is GET. + * + * @return $isGet Whether the request method is GET + */ + function isGetRequestMethod (); + + /** + * Checks if the request method is HEAD. + * + * @return $isHead Whether the request method is HEAD + */ + function isHeadRequestMethod (); + + /** + * Checks if the request method is POST. + * + * @return $isPost Whether the request method is POST + */ + function isPostRequestMethod (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/resolver/.htaccess b/inc/main/interfaces/resolver/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/resolver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/resolver/actions/.htaccess b/inc/main/interfaces/resolver/actions/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/resolver/actions/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/resolver/actions/class_ActionResolver.php b/inc/main/interfaces/resolver/actions/class_ActionResolver.php new file mode 100644 index 00000000..bdf99179 --- /dev/null +++ b/inc/main/interfaces/resolver/actions/class_ActionResolver.php @@ -0,0 +1,51 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ActionResolver extends Resolver { + /** + * Returns an action instance for the current action + * + * @return $actionInstance An instance of the resolved action + */ + function resolveAction (); + + /** + * Returns an action instance for a given request class + * + * @param $requestInstance An instance of a request class + * @return $actionInstance An instance of the resolved action + */ + function resolveActionByRequest (Requestable $requestInstance); + + /** + * Checks whether the given action is valid + * + * @param $actionName The default action we shall execute + * @return $isValid Whether the given action is valid + * @throws EmptyVariableException Thrown if given action is not set + */ + function isActionValid ($actionName); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/resolver/class_Resolver.php b/inc/main/interfaces/resolver/class_Resolver.php new file mode 100644 index 00000000..9620fb2f --- /dev/null +++ b/inc/main/interfaces/resolver/class_Resolver.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Resolver extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/resolver/commands/.htaccess b/inc/main/interfaces/resolver/commands/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/resolver/commands/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/resolver/commands/class_CommandResolver.php b/inc/main/interfaces/resolver/commands/class_CommandResolver.php new file mode 100644 index 00000000..16349bd6 --- /dev/null +++ b/inc/main/interfaces/resolver/commands/class_CommandResolver.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface CommandResolver extends Resolver { + /** + * Returns an command instance for a given request class + * + * @param $requestInstance An instance of a request class + * @return $commandInstance An instance of the resolved command + */ + function resolveCommandByRequest (Requestable $requestInstance); + + /** + * Checks whether the given command is valid + * + * @param $commandName The default command we shall execute + * @return $isValid Whether the given command is valid + * @throws EmptyVariableException Thrown if given command is not set + */ + function isCommandValid ($commandName); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/resolver/controller/.htaccess b/inc/main/interfaces/resolver/controller/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/resolver/controller/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/resolver/controller/class_ControllerResolver.php b/inc/main/interfaces/resolver/controller/class_ControllerResolver.php new file mode 100644 index 00000000..11a0dbb5 --- /dev/null +++ b/inc/main/interfaces/resolver/controller/class_ControllerResolver.php @@ -0,0 +1,34 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ControllerResolver extends Resolver { + /** + * Resolves the default controller of the given command + * + * @return $controllerInstance A controller instance for the default command + */ + function resolveController (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/resolver/state/.htaccess b/inc/main/interfaces/resolver/state/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/resolver/state/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/resolver/state/class_StateResolver.php b/inc/main/interfaces/resolver/state/class_StateResolver.php new file mode 100644 index 00000000..dc220cf6 --- /dev/null +++ b/inc/main/interfaces/resolver/state/class_StateResolver.php @@ -0,0 +1,46 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface StateResolver extends Resolver { + /** + * Returns an state instance for a given package raw data and socket resource + * + * @param $helperInstance An instance of a ConnectionHelper class + * @param $packageData Raw package data + * @param $socketResource A valid socket resource + * @return $stateInstance An instance of the resolved state + */ + static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource); + + /** + * Checks whether the given state is valid + * + * @param $stateName The default state we shall execute + * @return $isValid Whether the given state is valid + * @throws EmptyVariableException Thrown if given state is not set + */ + function isStateValid ($stateName); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/response/.htaccess b/inc/main/interfaces/response/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/response/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/response/class_Responseable.php b/inc/main/interfaces/response/class_Responseable.php new file mode 100644 index 00000000..976503d0 --- /dev/null +++ b/inc/main/interfaces/response/class_Responseable.php @@ -0,0 +1,114 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Responseable extends FrameworkInterface { + /** + * Setter for status + * + * @param $status New response status + * @return void + */ + function setResponseStatus ($status); + + /** + * Adds a header to the response. This method "wraps" the direct header() + * function call and so it can be done "generic". E.g. if a local + * application like my hub does not support redirects, this method can be + * kept empty or it can be done something else which would not be possible + * with a direct header() call. + * + * @param $name Name of header element + * @param $value Value of header element + * @return void + */ + function addHeader ($name, $value); + + /** + * "Writes" data to the response body + * + * @param $output Output we shall sent in the HTTP response + * @return void + */ + function writeToBody ($output); + + /** + * Flushs the cached HTTP response to the outer world + * + * @param $force Whether we shall force the output or abort if headers are + * already sent with an exception + * @return void + * @throws ResponseHeadersAlreadySentException Thrown if headers are + * already sent + */ + function flushBuffer ($force = FALSE); + + /** + * Adds a fatal message id to the response. The added messages can then be + * processed and outputed to the world + * + * @param $messageId The message id we shall add + * @return void + */ + function addFatalMessage ($messageId); + + /** + * Adds a cookie to the response + * + * @param $cookieName Cookie's name + * @param $cookieValue Value to store in the cookie + * @param $encrypted Do some extra encryption on the value + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + function addCookie ($cookieName, $cookieValue, $encrypted = FALSE); + + /** + * Redirect to a configured URL. The URL can be absolute or relative. In + * case of relative URL it will be extended automatically with the + * 'base_url' from configuration. + * + * @param $configEntry The configuration entry which holds our URL + * @return void + * @throws ResponseHeadersAlreadySentException If headers are already sent + */ + function redirectToConfiguredUrl ($configEntry); + + /** + * Expires the given cookie if it is set + * + * @param $cookieName Cookie to expire + * @return void + */ + function expireCookie ($cookieName); + + /** + * Refreshs a given cookie. This will make the cookie live longer + * + * @param $cookieName Cookie to refresh + * @return void + */ + function refreshCookie ($cookieName); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/result/.htaccess b/inc/main/interfaces/result/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/result/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/result/class_SearchableResult.php b/inc/main/interfaces/result/class_SearchableResult.php new file mode 100644 index 00000000..8e18e48f --- /dev/null +++ b/inc/main/interfaces/result/class_SearchableResult.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface SearchableResult extends FrameworkInterface { + /** + * Searches for an entry in the data result and returns it + * + * @param $criteriaInstance The criteria to look inside the data set + * @return $result Found result entry + */ + function searchEntry (LocalSearchCriteria $criteriaInstance); + + /** + * Solver for result index value with call-back method + * + * @param $databaseColumn Database column where the index might be found + * @para $callBack Call-back object for setting the index + * @return void + */ + function solveResultIndex ($databaseColumn, DatabaseWrapper $wrapperInstance, array $callBack); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/result/class_UpdateableResult.php b/inc/main/interfaces/result/class_UpdateableResult.php new file mode 100644 index 00000000..5f774ad8 --- /dev/null +++ b/inc/main/interfaces/result/class_UpdateableResult.php @@ -0,0 +1,37 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface UpdateableResult extends AddableCriteria { + /** + * Adds an update request to the database result for writing it to the + * database layer + * + * @param $criteriaInstance An instance of a updateable criteria + * @return void + * @throws ResultUpdateException If no result was updated + */ + function add2UpdateQueue (LocalUpdateCriteria $criteriaInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/stacker/.htaccess b/inc/main/interfaces/stacker/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/stacker/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/stacker/class_Stackable.php b/inc/main/interfaces/stacker/class_Stackable.php new file mode 100644 index 00000000..22376985 --- /dev/null +++ b/inc/main/interfaces/stacker/class_Stackable.php @@ -0,0 +1,74 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Stackable extends FrameworkInterface { + /** + * Pushs a value on a named stacker + * + * @param $stackerName Name of the stacker + * @param $value Value to push on it + * @return void + * @throws StackerFullException If the stacker is full + */ + function pushNamed ($stackerName, $value); + + /** + * 'Pops' a value from a named stacker and returns it's value + * + * @param $stackerName Name of the stacker + * @return $value Value of the current stack entry + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + function popNamed ($stackerName); + + /** + * Get value from named stacker but don't "pop" it + * + * @param $stackerName Name of the stacker + * @return $value Value of last added value + * @throws NoStackerException If the named stacker was not found + * @throws EmptyStackerException If the named stacker is empty + */ + function getNamed ($stackerName); + + /** + * Checks whether the given stack is initialized (set in array $stackers) + * + * @param $stackerName Name of the stack + * @return $isInitialized Whether the stack is initialized + */ + function isStackInitialized ($stackerName); + + /** + * Checks whether the given stack is empty + * + * @param $stackerName Name of the stack + * @return $isEmpty Whether the stack is empty + * @throws NoStackerException If given stack is missing + */ + function isStackEmpty ($stackerName); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/stacker/file/.htaccess b/inc/main/interfaces/stacker/file/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/stacker/file/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/stacker/file/class_StackableFile.php b/inc/main/interfaces/stacker/file/class_StackableFile.php new file mode 100644 index 00000000..daaf885e --- /dev/null +++ b/inc/main/interfaces/stacker/file/class_StackableFile.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface StackableFile extends Stackable { + /** + * Seeks to given position + * + * @param $seekPosition Seek position in file + * @return $status Status of this operation + */ + function seek ($seekPosition); + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + function size (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/state/.htaccess b/inc/main/interfaces/state/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/state/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/state/class_Stateable.php b/inc/main/interfaces/state/class_Stateable.php new file mode 100644 index 00000000..7ecfa0b9 --- /dev/null +++ b/inc/main/interfaces/state/class_Stateable.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Stateable extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/streams/.htaccess b/inc/main/interfaces/streams/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/streams/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/streams/class_Stream.php b/inc/main/interfaces/streams/class_Stream.php new file mode 100644 index 00000000..3cb93f4c --- /dev/null +++ b/inc/main/interfaces/streams/class_Stream.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Stream extends FrameworkInterface { + /** + * Streams the data and maybe does something to it + * + * @param $data The data (string mostly) to "stream" + * @return $data The data (string mostly) to "stream" + */ + function streamData ($data); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/streams/crypto/.htaccess b/inc/main/interfaces/streams/crypto/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/streams/crypto/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/streams/crypto/class_EncryptableStream.php b/inc/main/interfaces/streams/crypto/class_EncryptableStream.php new file mode 100644 index 00000000..59287d5d --- /dev/null +++ b/inc/main/interfaces/streams/crypto/class_EncryptableStream.php @@ -0,0 +1,44 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface EncryptableStream extends Stream { + /** + * Encrypt the string with fixed salt + * + * @param $str The unencrypted string + * @param $key Optional key, if none provided, a random key will be generated + * @return $encrypted Encrypted string + */ + function encryptStream ($str, $key = NULL); + + /** + * Decrypt the string with fixed salt + * + * @param $encrypted Encrypted string + * @return $str The unencrypted string + */ + function decryptStream ($encrypted); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/streams/input/.htaccess b/inc/main/interfaces/streams/input/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/streams/input/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/streams/input/class_InputStream.php b/inc/main/interfaces/streams/input/class_InputStream.php new file mode 100644 index 00000000..44b16f03 --- /dev/null +++ b/inc/main/interfaces/streams/input/class_InputStream.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface InputStream extends Stream { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/streams/output/.htaccess b/inc/main/interfaces/streams/output/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/streams/output/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/streams/output/class_OutputStream.php b/inc/main/interfaces/streams/output/class_OutputStream.php new file mode 100644 index 00000000..4802a8d4 --- /dev/null +++ b/inc/main/interfaces/streams/output/class_OutputStream.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface OutputStream extends Stream { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/tasks/.htaccess b/inc/main/interfaces/tasks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/tasks/class_Taskable.php b/inc/main/interfaces/tasks/class_Taskable.php new file mode 100644 index 00000000..b1915b92 --- /dev/null +++ b/inc/main/interfaces/tasks/class_Taskable.php @@ -0,0 +1,49 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Taskable extends FrameworkInterface { + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + function accept (Visitor $visitorInstance); + + /** + * Executes the task + * + * @return void + */ + function executeTask (); + + /** + * Shuts down the task + * + * @return void + */ + function doShutdown (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/template/.htaccess b/inc/main/interfaces/template/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/template/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/template/class_CompileableTemplate.php b/inc/main/interfaces/template/class_CompileableTemplate.php new file mode 100644 index 00000000..d1265687 --- /dev/null +++ b/inc/main/interfaces/template/class_CompileableTemplate.php @@ -0,0 +1,285 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface CompileableTemplate extends FrameworkInterface { + /** + * Assign variables for templates + * + * @param $variableName The "variable" we want to assign + * @param $value The value we want to store in the variable + * @return void + */ + function assignVariable ($variableName, $value); + + /** + * Load a specified HTML template into the engine + * + * @param $template The web template we shall load which is located in + * "html" by default + * @return void + */ + function loadHtmlTemplate ($template); + + /** + * Load a specified code template into the engine for later compilation + * with other code/web/email templates. + * + * @param $template The code template we shall load which is + * located in "html" by default + * @return void + */ + function loadCodeTemplate ($template); + + /** + * Load a specified email template into the engine for later compilation + * with other code/web/email templates. + * + * @param $template The email template we shall load which is + * located in "html" by default + * @return void + */ + function loadEmailTemplate ($template); + + /** + * Compile all variables by inserting their respective values + * + * @return void + */ + function compileVariables (); + + + /** + * Compile all required code/web/email-templates into the current one + * + * @return void + */ + function compileTemplate (); + + /** + * Adds a variable to current group + * + * @param $variableName Variable to set + * @param $value Value to store in variable + * @return void + */ + function addGroupVariable ($variableName, $value); + + /** + * Removes a given variable + * + * @param $variableName The variable we are looking for + * @param $variableGroup Name of variable group (default: 'general') + * @return void + */ + function removeVariable ($variableName, $variableGroup = 'general'); + + /** + * Assign a given congfiguration variable with a value + * + * @param $variableName The configuration variable we want to assign + * @return void + */ + function assignConfigVariable ($variableName); + + /** + * Compiles configuration place-holders in all variables. This 'walks' + * through the variable stack 'general'. It interprets all values from that + * variables as configuration entries after compiling them. + * + * @return void + */ + function compileConfigInVariables (); + + /** + * Assigns the last loaded raw template content with a given variable + * + * @param $templateName Name of the template we want to assign + * @param $variableName Name of the variable we want to assign + * @return void + */ + function assignTemplateWithVariable ($templateName, $variableName); + + /** + * Transfers the content of this template engine to a given response instance + * + * @param $responseInstance An instance of a response class + * @return void + */ + function transferToResponse (Responseable $responseInstance); + + /** + * Assigns all the application data with template variables + * + * @param $applicationInstance A manageable application instance + * @return void + */ + function assignApplicationData (ManageableApplication $applicationInstance); + + /** + * "Compiles" a variable by replacing {?var?} with it's content + * + * @param $rawCode Raw code to compile + * @param $setMatchAsCode Sets $match if readVariable() returns empty result (default: FALSE) + * @return $rawCode Compile code with inserted variable value + */ + function compileRawCode ($rawCode, $setMatchAsCode = FALSE); + + /** + * Renames a variable in code and in stack + * + * @param $oldName Old name of variable + * @param $newName New name of variable + * @return void + */ + function renameVariable ($oldName, $newName); + + /** + * Renders the given XML content + * + * @param $content Valid XML content or if not set the current loaded raw content + * @return void + * @throws XmlParserException If an XML error was found + */ + function renderXmlContent ($content = NULL); + + /** + * Enables or disables language support + * + * @param $languageSupport New language support setting + * @return void + */ + function enableLanguageSupport ($languageSupport = TRUE); + + /** + * Checks whether language support is enabled + * + * @return $languageSupport Whether language support is enabled or disabled + */ + function isLanguageSupportEnabled (); + + /** + * Enables or disables XML compacting + * + * @param $xmlCompacting New XML compacting setting + * @return void + */ + function enableXmlCompacting ($xmlCompacting = TRUE); + + /** + * Checks whether XML compacting is enabled + * + * @return $xmlCompacting Whether XML compacting is enabled or disabled + */ + function isXmlCompactingEnabled (); + + /** + * Removes all comments, tabs and new-line charcters to compact the content + * + * @param $uncompactedContent The uncompacted content + * @return $compactedContent The compacted content + */ + function compactContent ($uncompactedContent); + + /** + * Getter for given variable group + * + * @param $variableGroup Variable group to check + * @return $varStack Found variable group + */ + function getVarStack ($variableGroup); + + /** + * Settter for variable group + * + * @param $groupName Name of variable group + * @param $add Whether add this group + * @return void + */ + function setVariableGroup ($groupName, $add = TRUE); + + /** + * Getter for template type + * + * @return $templateType The current template's type + */ + function getTemplateType (); + + /** + * Getter for base path + * + * @return $templateBasePath The relative base path for all templates + */ + function getTemplateBasePath (); + + /** + * Getter for generic base path + * + * @return $templateBasePath The relative base path for all templates + */ + function getGenericBasePath (); + + /** + * Getter for template extension + * + * @return $templateExtension The file extension for all uncompiled + * templates + */ + function getRawTemplateExtension (); + + /** + * Getter for code-template extension + * + * @return $codeExtension The file extension for all code- + * templates + */ + function getCodeTemplateExtension (); + + /** + * Getter for raw template data + * + * @return $rawTemplateData The raw data from the template + */ + function getRawTemplateData (); + + /** + * Assigns a lot variables into the stack of currently loaded template. + * This method should only be used in very rare circumstances, e.g. when + * you have to copy a whole set of variables into the template engine. + * Before you use this method, please make sure you have considered all + * other possiblities. + * + * @param $variables An array with variables to be assigned + * @return void + */ + function assignMultipleVariables (array $variables); + + /** + * Getter for variable group array + * + * @return $variableGroups All variable groups + */ + function getVariableGroups (); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/template/view/class_ViewHelper.php b/inc/main/interfaces/template/view/class_ViewHelper.php new file mode 100644 index 00000000..51f51044 --- /dev/null +++ b/inc/main/interfaces/template/view/class_ViewHelper.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ViewHelper extends FrameworkInterface { + /** + * The execute method for executing the view helper + * + * @param $args Arguments to send to the view helper + * @return mixed Unknown return arguments, or void + */ + function execute (array $args = NULL); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/user/.htaccess b/inc/main/interfaces/user/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/user/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/user/class_ManageableAccount.php b/inc/main/interfaces/user/class_ManageableAccount.php new file mode 100644 index 00000000..6f015147 --- /dev/null +++ b/inc/main/interfaces/user/class_ManageableAccount.php @@ -0,0 +1,50 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableAccount extends FrameworkInterface { + /** + * Determines whether the username exists or not + * + * @return $exists Whether the username exists + */ + function ifUsernameExists (); + + /** + * Determines whether the email exists or not + * + * @return $exists Whether the email exists + */ + function ifEmailAddressExists (); + + /** + * Checks if supplied password hash in request matches with stored in + * database. + * + * @param $requestInstance A requestable class instance + * @return $matches Whether the supplied password hash matches + */ + function ifPasswordHashMatches (Requestable $requestInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/user/extended/.htaccess b/inc/main/interfaces/user/extended/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/user/extended/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/user/extended/class_ManageableGuest.php b/inc/main/interfaces/user/extended/class_ManageableGuest.php new file mode 100644 index 00000000..be24383c --- /dev/null +++ b/inc/main/interfaces/user/extended/class_ManageableGuest.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableGuest extends ManageableAccount { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/user/extended/class_ManageableMember.php b/inc/main/interfaces/user/extended/class_ManageableMember.php new file mode 100644 index 00000000..98106f06 --- /dev/null +++ b/inc/main/interfaces/user/extended/class_ManageableMember.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ManageableMember extends ManageableAccount { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/visitor/.htaccess b/inc/main/interfaces/visitor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/visitor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/visitor/class_Visitable.php b/inc/main/interfaces/visitor/class_Visitable.php new file mode 100644 index 00000000..149b671e --- /dev/null +++ b/inc/main/interfaces/visitor/class_Visitable.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Visitable extends FrameworkInterface { + /** + * Accepts the visitor to process the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + function accept (Visitor $visitorInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/visitor/class_Visitor.php b/inc/main/interfaces/visitor/class_Visitor.php new file mode 100644 index 00000000..96e9ceef --- /dev/null +++ b/inc/main/interfaces/visitor/class_Visitor.php @@ -0,0 +1,28 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface Visitor extends FrameworkInterface { +} + +// [EOF] +?> diff --git a/inc/main/interfaces/visitor/decorator/.htaccess b/inc/main/interfaces/visitor/decorator/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/visitor/decorator/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/visitor/decorator/class_DecoratorVisitor.php b/inc/main/interfaces/visitor/decorator/class_DecoratorVisitor.php new file mode 100644 index 00000000..0e08e479 --- /dev/null +++ b/inc/main/interfaces/visitor/decorator/class_DecoratorVisitor.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface DecoratorVisitor extends Visitor { + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A decorator instance + * @return void + */ + function visitDecorator (BaseDecorator $decoratorInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/visitor/listener/.htaccess b/inc/main/interfaces/visitor/listener/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/visitor/listener/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/visitor/listener/class_ListenerVisitor.php b/inc/main/interfaces/visitor/listener/class_ListenerVisitor.php new file mode 100644 index 00000000..57403719 --- /dev/null +++ b/inc/main/interfaces/visitor/listener/class_ListenerVisitor.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface ListenerVisitor extends Visitor { + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + function visitListener (Listenable $listenerInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/visitor/pool/.htaccess b/inc/main/interfaces/visitor/pool/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/visitor/pool/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/visitor/pool/class_PoolVisitor.php b/inc/main/interfaces/visitor/pool/class_PoolVisitor.php new file mode 100644 index 00000000..9deaec35 --- /dev/null +++ b/inc/main/interfaces/visitor/pool/class_PoolVisitor.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface PoolVisitor extends Visitor { + /** + * Visits the given pool instance + * + * @param $poolInstance A Poolable instance + * @return void + */ + function visitPool (Poolable $poolInstance); +} + +// [EOF] +?> diff --git a/inc/main/interfaces/visitor/tasks/.htaccess b/inc/main/interfaces/visitor/tasks/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/interfaces/visitor/tasks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/interfaces/visitor/tasks/class_TaskVisitor.php b/inc/main/interfaces/visitor/tasks/class_TaskVisitor.php new file mode 100644 index 00000000..b729a42f --- /dev/null +++ b/inc/main/interfaces/visitor/tasks/class_TaskVisitor.php @@ -0,0 +1,35 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface TaskVisitor extends Visitor { + /** + * Visits the given task instance + * + * @param $taskInstance A Taskable instance + * @return void + */ + function visitTask (Taskable $taskInstance); +} + +// [EOF] +?> diff --git a/inc/main/middleware/.htaccess b/inc/main/middleware/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/middleware/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/middleware/class_BaseMiddleware.php b/inc/main/middleware/class_BaseMiddleware.php new file mode 100644 index 00000000..5764f554 --- /dev/null +++ b/inc/main/middleware/class_BaseMiddleware.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseMiddleware extends BaseFrameworkSystem { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/inc/main/middleware/compressor/.htaccess b/inc/main/middleware/compressor/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/middleware/compressor/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/middleware/compressor/class_CompressorChannel.php b/inc/main/middleware/compressor/class_CompressorChannel.php new file mode 100644 index 00000000..f1189c5f --- /dev/null +++ b/inc/main/middleware/compressor/class_CompressorChannel.php @@ -0,0 +1,140 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class CompressorChannel extends BaseMiddleware implements Registerable { + /** + * Real compressor instance + */ + private $compressor = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor! + parent::__construct(__CLASS__); + } + + /** + * Create a new compressor channel. + * + * @return $compressorInstance A prepared instance of this class + */ + public static final function createCompressorChannel () { + // Get new instance + $compressorInstance = new CompressorChannel(); + + // Is the compressor handler set? + if ( + (is_null($compressorInstance->getCompressor())) + || (!$compressorInstance->getCompressor() instanceof Compressor) + ) { + // Init base directory + $baseDir = + $compressorInstance->getConfigInstance()->getConfigEntry('base_path') . + $compressorInstance->getConfigInstance()->getConfigEntry('compressor_base_path'); + + // Get a directory pointer + $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($baseDir)); + + // Read all directories but no sub directories, .htaccess files and NullCompressor class + while ($directoryEntry = $directoryInstance->readDirectoryExcept(array('.htaccess', 'class_NullCompressor.php'))) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMPRESSOR[' . __METHOD__ . ':' . __LINE__ . ']: directoryEntry=' . $directoryEntry); + + // Is this a class file? + if ((substr($directoryEntry, 0, 6) == 'class_') && (substr($directoryEntry, -4, 4) == '.php')) { + /* Get the compressor's name. That's why you must name + * your files like your classes and also that's why you + * must keep on class in one file. + */ + $className = substr($directoryEntry, 6, -4); + + // Get an instance from our object factory + $tempInstance = ObjectFactory::createObjectByName($className); + + // Is it null? + if (is_null($tempInstance)) { + // Then skip to the next one + continue; + } // END - if + + // Set the compressor + $compressorInstance->setCompressor($tempInstance); + + // No more searches required because we have found a valid compressor stream + break; + } // END - if + } // END - while + + // Close the directory + $directoryInstance->closeDirectory(); + } // END - if + + // Check again if there is a compressor + if ( + (is_null($compressorInstance->getCompressor())) + || (!is_object($compressorInstance->getCompressor())) + || (!$compressorInstance instanceof Compressor) + ) { + // Set the null compressor handler. This should not be configureable! + // @TODO Is there a configurable fall-back compressor needed, or is NullCompressor okay? + $compressorInstance->setCompressor(ObjectFactory::createObjectByName('NullCompressor')); + } // END - if + + // Return the compressor instance + return $compressorInstance; + } + + /** + * Getter for compressor instance + * + * @return $compressor The compressor instance + */ + public final function getCompressor () { + return $this->compressor; + } + + /** + * Setter for compressor + * + * @param $compressorInstance The compressor instance we shall use + * @return void + */ + public final function setCompressor (Compressor $compressorInstance = NULL) { + $this->compressor = $compressorInstance; + } + + /** + * Getter for the file extension of the current compressor + */ + public final function getCompressorExtension () { + // Get compressor extension from current compressor + return $this->getCompressor()->getCompressorExtension(); + } +} + +// [EOF] +?> diff --git a/inc/main/middleware/database/.htaccess b/inc/main/middleware/database/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/middleware/database/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/middleware/database/class_DatabaseConnection.php b/inc/main/middleware/database/class_DatabaseConnection.php new file mode 100644 index 00000000..d3225c41 --- /dev/null +++ b/inc/main/middleware/database/class_DatabaseConnection.php @@ -0,0 +1,218 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DatabaseConnection extends BaseMiddleware implements DatabaseConnector, Registerable { + /** + * Array for connection data + */ + private $connectData = array( + 'login' => '', + 'pass' => '', + 'dbase' => '', + 'host' => '' + ); + + // The real database layer + private $dbLayer = NULL; + + // An instance of this class + private static $selfInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + // Create new database connection layer + public static final function createDatabaseConnection (DebugMiddleware $debugInstance, DatabaseBackend $dbLayer) { + // Get instance + $databaseInstance = new DatabaseConnection(); + + // Set database layer + $databaseInstance->setDatabaseLayer($dbLayer); + + // Set db instance + self::$selfInstance = $databaseInstance; + + // Return instance + return $databaseInstance; + } + + // Get an instance of this class + public static final function getSelfInstance () { + return self::$selfInstance; + } + + // Public setter for database connection + public final function setConnectionData ($login, $pass, $dbase, $host='localhost') { + // Transfer connection data + $this->connectData['login'] = (string) $login; + $this->connectData['pass'] = (string) $pass; + $this->connectData['dbase'] = (string) $dbase; + $this->connectData['host'] = (string) $host; + } + + /** + * Getter for connection data + * + * @return $connectData Connection data stored with this clas + */ + public final function getConnectionData () { + return $this->connectData; + } + + /** + * Setter for the real database layer + * @param $dbLayer An instance of the real database layer + * @return void + */ + public final function setDatabaseLayer (DatabaseBackend $dbLayer) { + $this->dbLayer = $dbLayer; + } + + /** + * Getter for index key + * + * @return $indexKey Index key + */ + public final function getIndexKey () { + return $this->dbLayer->getIndexKey(); + } + + /** + * Runs a 'select' statement on the database layer with given table name + * and criteria. If this doesn't fail the result will be returned + * + * @param $tableName Name of the 'table' we shall query + * @param $criteriaInstance An instance of a Criteria class + * @return $result The result as an array + */ + public function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Get result from query + $result = $this->dbLayer->querySelect($tableName, $criteriaInstance); + + // Return the result + return $result; + } + + /** + * Getter for last exception + * + * @return $exceptionInstance Last thrown exception + */ + public final function getLastException () { + $exceptionInstance = $this->dbLayer->getLastException(); + return $exceptionInstance; + } + + /** + * 'Inserts' a data set instance into a local file database folder + * + * @param $dataSetInstance A storeable data set + * @return void + */ + public function queryInsertDataSet (StoreableCriteria $dataSetInstance) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Ask the database layer + $this->dbLayer->queryInsertDataSet($dataSetInstance); + } + + /** + * 'Updates' a data set instance with a database layer + * + * @param $dataSetInstance A storeable data set + * @return void + */ + public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Ask the database layer + $this->dbLayer->queryUpdateDataSet($dataSetInstance); + } + + /** + * Getter for primary key column of specified table name + * + * @param $tableName Name of table we need the primary key column from + * @return $primaryKey Primary key column of requested table + */ + public function getPrimaryKeyOfTable ($tableName) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Ask the database layer + $primaryKey = $this->dbLayer->getPrimaryKeyOfTable($tableName); + + // Return the value + return $primaryKey; + } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray (array $data) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Call database backend + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: Calling this->dbLayer->removeNonPublicDataFromArray(data) ...'); + $data = $this->dbLayer->removeNonPublicDataFromArray($data); + + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DB-CONNECTION[' . $this->__toString() . ']: data[]=' . gettype($data)); + return $data; + } + + /** + * Count total table rows + * + * @param $tableName Table name + * @return $count Total row count + */ + public function countTotalRows ($tableName) { + // Connect to the database + $this->dbLayer->connectToDatabase(); + + // Ask the database layer + $count = $this->dbLayer->countTotalRows($tableName); + + // Return the value + return $count; + } +} + +// [EOF] +?> diff --git a/inc/main/middleware/debug/.htaccess b/inc/main/middleware/debug/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/middleware/debug/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/middleware/debug/class_DebugMiddleware.php b/inc/main/middleware/debug/class_DebugMiddleware.php new file mode 100644 index 00000000..045a3308 --- /dev/null +++ b/inc/main/middleware/debug/class_DebugMiddleware.php @@ -0,0 +1,128 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @deprecated See LoggerFactory for a more flexible approach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DebugMiddleware extends BaseMiddleware implements Registerable { + /** + * An instance of this class + */ + private static $selfInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set own instance + self::$selfInstance = $this; + + // Set it so all can use it + $this->setDebugInstance($this); + } + + /** + * Create a new debug output system. + * If no output is given this class is currently being used for back-fall. + * This fall-back mechanism will become deprecated very soon. + * + * @param $outputClass The class name which we shall use for + * registering the *real* debug output + * @param $className Class where a output should be created and + * configured for + * @return $debugInstance An instance of this middleware class + */ + public static final function createDebugMiddleware ($outputClass, $className) { + //* DEBUG-DIE: */ die(__METHOD__.': outputClass=' . $outputClass . ',className=' . $className); + + // Create an instance if this middleware + $debugInstance = new DebugMiddleware(); + + // Default is that $outputClass may be invalid + $isInitialized = FALSE; + + // Is there a valid output instance provided? + if ((!is_null($outputClass)) && (is_object($outputClass)) && ($outputClass instanceof OutputStreamer)) { + // Use the given output instance + $debugInstance->setOutputInstance($outputClass); + + // All fine + $isInitialized = TRUE; + } elseif ((!is_null($outputClass)) && (is_string($outputClass)) && (class_exists($outputClass))) { + // A name for a debug output class has been provided so we try to get it + $outputInstance = ObjectFactory::createObjectByName($outputClass); + + // Set this as output class + $debugInstance->setOutputInstance($outputInstance); + + // All fine + $isInitialized = TRUE; + } + + // Is the output class initialized? + if ($isInitialized === TRUE) { + // Then set class name + $debugInstance->getOutputInstance()->setLoggerClassName($className); + } // END - if + + // Return instance + return $debugInstance; + } + + /** + * Getter for an instance of this class + * + * @return $selfInstance An instance of this class + */ + public static final function getSelfInstance() { + return self::$selfInstance; + } + + /** + * This method shall send debug output which can be HTML code for the + * browser or debug lines for a log file, etc. to the registered debug + * output instance. + * + * @param $outStream Data we shall 'stream' out to the world + * @param $stripTags Whether HTML tags shall be stripped out + * @return void + */ + public final function output ($outStream, $stripTags = FALSE) { + // Is the output stream set + if (empty($outStream)) { + // @TODO Initialization phase + return; + } // END - if + + // Use the output instance + $this->getOutputInstance()->outputStream($outStream, $stripTags); + } +} + +// [EOF] +?> diff --git a/inc/main/middleware/io/.htaccess b/inc/main/middleware/io/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/middleware/io/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/middleware/io/class_FileIoHandler.php b/inc/main/middleware/io/class_FileIoHandler.php new file mode 100644 index 00000000..3480a31d --- /dev/null +++ b/inc/main/middleware/io/class_FileIoHandler.php @@ -0,0 +1,202 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class FileIoHandler extends BaseMiddleware implements IoHandler { + /** + * The *real* file input class we shall use for reading data + */ + private $inputStream = NULL; + + /** + * The *real* file output class we shall use for reading data + */ + private $outputStream = NULL; + + /** + * An instance of this class + */ + private static $selfInstance = NULL; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set own instance + self::$selfInstance = $this; + } + + /** + * Creates an instance of this class and prepares the IO system. This is + * being done by setting the default file IO class + * + * @return $ioInstance A prepared instance of FilIOHandler + */ + public static final function createFileIoHandler () { + // Get instance + $ioHandler = new FileIoHandler(); + + // Set the *real* file IO instances (both the same) + $ioHandler->setInputStream(ObjectFactory::createObjectByConfiguredName('file_input_class')); + $ioHandler->setOutputStream(ObjectFactory::createObjectByConfiguredName('file_output_class')); + + // Return instance + return $ioHandler; + } + + /** + * Getter for an instance of this class + * + * @return $selfInstance An instance of this class + */ + public static final function getSelfInstance () { + return self::$selfInstance; + } + + /** + * Setter for the *real* file input instance + * + * @param $inputStream The *real* file-input class + * @return void + */ + public final function setInputStream (FileInputStreamer $inputStream) { + $this->inputStream = $inputStream; + } + + /** + * Getter for the *real* file input instance + * + * @return $inputStream The *real* file-input class + */ + public final function getInputStream () { + return $this->inputStream; + } + + /** + * Setter for the *real* file output instance + * + * @param $outputStream The *real* file-output class + * @return void + */ + public final function setOutputStream (FileOutputStreamer $outputStream) { + $this->outputStream = $outputStream; + } + + /** + * Getter for the *real* file output instance + * + * @return $outputStream The *real* file-output class + */ + public final function getOutputStream () { + return $this->outputStream; + } + /** + * Saves streamed (that are mostly serialized objects) data to files or + * external servers. + * + * @param $fileName The local file's name including full path + * @param $dataArray Array containing the compressor's extension and streamed data + * @return void + * @throws UnsupportedOperationException If this method is called + */ + public function saveFile ($fileName, array $dataArray) { + self::createDebugInstance(__CLASS__)->debugOutput('fileName=' . $fileName . ',dataArray()=' . count($dataArray)); + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Saves a file with data by using the current output stream + * + * @param $fileName Name of the file + * @param $dataStream File data stream + * @param $objectInstance An instance of a FrameworkInterface class (default: NULL) + * @return void + */ + public function saveStreamToFile ($fileName, $dataStream, FrameworkInterface $objectInstance = NULL) { + // Default is this array + $className = $this->__toString(); + + // Is the object instance set? + if ($objectInstance instanceof FrameworkInterface) { + // Then use this + $className = $objectInstance->__toString(); + } // END - if + + // Prepare output array + $dataArray = array( + 0 => $className, + 1 => $dataStream + ); + + // Send the fileName and dataArray to the output handler + $this->getOutputStream()->saveFile($fileName, $dataArray); + } + + /** Loads data from a file over the input handler + * + * @param $fqfn Given full-qualified file name (FQFN) to load + * @return $array Array with the file contents + */ + public function loadFileContents ($fqfn) { + // Read from the input handler + return $this->getInputStream()->loadFileContents($fqfn); + } + + /** + * Determines seek position + * + * @return $seekPosition Current seek position + * @todo 0% done + */ + public function determineSeekPosition () { + $this->partialStub(); + } + + /** + * Seek to given offset (default) or other possibilities as fseek() gives. + * + * @param $offset Offset to seek to (or used as "base" for other seeks) + * @param $whence Added to offset (default: only use offset to seek to) + * @return $status Status of file seek: 0 = success, -1 = failed + */ + public function seek ($offset, $whence = SEEK_SET) { + $this->partialStub('offset=' . $offset . ',whence=' . $whence); + } + + /** + * Size of file stack + * + * @return $size Size (in bytes) of file + */ + public function size () { + $this->partialStub(); + } +} + +// [EOF] +?> diff --git a/inc/main/third_party/.htaccess b/inc/main/third_party/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/third_party/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/third_party/akismet/.htaccess b/inc/main/third_party/akismet/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/third_party/akismet/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/third_party/akismet/akismet.class.php b/inc/main/third_party/akismet/akismet.class.php new file mode 100644 index 00000000..021447ec --- /dev/null +++ b/inc/main/third_party/akismet/akismet.class.php @@ -0,0 +1,388 @@ +Usage + * + * $comment = array( + * 'author' => 'viagra-test-123', + * 'email' => 'test@example.com', + * 'website' => 'http://www.example.com/', + * 'body' => 'This is a test comment', + * 'permalink' => 'http://yourdomain.com/yourblogpost.url', + * ); + * + * $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment); + * + * if($akismet->errorsExist()) { + * echo"Couldn't connected to Akismet server!"; + * } else { + * if($akismet->isSpam()) { + * echo"Spam detected"; + * } else { + * echo"yay, no spam!"; + * } + * } + * + * + * @author Bret Kuhns {@link www.miphp.net} + * @link http://www.miphp.net/blog/view/new_akismet_class/ + * @version 0.3.4 + * @license http://www.opensource.org/licenses/mit-license.php MIT License + */ + + + +// Error constants +define("AKISMET_SERVER_NOT_FOUND", 0); +define("AKISMET_RESPONSE_FAILED", 1); +define("AKISMET_INVALID_KEY", 2); + + + +// Base class to assist in error handling between Akismet classes +class AkismetObject { + var $errors = array(); + + + /** + * Add a new error to the errors array in the object + * + * @param String $name A name (array key) for the error + * @param String $string The error message + * @return void + */ + // Set an error in the object + function setError($name, $message) { + $this->errors[$name] = $message; + } + + + /** + * Return a specific error message from the errors array + * + * @param String $name The name of the error you want + * @return mixed Returns a String if the error exists, a false boolean if it does not exist + */ + function getError($name) { + if($this->isError($name)) { + return $this->errors[$name]; + } else { + return false; + } + } + + + /** + * Return all errors in the object + * + * @return String[] + */ + function getErrors() { + return (array)$this->errors; + } + + + /** + * Check if a certain error exists + * + * @param String $name The name of the error you want + * @return boolean + */ + function isError($name) { + return isset($this->errors[$name]); + } + + + /** + * Check if any errors exist + * + * @return boolean + */ + function errorsExist() { + return (count($this->errors) > 0); + } + + +} + + + + + +// Used by the Akismet class to communicate with the Akismet service +class AkismetHttpClient extends AkismetObject { + var $akismetVersion = '1.1'; + var $con; + var $host; + var $port; + var $apiKey; + var $blogUrl; + var $errors = array(); + + + // Constructor + function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) { + $this->host = $host; + $this->port = $port; + $this->blogUrl = $blogUrl; + $this->apiKey = $apiKey; + } + + + // Use the connection active in $con to get a response from the server and return that response + function getResponse($request, $path, $type = "post", $responseLength = 1160) { + $this->_connect(); + + if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) { + $request = + strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" . + "Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" . + "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" . + "Content-Length: ".strlen($request)."\r\n" . + "User-Agent: Akismet PHP4 Class\r\n" . + "\r\n" . + $request + ; + $response = ""; + + @fwrite($this->con, $request); + + while(!feof($this->con)) { + $response .= @fgets($this->con, $responseLength); + } + + $response = explode("\r\n\r\n", $response, 2); + return $response[1]; + } else { + $this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved."); + } + + $this->_disconnect(); + } + + + // Connect to the Akismet server and store that connection in the instance variable $con + function _connect() { + if(!($this->con = @fsockopen($this->host, $this->port))) { + $this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server."); + } + } + + + // Close the connection to the Akismet server + function _disconnect() { + @fclose($this->con); + } + + +} + + + + + +// The controlling class. This is the ONLY class the user should instantiate in +// order to use the Akismet service! +class Akismet extends AkismetObject { + var $apiPort = 80; + var $akismetServer = 'rest.akismet.com'; + var $akismetVersion = '1.1'; + var $http; + + var $ignore = array( + 'HTTP_COOKIE', + 'HTTP_X_FORWARDED_FOR', + 'HTTP_X_FORWARDED_HOST', + 'HTTP_MAX_FORWARDS', + 'HTTP_X_FORWARDED_SERVER', + 'REDIRECT_STATUS', + 'SERVER_PORT', + 'PATH', + 'DOCUMENT_ROOT', + 'SERVER_ADMIN', + 'QUERY_STRING', + 'PHP_SELF', + 'argv' + ); + + var $blogUrl = ""; + var $apiKey = ""; + var $comment = array(); + + + /** + * Constructor + * + * Set instance variables, connect to Akismet, and check API key + * + * @param String $blogUrl The URL to your own blog + * @param String $apiKey Your wordpress API key + * @param String[] $comment A formatted comment array to be examined by the Akismet service + * @return Akismet + */ + function Akismet($blogUrl, $apiKey, $comment = array()) { + $this->blogUrl = $blogUrl; + $this->apiKey = $apiKey; + $this->setComment($comment); + + // Connect to the Akismet server and populate errors if they exist + $this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey); + if($this->http->errorsExist()) { + $this->errors = array_merge($this->errors, $this->http->getErrors()); + } + + // Check if the API key is valid + if(!$this->_isValidApiKey($apiKey)) { + $this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid."); + } + } + + + /** + * Query the Akismet and determine if the comment is spam or not + * + * @return boolean + */ + function isSpam() { + $response = $this->http->getResponse($this->_getQueryString(), 'comment-check'); + + return ($response == "true"); + } + + + /** + * Submit this comment as an unchecked spam to the Akismet server + * + * @return void + */ + function submitSpam() { + $this->http->getResponse($this->_getQueryString(), 'submit-spam'); + } + + + /** + * Submit a false-positive comment as "ham" to the Akismet server + * + * @return void + */ + function submitHam() { + $this->http->getResponse($this->_getQueryString(), 'submit-ham'); + } + + + /** + * Manually set the comment value of the instantiated object. + * + * @param Array $comment + * @return void + */ + function setComment($comment) { + $this->comment = $comment; + if(!empty($comment)) { + $this->_formatCommentArray(); + $this->_fillCommentValues(); + } + } + + + /** + * Returns the current value of the object's comment array. + * + * @return Array + */ + function getComment() { + return $this->comment; + } + + + /** + * Check with the Akismet server to determine if the API key is valid + * + * @access Protected + * @param String $key The Wordpress API key passed from the constructor argument + * @return boolean + */ + function _isValidApiKey($key) { + $keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key'); + + return ($keyCheck == "valid"); + } + + + /** + * Format the comment array in accordance to the Akismet API + * + * @access Protected + * @return void + */ + function _formatCommentArray() { + $format = array( + 'type' => 'comment_type', + 'author' => 'comment_author', + 'email' => 'comment_author_email', + 'website' => 'comment_author_url', + 'body' => 'comment_content' + ); + + foreach($format as $short => $long) { + if(isset($this->comment[$short])) { + $this->comment[$long] = $this->comment[$short]; + unset($this->comment[$short]); + } + } + } + + + /** + * Fill any values not provided by the developer with available values. + * + * @return void + */ + function _fillCommentValues() { + if(!isset($this->comment['user_ip'])) { + $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR'); + } + if(!isset($this->comment['user_agent'])) { + $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; + } + if(!isset($this->comment['referrer'])) { + $this->comment['referrer'] = $_SERVER['HTTP_REFERER']; + } + if(!isset($this->comment['blog'])) { + $this->comment['blog'] = $this->blogUrl; + } + } + + + /** + * Build a query string for use with HTTP requests + * + * @access Protected + * @return String + */ + function _getQueryString() { + foreach($_SERVER as $key => $value) { + if(!in_array($key, $this->ignore)) { + if($key == 'REMOTE_ADDR') { + $this->comment[$key] = $this->comment['user_ip']; + } else { + $this->comment[$key] = $value; + } + } + } + + $query_string = ''; + + foreach($this->comment as $key => $data) { + $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&'; + } + + return $query_string; + } + + +} +?> \ No newline at end of file diff --git a/inc/main/third_party/api/.htaccess b/inc/main/third_party/api/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/third_party/api/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/third_party/api/primusportal/.htaccess b/inc/main/third_party/api/primusportal/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/third_party/api/primusportal/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/third_party/api/primusportal/class_PrimeraApi.php b/inc/main/third_party/api/primusportal/class_PrimeraApi.php new file mode 100644 index 00000000..b78bf55d --- /dev/null +++ b/inc/main/third_party/api/primusportal/class_PrimeraApi.php @@ -0,0 +1,263 @@ +payPrimera($PayReceiver, $PayAmount, $PayDescription); + * + * Wobei $PayReicer der Username des Empf�ngers bei + * Primusportal.de ist. $PayAmount ist der gerundete( !! ) Betrag an Primera, + * die der Empf�nger erhalten soll. $PayDescription ist eine von Ihnen + * festgelegte kurze Beschreibung. Die L�nge dieses Textes darf 100 Zeichen + * nicht �berschreiten. Beispiel: + * $status = $apiInstance->payPrimera('garbage', 10000, 'Auszahlung IhreSeite.de - ID: 12345'); + * 3. �berpr�fung des Status (R�ckgabecode): + * CODE: + * if ($status === FALSE) { + * // Ein Fehler ist aufgetreten + * // Fehlerbehandlung hier einf�gen... + * } else { + * // Auszahlung erfolgreich durchgef�hrt + * // F�hren Sie hier Ihre Datenbankabfragen durch, um die Auszahlung zu + * // best�tigen... + * } + * + * Die komplette R�ckgabe des Interfaces wird als assoziatives Array in der Klassen- + * variable $data gespeichert: + * $data = array( + * 'status' => R�ckgabecode (PI_DONE, PI_SENDER_ERROR, ...), + * 'statustext' => Status in Worten (z.B.: 'Transaktion erfolgreich durchgef�hrt'), + * ); + * + * + * @author Andreas Schmidt + * @author Roland Haeder + * @version 1.0 - beta + * @copyright (c) 2007 by Primusportal.de + * @copyright (c) 2008, 2011 by Roland Haeder + */ +class PrimeraApi extends BaseFrameworkSystem { + /** + * Fehler - Interfacebenutzer + */ + const PI_ERROR = -1; + + /** + * Statuscode f�r erfolgreich ausgef�hrte Transaktion + */ + const PI_DONE = 200; + + /** + * Fehler - User existiert nicht oder ist gesperrt + */ + const PI_RECEIVER_ERROR = 301; + + /** + * Sender-Account Fehler (User nicht existent, gesperrt, ...) + */ + const PI_SENDER_ERROR = 401; + + /** + * Betrag fehler + */ + const PI_AMOUNT_ERROR = 501; + + /** + * Zu wenig Primera + */ + const PI_TOO_LESS_PRIMERA = 502; + + /** + * User nicht aktiv oder existiert nicht + */ + const PI_USER_CHECK_ERROR = 601; + + /** + * User aktiv + */ + const PI_USER_CHECK_OK = 602; + + /** + * Primerastand erfolgreich geholt + */ + const PI_GET_PRIMERA_DONE = 701; + + /** + * HTTP-EOL + */ + const HTTP_EOL = "\r\n"; + + /** + * URL f�r das Interface auf dem Primusserver: + */ + private $host = 'www.primusportal.de'; + private $path = '/transfer.interface.2.0.php'; + + private $errno = 0; + private $err = ''; + + private $separator = ':'; + + private $username = ''; + private $password = ''; + + private $data = array(); + + /** + * Konstruktor + */ + public function __construct ($primusUsername, $primusPassword) { + // Call parent constructor + parent::__construct(); + + // Set data + $this->username = $primusUsername; + $this->password = $primusPassword; + } + + /** + * Anfrage senden und Rueckgabecode in Variable speichern + */ + private function queryApi ( $data = array() ) { + $fp = fsockopen($this->host, 80, $this->errno, $this->_err); + if (!$fp) return false; + + $data['PrimusInterface_Username'] = base64_encode($this->username); + $data['PrimusInterface_Password'] = base64_encode(md5($this->password)); + + // POST-Daten uebermitteln: + $queryData = http_build_query($data, '', '&'); + + $request .= 'POST ' . $this->path . 'HTTP/1.1' . self::HTTP_EOL; + $request .= 'Host: ' . $this->host . self::HTTP_EOL; + $request .= 'Content-type: application/x-www-form-urlencoded' . self::HTTP_EOL; + $request .= 'Content-length: '. strlen($queryData) . self::HTTP_EOL; + $request .= 'Connection: close' . self::HTTP_EOL; + $request .= self::HTTP_EOL; + $request .= $queryData; + + fputs($fp, $request); + + $return = ''; + while (!feof($fp)) { + $return .= fgets($fp, 128); + } // END - while + + $content = explode('', $return); + return $content[1]; + } + + /** + * Funktion parst die R�ckgabe vom Transferskript: + */ + private function parseContent ( $content ) { + $x = explode("\n", $content); + $return = array(); + foreach($x as $currentLine) { + $line_exploded = explode($this->separator, $currentLine,2); + if (count($line_exploded) > 1) { + $return[$line_exploded[0]] = $line_exploded[1]; + } // END - if + } // END - foreach + return $return; + } + + /** + * @param int/string $Receiver UserID / Username des Empf�ngers + * @param int$Amount Betrag in ganzzahligen Primera + * @param string $Description Beschreibung (Sichtbar in Einzelauflistung) + */ + public function payPrimera ($Receiver, $Amount, $Description = '') { + $valid = FALSE; + $postData = array( + 'PrimusInterface_Action' => 'Pay', + 'PrimusInterface_Receiver' => base64_encode($Receiver), + 'PrimusInterface_Amount' => base64_encode($Amount), + 'PrimusInterface_Description' => base64_encode($Description) + ); + + $postReturn = $this->parseContent( $this->queryApi($postData) ); + + $this->data = $postReturn; + if ($postReturn['status'] == '200') { + $valid = TRUE; + } // END - if + return $valid; + } + + /** + * �berpr�ft den Status eines Primus-Users + * - existiert der User + * - ist er aktiv + * @param string/int $User Userid / Username + */ + public function checkPrimusUser ($userName) { + $valid = FALSE; + $postData = array( + 'PrimusInterface_Action' => 'CheckPrimusUser', + 'PrimusInterface_CheckPrimusUser' => $userName + ); + + $postReturn = $this->parseContent( $this->queryApi($postData) ); + + $this->data = $postReturn; + + if ($postReturn['status'] == self::PI_USER_CHECK_OK) { + $valid = TRUE; + } // END - if + return $valid; + } + + /** + * Die Funktion liefer den aktuellen Primerastand + */ + public function getPrimera() { + $primera = FALSE; + $postData = array( + 'PrimusInterface_Action' => 'GetPrimera' + ); + $postReturn = $this->parseContent( $this->queryApi($postData) ); + + $this->data = $postReturn; + if ($postReturn['status'] == self::PI_GET_PRIMERA_DONE) { + $primera = $postReturn['primera']; + } // END - if + return $primera; + } +} + +// [EOF] +?> diff --git a/inc/main/third_party/api/wernisportal/.htaccess b/inc/main/third_party/api/wernisportal/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/third_party/api/wernisportal/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/third_party/api/wernisportal/class_WernisApi.php b/inc/main/third_party/api/wernisportal/class_WernisApi.php new file mode 100644 index 00000000..3c5a1a4c --- /dev/null +++ b/inc/main/third_party/api/wernisportal/class_WernisApi.php @@ -0,0 +1,424 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * @todo Out-dated since 0.6-BETA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class WernisApi extends BaseFrameworkSystem { + /** + * Static base API URL + */ + private static $apiUrl = 'http://www.wds66.com/api/'; + + /** + * API Wernis amount + */ + private $wernis_amount = 0; + + /** + * API username + */ + private $w_id = 0; + + /** + * API Wernis password (not account password!) + */ + private $w_md5 = ''; + + /** + * Nickname of the user + */ + private $w_nick = ''; + + /** + * Wernis amount of the user + */ + private $w_amount = 0; + + /** + * Array with status informations + */ + private $statusArray = array(); + + /** + * Status for 'okay' + */ + private $statusOkay = 'OK'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this API class + * + * @param $cfg Configuration array + * @return $apiInstance An instance of this API class + */ + public static final function createWernisApi (array $cfg) { + // Create a new instance + $apiInstance = new WernisApi(); + + // Fix missing + if (!isset($cfg['api_url'])) $cfg['api_url'] = self::$apiUrl; + + // Konfiguration uebertragen + $apiInstance->setCoonfigArray($cfg); + + // Return the instance + return $apiInstance; + } + + /** + * Setter for gamer data + * + * @param $w_id Username (id) of the gamer + * @param $w_pwd Clear password of the gamer + * @return void + */ + public function setUser ($w_id, $w_pwd) { + // Set username (id) + $this->w_id = $w_id; + + // Hash clear password and set it + $this->w_md5 = md5($w_pwd); + } + + /************************************************ + * The following methods are not yet rewritten! * + ************************************************/ + + public function einziehen ($amount) { + // amount auf Gueltigkeit pruefen + $amount = isset($amount) ? $amount+0 : 0; + + if ($amount < $this->config['mineinsatz']) { + $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); + return false; + } + + // Abfrage senden + return $this->executeWithdraw($amount); + } + + public function verschicken ($amount) { + // amount auf Gueltigkeit pruefen + $amount = isset($amount) ? $amount+0 : 0; + + if ($amount < $this->config['mineinsatz']) { + $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz'])); + return false; + } + + // Abfrage senden + return $this->executePayout($amount); + } + + // Script abbrechen mit Zurueck-Buttom + public function ende () { + global $_CONFIG; + include 'templates/zurueck.html'; + include 'templates/fuss.html'; + exit(); + } + + // Fehlermeldung ausgeben und beenden + public function error () { + print "
    Fehler im Spiel: ".$this->getErrorMessage()."

    \n"; + $this->ende(); + } + + // Sets a status message and code + public function setStatusMessage ($msg, $status) { + $this->statusArray['message'] = $msg; + $this->statusArray['status'] = $status; + } + + // Get the status message + public function getErrorMessage () { + if (isset($this->statusArray['message'])) { + // Use raw message + return $this->statusArray['message']; + } else { + // Fall-back to status + return sprintf('Fehler-Code %s ist keiner Nachricht zugewiesen.', $this->getErrorCode()); + } + } + + // Get the status code + public function getErrorCode () { + if (isset($this->statusArray['status'])) { + // Use raw message + return $this->statusArray['status']; + } else { + // Something bad happend + return 'unknown'; + } + } + + // Sends out a request to the API and returns it's result + private function sendRequest ($scriptName, array $requestData = array()) { + // Is the requestData an array? + if (!is_array($requestData)) { + // Then abort here! + return array( + 'status' => 'failed_general', + 'message' => 'API-Daten in config sind ungültig!' + ); + } + + // Is the API id and MD5 hash there? + if ((empty($this->config['wernis_api_id'])) || (empty($this->config['wernis_api_key']))) { + // Abort here... + return array( + 'status' => 'failed_general', + 'message' => 'API-Daten in config.php sind leer!' + ); + } + + // Construct the request string + $requestString = $this->config['api_url'] . $scriptName . '?api_id=' . $this->config['wernis_api_id'] . '&api_key='.$this->config['wernis_api_key']; + foreach ($requestData as $key => $value) { + $requestString .= '&' . $key . '=' . $value; + } + + // Get the raw response from the lower function + $response = $this->sendRawRequest($requestString); + + // Check the response header if all is fine + if (strpos($response[0], '200') === FALSE) { + // Something bad happend... :( + return array( + 'status' => 'request_error', + 'message' => sprintf('Servermeldung %s von WDS66-API erhalten.', $response[0]) + ); + } + + // All (maybe) fine so remove the response header from server + for ($idx = (count($response) - 1); $idx > 1; $idx--) { + $line = trim($response[$idx]); + if (!empty($line)) { + $response = $line; + break; + } + } + + // Prepare the returning result for higher functions + if (substr($response, 0, 1) == '&') { + // Remove the leading & (which can be used in Flash) + $response = substr($response, 1); + } + + // Bring back the response + $data = explode('=', $response); + + // Default return array (should not stay empty) + $return = array(); + + // We use only the first two entries (which shall be fine) + if ($data[0] === 'error') { + // The request has failed... :( + switch ($data[1]) { + case '404': // Invalid API ID + case 'AUTH': // Authorization has failed + $return = array( + 'status' => 'auth_failed', + 'message' => 'API-Daten scheinen nicht zu stimmen! (Access Denied)' + ); + break; + + case 'LOCKED': // User account is locked! + case 'PASS': // Bad passphrase entered + case 'USER': // Missing account or invalid password + $return = array( + 'status' => 'user_failed', + 'message' => 'Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben.' + ); + break; + + case 'OWN': // Transfer to own account + $return = array( + 'status' => 'own_failed', + 'message' => 'Du darfst dein eigenes Spiel leider nicht spielen.' + ); + break; + + case 'AMOUNT': // Amount is depleted + $return = array( + 'status' => 'amount_failed', + 'message' => 'Dein Guthaben reicht nicht aus, um das Spiel zu spielen.' + ); + break; + + case 'AMOUNT-SEND': // API amount is depleted + $return = array( + 'status' => 'api_amount_failed', + 'message' => 'Nicht genügend Guthaben auf dem API-Account.' + ); + break; + + default: // Unknown error (maybe new?) + $return = array( + 'status' => 'request_failed', + 'message' => sprintf('Unbekannter Fehler %s von API erhalten.', $data[1]) + ); + break; + } + } else { + // All fine here + $return = array( + 'status' => $this->statusOkay, + 'response' => $response + ); + } + + // Return the result + return $return; + } + + // Widthdraw this amount + private function executeWithdraw ($amount) { + // First all fails... + $result = FALSE; + + // Prepare the purpose + $purpose = "\"Bube oder Dame\"-Einsatz gesetzt."; + + // Prepare the request data + $requestData = array( + 'sub_request' => 'receive', + 't_uid' => $this->w_id, + 't_md5' => $this->w_md5, + 'r_uid' => (int) $this->config['wernis_refid'], + 'amount' => (int) $amount, + 'purpose' => urlencode(base64_encode($purpose)) + ); + + // Return the result from the lower functions + $return = $this->sendRequest('book.php', $requestData); + + if ($return['status'] == $this->statusOkay) { + // All fine! + $result = TRUE; + } else { + // Status failture text + $this->setStatusMessage($return['message'], $return['status']); + } + + // Return result + return $result; + } + + // Payout this amount + private function executePayout ($amount) { + // First all fails... + $result = FALSE; + + // Prepare the purpose + $purpose = "\"Bube oder Dame\"-Gewinn erhalten."; + + // Prepare the request data + $requestData = array( + 'sub_request' => 'send', + 't_uid' => $this->w_id, + 't_md5' => $this->w_md5, + 'r_uid' => (int) $this->config['wernis_refid'], + 'amount' => (int) $amount, + 'purpose' => urlencode(base64_encode($purpose)) + ); + + // Return the result from the lower functions + $return = $this->sendRequest("book.php", $requestData); + + if ($return['status'] == $this->statusOkay) { + // All fine! + $result = TRUE; + } else { + // Status failture text + $this->setStatusMessage($return['message'], $return['status']); + } + + // Return result + return $result; + } + + // Send raw GET request + private function sendRawRequest ($script) { + // Use the hostname from script URL as new hostname + $url = substr($script, 7); + $extract = explode('/', $url); + + // Done extracting the URL :) + $url = $extract[0]; + + // Extract host name + $host = str_replace('http://', '', $url); + if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/')); + + // Generate relative URL + $script = substr($script, (strlen($url) + 7)); + if (substr($script, 0, 1) == '/') $script = substr($script, 1); + + // Open connection + $fp = @fsockopen($host, 80, $errno, $errdesc, 30); + if (!$fp) { + // Failed! + return array('', '', ''); + } + + // Generate request header + $request = "GET /" . trim($script) . " HTTP/1.0\r\n"; + $request .= "Host: " . $host . "\r\n"; + $request .= sprintf("User-Agent: WernisApi/1.0 by Quix0r [Spieler: %d]\r\n\r\n", $this->w_id); + + // Initialize array + $response = array(); + + // Write request + fputs($fp, $request); + + // Read response + while(!feof($fp)) { + array_push($response, trim(fgets($fp, 1024))); + } // END - while + + // Close socket + fclose($fp); + + // Was the request successfull? + if ((!ereg('200 OK', $response[0])) && (empty($response[0]))) { + // Not found / access forbidden + $response = array('', '', ''); + } // END - if + + // Return response + return $response; + } +} + +// [EOF] +?> diff --git a/inc/main/third_party/php_mailer/.htaccess b/inc/main/third_party/php_mailer/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/third_party/php_mailer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/third_party/php_mailer/ChangeLog.txt b/inc/main/third_party/php_mailer/ChangeLog.txt new file mode 100644 index 00000000..5de251ee --- /dev/null +++ b/inc/main/third_party/php_mailer/ChangeLog.txt @@ -0,0 +1,330 @@ +ChangeLog + +NOTE: THIS VERSION OF PHPMAILER IS DESIGNED FOR PHP5/PHP6. IT WILL NOT WORK WITH PHP4. + +Version 2.3 (November 06, 2008) + +* added Arabic language (many thanks to Bahjat Al Mostafa) +* removed English language from language files and made it a default within + class.phpmailer.php - if no language is found, it will default to use + the english language translation +* fixed public/private declarations +* corrected line 1728, $basedir to $directory +* added $sign_cert_file to avoid improper duplicate use of $sign_key_file +* corrected $this->Hello on line 612 to $this->Helo +* changed default of $LE to "\r\n" to comply with RFC 2822. Can be set by the user + if default is not acceptable +* removed trim() from return results in EncodeQP +* /test and three files it contained are removed from version 2.3 +* fixed phpunit.php for compliance with PHP5 +* changed $this->AltBody = $textMsg; to $this->AltBody = html_entity_decode($textMsg); +* We have removed the /phpdoc from the downloads. All documentation is now on + the http://phpmailer.codeworxtech.com website. + +Version 2.2.1 () July 19 2008 + +* fixed line 1092 in class.smtp.php (my apologies, error on my part) + +Version 2.2 () July 15 2008 + +* Fixed redirect issue (display of UTF-8 in thank you redirect) +* fixed error in getResponse function declaration (class.pop3.php) +* PHPMailer now PHP6 compliant +* fixed line 1092 in class.smtp.php (endless loop from missing = sign) + +Version 2.1 (Wed, June 04 2008) + +** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. + IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE + APPRECIATED. + +* added S/MIME functionality (ability to digitally sign emails) + BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. + The "Signed Emails" functionality adds the Sign method to pass the private key + filename and the password to read it, and then email will be sent with + content-type multipart/signed and with the digital signature attached. +* fully compatible with E_STRICT error level + - Please note: + In about half the test environments this development version was subjected + to, an error was thrown for the date() functions used (line 1565 and 1569). + This is NOT a PHPMailer error, it is the result of an incorrectly configured + PHP5 installation. The fix is to modify your 'php.ini' file and include the + date.timezone = America/New York + directive, to your own server timezone + - If you do get this error, and are unable to access your php.ini file: + In your PHP script, add + date_default_timezone_set('America/Toronto'); + - do not try to use + $myVar = date_default_timezone_get(); + as a test, it will throw an error. +* added ability to define path (mainly for embedded images) + function MsgHTML($message,$basedir='') ... where: + $basedir is the fully qualified path +* fixed MsgHTML() function: + - Embedded Images where images are specified by :// will not be altered or embedded +* fixed the return value of SMTP exit code ( pclose ) +* addressed issue of multibyte characters in subject line and truncating +* added ability to have user specified Message ID + (default is still that PHPMailer create a unique Message ID) +* corrected unidentified message type to 'application/octet-stream' +* fixed chunk_split() multibyte issue (thanks to Colin Brown, et al). +* added check for added attachments +* enhanced conversion of HTML to text in MsgHTML (thanks to "brunny") + +Version 2.1.0beta2 (Sun, Dec 02 2007) +* implemented updated EncodeQP (thanks to coolbru, aka Marcus Bointon) +* finished all testing, all known bugs corrected, enhancements tested +- note: will NOT work with PHP4. + +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +Version 2.1.0beta1 +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release +* implements new property to control VERP in class.smtp.php + example (requires instantiating class.smtp.php): + $mail->do_verp = true; +* POP-before-SMTP functionality included, thanks to Richard Davey + (see class.pop3.php & pop3_before_smtp_test.php for examples) +* included example showing how to use PHPMailer with GMAIL +* fixed the missing Cc in SendMail() and Mail() + +****************** +A note on sending bulk emails: + +If the email you are sending is not personalized, consider using the +"undisclosed-recipient:;" strategy. That is, put all of your recipients +in the Bcc field and set the To field to "undisclosed-recipients:;". +It's a lot faster (only one send) and saves quite a bit on resources. +Contrary to some opinions, this will not get you listed in spam engines - +it's a legitimate way for you to send emails. + +A partial example for use with PHPMailer: + +$mail->AddAddress("undisclosed-recipients:;"); +$mail->AddBCC("email1@anydomain.com,email2@anyotherdomain.com,email3@anyalternatedomain.com"); + +Many email service providers restrict the number of emails that can be sent +in any given time period. Often that is between 50 - 60 emails maximum +per hour or per send session. + +If that's the case, then break up your Bcc lists into chunks that are one +less than your limit, and put a pause in your script. +******************* + +Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release +* dramatically simplified using inline graphics ... it's fully automated and requires no user input +* added automatic document type detection for attachments and pictures +* added MsgHTML() function to replace Body tag for HTML emails +* fixed the SendMail security issues (input validation vulnerability) +* enhanced the AddAddresses functionality so that the "Name" portion is used in the email address +* removed the need to use the AltBody method (set from the HTML, or default text used) +* set the PHP Mail() function as the default (still support SendMail, SMTP Mail) +* removed the need to set the IsHTML property (set automatically) +* added Estonian language file by Indrek Päri +* added header injection patch +* added "set" method to permit users to create their own pseudo-properties like 'X-Headers', etc. + example of use: + $mail->set('X-Priority', '3'); + $mail->set('X-MSMail-Priority', 'Normal'); +* fixed warning message in SMTP get_lines method +* added TLS/SSL SMTP support + example of use: + $mail = new PHPMailer(); + $mail->Mailer = "smtp"; + $mail->Host = "smtp.example.com"; + $mail->SMTPSecure = "tls"; // option + //$mail->SMTPSecure = "ssl"; // option + ... + $mail->Send(); +* PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7) +* Works with PHP installed as a module or as CGI-PHP +- NOTE: will NOT work with PHP5 in E_STRICT error mode + +Version 1.73 (Sun, Jun 10 2005) +* Fixed denial of service bug: http://www.cybsec.com/vuln/PHPMailer-DOS.pdf +* Now has a total of 20 translations +* Fixed alt attachments bug: http://tinyurl.com/98u9k + +Version 1.72 (Wed, May 25 2004) +* Added Dutch, Swedish, Czech, Norwegian, and Turkish translations. +* Received: Removed this method because spam filter programs like +SpamAssassin reject this header. +* Fixed error count bug. +* SetLanguage default is now "language/". +* Fixed magic_quotes_runtime bug. + +Version 1.71 (Tue, Jul 28 2003) +* Made several speed enhancements +* Added German and Italian translation files +* Fixed HELO/AUTH bugs on keep-alive connects +* Now provides an error message if language file does not load +* Fixed attachment EOL bug +* Updated some unclear documentation +* Added additional tests and improved others + +Version 1.70 (Mon, Jun 20 2003) +* Added SMTP keep-alive support +* Added IsError method for error detection +* Added error message translation support (SetLanguage) +* Refactored many methods to increase library performance +* Hello now sends the newer EHLO message before HELO as per RFC 2821 +* Removed the boundary class and replaced it with GetBoundary +* Removed queue support methods +* New $Hostname variable +* New Message-ID header +* Received header reformat +* Helo variable default changed to $Hostname +* Removed extra spaces in Content-Type definition (#667182) +* Return-Path should be set to Sender when set +* Adds Q or B encoding to headers when necessary +* quoted-encoding should now encode NULs \000 +* Fixed encoding of body/AltBody (#553370) +* Adds "To: undisclosed-recipients:;" when all recipients are hidden (BCC) +* Multiple bug fixes + +Version 1.65 (Fri, Aug 09 2002) +* Fixed non-visible attachment bug (#585097) for Outlook +* SMTP connections are now closed after each transaction +* Fixed SMTP::Expand return value +* Converted SMTP class documentation to phpDocumentor format + +Version 1.62 (Wed, Jun 26 2002) +* Fixed multi-attach bug +* Set proper word wrapping +* Reduced memory use with attachments +* Added more debugging +* Changed documentation to phpDocumentor format + +Version 1.60 (Sat, Mar 30 2002) +* Sendmail pipe and address patch (Christian Holtje) +* Added embedded image and read confirmation support (A. Ognio) +* Added unit tests +* Added SMTP timeout support (*nix only) +* Added possibly temporary PluginDir variable for SMTP class +* Added LE message line ending variable +* Refactored boundary and attachment code +* Eliminated SMTP class warnings +* Added SendToQueue method for future queuing support + +Version 1.54 (Wed, Dec 19 2001) +* Add some queuing support code +* Fixed a pesky multi/alt bug +* Messages are no longer forced to have "To" addresses + +Version 1.50 (Thu, Nov 08 2001) +* Fix extra lines when not using SMTP mailer +* Set WordWrap variable to int with a zero default + +Version 1.47 (Tue, Oct 16 2001) +* Fixed Received header code format +* Fixed AltBody order error +* Fixed alternate port warning + +Version 1.45 (Tue, Sep 25 2001) +* Added enhanced SMTP debug support +* Added support for multiple ports on SMTP +* Added Received header for tracing +* Fixed AddStringAttachment encoding +* Fixed possible header name quote bug +* Fixed wordwrap() trim bug +* Couple other small bug fixes + +Version 1.41 (Wed, Aug 22 2001) +* Fixed AltBody bug w/o attachments +* Fixed rfc_date() for certain mail servers + +Version 1.40 (Sun, Aug 12 2001) +* Added multipart/alternative support (AltBody) +* Documentation update +* Fixed bug in Mercury MTA + +Version 1.29 (Fri, Aug 03 2001) +* Added AddStringAttachment() method +* Added SMTP authentication support + +Version 1.28 (Mon, Jul 30 2001) +* Fixed a typo in SMTP class +* Fixed header issue with Imail (win32) SMTP server +* Made fopen() calls for attachments use "rb" to fix win32 error + +Version 1.25 (Mon, Jul 02 2001) +* Added RFC 822 date fix (Patrice) +* Added improved error handling by adding a $ErrorInfo variable +* Removed MailerDebug variable (obsolete with new error handler) + +Version 1.20 (Mon, Jun 25 2001) +* Added quoted-printable encoding (Patrice) +* Set Version as public and removed PrintVersion() +* Changed phpdoc to only display public variables and methods + +Version 1.19 (Thu, Jun 21 2001) +* Fixed MS Mail header bug +* Added fix for Bcc problem with mail(). *Does not work on Win32* + (See PHP bug report: http://www.php.net/bugs.php?id=11616) +* mail() no longer passes a fifth parameter when not needed + +Version 1.15 (Fri, Jun 15 2001) +[Note: these changes contributed by Patrice Fournier] +* Changed all remaining \n to \r\n +* Bcc: header no longer writen to message except +when sent directly to sendmail +* Added a small message to non-MIME compliant mail reader +* Added Sender variable to change the Sender email +used in -f for sendmail/mail and in 'MAIL FROM' for smtp mode +* Changed boundary setting to a place it will be set only once +* Removed transfer encoding for whole message when using multipart +* Message body now uses Encoding in multipart messages +* Can set encoding and type to attachments 7bit, 8bit +and binary attachment are sent as is, base64 are encoded +* Can set Encoding to base64 to send 8 bits body +through 7 bits servers + +Version 1.10 (Tue, Jun 12 2001) +* Fixed win32 mail header bug (printed out headers in message body) + +Version 1.09 (Fri, Jun 08 2001) +* Changed date header to work with Netscape mail programs +* Altered phpdoc documentation + +Version 1.08 (Tue, Jun 05 2001) +* Added enhanced error-checking +* Added phpdoc documentation to source + +Version 1.06 (Fri, Jun 01 2001) +* Added optional name for file attachments + +Version 1.05 (Tue, May 29 2001) +* Code cleanup +* Eliminated sendmail header warning message +* Fixed possible SMTP error + +Version 1.03 (Thu, May 24 2001) +* Fixed problem where qmail sends out duplicate messages + +Version 1.02 (Wed, May 23 2001) +* Added multiple recipient and attachment Clear* methods +* Added Sendmail public variable +* Fixed problem with loading SMTP library multiple times + +Version 0.98 (Tue, May 22 2001) +* Fixed problem with redundant mail hosts sending out multiple messages +* Added additional error handler code +* Added AddCustomHeader() function +* Added support for Microsoft mail client headers (affects priority) +* Fixed small bug with Mailer variable +* Added PrintVersion() function + +Version 0.92 (Tue, May 15 2001) +* Changed file names to class.phpmailer.php and class.smtp.php to match + current PHP class trend. +* Fixed problem where body not being printed when a message is attached +* Several small bug fixes + +Version 0.90 (Tue, April 17 2001) +* Intial public release diff --git a/inc/main/third_party/php_mailer/LICENSE b/inc/main/third_party/php_mailer/LICENSE new file mode 100644 index 00000000..f3f1b3b6 --- /dev/null +++ b/inc/main/third_party/php_mailer/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/inc/main/third_party/php_mailer/README b/inc/main/third_party/php_mailer/README new file mode 100644 index 00000000..3f0ee3fa --- /dev/null +++ b/inc/main/third_party/php_mailer/README @@ -0,0 +1,193 @@ +/******************************************************************* +* The http://phpmailer.codeworxtech.com/ website now carries a few * +* advertisements through the Google Adsense network. Please visit * +* the advertiser sites and help us offset some of our costs. * +* Thanks .... * +********************************************************************/ + +PHPMailer +Full Featured Email Transfer Class for PHP +========================================== + +Version 2.3 (November 08, 2008) + +We have removed the /phpdoc from the downloads. All documentation is now on +the http://phpmailer.codeworxtech.com website. + +The phpunit.php has been updated to support PHP5. + +For all other changes and notes, please see the changelog. + +Donations are accepted at PayPal with our id "paypal@worxteam.com". + +Version 2.2 (July 15 2008) + +- see the changelog. + +Version 2.1 (June 04 2008) + +With this release, we are announcing that the development of PHPMailer for PHP5 +will be our focus from this date on. We have implemented all the enhancements +and fixes from the latest release of PHPMailer for PHP4. + +Far more important, though, is that this release of PHPMailer (v2.1) is +fully tested with E_STRICT error checking enabled. + +** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. + IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE + APPRECIATED. + +We have now added S/MIME functionality (ability to digitally sign emails). +BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. +The "Signed Emails" functionality adds the Sign method to pass the private key +filename and the password to read it, and then email will be sent with +content-type multipart/signed and with the digital signature attached. + +A quick note on E_STRICT: + +- In about half the test environments the development version was subjected + to, an error was thrown for the date() functions (used at line 1565 and 1569). + This is NOT a PHPMailer error, it is the result of an incorrectly configured + PHP5 installation. The fix is to modify your 'php.ini' file and include the + date.timezone = America/New York + directive, (for your own server timezone) +- If you do get this error, and are unable to access your php.ini file, there is + a workaround. In your PHP script, add + date_default_timezone_set('America/Toronto'); + + * do NOT try to use + $myVar = date_default_timezone_get(); + as a test, it will throw an error. + +We have also included more example files to show the use of "sendmail", "mail()", +"smtp", and "gmail". + +We are also looking for more programmers to join the volunteer development team. +If you have an interest in this, please let us know. + +Enjoy! + + +Version 2.1.0beta1 & beta2 + +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +** NOTE: + +As of November 2007, PHPMailer has a new project team headed by industry +veteran Andy Prevost (codeworxtech). The first release in more than two +years will focus on fixes, adding ease-of-use enhancements, provide +basic compatibility with PHP4 and PHP5 using PHP5 backwards compatibility +features. A new release is planned before year-end 2007 that will provide +full compatiblity with PHP4 and PHP5, as well as more bug fixes. + +We are looking for project developers to assist in restoring PHPMailer to +its leadership position. Our goals are to simplify use of PHPMailer, provide +good documentation and examples, and retain backward compatibility to level +1.7.3 standards. + +If you are interested in helping out, visit http://sourceforge.net/projects/phpmailer +and indicate your interest. + +** + +http://phpmailer.sourceforge.net/ + +This software is licenced under the LGPL. Please read LICENSE for information on the +software availability and distribution. + +Class Features: +- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs +- Redundant SMTP servers +- Multipart/alternative emails for mail clients that do not read HTML email +- Support for 8bit, base64, binary, and quoted-printable encoding +- Uses the same methods as the very popular AspEmail active server (COM) component +- SMTP authentication +- Native language support +- Word wrap, and more! + +Why you might need it: + +Many PHP developers utilize email in their code. The only PHP function +that supports this is the mail() function. However, it does not expose +any of the popular features that many email clients use nowadays like +HTML-based emails and attachments. There are two proprietary +development tools out there that have all the functionality built into +easy to use classes: AspEmail(tm) and AspMail. Both of these +programs are COM components only available on Windows. They are also a +little pricey for smaller projects. + +Since I do Linux development I’ve missed these tools for my PHP coding. +So I built a version myself that implements the same methods (object +calls) that the Windows-based components do. It is open source and the +LGPL license allows you to place the class in your proprietary PHP +projects. + + +Installation: + +Copy class.phpmailer.php into your php.ini include_path. If you are +using the SMTP mailer then place class.smtp.php in your path as well. +In the language directory you will find several files like +phpmailer.lang-en.php. If you look right before the .php extension +that there are two letters. These represent the language type of the +translation file. For instance "en" is the English file and "br" is +the Portuguese file. Chose the file that best fits with your language +and place it in the PHP include path. If your language is English +then you have nothing more to do. If it is a different language then +you must point PHPMailer to the correct translation. To do this, call +the PHPMailer SetLanguage method like so: + +// To load the Portuguese version +$mail->SetLanguage("br", "/optional/path/to/language/directory/"); + +That's it. You should now be ready to use PHPMailer! + + +A Simple Example: + +IsSMTP(); // set mailer to use SMTP +$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server +$mail->SMTPAuth = true; // turn on SMTP authentication +$mail->Username = "jswan"; // SMTP username +$mail->Password = "secret"; // SMTP password + +$mail->From = "from@example.com"; +$mail->FromName = "Mailer"; +$mail->AddAddress("josh@example.net", "Josh Adams"); +$mail->AddAddress("ellen@example.com"); // name is optional +$mail->AddReplyTo("info@example.com", "Information"); + +$mail->WordWrap = 50; // set word wrap to 50 characters +$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments +$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name +$mail->IsHTML(true); // set email format to HTML + +$mail->Subject = "Here is the subject"; +$mail->Body = "This is the HTML message body in bold!"; +$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; + +if(!$mail->Send()) +{ + echo "Message could not be sent.

    "; + echo "Mailer Error: " . $mail->ErrorInfo; + exit; +} + +echo "Message has been sent"; +?> + +CHANGELOG + +See ChangeLog.txt + +Download: http://sourceforge.net/project/showfiles.php?group_id=26031 + +Andy Prevost diff --git a/inc/main/third_party/php_mailer/class.phpmailer.php b/inc/main/third_party/php_mailer/class.phpmailer.php new file mode 100644 index 00000000..419b26b6 --- /dev/null +++ b/inc/main/third_party/php_mailer/class.phpmailer.php @@ -0,0 +1,1910 @@ +ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Sets Mailer to send message using SMTP. + * @return void + */ + public function IsSMTP() { + $this->Mailer = 'smtp'; + } + + /** + * Sets Mailer to send message using PHP mail() function. + * @return void + */ + public function IsMail() { + $this->Mailer = 'mail'; + } + + /** + * Sets Mailer to send message using the $Sendmail program. + * @return void + */ + public function IsSendmail() { + $this->Mailer = 'sendmail'; + } + + /** + * Sets Mailer to send message using the qmail MTA. + * @return void + */ + public function IsQmail() { + $this->Sendmail = '/var/qmail/bin/sendmail'; + $this->Mailer = 'sendmail'; + } + + ///////////////////////////////////////////////// + // METHODS, RECIPIENTS + ///////////////////////////////////////////////// + + /** + * Adds a "To" address. + * @param string $address + * @param string $name + * @return void + */ + public function AddAddress($address, $name = '') { + $cur = count($this->to); + $this->to[$cur][0] = trim($address); + $this->to[$cur][1] = $name; + } + + /** + * Adds a "Cc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + public function AddCC($address, $name = '') { + $cur = count($this->cc); + $this->cc[$cur][0] = trim($address); + $this->cc[$cur][1] = $name; + } + + /** + * Adds a "Bcc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + public function AddBCC($address, $name = '') { + $cur = count($this->bcc); + $this->bcc[$cur][0] = trim($address); + $this->bcc[$cur][1] = $name; + } + + /** + * Adds a "Reply-to" address. + * @param string $address + * @param string $name + * @return void + */ + public function AddReplyTo($address, $name = '') { + $cur = count($this->ReplyTo); + $this->ReplyTo[$cur][0] = trim($address); + $this->ReplyTo[$cur][1] = $name; + } + + ///////////////////////////////////////////////// + // METHODS, MAIL SENDING + ///////////////////////////////////////////////// + + /** + * Creates message and assigns Mailer. If the message is + * not sent successfully then it returns false. Use the ErrorInfo + * variable to view description of the error. + * @return bool + */ + public function Send() { + $header = ''; + $body = ''; + $result = true; + + if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + $this->SetError($this->Lang('provide_address')); + return false; + } + + /* Set whether the message is multipart/alternative */ + if(!empty($this->AltBody)) { + $this->ContentType = 'multipart/alternative'; + } + + $this->error_count = 0; // reset errors + $this->SetMessageType(); + $header .= $this->CreateHeader(); + $body = $this->CreateBody(); + + if($body == '') { + return false; + } + + /* Choose the mailer */ + switch($this->Mailer) { + case 'sendmail': + $result = $this->SendmailSend($header, $body); + break; + case 'smtp': + $result = $this->SmtpSend($header, $body); + break; + case 'mail': + $result = $this->MailSend($header, $body); + break; + default: + $result = $this->MailSend($header, $body); + break; + //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); + //$result = false; + //break; + } + + return $result; + } + + /** + * Sends mail using the $Sendmail program. + * @access public + * @return bool + */ + public function SendmailSend($header, $body) { + if ($this->Sender != '') { + $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } else { + $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); + } + + if(!@$mail = popen($sendmail, 'w')) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + + fputs($mail, $header); + fputs($mail, $body); + + $result = pclose($mail); + if (version_compare(phpversion(), '4.2.3') == -1) { + $result = $result >> 8 & 0xFF; + } + if($result != 0) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + + return true; + } + + /** + * Sends mail using the PHP mail() function. + * @access public + * @return bool + */ + public function MailSend($header, $body) { + + $to = ''; + for($i = 0; $i < count($this->to); $i++) { + if($i != 0) { $to .= ', '; } + $to .= $this->AddrFormat($this->to[$i]); + } + + $toArr = split(',', $to); + + $params = sprintf("-oi -f %s", $this->Sender); + if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); + } + } + + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + + if(!$rt) { + $this->SetError($this->Lang('instantiate')); + return false; + } + + return true; + } + + /** + * Sends mail via SMTP using PhpSMTP (Author: + * Chris Ryan). Returns bool. Returns false if there is a + * bad MAIL FROM, RCPT, or DATA input. + * @access public + * @return bool + */ + public function SmtpSend($header, $body) { + include_once($this->PluginDir . 'class.smtp.php'); + $error = ''; + $bad_rcpt = array(); + + if(!$this->SmtpConnect()) { + return false; + } + + $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) { + $error = $this->Lang('from_failed') . $smtp_from; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + /* Attempt to send attach all recipients */ + for($i = 0; $i < count($this->to); $i++) { + if(!$this->smtp->Recipient($this->to[$i][0])) { + $bad_rcpt[] = $this->to[$i][0]; + } + } + for($i = 0; $i < count($this->cc); $i++) { + if(!$this->smtp->Recipient($this->cc[$i][0])) { + $bad_rcpt[] = $this->cc[$i][0]; + } + } + for($i = 0; $i < count($this->bcc); $i++) { + if(!$this->smtp->Recipient($this->bcc[$i][0])) { + $bad_rcpt[] = $this->bcc[$i][0]; + } + } + + if(count($bad_rcpt) > 0) { // Create error message + for($i = 0; $i < count($bad_rcpt); $i++) { + if($i != 0) { + $error .= ', '; + } + $error .= $bad_rcpt[$i]; + } + $error = $this->Lang('recipients_failed') . $error; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + if(!$this->smtp->Data($header . $body)) { + $this->SetError($this->Lang('data_not_accepted')); + $this->smtp->Reset(); + return false; + } + if($this->SMTPKeepAlive == true) { + $this->smtp->Reset(); + } else { + $this->SmtpClose(); + } + + return true; + } + + /** + * Initiates a connection to an SMTP server. Returns false if the + * operation failed. + * @access public + * @return bool + */ + public function SmtpConnect() { + if($this->smtp == NULL) { + $this->smtp = new SMTP(); + } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(';', $this->Host); + $index = 0; + $connection = ($this->smtp->Connected()); + + /* Retry while there is no connection */ + while($index < count($hosts) && $connection == false) { + $hostinfo = array(); + if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { + $host = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $host = $hosts[$index]; + $port = $this->Port; + } + + $tls = ($this->SMTPSecure == 'tls'); + $ssl = ($this->SMTPSecure == 'ssl'); + + if($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { + + $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname()); + $this->smtp->Hello($hello); + + if($tls) { + if(!$this->smtp->StartTLS()) { + $this->SetError($this->Lang("tls")); + $this->smtp->Reset(); + $connection = false; + } + + //We must resend HELLO after tls negociation + $this->smtp->Hello($hello); + } + + $connection = true; + if($this->SMTPAuth) { + if(!$this->smtp->Authenticate($this->Username, $this->Password)) { + $this->SetError($this->Lang('authenticate')); + $this->smtp->Reset(); + $connection = false; + } + } + } + $index++; + } + if(!$connection) { + $this->SetError($this->Lang('connect_host')); + } + + return $connection; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + public function SmtpClose() { + if($this->smtp != NULL) { + if($this->smtp->Connected()) { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. Returns false + * if it cannot load the language file. The default language type + * is English. + * @param string $lang_type Type of language (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + * @return bool + */ + function SetLanguage($lang_type = 'en', $lang_path = 'language/') { + if( !(@include $lang_path.'phpmailer.lang-'.$lang_type.'.php') ) { + $PHPMAILER_LANG = array(); + $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' . + $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.'; + $PHPMAILER_LANG["execute"] = 'Could not execute: '; + $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.'; + $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.'; + $PHPMAILER_LANG["from_failed"] = 'The following From address failed: '; + $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' . + $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.'; + $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.'; + $PHPMAILER_LANG["file_access"] = 'Could not access file: '; + $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: '; + $PHPMAILER_LANG["encoding"] = 'Unknown encoding: '; + $PHPMAILER_LANG["signing"] = 'Signing Error: '; + } + $this->language = $PHPMAILER_LANG; + return true; + } + + ///////////////////////////////////////////////// + // METHODS, MESSAGE CREATION + ///////////////////////////////////////////////// + + /** + * Creates recipient headers. + * @access public + * @return string + */ + public function AddrAppend($type, $addr) { + $addr_str = $type . ': '; + $addr_str .= $this->AddrFormat($addr[0]); + if(count($addr) > 1) { + for($i = 1; $i < count($addr); $i++) { + $addr_str .= ', ' . $this->AddrFormat($addr[$i]); + } + } + $addr_str .= $this->LE; + + return $addr_str; + } + + /** + * Formats an address correctly. + * @access public + * @return string + */ + public function AddrFormat($addr) { + if(empty($addr[1])) { + $formatted = $this->SecureHeader($addr[0]); + } else { + $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; + } + + return $formatted; + } + + /** + * Wraps message for use with mailers that do not + * automatically perform wrapping and for quoted-printable. + * Original written by philippe. + * @access public + * @return string + */ + public function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == "utf-8"); + + $message = $this->FixEOL($message); + if (substr($message, -1) == $this->LE) { + $message = substr($message, 0, -1); + } + + $line = explode($this->LE, $message); + $message = ''; + for ($i=0 ;$i < count($line); $i++) { + $line_part = explode(' ', $line[$i]); + $buf = ''; + for ($e = 0; $e $length)) { + $space_left = $length - strlen($buf) - 1; + if ($e != 0) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf("=%s", $this->LE); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + $len = $length; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf("=%s", $this->LE); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + $buf .= ($e == 0) ? $word : (' ' . $word); + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + } + $message .= $buf . $this->LE; + } + + return $message; + } + + /** + * Finds last character boundary prior to maxLength in a utf-8 + * quoted (printable) encoded string. + * Original written by Colin Brown. + * @access public + * @param string $encodedText utf-8 QP text + * @param int $maxLength find last character boundary prior to this length + * @return int + */ + public function UTF8CharBoundary($encodedText, $maxLength) { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, "="); + if ($encodedCharPos !== false) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + $maxLength = ($encodedCharPos == 0) ? $maxLength : + $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec >= 192) { // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + + /** + * Set the body wrapping. + * @access public + * @return void + */ + public function SetWordWrap() { + if($this->WordWrap < 1) { + return; + } + + switch($this->message_type) { + case 'alt': + /* fall through */ + case 'alt_attachments': + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assembles message header. + * @access public + * @return string + */ + public function CreateHeader() { + $result = ''; + + /* Set the boundaries */ + $uniq_id = md5(uniqid(time())); + $this->boundary[1] = 'b1_' . $uniq_id; + $this->boundary[2] = 'b2_' . $uniq_id; + + $result .= $this->HeaderLine('Date', $this->RFCDate()); + if($this->Sender == '') { + $result .= $this->HeaderLine('Return-Path', trim($this->From)); + } else { + $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); + } + + /* To be created automatically by mail() */ + if($this->Mailer != 'mail') { + if(count($this->to) > 0) { + $result .= $this->AddrAppend('To', $this->to); + } elseif (count($this->cc) == 0) { + $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); + } + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend('From', $from); + + /* sendmail and mail() extract Cc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + + /* sendmail and mail() extract Bcc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { + $result .= $this->AddrAppend('Bcc', $this->bcc); + } + + if(count($this->ReplyTo) > 0) { + $result .= $this->AddrAppend('Reply-to', $this->ReplyTo); + } + + /* mail() sets the subject itself */ + if($this->Mailer != 'mail') { + $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); + } + + if($this->MessageID != '') { + $result .= $this->HeaderLine('Message-ID',$this->MessageID); + } else { + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + } + $result .= $this->HeaderLine('X-Priority', $this->Priority); + $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.codeworxtech.com) [version ' . $this->Version . ']'); + + if($this->ConfirmReadingTo != '') { + $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); + } + + // Add custom headers + for($index = 0; $index < count($this->CustomHeader); $index++) { + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); + } + if (!$this->sign_key_file) { + $result .= $this->HeaderLine('MIME-Version', '1.0'); + $result .= $this->GetMailMIME(); + } + + return $result; + } + + /** + * Returns the message MIME. + * @access public + * @return string + */ + public function GetMailMIME() { + $result = ''; + switch($this->message_type) { + case 'plain': + $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); + break; + case 'attachments': + /* fall through */ + case 'alt_attachments': + if($this->InlineImageExists()){ + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); + } else { + $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + } + break; + case 'alt': + $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + } + + if($this->Mailer != 'mail') { + $result .= $this->LE.$this->LE; + } + + return $result; + } + + /** + * Assembles the message body. Returns an empty string on failure. + * @access public + * @return string + */ + public function CreateBody() { + $result = ''; + + if ($this->sign_key_file) { + $result .= $this->GetMailMIME(); + } + + $this->SetWordWrap(); + + switch($this->message_type) { + case 'alt': + $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[1]); + break; + case 'plain': + $result .= $this->EncodeString($this->Body, $this->Encoding); + break; + case 'attachments': + $result .= $this->GetBoundary($this->boundary[1], '', '', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE; + $result .= $this->AttachAll(); + break; + case 'alt_attachments': + $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); + $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); + $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[2]); + $result .= $this->AttachAll(); + break; + } + + if($this->IsError()) { + $result = ''; + } else if ($this->sign_key_file) { + $file = tempnam("", "mail"); + $fp = fopen($file, "w"); + fwrite($fp, $result); + fclose($fp); + $signed = tempnam("", "signed"); + + if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { + $fp = fopen($signed, "r"); + $result = ''; + while(!feof($fp)){ + $result = $result . fread($fp, 1024); + } + fclose($fp); + } else { + $this->SetError($this->Lang("signing").openssl_error_string()); + $result = ''; + } + + unlink($file); + unlink($signed); + } + + return $result; + } + + /** + * Returns the start of a message boundary. + * @access public + */ + public function GetBoundary($boundary, $charSet, $contentType, $encoding) { + $result = ''; + if($charSet == '') { + $charSet = $this->CharSet; + } + if($contentType == '') { + $contentType = $this->ContentType; + } + if($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->TextLine('--' . $boundary); + $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); + $result .= $this->LE; + $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access public + */ + public function EndBoundary($boundary) { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Sets the message type. + * @access public + * @return void + */ + public function SetMessageType() { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { + $this->message_type = 'plain'; + } else { + if(count($this->attachment) > 0) { + $this->message_type = 'attachments'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { + $this->message_type = 'alt'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { + $this->message_type = 'alt_attachments'; + } + } + } + + /* Returns a formatted header line. + * @access public + * @return string + */ + public function HeaderLine($name, $value) { + return $name . ': ' . $value . $this->LE; + } + + /** + * Returns a formatted mail line. + * @access public + * @return string + */ + public function TextLine($value) { + return $value . $this->LE; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, ATTACHMENTS + ///////////////////////////////////////////////// + + /** + * Adds an attachment from a path on the filesystem. + * Returns false if the file could not be found + * or accessed. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; // isStringAttachment + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + + return true; + } + + /** + * Attaches all fs, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access public + * @return string + */ + public function AttachAll() { + /* Return text of body */ + $mime = array(); + + /* Add all attachments */ + for($i = 0; $i < count($this->attachment); $i++) { + /* Check for string attachment */ + $bString = $this->attachment[$i][5]; + if ($bString) { + $string = $this->attachment[$i][0]; + } else { + $path = $this->attachment[$i][0]; + } + + $filename = $this->attachment[$i][1]; + $name = $this->attachment[$i][2]; + $encoding = $this->attachment[$i][3]; + $type = $this->attachment[$i][4]; + $disposition = $this->attachment[$i][6]; + $cid = $this->attachment[$i][7]; + + $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); + //$mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); + $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); + + if($disposition == 'inline') { + $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); + } + + //$mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE); + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); + + /* Encode as string attachment */ + if($bString) { + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } else { + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } + } + + $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); + + return join('', $mime); + } + + /** + * Encodes attachment in requested format. Returns an + * empty string on failure. + * @access public + * @return string + */ + public function EncodeFile ($path, $encoding = 'base64') { + if(!@$fd = fopen($path, 'rb')) { + $this->SetError($this->Lang('file_open') . $path); + return ''; + } + if (function_exists('get_magic_quotes')) { + function get_magic_quotes() { + return false; + } +} + if (PHP_VERSION < 6) { + $magic_quotes = get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + } + $file_buffer = file_get_contents($path); + $file_buffer = $this->EncodeString($file_buffer, $encoding); + fclose($fd); + if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } + return $file_buffer; + } + + /** + * Encodes string to requested format. Returns an + * empty string on failure. + * @access public + * @return string + */ + public function EncodeString ($str, $encoding = 'base64') { + $encoded = ''; + switch(strtolower($encoding)) { + case 'base64': + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->FixEOL($str); + if (substr($encoded, -(strlen($this->LE))) != $this->LE) + $encoded .= $this->LE; + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->EncodeQP($str); + break; + default: + $this->SetError($this->Lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string to best of Q, B, quoted or none. + * @access public + * @return string + */ + public function EncodeHeader ($str, $position = 'text') { + $x = 0; + + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */ + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + case 'comment': + $x = preg_match_all('/[()"]/', $str, $matches); + /* Fall-through */ + case 'text': + default: + $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + if ($x == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + /* Try to select the encoding which should produce the shortest output */ + if (strlen($str)/3 < $x) { + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->Base64EncodeWrapMB($str); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->EncodeQ($str, $position); + $encoded = $this->WrapText($encoded, $maxlen, true); + $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Checks if a string contains multibyte characters. + * @access public + * @param string $str multi-byte text to wrap encode + * @return bool + */ + public function HasMultiBytes($str) { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return False; + } + } + + /** + * Correctly encodes and wraps long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php + * @access public + * @param string $str multi-byte text to wrap encode + * @return string + */ + public function Base64EncodeWrapMB($str) { + $start = "=?".$this->CharSet."?B?"; + $end = "?="; + $encoded = ""; + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $offset = $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } + while (strlen($chunk) > $length); + + $encoded .= $chunk . $this->LE; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($this->LE)); + return $encoded; + } + + /** + * Encode string to quoted-printable. + * @access public + * @param string $string the text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @return string + */ + public function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) { + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $lines = preg_split('/(?:\r\n|\r|\n)/', $input); + $eol = "\r\n"; + $escape = '='; + $output = ''; + while( list(, $line) = each($lines) ) { + $linlen = strlen($line); + $newline = ''; + for($i = 0; $i < $linlen; $i++) { + $c = substr( $line, $i, 1 ); + $dec = ord( $c ); + if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E + $c = '=2E'; + } + if ( $dec == 32 ) { + if ( $i == ( $linlen - 1 ) ) { // convert space at eol only + $c = '=20'; + } else if ( $space_conv ) { + $c = '=20'; + } + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); + $h1 = floor($dec%16); + $c = $escape.$hex[$h2].$hex[$h1]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay + $newline = ''; + // check if newline first character will be point or not + if ( $dec == 46 ) { + $c = '=2E'; + } + } + $newline .= $c; + } // end of for + $output .= $newline.$eol; + } // end of while + return $output; + } + + /** + * Encode string to q encoding. + * @access public + * @return string + */ + public function EncodeQ ($str, $position = 'text') { + /* There should not be any EOL in the string */ + $encoded = preg_replace("[\r\n]", '', $str); + + switch (strtolower($position)) { + case 'phrase': + $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + case 'comment': + $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + case 'text': + default: + /* Replace every high ascii, control =, ? and _ characters */ + $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', + "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + } + + /* Replace every spaces to _ (more readable than =20) */ + $encoded = str_replace(' ', '_', $encoded); + + return $encoded; + } + + /** + * Adds a string or binary attachment (non-filesystem) to the list. + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return void + */ + public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $string; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $filename; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = true; // isString + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + } + + /** + * Adds an embedded attachment. This can include images, sounds, and + * just about any other document. Make sure to set the $type to an + * image type. For JPEG images use "image/jpeg" and for GIF images + * use "image/gif". + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment. Use this to identify + * the Id for accessing the image in an HTML form. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; + $this->attachment[$cur][6] = 'inline'; + $this->attachment[$cur][7] = $cid; + + return true; + } + + /** + * Returns true if an inline attachment is present. + * @access public + * @return bool + */ + public function InlineImageExists() { + $result = false; + for($i = 0; $i < count($this->attachment); $i++) { + if($this->attachment[$i][6] == 'inline') { + $result = true; + break; + } + } + + return $result; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MESSAGE RESET + ///////////////////////////////////////////////// + + /** + * Clears all recipients assigned in the TO array. Returns void. + * @return void + */ + public function ClearAddresses() { + $this->to = array(); + } + + /** + * Clears all recipients assigned in the CC array. Returns void. + * @return void + */ + public function ClearCCs() { + $this->cc = array(); + } + + /** + * Clears all recipients assigned in the BCC array. Returns void. + * @return void + */ + public function ClearBCCs() { + $this->bcc = array(); + } + + /** + * Clears all recipients assigned in the ReplyTo array. Returns void. + * @return void + */ + public function ClearReplyTos() { + $this->ReplyTo = array(); + } + + /** + * Clears all recipients assigned in the TO, CC and BCC + * array. Returns void. + * @return void + */ + public function ClearAllRecipients() { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + } + + /** + * Clears all previously set filesystem, string, and binary + * attachments. Returns void. + * @return void + */ + public function ClearAttachments() { + $this->attachment = array(); + } + + /** + * Clears all custom headers. Returns void. + * @return void + */ + public function ClearCustomHeaders() { + $this->CustomHeader = array(); + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MISCELLANEOUS + ///////////////////////////////////////////////// + + /** + * Adds the error message to the error container. + * Returns void. + * @access private + * @return void + */ + private function SetError($msg) { + $this->error_count++; + $this->ErrorInfo = $msg; + } + + /** + * Returns the proper RFC 822 formatted date. + * @access private + * @return string + */ + private static function RFCDate() { + $tz = date('Z'); + $tzs = ($tz < 0) ? '-' : '+'; + $tz = abs($tz); + $tz = (int)($tz/3600)*100 + ($tz%3600)/60; + $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); + + return $result; + } + + /** + * Returns the server hostname or 'localhost.localdomain' if unknown. + * @access private + * @return string + */ + private function ServerHostname() { + if (!empty($this->Hostname)) { + $result = $this->Hostname; + } elseif (isset($_SERVER['SERVER_NAME'])) { + $result = $_SERVER['SERVER_NAME']; + } else { + $result = "localhost.localdomain"; + } + + return $result; + } + + /** + * Returns a message in the appropriate language. + * @access private + * @return string + */ + private function Lang($key) { + if(count($this->language) < 1) { + $this->SetLanguage('en'); // set the default language + } + + if(isset($this->language[$key])) { + return $this->language[$key]; + } else { + return 'Language string failed to load: ' . $key; + } + } + + /** + * Returns true if an error occurred. + * @access public + * @return bool + */ + public function IsError() { + return ($this->error_count > 0); + } + + /** + * Changes every end of line from CR or LF to CRLF. + * @access private + * @return string + */ + private function FixEOL($str) { + $str = str_replace("\r\n", "\n", $str); + $str = str_replace("\r", "\n", $str); + $str = str_replace("\n", $this->LE, $str); + return $str; + } + + /** + * Adds a custom header. + * @access public + * @return void + */ + public function AddCustomHeader($custom_header) { + $this->CustomHeader[] = explode(':', $custom_header, 2); + } + + /** + * Evaluates the message and returns modifications for inline images and backgrounds + * @access public + * @return $message + */ + public function MsgHTML($message,$basedir='') { + preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); + if(isset($images[2])) { + foreach($images[2] as $i => $url) { + // do not change urls for absolute images (thanks to corvuscorax) + if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) { + $filename = basename($url); + $directory = dirname($url); + ($directory == '.')?$directory='':''; + $cid = 'cid:' . md5($filename); + $fileParts = split("\.", $filename); + $ext = $fileParts[1]; + $mimeType = $this->_mime_types($ext); + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } + if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } + if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { + $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); + } + } + } + } + $this->IsHTML(true); + $this->Body = $message; + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); + if ( !empty($textMsg) && empty($this->AltBody) ) { + $this->AltBody = html_entity_decode($textMsg); + } + if ( empty($this->AltBody) ) { + $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; + } + } + + /** + * Gets the mime type of the embedded or inline image + * @access public + * @return mime type of ext + */ + public function _mime_types($ext = '') { + $mimes = array( + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'doc' => 'application/msword', + 'bin' => 'application/macbinary', + 'dms' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'class' => 'application/octet-stream', + 'psd' => 'application/octet-stream', + 'so' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'php' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'js' => 'application/x-javascript', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xhtml' => 'application/xhtml+xml', + 'xht' => 'application/xhtml+xml', + 'zip' => 'application/zip', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mpga' => 'audio/mpeg', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'rv' => 'video/vnd.rn-realvideo', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'png' => 'image/png', + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'txt' => 'text/plain', + 'text' => 'text/plain', + 'log' => 'text/plain', + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'qt' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'doc' => 'application/msword', + 'word' => 'application/msword', + 'xl' => 'application/excel', + 'eml' => 'message/rfc822' + ); + return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; + } + + /** + * Set (or reset) Class Objects (variables) + * + * Usage Example: + * $page->set('X-Priority', '3'); + * + * @access public + * @param string $name Parameter Name + * @param mixed $value Parameter Value + * NOTE: will not work with arrays, there are no arrays to set/reset + */ + public function set ( $name, $value = '' ) { + if ( isset($this->$name) ) { + $this->$name = $value; + } else { + $this->SetError('Cannot set or reset variable ' . $name); + return false; + } + } + + /** + * Read a file from a supplied filename and return it. + * + * @access public + * @param string $filename Parameter File Name + */ + public function getFile($filename) { + $return = ''; + if ($fp = fopen($filename, 'rb')) { + while (!feof($fp)) { + $return .= fread($fp, 1024); + } + fclose($fp); + return $return; + } else { + return false; + } + } + + /** + * Strips newlines to prevent header injection. + * @access public + * @param string $str String + * @return string + */ + public function SecureHeader($str) { + $str = trim($str); + $str = str_replace("\r", "", $str); + $str = str_replace("\n", "", $str); + return $str; + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + public function Sign($cert_filename, $key_filename, $key_pass) { + $this->sign_cert_file = $cert_filename; + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + } +} + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/class.pop3.php b/inc/main/third_party/php_mailer/class.pop3.php new file mode 100644 index 00000000..0884a825 --- /dev/null +++ b/inc/main/third_party/php_mailer/class.pop3.php @@ -0,0 +1,393 @@ +pop_conn = 0; + $this->connected = false; + $this->error = null; + } + + /** + * Combination of public events - connect, login, disconnect + * @access public + * @param string $host + * @param integer $port + * @param integer $tval + * @param string $username + * @param string $password + */ + public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { + $this->host = $host; + + // If no port value is passed, retrieve it + if ($port == false) { + $this->port = $this->POP3_PORT; + } else { + $this->port = $port; + } + + // If no port value is passed, retrieve it + if ($tval == false) { + $this->tval = $this->POP3_TIMEOUT; + } else { + $this->tval = $tval; + } + + $this->do_debug = $debug_level; + $this->username = $username; + $this->password = $password; + + // Refresh the error log + $this->error = null; + + // Connect + $result = $this->Connect($this->host, $this->port, $this->tval); + + if ($result) { + $login_result = $this->Login($this->username, $this->password); + + if ($login_result) { + $this->Disconnect(); + + return true; + } + + } + + // We need to disconnect regardless if the login succeeded + $this->Disconnect(); + + return false; + } + + /** + * Connect to the POP3 server + * @access public + * @param string $host + * @param integer $port + * @param integer $tval + * @return boolean + */ + public function Connect ($host, $port = false, $tval = 30) { + // Are we already connected? + if ($this->connected) { + return true; + } + + /* + On Windows this will raise a PHP Warning error if the hostname doesn't exist. + Rather than supress it with @fsockopen, let's capture it cleanly instead + */ + + set_error_handler(array(&$this, 'catchWarning')); + + // Connect to the POP3 server + $this->pop_conn = fsockopen($host, // POP3 Host + $port, // Port # + $errno, // Error Number + $errstr, // Error Message + $tval); // Timeout (seconds) + + // Restore the error handler + restore_error_handler(); + + // Does the Error Log now contain anything? + if ($this->error && $this->do_debug >= 1) { + $this->displayErrors(); + } + + // Did we connect? + if ($this->pop_conn == false) { + // It would appear not... + $this->error = array( + 'error' => "Failed to connect to server $host on port $port", + 'errno' => $errno, + 'errstr' => $errstr + ); + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + + return false; + } + + // Increase the stream time-out + + // Check for PHP 4.3.0 or later + if (version_compare(phpversion(), '5.0.0', 'ge')) { + stream_set_timeout($this->pop_conn, $tval, 0); + } else { + // Does not work on Windows + if (substr(PHP_OS, 0, 3) !== 'WIN') { + socket_set_timeout($this->pop_conn, $tval, 0); + } + } + + // Get the POP3 server response + $pop3_response = $this->getResponse(); + + // Check for the +OK + if ($this->checkResponse($pop3_response)) { + // The connection is established and the POP3 server is talking + $this->connected = true; + return true; + } + + } + + /** + * Login to the POP3 server (does not support APOP yet) + * @access public + * @param string $username + * @param string $password + * @return boolean + */ + public function Login ($username = '', $password = '') { + if ($this->connected == false) { + $this->error = 'Not connected to POP3 server'; + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + } + + if (empty($username)) { + $username = $this->username; + } + + if (empty($password)) { + $password = $this->password; + } + + $pop_username = "USER $username" . $this->CRLF; + $pop_password = "PASS $password" . $this->CRLF; + + // Send the Username + $this->sendString($pop_username); + $pop3_response = $this->getResponse(); + + if ($this->checkResponse($pop3_response)) { + // Send the Password + $this->sendString($pop_password); + $pop3_response = $this->getResponse(); + + if ($this->checkResponse($pop3_response)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Disconnect from the POP3 server + * @access public + */ + public function Disconnect () { + $this->sendString('QUIT'); + + fclose($this->pop_conn); + } + + ///////////////////////////////////////////////// + // Private Methods + ///////////////////////////////////////////////// + + /** + * Get the socket response back. + * $size is the maximum number of bytes to retrieve + * @access private + * @param integer $size + * @return string + */ + private function getResponse ($size = 128) { + $pop3_response = fgets($this->pop_conn, $size); + + return $pop3_response; + } + + /** + * Send a string down the open socket connection to the POP3 server + * @access private + * @param string $string + * @return integer + */ + private function sendString ($string) { + $bytes_sent = fwrite($this->pop_conn, $string, strlen($string)); + + return $bytes_sent; + } + + /** + * Checks the POP3 server response for +OK or -ERR + * @access private + * @param string $string + * @return boolean + */ + private function checkResponse ($string) { + if (substr($string, 0, 3) !== '+OK') { + $this->error = array( + 'error' => "Server reported an error: $string", + 'errno' => 0, + 'errstr' => '' + ); + + if ($this->do_debug >= 1) { + $this->displayErrors(); + } + + return false; + } else { + return true; + } + + } + + /** + * If debug is enabled, display the error message array + * @access private + */ + private function displayErrors () { + echo '

    ';
    +
    +    foreach ($this->error as $single_error) {
    +      print_r($single_error);
    +    }
    +
    +    echo '
    '; + } + + /** + * Takes over from PHP for the socket warning handler + * @access private + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + */ + private function catchWarning ($errno, $errstr, $errfile, $errline) { + $this->error[] = array( + 'error' => "Connecting to the POP3 server raised a PHP warning: ", + 'errno' => $errno, + 'errstr' => $errstr + ); + } + + // End of class +} +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/class.smtp.php b/inc/main/third_party/php_mailer/class.smtp.php new file mode 100644 index 00000000..360d6afd --- /dev/null +++ b/inc/main/third_party/php_mailer/class.smtp.php @@ -0,0 +1,1112 @@ +smtp_conn = 0; + $this->error = null; + $this->helo_rply = null; + + $this->do_debug = 0; + } + + /************************************************************* + * CONNECTION FUNCTIONS * + ***********************************************************/ + + /** + * Connect to the server specified on the port specified. + * If the port is not specified use the default SMTP_PORT. + * If tval is specified then a connection will try and be + * established with the server for that number of seconds. + * If tval is not specified the default is 30 seconds to + * try on the connection. + * + * SMTP CODE SUCCESS: 220 + * SMTP CODE FAILURE: 421 + * @access public + * @return bool + */ + public function Connect($host,$port=0,$tval=30) { + /* set the error val to null so there is no confusion */ + $this->error = null; + + /* make sure we are __not__ connected */ + if($this->connected()) { + /* ok we are connected! what should we do? + * for now we will just give an error saying we + * are already connected + */ + $this->error = array("error" => "Already connected to a server"); + return false; + } + + if(empty($port)) { + $port = $this->SMTP_PORT; + } + + /* connect to the smtp server */ + $this->smtp_conn = fsockopen($host, // the host of the server + $port, // the port to use + $errno, // error number if any + $errstr, // error message if any + $tval); // give up after ? secs + /* verify we connected properly */ + if(empty($this->smtp_conn)) { + $this->error = array("error" => "Failed to connect to server", + "errno" => $errno, + "errstr" => $errstr); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": $errstr ($errno)" . $this->CRLF; + } + return false; + } + + /* sometimes the SMTP server takes a little longer to respond + * so we will give it a longer timeout for the first read + * - Windows still does not have support for this timeout function + */ + if(substr(PHP_OS, 0, 3) != "WIN") + socket_set_timeout($this->smtp_conn, $tval, 0); + + /* get any announcement stuff */ + $announce = $this->get_lines(); + + /* set the timeout of any socket functions at 1/10 of a second */ + //if(function_exists("socket_set_timeout")) + // socket_set_timeout($this->smtp_conn, 0, 100000); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; + } + + return true; + } + + /** + * Initiate a TSL communication with the server. + * + * SMTP CODE 220 Ready to start TLS + * SMTP CODE 501 Syntax error (no parameters allowed) + * SMTP CODE 454 TLS not available due to temporary reason + * @access public + * @return bool success + */ + public function StartTLS() { + $this->error = null; # to avoid confusion + + if(!$this->connected()) { + $this->error = array("error" => "Called StartTLS() without being connected"); + return false; + } + + fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 220) { + $this->error = + array("error" => "STARTTLS not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF; + } + return false; + } + + //Begin encrypted connection + if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { + return false; + } + + return true; + } + + /** + * Performs SMTP authentication. Must be run after running the + * Hello() method. Returns true if successfully authenticated. + * @access public + * @return bool + */ + public function Authenticate($username, $password) { + // Start authentication + fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "AUTH not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // Send encoded username + fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "Username not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // Send encoded password + fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 235) { + $this->error = + array("error" => "Password not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return true; + } + + /** + * Returns true if connected to a server otherwise false + * @access public + * @return bool + */ + public function Connected() { + if(!empty($this->smtp_conn)) { + $sock_status = socket_get_status($this->smtp_conn); + if($sock_status["eof"]) { + // hmm this is an odd situation... the socket is + // valid but we are not connected anymore + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE:" . $this->CRLF . + "EOF caught while checking if connected"; + } + $this->Close(); + return false; + } + return true; // everything looks good + } + return false; + } + + /** + * Closes the socket and cleans up the state of the class. + * It is not considered good to use this function without + * first trying to use QUIT. + * @access public + * @return void + */ + public function Close() { + $this->error = null; // so there is no confusion + $this->helo_rply = null; + if(!empty($this->smtp_conn)) { + // close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = 0; + } + } + + /*************************************************************** + * SMTP COMMANDS * + *************************************************************/ + + /** + * Issues a data command and sends the msg_data to the server + * finializing the mail transaction. $msg_data is the message + * that is to be send with the headers. Each header needs to be + * on a single line followed by a with the message headers + * and the message body being seperated by and additional . + * + * Implements rfc 821: DATA + * + * SMTP CODE INTERMEDIATE: 354 + * [data] + * . + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 552,554,451,452 + * SMTP CODE FAILURE: 451,554 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Data($msg_data) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Data() without being connected"); + return false; + } + + fputs($this->smtp_conn,"DATA" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 354) { + $this->error = + array("error" => "DATA command not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + /* the server is ready to accept data! + * according to rfc 821 we should not send more than 1000 + * including the CRLF + * characters on a single line so we will break the data up + * into lines by \r and/or \n then if needed we will break + * each of those into smaller lines to fit within the limit. + * in addition we will be looking for lines that start with + * a period '.' and append and additional period '.' to that + * line. NOTE: this does not count towards are limit. + */ + + // normalize the line breaks so we know the explode works + $msg_data = str_replace("\r\n","\n",$msg_data); + $msg_data = str_replace("\r","\n",$msg_data); + $lines = explode("\n",$msg_data); + + /* we need to find a good way to determine is headers are + * in the msg_data or if it is a straight msg body + * currently I am assuming rfc 822 definitions of msg headers + * and if the first field of the first line (':' sperated) + * does not contain a space then it _should_ be a header + * and we can process all lines before a blank "" line as + * headers. + */ + $field = substr($lines[0],0,strpos($lines[0],":")); + $in_headers = false; + if(!empty($field) && !strstr($field," ")) { + $in_headers = true; + } + + $max_line_length = 998; // used below; set here for ease in change + + while(list(,$line) = @each($lines)) { + $lines_out = null; + if($line == "" && $in_headers) { + $in_headers = false; + } + // ok we need to break this line up into several smaller lines + while(strlen($line) > $max_line_length) { + $pos = strrpos(substr($line,0,$max_line_length)," "); + + // Patch to fix DOS attack + if(!$pos) { + $pos = $max_line_length - 1; + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos); + } else { + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos + 1); + } + + /* if we are processing headers we need to + * add a LWSP-char to the front of the new line + * rfc 822 on long msg headers + */ + if($in_headers) { + $line = "\t" . $line; + } + } + $lines_out[] = $line; + + // now send the lines to the server + while(list(,$line_out) = @each($lines_out)) { + if(strlen($line_out) > 0) + { + if(substr($line_out, 0, 1) == ".") { + $line_out = "." . $line_out; + } + } + fputs($this->smtp_conn,$line_out . $this->CRLF); + } + } + + // ok all the message data has been sent so lets get this + // over with aleady + fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "DATA not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Expand takes the name and asks the server to list all the + * people who are members of the _list_. Expand will return + * back and array of the result or false if an error occurs. + * Each value in the array returned has the format of: + * [ ] + * The definition of is defined in rfc 821 + * + * Implements rfc 821: EXPN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 550 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string array + */ + public function Expand($name) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Expand() without being connected"); + return false; + } + + fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "EXPN not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // parse the reply and place in our array to return to user + $entries = explode($this->CRLF,$rply); + while(list(,$l) = @each($entries)) { + $list[] = substr($l,4); + } + + return $list; + } + + /** + * Sends the HELO command to the smtp server. + * This makes sure that we and the server are in + * the same known state. + * + * Implements from rfc 821: HELO + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 501, 504, 421 + * @access public + * @return bool + */ + public function Hello($host="") { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Hello() without being connected"); + return false; + } + + // if a hostname for the HELO was not specified determine + //a suitable one to send + if(empty($host)) { + // we need to determine some sort of appopiate default + // to send to the server + $host = "localhost"; + } + + // Send extended hello first (RFC 2821) + if(!$this->SendHello("EHLO", $host)) + { + if(!$this->SendHello("HELO", $host)) + return false; + } + + return true; + } + + /** + * Sends a HELO/EHLO command. + * @access private + * @return bool + */ + private function SendHello($hello, $host) { + fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => $hello . " not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + $this->helo_rply = $rply; + + return true; + } + + /** + * Gets help information on the keyword specified. If the keyword + * is not specified then returns generic help, ussually contianing + * A list of keywords that help is available on. This function + * returns the results back to the user. It is up to the user to + * handle the returned data. If an error occurs then false is + * returned with $this->error set appropiately. + * + * Implements rfc 821: HELP [ ] + * + * SMTP CODE SUCCESS: 211,214 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string + */ + public function Help($keyword="") { + $this->error = null; // to avoid confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Help() without being connected"); + return false; + } + + $extra = ""; + if(!empty($keyword)) { + $extra = " " . $keyword; + } + + fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 211 && $code != 214) { + $this->error = + array("error" => "HELP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return $rply; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. + * + * Implements rfc 821: MAIL FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,421 + * @access public + * @return bool + */ + public function Mail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Mail() without being connected"); + return false; + } + + $useVerp = ($this->do_verp ? "XVERP" : ""); + fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "MAIL not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the command NOOP to the SMTP server. + * + * Implements from rfc 821: NOOP + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 421 + * @access public + * @return bool + */ + public function Noop() { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Noop() without being connected"); + return false; + } + + fputs($this->smtp_conn,"NOOP" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "NOOP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the quit command to the server and then closes the socket + * if there is no error or the $close_on_error argument is true. + * + * Implements from rfc 821: QUIT + * + * SMTP CODE SUCCESS: 221 + * SMTP CODE ERROR : 500 + * @access public + * @return bool + */ + public function Quit($close_on_error=true) { + $this->error = null; // so there is no confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Quit() without being connected"); + return false; + } + + // send the quit command to the server + fputs($this->smtp_conn,"quit" . $this->CRLF); + + // get any good-bye messages + $byemsg = $this->get_lines(); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; + } + + $rval = true; + $e = null; + + $code = substr($byemsg,0,3); + if($code != 221) { + // use e as a tmp var cause Close will overwrite $this->error + $e = array("error" => "SMTP server rejected quit command", + "smtp_code" => $code, + "smtp_rply" => substr($byemsg,4)); + $rval = false; + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $e["error"] . ": " . + $byemsg . $this->CRLF; + } + } + + if(empty($e) || $close_on_error) { + $this->Close(); + } + + return $rval; + } + + /** + * Sends the command RCPT to the SMTP server with the TO: argument of $to. + * Returns true if the recipient was accepted false if it was rejected. + * + * Implements from rfc 821: RCPT TO: + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Recipient($to) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Recipient() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "RCPT not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the RSET command to abort and transaction that is + * currently in progress. Returns true if successful false + * otherwise. + * + * Implements rfc 821: RSET + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500,501,504,421 + * @access public + * @return bool + */ + public function Reset() { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Reset() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RSET" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "RSET failed", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in. + * + * Implements rfc 821: SEND FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function Send($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Send() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SEND not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in and send them an email. + * + * Implements rfc 821: SAML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function SendAndMail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendAndMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SAML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in or mail it to them if they are not. + * + * Implements rfc 821: SOML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function SendOrMail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendOrMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SOML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * This is an optional command for SMTP that this class does not + * support. This method is here to make the RFC821 Definition + * complete for this class and __may__ be implimented in the future + * + * Implements from rfc 821: TURN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 502 + * SMTP CODE ERROR : 500, 503 + * @access public + * @return bool + */ + public function Turn() { + $this->error = array("error" => "This method, TURN, of the SMTP ". + "is not implemented"); + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; + } + return false; + } + + /** + * Verifies that the name is recognized by the server. + * Returns false if the name could not be verified otherwise + * the response from the server is returned. + * + * Implements rfc 821: VRFY + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,553 + * SMTP CODE ERROR : 500,501,502,421 + * @access public + * @return int + */ + public function Verify($name) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Verify() without being connected"); + return false; + } + + fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "VRFY failed on name '$name'", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return $rply; + } + + /******************************************************************* + * INTERNAL FUNCTIONS * + ******************************************************************/ + + /** + * Read in as many lines as possible + * either before eof or socket timeout occurs on the operation. + * With SMTP we can tell if we have more lines to read if the + * 4th character is '-' symbol. If it is a space then we don't + * need to read anything else. + * @access private + * @return string + */ + private function get_lines() { + $data = ""; + while($str = @fgets($this->smtp_conn,515)) { + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data was \"$data\"" . + $this->CRLF; + echo "SMTP -> get_lines(): \$str is \"$str\"" . + $this->CRLF; + } + $data .= $str; + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; + } + // if the 4th character is a space then we are done reading + // so just break the loop + if(substr($str,3,1) == " ") { break; } + } + return $data; + } + +} + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/docs/extending.html b/inc/main/third_party/php_mailer/docs/extending.html new file mode 100644 index 00000000..310f97a3 --- /dev/null +++ b/inc/main/third_party/php_mailer/docs/extending.html @@ -0,0 +1,148 @@ + + +Examples using phpmailer + + + + +

    Examples using phpmailer

    + +

    1. Advanced Example

    +

    + +This demonstrates sending out multiple email messages with binary attachments +from a MySQL database with multipart/alternative support.

    + + + + +
    +
    +require("class.phpmailer.php");
    +
    +$mail = new phpmailer();
    +
    +$mail->From     = "list@example.com";
    +$mail->FromName = "List manager";
    +$mail->Host     = "smtp1.example.com;smtp2.example.com";
    +$mail->Mailer   = "smtp";
    +
    +@MYSQL_CONNECT("localhost","root","password");
    +@mysql_select_db("my_company");
    +$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";
    +$result = @MYSQL_QUERY($query);
    +
    +while ($row = mysql_fetch_array ($result))
    +{
    +    // HTML body
    +    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
    +    $body .= "<i>Your</i> personal photograph to this message.<p>";
    +    $body .= "Sincerely, <br>";
    +    $body .= "phpmailer List manager";
    +
    +    // Plain text body (for mail clients that cannot read HTML)
    +    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
    +    $text_body .= "Your personal photograph to this message.\n\n";
    +    $text_body .= "Sincerely, \n";
    +    $text_body .= "phpmailer List manager";
    +
    +    $mail->Body    = $body;
    +    $mail->AltBody = $text_body;
    +    $mail->AddAddress($row["email"], $row["full_name"]);
    +    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
    +
    +    if(!$mail->Send())
    +        echo "There has been a mail error sending to " . $row["email"] . "<br>";
    +
    +    // Clear all addresses and attachments for next loop
    +    $mail->ClearAddresses();
    +    $mail->ClearAttachments();
    +}
    +
    +
    +

    + +

    2. Extending phpmailer

    +

    + +Extending classes with inheritance is one of the most +powerful features of object-oriented +programming. It allows you to make changes to the +original class for your +own personal use without hacking the original +classes. Plus, it is very +easy to do. I've provided an example: + +

    +Here's a class that extends the phpmailer class and sets the defaults +for the particular site:
    +PHP include file: mail.inc.php +

    + + + + + +
    +
    +require("class.phpmailer.php");
    +
    +class my_phpmailer extends phpmailer {
    +    // Set default variables for all new objects
    +    var $From     = "from@example.com";
    +    var $FromName = "Mailer";
    +    var $Host     = "smtp1.example.com;smtp2.example.com";
    +    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
    +    var $WordWrap = 75;
    +
    +    // Replace the default error_handler
    +    function error_handler($msg) {
    +        print("My Site Error");
    +        print("Description:");
    +        printf("%s", $msg);
    +        exit;
    +    }
    +
    +    // Create an additional function
    +    function do_something($something) {
    +        // Place your new code here
    +    }
    +}
    +
    +
    + +Now here's a normal PHP page in the site, which will have all the defaults set +above:
    +Normal PHP file: mail_test.php +

    + + + + + +
    +
    +require("mail.inc.php");
    +
    +// Instantiate your new class
    +$mail = new my_phpmailer;
    +
    +// Now you only need to add the necessary stuff
    +$mail->AddAddress("josh@example.com", "Josh Adams");
    +$mail->Subject = "Here is the subject";
    +$mail->Body    = "This is the message body";
    +$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
    +
    +if(!$mail->Send())
    +{
    +   echo "There was an error sending the message";
    +   exit;
    +}
    +
    +echo "Message was sent successfully";
    +
    +
    +

    + + + diff --git a/inc/main/third_party/php_mailer/docs/faq.html b/inc/main/third_party/php_mailer/docs/faq.html new file mode 100644 index 00000000..f71c6c89 --- /dev/null +++ b/inc/main/third_party/php_mailer/docs/faq.html @@ -0,0 +1,67 @@ + + +PHPMailer FAQ + + + +
    +
    +

    PHPMailer FAQ

    +
      + +
    • Q: I'm using the SMTP mailer and I keep on getting a timeout message + well before the X seconds I set it for. What gives?
      + A: PHP versions 4.0.4pl1 and earlier have a bug in which sockets timeout + early. You can fix this by re-compiling PHP 4.0.4pl1 with this fix: + timeoutfix.diff. Otherwise you can wait for the new PHP release.

    • + +
    • Q: I am concerned that using include files will take up too much + processing time on my computer. How can I make it run faster?
      + A: PHP by itself is very fast. Much faster than ASP or JSP running on + the same type of server. This is because it has very little overhead compared + to its competitors and it pre-compiles all of + its code before it runs each script (in PHP4). However, all of + this compiling and re-compiling can take up a lot of valuable + computer resources. However, there are programs out there that compile + PHP code and store it in memory (or on mmaped files) to reduce the + processing immensely. Two of these: APC + (Alternative PHP Cache) and Afterburner + (Win32 download) + are excellent free tools that do just this. If you have the money + you might also try Zend Cache, it is + even faster than the open source varieties. All of these tools make your + scripts run faster while also reducing the load on your server. I have tried + them myself and they are quite stable too.

    • + +
    • Q: What mailer gives me the best performance?
      + A: On a single machine the sendmail (or Qmail) is fastest overall. + Next fastest is mail() to give you the best performance. Both do not have the overhead of SMTP. + If you have you have your mail server on a another machine then + SMTP is your only option, but you do get the benefit of redundant mail servers.
      + If you are running a mailing list with thousands of names, the fastest mailers in order are: SMTP, sendmail (or Qmail), mail().

    • + +
    • Q: When I try to attach a file with on my server I get a + "Could not find {file} on filesystem error". Why is this?
      + A: If you are using a Unix machine this is probably because the user + running your web server does not have read access to the directory in question. If you are using Windows, + then the problem probably is that you have used single backslashes to denote directories (\). + A single backslash has a special meaning to PHP so these are not + valid. Instead use double backslashes ("\\") or a single forward + slash ("/").

    • + +
    + +
    +
    + + + diff --git a/inc/main/third_party/php_mailer/docs/pop3_article.txt b/inc/main/third_party/php_mailer/docs/pop3_article.txt new file mode 100644 index 00000000..cc54f7c0 --- /dev/null +++ b/inc/main/third_party/php_mailer/docs/pop3_article.txt @@ -0,0 +1,39 @@ +This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. + +With that noted, here is how to implement it: +Install the class file + +I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory: +[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi] +When you need it, create your POP3 object + +Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: +[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi] + +The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. +The Parameters + +The Authorise parameters are as follows: +[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi] + + 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) + 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) + 3. 30 - A connection time-out value (in seconds) + 4. mailer - The POP3 Username required to logon + 5. password - The POP3 Password required to logon + 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) + +Final Comments + the Download + +1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. + +2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. + +3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. + +4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. +Download + +Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself. + +My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) diff --git a/inc/main/third_party/php_mailer/docs/use_gmail.txt b/inc/main/third_party/php_mailer/docs/use_gmail.txt new file mode 100644 index 00000000..7519d7d2 --- /dev/null +++ b/inc/main/third_party/php_mailer/docs/use_gmail.txt @@ -0,0 +1,45 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->SMTPSecure = "ssl"; // sets the prefix to the servier +$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server +$mail->Port = 465; // set the SMTP port + +$mail->Username = "yourname@gmail.com"; // GMAIL username +$mail->Password = "password"; // GMAIL password + +$mail->From = "replyto@yourdomain.com"; +$mail->FromName = "Webmaster"; +$mail->Subject = "This is the subject"; +$mail->AltBody = "This is the body when user views in plain text format"; //Text Body +$mail->WordWrap = 50; // set word wrap + +$mail->MsgHTML($body); + +$mail->AddReplyTo("replyto@yourdomain.com","Webmaster"); + +$mail->AddAttachment("/path/to/file.zip"); // attachment +$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment + +$mail->AddAddress("username@domain.com","First Last"); + +$mail->IsHTML(true); // send as HTML + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message has been sent"; +} + +?> diff --git a/inc/main/third_party/php_mailer/examples/contents.html b/inc/main/third_party/php_mailer/examples/contents.html new file mode 100644 index 00000000..3efbda27 --- /dev/null +++ b/inc/main/third_party/php_mailer/examples/contents.html @@ -0,0 +1,12 @@ + +
    +

    +
    + This is a test of PHPMailer v2.0.0 rc1.
    +
    +This particular example uses HTML, with a <div> tag and inline
    +styles.
    +
    +Also note the use of the PHPMailer at the top with no specific code to handle +including it in the body of the email.
    + diff --git a/inc/main/third_party/php_mailer/examples/images/bkgrnd.gif b/inc/main/third_party/php_mailer/examples/images/bkgrnd.gif new file mode 100644 index 00000000..bc89624c Binary files /dev/null and b/inc/main/third_party/php_mailer/examples/images/bkgrnd.gif differ diff --git a/inc/main/third_party/php_mailer/examples/images/phpmailer.gif b/inc/main/third_party/php_mailer/examples/images/phpmailer.gif new file mode 100644 index 00000000..5e269714 Binary files /dev/null and b/inc/main/third_party/php_mailer/examples/images/phpmailer.gif differ diff --git a/inc/main/third_party/php_mailer/examples/images/phpmailer.png b/inc/main/third_party/php_mailer/examples/images/phpmailer.png new file mode 100644 index 00000000..abe0101f Binary files /dev/null and b/inc/main/third_party/php_mailer/examples/images/phpmailer.png differ diff --git a/inc/main/third_party/php_mailer/examples/images/phpmailer_mini.gif b/inc/main/third_party/php_mailer/examples/images/phpmailer_mini.gif new file mode 100644 index 00000000..dc7d7827 Binary files /dev/null and b/inc/main/third_party/php_mailer/examples/images/phpmailer_mini.gif differ diff --git a/inc/main/third_party/php_mailer/examples/index.html b/inc/main/third_party/php_mailer/examples/index.html new file mode 100644 index 00000000..3ac45d3b --- /dev/null +++ b/inc/main/third_party/php_mailer/examples/index.html @@ -0,0 +1,73 @@ +

    The example file "test_mail.php" contents include:

    +
    + +<?php
    +
    +include_once('../class.phpmailer.php');
    +
    +$mail = new PHPMailer();
    +
    +$body = $mail->getFile('contents.html');
    +
    +$body = eregi_replace("[\]",'',$body);
    +$subject = eregi_replace("[\]",'',$subject);
    +
    +$mail->From = "name@yourdomain.com";
    +$mail->FromName = "First Last";
    +
    +$mail->Subject = "PHPMailer Test Subject";
    +
    +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    +
    +$mail->MsgHTML($body);
    +
    +$mail->AddAddress("whoto@otherdomain.com", "John Doe");
    +
    +if(!$mail->Send()) {
    + echo 'Failed to send mail';
    +} else {
    + echo 'Mail sent';
    +}
    +
    +?> +
    +
    +
    +Although you could use full compabitility with PHPMailer 1.7.3, this example +shows how to use the new features. If you view 'contents.html', you will note +that there is a background image used in the <body tag as well as an image used +with a regular <img tag. Here's what the HTML file looks like:
    +
    +
    + +<body background="images/bkgrnd.gif" style="margin: 0px;">
    +<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
    +<div align="center"><img src="images/phpmailer.gif" style="height: 90px; width: 340px"></div><br>
    +<br>
    + This is a test of PHPMailer v2.0.0 rc1.<br>
    +<br>
    +This particular example uses <strong>HTML</strong>, with a <div> tag and inline<br>
    +styles.<br>
    +<br>
    +Also note the use of the PHPMailer at the top with no specific code to handle
    +including it in the body of the email.</div>
    +</body>
    +
    +
    +
    +A few things to notice in the PHP script that generates the email: +
      +
    • the use of $mail->AltBody is completely optional. If not used, PHPMailer + will use the HTML text with htmlentities().
    • +
    • the background= and <img src= images were processed without any directives + or methods from the PHP script
    • +
    • there is no specific code to define the image type ... that is handled + automatically by PHPMailer when it parses the images
    • +
    • we are using a new class method '$mail->MsgHTML($body)' ... that is what will handle the parsing of the images and creating the AltBody text
    • +
    +

    Of course, you can still use PHPMailer the same way you have in the past. +That provides full compatibility with all existing scripts, while new scripts +can take advantage of the new features.

    +

    Modify test_mail.php now with your own email address and try it out.

    +To see what the email SHOULD look like in your HTML compatible email viewer: click here
    + diff --git a/inc/main/third_party/php_mailer/examples/pop3_before_smtp_test.php b/inc/main/third_party/php_mailer/examples/pop3_before_smtp_test.php new file mode 100644 index 00000000..b10b5e15 --- /dev/null +++ b/inc/main/third_party/php_mailer/examples/pop3_before_smtp_test.php @@ -0,0 +1,39 @@ + + +POP before SMTP Test + + + + +
    +Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
    +
    +  $mail = new PHPMailer();
    +
    +  $mail->IsSMTP();
    +  $mail->SMTPDebug = 2;
    +  $mail->IsHTML(false);
    +
    +  $mail->Host     = 'relay.example.com';
    +
    +  $mail->From     = 'mailer@example.com';
    +  $mail->FromName = 'Example Mailer';
    +
    +  $mail->Subject  =  'My subject';
    +  $mail->Body     =  'Hello world';
    +  $mail->AddAddress('name@anydomain.com', 'First Last');
    +
    +  if (!$mail->Send())
    +  {
    +    echo $mail->ErrorInfo;
    +  }
    +?>
    +
    + + + diff --git a/inc/main/third_party/php_mailer/examples/test_gmail.php b/inc/main/third_party/php_mailer/examples/test_gmail.php new file mode 100644 index 00000000..1fc2c5e8 --- /dev/null +++ b/inc/main/third_party/php_mailer/examples/test_gmail.php @@ -0,0 +1,50 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->SMTPSecure = "ssl"; // sets the prefix to the servier +$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server +$mail->Port = 465; // set the SMTP port for the GMAIL server + +$mail->Username = "yourusername@gmail.com"; // GMAIL username +$mail->Password = "yourpassword"; // GMAIL password + +$mail->AddReplyTo("yourusername@gmail.com","First Last"); + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via gmail"; + +//$mail->Body = "Hi,
    This is the HTML BODY
    "; //HTML Body +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test +$mail->WordWrap = 50; // set word wrap + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +$mail->IsHTML(true); // send as HTML + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/main/third_party/php_mailer/examples/test_mail.php b/inc/main/third_party/php_mailer/examples/test_mail.php new file mode 100644 index 00000000..6e0ac2fd --- /dev/null +++ b/inc/main/third_party/php_mailer/examples/test_mail.php @@ -0,0 +1,29 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via mail()"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/main/third_party/php_mailer/examples/test_sendmail.php b/inc/main/third_party/php_mailer/examples/test_sendmail.php new file mode 100644 index 00000000..3b9cc266 --- /dev/null +++ b/inc/main/third_party/php_mailer/examples/test_sendmail.php @@ -0,0 +1,37 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSendmail(); // telling the class to use SendMail transport + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via smtp"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/main/third_party/php_mailer/examples/test_smtp.php b/inc/main/third_party/php_mailer/examples/test_smtp.php new file mode 100644 index 00000000..d8da32b0 --- /dev/null +++ b/inc/main/third_party/php_mailer/examples/test_smtp.php @@ -0,0 +1,39 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); // telling the class to use SMTP +$mail->Host = "mail.worxteam.com"; // SMTP server + +$mail->From = "name@yourdomain.com"; +$mail->FromName = "First Last"; + +$mail->Subject = "PHPMailer Test Subject via smtp"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAddress("whoto@otherdomain.com", "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-ar.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-ar.php new file mode 100644 index 00000000..61ac12c6 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-ar.php @@ -0,0 +1,25 @@ + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = ' íÌÈ Ãä ÊÖÚ Úáì ÇáÃÞá ' . + 'ÚäæÇä ÈÑíÏ ÅáßÊÑæäí ãÓÊÞÈá æÇÍÏ'; +$PHPMAILER_LANG["mailer_not_supported"] = ' ãÑÓá ÇáÈÑíÏ ÛíÑ ãÏÚæã :'; +$PHPMAILER_LANG["execute"] = 'áÇ íãßä ÊäÝíÐ : '; +$PHPMAILER_LANG["instantiate"] = 'áã íÓÊØÚ ÊåíÆÉ ÊÇÈÚ ÇáÈÑíÏ'; +$PHPMAILER_LANG["authenticate"] = 'ÎØà STMP : áã íãáß ÇáÕáÇÍíÉ'; +$PHPMAILER_LANG["from_failed"] = 'ÇáÚäæÇä ÇáãÑÓá ÇáÊÇáí ÝÔá : '; +$PHPMAILER_LANG["recipients_failed"] = 'ÎØà STMP : ' . + 'åÄáÇÁ ÇáãÓÊÞÈáæä ÝÔáæÇ : '; +$PHPMAILER_LANG["data_not_accepted"] = 'ÎØà STMP : ÇáãÚØíÇÊ áã ÊÞÈá .'; +$PHPMAILER_LANG["connect_host"] = 'ÎØà STMP : ÇáÇÊÕÇá ÈãÓÊÖíÝ STMP áã íÊã'; +$PHPMAILER_LANG["file_access"] = 'áÇ íãßä ÇáæÕæá áãáÝ : '; +$PHPMAILER_LANG["file_open"] = 'ÎØà ãáÝ : áã íãßä ÝÊÍ ãáÝ :'; +$PHPMAILER_LANG["encoding"] = 'ÊÔÝíÑ ÛíÑ ãÚÑæÝ : '; +$PHPMAILER_LANG["signing"] = 'ÎØà ÊÓÌíá : '; + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-br.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-br.php new file mode 100644 index 00000000..abb2fed0 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-br.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-ca.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-ca.php new file mode 100644 index 00000000..c5ca72b9 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-ca.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-cz.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-cz.php new file mode 100644 index 00000000..48e4669e --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-cz.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-de.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-de.php new file mode 100644 index 00000000..843971b9 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-de.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-dk.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-dk.php new file mode 100644 index 00000000..1580da69 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-dk.php @@ -0,0 +1,25 @@ + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Du skal indtaste mindst en ' . + 'modtagers emailadresse.'; +$PHPMAILER_LANG["mailer_not_supported"] = ' mailer understøttes ikke.'; +$PHPMAILER_LANG["execute"] = 'Kunne ikke køre: '; +$PHPMAILER_LANG["instantiate"] = 'Kunne ikke initialisere email funktionen.'; +$PHPMAILER_LANG["authenticate"] = 'SMTP fejl: Kunne ikke logge pÃ¥.'; +$PHPMAILER_LANG["from_failed"] = 'Følgende afsenderadresse er forkert: '; +$PHPMAILER_LANG["recipients_failed"] = 'SMTP fejl: Følgende' . + 'modtagere er forkerte: '; +$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fejl: Data kunne ikke accepteres.'; +$PHPMAILER_LANG["connect_host"] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.'; +$PHPMAILER_LANG["file_access"] = 'Ingen adgang til fil: '; +$PHPMAILER_LANG["file_open"] = 'Fil fejl: Kunne ikke Ã¥bne filen: '; +$PHPMAILER_LANG["encoding"] = 'Ukendt encode-format: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-en.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-en.php new file mode 100644 index 00000000..f7d4286d --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-en.php @@ -0,0 +1,25 @@ + diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-es.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-es.php new file mode 100644 index 00000000..493e9b41 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-es.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-et.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-et.php new file mode 100644 index 00000000..40cfc622 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-et.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-fi.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-fi.php new file mode 100644 index 00000000..1c4feace --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-fi.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-fo.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-fo.php new file mode 100644 index 00000000..5cb24ced --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-fo.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-fr.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-fr.php new file mode 100644 index 00000000..e00dac70 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-fr.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-hu.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-hu.php new file mode 100644 index 00000000..f97e0d9e --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-hu.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-it.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-it.php new file mode 100644 index 00000000..9bb3a558 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-it.php @@ -0,0 +1,29 @@ +*/ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Deve essere fornito almeno un'. + ' indirizzo ricevente'; +$PHPMAILER_LANG["mailer_not_supported"] = 'Mailer non supportato'; +$PHPMAILER_LANG["execute"] = "Impossibile eseguire l'operazione: "; +$PHPMAILER_LANG["instantiate"] = 'Impossibile istanziare la funzione mail'; +$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Impossibile autenticarsi.'; +$PHPMAILER_LANG["from_failed"] = 'I seguenti indirizzi mittenti hanno'. + ' generato errore: '; +$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: I seguenti indirizzi'. + 'destinatari hanno generato errore: '; +$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data non accettati dal'. + 'server.'; +$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Impossibile connettersi'. + ' all\'host SMTP.'; +$PHPMAILER_LANG["file_access"] = 'Impossibile accedere al file: '; +$PHPMAILER_LANG["file_open"] = 'File Error: Impossibile aprire il file: '; +$PHPMAILER_LANG["encoding"] = 'Encoding set dei caratteri sconosciuto: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-ja.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-ja.php new file mode 100644 index 00000000..92e2b666 Binary files /dev/null and b/inc/main/third_party/php_mailer/language/phpmailer.lang-ja.php differ diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-nl.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-nl.php new file mode 100644 index 00000000..459de614 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-nl.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-no.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-no.php new file mode 100644 index 00000000..06d93107 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-no.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-pl.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-pl.php new file mode 100644 index 00000000..2b342a3a --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-pl.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-ro.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-ro.php new file mode 100644 index 00000000..3c8bc117 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-ro.php @@ -0,0 +1,24 @@ + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).'; +$PHPMAILER_LANG["mailer_not_supported"] = ' mailer nu este suportat.'; +$PHPMAILER_LANG["execute"] = 'Nu pot executa: '; +$PHPMAILER_LANG["instantiate"] = 'Nu am putut instantia functia mail.'; +$PHPMAILER_LANG["authenticate"] = 'Eroare SMTP: Nu a functionat autentificarea.'; +$PHPMAILER_LANG["from_failed"] = 'Urmatoarele adrese From au dat eroare: '; +$PHPMAILER_LANG["recipients_failed"] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: '; +$PHPMAILER_LANG["data_not_accepted"] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.'; +$PHPMAILER_LANG["connect_host"] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.'; +$PHPMAILER_LANG["file_access"] = 'Nu pot accesa fisierul: '; +$PHPMAILER_LANG["file_open"] = 'Eroare de fisier: Nu pot deschide fisierul: '; +$PHPMAILER_LANG["encoding"] = 'Encodare necunoscuta: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-ru.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-ru.php new file mode 100644 index 00000000..e456c493 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-ru.php @@ -0,0 +1,24 @@ + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Ïîæàëóéñòà, ââåäèòå õîòÿ áû îäèí àäðåñ e-mail ' . + 'ïîëó÷àòåëÿ.'; +$PHPMAILER_LANG["mailer_not_supported"] = ' - ïî÷òîâûé ñåðâåð íå ïîääåðæèâàåòñÿ.'; +$PHPMAILER_LANG["execute"] = 'Íåâîçìîæíî âûïîëíèòü êîìàíäó: '; +$PHPMAILER_LANG["instantiate"] = 'Íåâîçìîæíî çàïóñòèòü ôóíêöèþ mail.'; +$PHPMAILER_LANG["authenticate"] = 'Îøèáêà SMTP: îøèáêà àâòîðèçàöèè.'; +$PHPMAILER_LANG["from_failed"] = 'Íåâåðíûé àäðåñ îòïðàâèòåëÿ: '; +$PHPMAILER_LANG["recipients_failed"] = 'Îøèáêà SMTP: îòïðàâêà ïî ñëåäóþùèì ' . + 'àäðåñàì ïîëó÷àòåëåé íå óäàëàñü: '; +$PHPMAILER_LANG["data_not_accepted"] = 'Îøèáêà SMTP: äàííûå íå ïðèíÿòû.'; +$PHPMAILER_LANG["connect_host"] = 'Îøèáêà SMTP: íå óäàåòñÿ ïîäêëþ÷èòüñÿ ê ñåðâåðó SMTP.'; +$PHPMAILER_LANG["file_access"] = 'Íåò äîñòóïà ê ôàéëó: '; +$PHPMAILER_LANG["file_open"] = 'Ôàéëîâàÿ îøèáêà: íå óäàåòñÿ îòêðûòü ôàéë: '; +$PHPMAILER_LANG["encoding"] = 'Íåèçâåñòíûé âèä êîäèðîâêè: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-se.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-se.php new file mode 100644 index 00000000..0670afc0 --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-se.php @@ -0,0 +1,25 @@ + */ + +$PHPMAILER_LANG = array(); + +$PHPMAILER_LANG["provide_address"] = 'Du måste ange minst en ' . + 'mottagares e-postadress.'; +$PHPMAILER_LANG["mailer_not_supported"] = ' mailer stöds inte.'; +$PHPMAILER_LANG["execute"] = 'Kunde inte köra: '; +$PHPMAILER_LANG["instantiate"] = 'Kunde inte initiera e-postfunktion.'; +$PHPMAILER_LANG["authenticate"] = 'SMTP fel: Kunde inte autentisera.'; +$PHPMAILER_LANG["from_failed"] = 'Följande avsändaradress är felaktig: '; +$PHPMAILER_LANG["recipients_failed"] = 'SMTP fel: Följande ' . + 'mottagare är felaktig: '; +$PHPMAILER_LANG["data_not_accepted"] = 'SMTP fel: Data accepterades inte.'; +$PHPMAILER_LANG["connect_host"] = 'SMTP fel: Kunde inte ansluta till SMTP-server.'; +$PHPMAILER_LANG["file_access"] = 'Ingen åtkomst till fil: '; +$PHPMAILER_LANG["file_open"] = 'Fil fel: Kunde inte öppna fil: '; +$PHPMAILER_LANG["encoding"] = 'Okänt encode-format: '; +$PHPMAILER_LANG["signing"] = 'Signing Error: '; + +?> \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/language/phpmailer.lang-tr.php b/inc/main/third_party/php_mailer/language/phpmailer.lang-tr.php new file mode 100644 index 00000000..4e3e675c --- /dev/null +++ b/inc/main/third_party/php_mailer/language/phpmailer.lang-tr.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/inc/main/third_party/php_mailer/test/phpmailer_test.php b/inc/main/third_party/php_mailer/test/phpmailer_test.php new file mode 100644 index 00000000..ffbe4bd4 --- /dev/null +++ b/inc/main/third_party/php_mailer/test/phpmailer_test.php @@ -0,0 +1,572 @@ +TestCase( $name ); + } + + /** + * Run before each test is started. + */ + function setUp() { + global $global_vars; + global $INCLUDE_DIR; + + $this->Mail = new PHPMailer(); + + $this->Mail->Priority = 3; + $this->Mail->Encoding = "8bit"; + $this->Mail->CharSet = "iso-8859-1"; + $this->Mail->From = "unit_test@phpmailer.sf.net"; + $this->Mail->FromName = "Unit Tester"; + $this->Mail->Sender = ""; + $this->Mail->Subject = "Unit Test"; + $this->Mail->Body = ""; + $this->Mail->AltBody = ""; + $this->Mail->WordWrap = 0; + $this->Mail->Host = $global_vars["mail_host"]; + $this->Mail->Port = 25; + $this->Mail->Helo = "localhost.localdomain"; + $this->Mail->SMTPAuth = false; + $this->Mail->Username = ""; + $this->Mail->Password = ""; + $this->Mail->PluginDir = $INCLUDE_DIR; + $this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy"); + $this->Mail->Sender = "unit_test@phpmailer.sf.net"; + + if(strlen($this->Mail->Host) > 0) + $this->Mail->Mailer = "smtp"; + else + { + $this->Mail->Mailer = "mail"; + $this->Sender = "unit_test@phpmailer.sf.net"; + } + + global $global_vars; + $this->SetAddress($global_vars["mail_to"], "Test User"); + if(strlen($global_vars["mail_cc"]) > 0) + $this->SetAddress($global_vars["mail_cc"], "Carbon User", "cc"); + } + + /** + * Run after each test is completed. + */ + function tearDown() { + // Clean global variables + $this->Mail = NULL; + $this->ChangeLog = array(); + $this->NoteLog = array(); + } + + + /** + * Build the body of the message in the appropriate format. + * @private + * @returns void + */ + function BuildBody() { + $this->CheckChanges(); + + // Determine line endings for message + if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) + { + $eol = "
    "; + $bullet = "
  • "; + $bullet_start = "
      "; + $bullet_end = "
    "; + } + else + { + $eol = "\n"; + $bullet = " - "; + $bullet_start = ""; + $bullet_end = ""; + } + + $ReportBody = ""; + + $ReportBody .= "---------------------" . $eol; + $ReportBody .= "Unit Test Information" . $eol; + $ReportBody .= "---------------------" . $eol; + $ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol; + $ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol; + + if(strlen($this->Mail->Host) > 0) + $ReportBody .= "Host: " . $this->Mail->Host . $eol; + + // If attachments then create an attachment list + if(count($this->Mail->attachment) > 0) + { + $ReportBody .= "Attachments:" . $eol; + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->Mail->attachment); $i++) + { + $ReportBody .= $bullet . "Name: " . $this->Mail->attachment[$i][1] . ", "; + $ReportBody .= "Encoding: " . $this->Mail->attachment[$i][3] . ", "; + $ReportBody .= "Type: " . $this->Mail->attachment[$i][4] . $eol; + } + $ReportBody .= $bullet_end . $eol; + } + + // If there are changes then list them + if(count($this->ChangeLog) > 0) + { + $ReportBody .= "Changes" . $eol; + $ReportBody .= "-------" . $eol; + + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->ChangeLog); $i++) + { + $ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" . + $this->ChangeLog[$i][1] . "]" . $eol; + } + $ReportBody .= $bullet_end . $eol . $eol; + } + + // If there are notes then list them + if(count($this->NoteLog) > 0) + { + $ReportBody .= "Notes" . $eol; + $ReportBody .= "-----" . $eol; + + $ReportBody .= $bullet_start; + for($i = 0; $i < count($this->NoteLog); $i++) + { + $ReportBody .= $bullet . $this->NoteLog[$i] . $eol; + } + $ReportBody .= $bullet_end; + } + + // Re-attach the original body + $this->Mail->Body .= $eol . $eol . $ReportBody; + } + + /** + * Check which default settings have been changed for the report. + * @private + * @returns void + */ + function CheckChanges() { + if($this->Mail->Priority != 3) + $this->AddChange("Priority", $this->Mail->Priority); + if($this->Mail->Encoding != "8bit") + $this->AddChange("Encoding", $this->Mail->Encoding); + if($this->Mail->CharSet != "iso-8859-1") + $this->AddChange("CharSet", $this->Mail->CharSet); + if($this->Mail->Sender != "") + $this->AddChange("Sender", $this->Mail->Sender); + if($this->Mail->WordWrap != 0) + $this->AddChange("WordWrap", $this->Mail->WordWrap); + if($this->Mail->Mailer != "mail") + $this->AddChange("Mailer", $this->Mail->Mailer); + if($this->Mail->Port != 25) + $this->AddChange("Port", $this->Mail->Port); + if($this->Mail->Helo != "localhost.localdomain") + $this->AddChange("Helo", $this->Mail->Helo); + if($this->Mail->SMTPAuth) + $this->AddChange("SMTPAuth", "true"); + } + + /** + * Adds a change entry. + * @private + * @returns void + */ + function AddChange($sName, $sNewValue) { + $cur = count($this->ChangeLog); + $this->ChangeLog[$cur][0] = $sName; + $this->ChangeLog[$cur][1] = $sNewValue; + } + + /** + * Adds a simple note to the message. + * @public + * @returns void + */ + function AddNote($sValue) { + $this->NoteLog[] = $sValue; + } + + /** + * Adds all of the addresses + * @public + * @returns void + */ + function SetAddress($sAddress, $sName = "", $sType = "to") { + switch($sType) + { + case "to": + $this->Mail->AddAddress($sAddress, $sName); + break; + case "cc": + $this->Mail->AddCC($sAddress, $sName); + break; + case "bcc": + $this->Mail->AddBCC($sAddress, $sName); + break; + } + } + + ///////////////////////////////////////////////// + // UNIT TESTS + ///////////////////////////////////////////////// + + /** + * Try a plain message. + */ + function test_WordWrap() { + + $this->Mail->WordWrap = 40; + $my_body = "Here is the main body of this message. It should " . + "be quite a few lines. It should be wrapped at the " . + "40 characters. Make sure that it is."; + $nBodyLen = strlen($my_body); + $my_body .= "\n\nThis is the above body length: " . $nBodyLen; + + $this->Mail->Body = $my_body; + $this->Mail->Subject .= ": Wordwrap"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Try a plain message. + */ + function test_Low_Priority() { + + $this->Mail->Priority = 5; + $this->Mail->Body = "Here is the main body. There should be " . + "a reply to address in this message."; + $this->Mail->Subject .= ": Low Priority"; + $this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)"); + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple plain file attachment test. + */ + function test_Multiple_Plain_FileAttachment() { + + $this->Mail->Body = "Here is the text body"; + $this->Mail->Subject .= ": Plain + Multiple FileAttachments"; + + if(!$this->Mail->AddAttachment("test.png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple plain string attachment test. + */ + function test_Plain_StringAttachment() { + + $this->Mail->Body = "Here is the text body"; + $this->Mail->Subject .= ": Plain + StringAttachment"; + + $sAttachment = "These characters are the content of the " . + "string attachment.\nThis might be taken from a ". + "database or some other such thing. "; + + $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Plain quoted-printable message. + */ + function test_Quoted_Printable() { + + $this->Mail->Body = "Here is the main body"; + $this->Mail->Subject .= ": Plain + Quoted-printable"; + $this->Mail->Encoding = "quoted-printable"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Try a plain message. + */ + function test_Html() { + + $this->Mail->IsHTML(true); + $this->Mail->Subject .= ": HTML only"; + + $this->Mail->Body = "This is a test message written in HTML.
    " . + "Go to " . + "http://phpmailer.sourceforge.net/ for new versions of " . + "phpmailer.

    Thank you!"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple HTML and attachment test + */ + function test_HTML_Attachment() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->Subject .= ": HTML + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * An embedded attachment test. + */ + function test_Embedded_Image() { + + $this->Mail->Body = "Embedded Image: \"phpmailer\"" . + "Here is an image!"; + $this->Mail->Subject .= ": Embedded Image"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", + "base64", "image/png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * An embedded attachment test. + */ + function test_Multi_Embedded_Image() { + + $this->Mail->Body = "Embedded Image: \"phpmailer\"" . + "Here is an image!"; + $this->Mail->Subject .= ": Embedded Image + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddEmbeddedImage("test.png", "my-attach", "test.png", + "base64", "image/png")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple multipart/alternative test. + */ + function test_AltBody() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->AltBody = "Here is the text body of this message. " . + "It should be quite a few lines. It should be wrapped at the " . + "40 characters. Make sure that it is."; + $this->Mail->WordWrap = 40; + $this->AddNote("This is a mulipart alternative email"); + $this->Mail->Subject .= ": AltBody + Word Wrap"; + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + /** + * Simple HTML and attachment test + */ + function test_AltBody_Attachment() { + + $this->Mail->Body = "This is the HTML part of the email."; + $this->Mail->AltBody = "This is the text part of the email."; + $this->Mail->Subject .= ": AltBody + Attachment"; + $this->Mail->IsHTML(true); + + if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) + { + $this->assert(false, $this->Mail->ErrorInfo); + return; + } + + $this->BuildBody(); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $fp = fopen("message.txt", "w"); + fwrite($fp, $this->Mail->CreateHeader() . $this->Mail->CreateBody()); + fclose($fp); + } + + function test_MultipleSend() { + $this->Mail->Body = "Sending two messages without keepalive"; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->Subject = $subject . ": SMTP 1"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $this->Mail->Subject = $subject . ": SMTP 2"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_SmtpKeepAlive() { + $this->Mail->Body = "This was done using the SMTP keep-alive."; + $this->BuildBody(); + $subject = $this->Mail->Subject; + + $this->Mail->SMTPKeepAlive = true; + $this->Mail->Subject = $subject . ": SMTP keep-alive 1"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + + $this->Mail->Subject = $subject . ": SMTP keep-alive 2"; + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + $this->Mail->SmtpClose(); + } + + /** + * Tests this denial of service attack: + * http://www.cybsec.com/vuln/PHPMailer-DOS.pdf + */ + function test_DenialOfServiceAttack() { + $this->Mail->Body = "This should no longer cause a denial of service."; + $this->BuildBody(); + + $this->Mail->Subject = str_repeat("A", 998); + $this->assert($this->Mail->Send(), $this->Mail->ErrorInfo); + } + + function test_Error() { + $this->Mail->Subject .= ": This should be sent"; + $this->BuildBody(); + $this->Mail->ClearAllRecipients(); // no addresses should cause an error + $this->assert($this->Mail->IsError() == false, "Error found"); + $this->assert($this->Mail->Send() == false, "Send succeeded"); + $this->assert($this->Mail->IsError(), "No error found"); + $this->assertEquals('You must provide at least one ' . + 'recipient email address.', $this->Mail->ErrorInfo); + $this->Mail->AddAddress(get("mail_to")); + $this->assert($this->Mail->Send(), "Send failed"); + } +} + +/** + * Create and run test instance. + */ + +if(isset($HTTP_GET_VARS)) + $global_vars = $HTTP_GET_VARS; +else + $global_vars = $_REQUEST; + +if(isset($global_vars["submitted"])) +{ + echo "Test results:
    "; + $suite = new TestSuite( "phpmailerTest" ); + + $testRunner = new TestRunner; + $testRunner->run($suite); + echo "


    "; +} + +function get($sName) { + global $global_vars; + if(isset($global_vars[$sName])) + return $global_vars[$sName]; + else + return ""; +} + +?> + + + +

    phpmailer Unit Test

    +By entering a SMTP hostname it will automatically perform tests with SMTP. + + + +To Address: "/> +
    +Cc Address: "/> +
    +SMTP Hostname: "/> +

    + + + + + diff --git a/inc/main/third_party/php_mailer/test/phpunit.php b/inc/main/third_party/php_mailer/test/phpunit.php new file mode 100644 index 00000000..8c7256e3 --- /dev/null +++ b/inc/main/third_party/php_mailer/test/phpunit.php @@ -0,0 +1,378 @@ + +// OntoSys, Inc +// +// $Id$ + +// Copyright (c) 2000 Fred Yankowski + +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE | + E_CORE_ERROR | E_CORE_WARNING); + +/* +interface Test { + function run(&$aTestResult); + function countTestCases(); +} +*/ + +function trace($msg) { + return; + print($msg); + flush(); +} + + +class phpUnitException { + /* Emulate a Java exception, sort of... */ + var $message; + var $type; + function phpUnitException($message, $type = 'FAILURE') { + $this->message = $message; + $this->type = $type; + } + function getMessage() { + return $this->message; + } +} + +class Assert { + function assert($boolean, $message=0) { + if (! $boolean) + $this->fail($message); + } + + function assertEquals($expected, $actual, $message=0) { + if ($expected != $actual) { + $this->failNotEquals($expected, $actual, "expected", $message); + } + } + + function assertRegexp($regexp, $actual, $message=false) { + if (! preg_match($regexp, $actual)) { + $this->failNotEquals($regexp, $actual, "pattern", $message); + } + } + + function failNotEquals($expected, $actual, $expected_label, $message=0) { + // Private function for reporting failure to match. + $str = $message ? ($message . ' ') : ''; + $str .= "($expected_label/actual)
    "; + $htmlExpected = htmlspecialchars($expected); + $htmlActual = htmlspecialchars($actual); + $str .= sprintf("

    %s\n--------\n%s
    ", + $htmlExpected, $htmlActual); + $this->fail($str); + } +} + +class TestCase extends Assert /* implements Test */ { + /* Defines context for running tests. Specific context -- such as + instance variables, global variables, global state -- is defined + by creating a subclass that specializes the setUp() and + tearDown() methods. A specific test is defined by a subclass + that specializes the runTest() method. */ + var $fName; + var $fResult; + var $fExceptions = array(); + + function TestCase($name) { + $this->fName = $name; + } + + function run($testResult=0) { + /* Run this single test, by calling the run() method of the + TestResult object which will in turn call the runBare() method + of this object. That complication allows the TestResult object + to do various kinds of progress reporting as it invokes each + test. Create/obtain a TestResult object if none was passed in. + Note that if a TestResult object was passed in, it must be by + reference. */ + if (! $testResult) + $testResult = $this->_createResult(); + $this->fResult = $testResult; + $testResult->run(&$this); + $this->fResult = 0; + return $testResult; + } + + function countTestCases() { + return 1; + } + + function runTest() { + $name = $this->name(); + // Since isset($this->$name) is false, no way to run defensive checks + $this->$name(); + } + + function setUp() /* expect override */ { + //print("TestCase::setUp()
    \n"); + } + + function tearDown() /* possible override */ { + //print("TestCase::tearDown()
    \n"); + } + + //////////////////////////////////////////////////////////////// + + + function _createResult() /* protected */ { + /* override this to use specialized subclass of TestResult */ + return new TestResult; + } + + function fail($message=0) { + //printf("TestCase::fail(%s)
    \n", ($message) ? $message : ''); + /* JUnit throws AssertionFailedError here. We just record the + failure and carry on */ + $this->fExceptions[] = new Exception(&$message); + } + + function error($message) { + /* report error that requires correction in the test script + itself, or (heaven forbid) in this testing infrastructure */ + printf('ERROR: ' . $message . '
    '); + $this->fResult->stop(); + } + + function failed() { + return count($this->fExceptions); + } + + function getExceptions() { + return $this->fExceptions; + } + + function name() { + return $this->fName; + } + + function runBare() { + $this->setup(); + $this->runTest(); + $this->tearDown(); + } +} + + +class TestSuite /* implements Test */ { + /* Compose a set of Tests (instances of TestCase or TestSuite), and + run them all. */ + var $fTests = array(); + + function TestSuite($classname=false) { + if ($classname) { + // Find all methods of the given class whose name starts with + // "test" and add them to the test suite. We are just _barely_ + // able to do this with PHP's limited introspection... Note + // that PHP seems to store method names in lower case, and we + // have to avoid the constructor function for the TestCase class + // superclass. This will fail when $classname starts with + // "Test" since that will have a constructor method that will + // get matched below and then treated (incorrectly) as a test + // method. So don't name any TestCase subclasses as "Test..."! + if (floor(phpversion()) >= 4) { + // PHP4 introspection, submitted by Dylan Kuhn + $names = get_class_methods($classname); + while (list($key, $method) = each($names)) { + if (preg_match('/^test/', $method) && $method != "testcase") { + $this->addTest(new $classname($method)); + } + } + } + else { + $dummy = new $classname("dummy"); + $names = (array) $dummy; + while (list($key, $value) = each($names)) { + $type = gettype($value); + if ($type == "user function" && preg_match('/^test/', $key) + && $key != "testcase") { + $this->addTest(new $classname($key)); + } + } + } + } + } + + function addTest($test) { + /* Add TestCase or TestSuite to this TestSuite */ + $this->fTests[] = $test; + } + + function run(&$testResult) { + /* Run all TestCases and TestSuites comprising this TestSuite, + accumulating results in the given TestResult object. */ + reset($this->fTests); + while (list($na, $test) = each($this->fTests)) { + if ($testResult->shouldStop()) + break; + $test->run(&$testResult); + } + } + + function countTestCases() { + /* Number of TestCases comprising this TestSuite (including those + in any constituent TestSuites) */ + $count = 0; + reset($fTests); + while (list($na, $test_case) = each($this->fTests)) { + $count += $test_case->countTestCases(); + } + return $count; + } +} + + +class TestFailure { + /* Record failure of a single TestCase, associating it with the + exception(s) that occurred */ + var $fFailedTestName; + var $fExceptions; + + function TestFailure(&$test, &$exceptions) { + $this->fFailedTestName = $test->name(); + $this->fExceptions = $exceptions; + } + + function getExceptions() { + return $this->fExceptions; + } + function getTestName() { + return $this->fFailedTestName; + } +} + + +class TestResult { + /* Collect the results of running a set of TestCases. */ + var $fFailures = array(); + var $fRunTests = 0; + var $fStop = false; + + function TestResult() { } + + function _endTest($test) /* protected */ { + /* specialize this for end-of-test action, such as progress + reports */ + } + + function getFailures() { + return $this->fFailures; + } + + function run($test) { + /* Run a single TestCase in the context of this TestResult */ + $this->_startTest($test); + $this->fRunTests++; + + $test->runBare(); + + /* this is where JUnit would catch AssertionFailedError */ + $exceptions = $test->getExceptions(); + if ($exceptions) + $this->fFailures[] = new TestFailure(&$test, &$exceptions); + $this->_endTest($test); + } + + function countTests() { + return $this->fRunTests; + } + + function shouldStop() { + return $this->fStop; + } + + function _startTest($test) /* protected */ { + /* specialize this for start-of-test actions */ + } + + function stop() { + /* set indication that the test sequence should halt */ + $fStop = true; + } + + function countFailures() { + return count($this->fFailures); + } +} + + +class TextTestResult extends TestResult { + /* Specialize TestResult to produce text/html report */ + function TextTestResult() { + $this->TestResult(); // call superclass constructor + } + + function report() { + /* report result of test run */ + $nRun = $this->countTests(); + $nFailures = $this->countFailures(); + printf("

    %s test%s run
    ", $nRun, ($nRun == 1) ? '' : 's'); + printf("%s failure%s.
    \n", $nFailures, ($nFailures == 1) ? '' : 's'); + if ($nFailures == 0) + return; + + print("

      \n"); + $failures = $this->getFailures(); + while (list($i, $failure) = each($failures)) { + $failedTestName = $failure->getTestName(); + printf("
    1. %s\n", $failedTestName); + + $exceptions = $failure->getExceptions(); + print("
        "); + while (list($na, $exception) = each($exceptions)) + printf("
      • %s\n", $exception->getMessage()); + print("
      "); + } + print("
    \n"); + } + + function _startTest($test) { + printf("%s ", $test->name()); + flush(); + } + + function _endTest($test) { + $outcome = $test->failed() + ? "FAIL" + : "ok"; + printf("$outcome
    \n"); + flush(); + } +} + + +class TestRunner { + /* Run a suite of tests and report results. */ + function run($suite) { + $result = new TextTestResult; + $suite->run($result); + $result->report(); + } +} + +?> diff --git a/inc/main/third_party/php_mailer/test/test.png b/inc/main/third_party/php_mailer/test/test.png new file mode 100644 index 00000000..02de5a7a Binary files /dev/null and b/inc/main/third_party/php_mailer/test/test.png differ diff --git a/inc/main/third_party/scrypt/.htaccess b/inc/main/third_party/scrypt/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/third_party/scrypt/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/inc/main/third_party/scrypt/CREDITS b/inc/main/third_party/scrypt/CREDITS new file mode 100644 index 00000000..79c72e5a --- /dev/null +++ b/inc/main/third_party/scrypt/CREDITS @@ -0,0 +1,2 @@ +scrypt +Dominic Black \ No newline at end of file diff --git a/inc/main/third_party/scrypt/LICENSE b/inc/main/third_party/scrypt/LICENSE new file mode 100644 index 00000000..381d3aff --- /dev/null +++ b/inc/main/third_party/scrypt/LICENSE @@ -0,0 +1,15 @@ +Original Scrypt Implementation; + Copyright (c) 2009 Colin Percival + +PHP Module; + Copyright (c) 2012, Dominic Black + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/inc/main/third_party/scrypt/README.md b/inc/main/third_party/scrypt/README.md new file mode 100644 index 00000000..fef282bd --- /dev/null +++ b/inc/main/third_party/scrypt/README.md @@ -0,0 +1,90 @@ +PHP scrypt module +================= + +[![Build Status](https://travis-ci.org/DomBlack/php-scrypt.svg?branch=master)](https://travis-ci.org/DomBlack/php-scrypt) + +This is a PHP library providing a wrapper to [Colin Percival's scrypt implementation](http://www.tarsnap.com/scrypt.html). Scrypt is a key derivation function designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt. + +Details of the scrypt key derivation function are given in a paper by Colin Percival, Stronger Key Derivation via Sequential Memory-Hard Functions: [PDF](http://www.tarsnap.com/scrypt/scrypt-slides.pdf). + +An example class using this module can be found in; scrypt.php + +Join in! +-------- + +We are happy to receive bug reports, fixes, documentation enhancements, and other improvements. + +Please report bugs via the [github issue tracker](http://github.com/DomBlack/php-scrypt/issues). + +Master [git repository](https://github.com/DomBlack/php-scrypt): + + git clone git://github.com/DomBlack/php-scrypt.git + +Authors +------- + +This library is written and maintained by Dominic Black, . + +---- + +PECL Install +============ + +This extension is now avaible through PECL. + +``` +pecl install scrypt +``` + +Build From Source +================= + +Unix/OSX +-------- + +1. `phpize` +2. If on OSX; `export CFLAGS='-arch i386 -arch x86_64'` +3. `./configure --enable-scrypt` +4. `make` +5. `make install` +6. Add the extension to your php.ini + +```` + ; Enable scrypt extension module + extension=scrypt.so +```` + +Windows +------- + +Using Visual Studio 2008 (or Visual C++ Express 2008) open up the attached project +inside the VS2008 folder. This project assumes you have the PHP thread safe source at; +`C:\phpsrcts\`, a PHP install at `C:\php\` and this source code extracted to +`C:\php-scrypt\`. + +1. Build the project. +2. Copy the resultant `scrypt.dll` to your ext directory in PHP. +3. Add the extension to your php.ini + +```` + ; Enable scrypt extension module + extension=scrypt.dll +```` + +Legal Stuff +=========== +This works is licensed under the BSD 2-Clause license. + +Original Scrypt Implementation; + Copyright (c) 2009 Colin Percival + +PHP Module; + Copyright (c) 2012, Dominic Black + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.