/** * Will render the 'Screen Of Death', by using tested and well working PHP functions. This method relies on the fact that, at least * the framework abstract classes are working. Non-core developers should not modify anything here as they can get their hands * dirty really quick and destroy something without even knowing it; * * @param S $errFrom Error from where did it came * @param S $errString What's the string of the error * @param S $errTip Do you have an information to show * @param S $debugErrorString Should we show the debugger * @param B $errFATAL Is this error FATAL * @return S Will return the error screen string, or just void, depends on what kind of error we caught * @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 protected * @static * @final */ protected static function renderScreenOfDeath(S $errFrom, S $errString = NULL, S $errTip = NULL, S $debugErrorString = NULL, B $errFATAL = NULL) { // Set the execution time, discard the output stream, and set the error status to TRUE; self::setExeTime(new S(__FUNCTION__)); // Add header, if it's a CSS file, on an error!; switch (checkIfItsACSSFile() or checkIfItsAJSSFile()) { case TRUE: // Set the text/HTML, header!; self::setHeaderKey(new S('text/html'), new S('Content-type:')); break; } // Se the errorStatus to TRUE; self::setErrorStatus(); $catchedKrumoContent = _NONE; // Change behaviour, if this is a FATAL error; if ($errFATAL != NULL && $errFATAL->toBoolean() == TRUE) { $errString = new S(FATAL_ERROR); $errTip = new S(FATAL_ERROR_CHECK_LOG); // Clean the output buffer; self::$objOutputBuffer = _NONE; } else { // Clean the output buffer; self::discardOutputStream(new B(TRUE)); // Execute the KRUMO PLUGIN Framework; $catchedKrumoContent = self::getKrumoContent(); } // Get the file contents; $debugContent = new FileContent(FORM_TP_DIR . _S . 'frm_error_screen.tp'); // Do an if, for the [%CODE%] part of our template; if (GESHI >= 1 && DEBUG >= 1) { // Replace [%CODE%], with GeSHi parsed code from our PHP files; // Really helpfull when trying to find hidden bugs; $debugContent->doToken('[%CODE%]', self::getDebugBacktrace(array_reverse(debug_backtrace()))); $debugContent->doToken('[%KRUMO%]', $catchedKrumoContent); } else { // Replace [%CODE%], with _NONE, hiding the output; // Well, can't help the developer here!; $debugContent->doToken('[%CODE%]', _NONE); $debugContent->doToken('[%KRUMO%]', _NONE); // Set as 'Hacking attempt'; $errString = VIEW_FILE_DIRECTLY_DENIED; $errTip = VIEW_FILE_DIRECTLY_DENIED_FIX; $debugErrorString = HACKING_ATTEMPT_BANG_YOU_DEAD; } // Start replacing information in the 'frm_error_screen.tp'; $debugContent->doToken('[%HSIMG%]', DOCUMENT_HOST . IMAGE_DIR . _WS); $debugContent->doToken('[%HSJSS%]', DOCUMENT_HOST . JAVASCRIPT_DIR . _WS); $debugContent->doToken('[%ERBGR%]', ERBGR); $debugContent->doToken('[%ERPIX%]', ERPIX); $debugContent->doToken('[%ERPXL%]', ERPXL); $debugContent->doToken('[%MEMORY%]', memory_get_usage() / 1024); $debugContent->doToken('[%PID%]', getmypid()); $debugContent->doToken('[%MICROTIME%]', self::getExeTime(new S(__CLASS__), new S(__FUNCTION__))); $debugContent->doToken('[%ERROR_FROM%]', $errFrom); $debugContent->doToken('[%ERROR_DATE%]', date(DATE_STRING, $_SERVER['REQUEST_TIME'])); $debugContent->doToken('[%ERROR_EMSG%]', $errString); $debugContent->doToken('[%ERROR_ETIP%]', $errTip); $debugContent->doToken('[%ERROR_FROM_PHP%]', $debugErrorString); // Try to MAIL ... If we got this far, we have MAIL ... if (self::checkClassExistence(new S('MAIL'))->toBoolean() == TRUE) { // Set some requirements ... if ($errString == NULL) { $errString = new S(); } if ($errTip == NULL) { $errTip = new S(); } // Make'em as new as possible ... $objEML = new MAIL(); $objEML->setFrom(new S(MAIL_FROM)); $objEML->setStringAttachment(new S($debugContent)); $objEML->doMAIL(new S(MAIL_FROM), $errString, new S($errTip . _DCSP . URL::rewriteURL() . _DCSP . $_SERVER['HTTP_USER_AGENT'] . _DCSP . $_SERVER['REMOTE_ADDR'])); } // Exit, with an error screen. We could also die, it would mean the same; if ($errFATAL != NULL && $errFATAL->toBoolean() == TRUE) { // Return the content; if (OB_GZIP == TRUE && OB_GZIP_LEVEL > 0 && OB_GZIP_LEVEL <= 9) { return gzencode($debugContent, OB_GZIP_LEVEL); } else { return $debugContent; } } else { // Or die script now; if (OB_GZIP == TRUE && OB_GZIP_LEVEL > 0 && OB_GZIP_LEVEL <= 9) { exit(gzencode($debugContent, OB_GZIP_LEVEL)); } else { exit($debugContent); } } }