public static function getInstance($theCLSName) { if (checkIfItsACSSFile() or checkIfItsAJSSFile()) { switch ($theCLSName) { case 'ERR': if (isset(self::$objInstanceArray[$theCLSName])) { # Return the saved instance; return self::$objInstanceArray[$theCLSName]; } else { # Return the first instance; return self::$objInstanceArray[$theCLSName] = new $theCLSName(); } break; case 'TPL': if (isset(self::$objInstanceArray[$theCLSName])) { # Return the saved instance; return self::$objInstanceArray[$theCLSName]; } else { # Return the first instance; return self::$objInstanceArray[$theCLSName] = new $theCLSName(); } break; default: return NULL; break; } } else { if (isset(self::$objInstanceArray[$theCLSName])) { # Return the saved instance; return self::$objInstanceArray[$theCLSName]; } else { # Return the first instance; return self::$objInstanceArray[$theCLSName] = new $theCLSName(); } } }
/** * Will set all necessary headers to ensure that NO cache will be done by the browser. We set this method in the framework to skip * some refresh bugs caused by not sending these headers. These will ensure that the content the user gets are the latest. If we * actually want to do some caching, then that caching should be done server-side and relied more on the server than on the user; * * @return void Will not return a thing; * @author Catalin Z. Alexandru <*****@*****.**> * @copyright Under the terms of the GNU General Public License v3 * @version $Id: 08_ERR.php 313 2009-10-09 13:27:52Z catalin.zamfir $ * @since Version 1.0 * @access private * @static */ private static function setCacheHeaderKeys() { if (!(checkIfItsACSSFile() or checkIfItsAJSSFile())) { self::setHeaderKey(new S('no-store, no-cache, must-revalidate'), new S('Cache-Control')); self::setHeaderKey(new S('pre-check=0, post-check=0, max-age=0'), new S('Cache-Control')); self::setHeaderKey(new S('no-cache'), new S('Pragma')); } }
// Include ALL files in INCLUDE_DIR, so we can have some features working; $includeFiles = scandir(DOCUMENT_ROOT . INCLUDE_DIR . _S); sort($includeFiles, SORT_STRING); $includeFilesCount = count($includeFiles); for ($i = 0; $i < $includeFilesCount - 1; ++$i) { if ($includeFiles[$i][0] != '.') { $f = DOCUMENT_ROOT . INCLUDE_DIR . _S . $includeFiles[$i]; require_once $f; // Get the error handler up as soon as possible; if (class_exists('ERR')) { // Make the ERR object, NOW! $ERR = TheFactoryMethodOfSingleton::getInstance('ERR'); } // If it's a CSS/JSS file, get out!; if (class_exists('TPL')) { if (checkIfItsACSSFile()) { break; } if (checkIfItsAJSSFile()) { break; } } } } ### DEVELOPER: // Include all developer files in DEVELOPER_DIR/DEVELOPER_HEADER; $includeFiles = scandir(DOCUMENT_ROOT . DEVELOPER_DIR . _S . DEVELOPER_HEADER); sort($includeFiles, SORT_STRING); foreach ($includeFiles as $k => $v) { if ($v[0] != '.') { $f = DOCUMENT_ROOT . DEVELOPER_DIR . _S . DEVELOPER_HEADER . _S . $v;
/** * Will output the stored output buffer normaly, gzipped or deflated, according to the client 'Accept-Encoding' header at first, * while taking care to remember the general framework settings; * * @param S $whatActionToTake An internal action passed to this method, to be taken for Gzipped output * @return void Being an internal method, it doesn't need to explicitly return something * @author Catalin Z. Alexandru <*****@*****.**> * @copyright Under the terms of the GNU General Public License v3 * @version $Id: 10_TPL.php 315 2009-10-11 07:11:31Z catalin.zamfir $ * @since Version 1.0 * @access private * @static * @final */ private static final function setGzippedOutputRequest(S $whatActionToTake) { // Get the browser - APACHE, request headers ... if (self::getApacheRequestHeaders()->toBoolean() == TRUE) { // Explode the 'Accept-Encoding' HDR, determine what kind of encodings we have; $typeOfEncoding = explode(',', self::$objApacheReqHeaders['Accept-Encoding']); // Chose first one, which should be 'gzip', over deflate ... $typeOfEncoding = str_replace(_SP, _NONE, $typeOfEncoding[OB_GZIP_TYPE]); // Switch the action to TAKE switch ($whatActionToTake) { case 'set_header_information': // Fix Linux/Windows bug, when adding the Content-enconding: gzip HDR, works both in Linux/Win; if (OB_GZIP == TRUE && OB_GZIP_LEVEL > 0 && OB_GZIP_LEVEL <= 9 && self::getErrorStatus()->toInt() != 1 && self::getContainerHTMLStatus()->toInt() == 1 && !(checkIfItsACSSFile() || checkIfItsAJSSFile())) { // Determine GZIP or DEFLATE; // Use the first one, which should be 'gzip', in theory ... self::setHeaderKey(new S($typeOfEncoding), new S('Content-encoding')); } break; case 'output_stored_content': // Do just ONE echo ... if (checkIfItsACSSFile() or checkIfItsAJSSFile()) { // Get the content out as quickly as possible; echo str_replace(self::$objTokensReplace->toArray(), self::$objStringReplace->toArray(), implode(_NONE, self::$objOutputBuffer->toArray())); // ELSE: } else { if (OB_GZIP == TRUE && OB_GZIP_LEVEL > 0 && OB_GZIP_LEVEL <= 9 && self::getErrorStatus()->toInt() != 1 && self::getContainerHTMLStatus()->toInt() == 1) { // Echo as GZIP or DELAFTE; switch ($typeOfEncoding) { case 'deflate': // Echo as DEFLATE; echo gzcompress(str_replace(self::$objTokensReplace->toArray(), self::$objStringReplace->toArray(), implode(_NONE, self::$objOutputBuffer->toArray())), OB_GZIP_LEVEL); break; default: // Echo as GZIPPED; echo gzencode(str_replace(self::$objTokensReplace->toArray(), self::$objStringReplace->toArray(), implode(_NONE, self::$objOutputBuffer->toArray())), OB_GZIP_LEVEL, FORCE_GZIP); break; } } else { // Echo, un-encoded string ... RAW output ... echo str_replace(self::$objTokensReplace->toArray(), self::$objStringReplace->toArray(), implode(_NONE, self::$objOutputBuffer->toArray())); } } break; } } }