// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Criteria\Criteria;
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
use Org\Mxchange\CoreFramework\Crypto\Cryptable;
-use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Filesystem\Block;
-use Org\Mxchange\CoreFramework\Filesystem\FilePointer;
-use Org\Mxchange\CoreFramework\Filesystem\FrameworkDirectory;
use Org\Mxchange\CoreFramework\Filesystem\PathWriteProtectedException;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Handler\Handleable;
use Org\Mxchange\CoreFramework\Helper\Helper;
-use Org\Mxchange\CoreFramework\Index\Indexable;
-use Org\Mxchange\CoreFramework\Lists\Listable;
use Org\Mxchange\CoreFramework\Loader\ClassLoader;
use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
-use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
-use Org\Mxchange\CoreFramework\Parser\Parseable;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Result\Database\CachedDatabaseResult;
use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
-use Org\Mxchange\CoreFramework\Stacker\Stackable;
use Org\Mxchange\CoreFramework\State\Stateable;
use Org\Mxchange\CoreFramework\Stream\Input\InputStream;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer;
use Org\Mxchange\CoreFramework\Stream\Output\OutputStream;
-use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\User\ManageableAccount;
use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
-use Org\Mxchange\CoreFramework\Visitor\Visitor;
// Import SPL stuff
use \stdClass;
*/
private $realClass = __CLASS__;
- /**
- * Search criteria instance
- */
- private $searchInstance = NULL;
-
- /**
- * Update criteria instance
- */
- private $updateInstance = NULL;
-
- /**
- * Template engine instance
- */
- private $templateInstance = NULL;
-
/**
* Database result instance
*/
*/
private $userInstance = NULL;
- /**
- * Instance of a RNG
- */
- private $rngInstance = NULL;
-
/**
* Instance of a crypto helper
*/
*/
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 Parseable instance
- */
- private $parserInstance = NULL;
-
/**
* A helper instance for the form
*/
*/
private $handlerInstance = NULL;
- /**
- * Visitor handler instance
- */
- private $visitorInstance = 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 FrameworkDirectory instance
- */
- private $directoryInstance = NULL;
-
- /**
- * The concrete output instance
- */
- private $outputInstance = NULL;
-
/**
* State instance
*/
const EXCEPTION_INVALID_SOCKET = 0x03e;
const EXCEPTION_SELF_INSTANCE = 0x03f;
- /**
- * 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
*/
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 An instance of a LocalUpdateCriteria clase
- * @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 debug instance
*
return $this->userInstance;
}
- /**
- * 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
*
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 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 DatabaseWrapper instance
*
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 Iterator instance
*
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 FrameworkDirectory instance
- *
- * @param $directoryInstance A FrameworkDirectory 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 state instance
*
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 call-back instance
*
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 = GenericRegistry::getRegistry()->getInstance('application');
-
- // 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
*
// 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:
- * <http://de.php.net/manual/en/function.dechex.php#86673>
- *
- * @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:
- * <http://de.php.net/manual/en/function.hexdec.php#97756>
- *
- * @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__, __LINE__)->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