/** * Renders a Koch Framework Error. * * @param int $errno * @param string $errstr * @param string $errfile * @param string $errline * @param int $errline * @param string $errcontext * @param string $errorname */ public static function renderError($errno, $errorname, $errstr, $errfile, $errline, $errcontext) { // shorten errorfile string by removing the root path $errfile_short = str_replace(APPLICATION_PATH, '', $errfile); $short_errorstring = \Koch\Functions\Functions::shortenString($errfile, 70, '...'); // Header $html = '<html><head>'; $html .= '<title>Koch Framework Error</title>'; $html .= '<link rel="stylesheet" href="' . WWW_ROOT_THEMES_CORE . 'css/error.css" type="text/css" />'; $html .= '</head>'; // Body $html .= '<body>'; // Fieldset with Legend $html .= '<fieldset id="top" class="error_red">'; $html .= '<legend>Koch Framework Error</legend>'; // Add Errorlogo $html .= '<div style="float: left; margin: 5px; margin-right: 25px; padding: 20px;">'; $html .= '<img src="' . WWW_ROOT_THEMES_CORE . 'images/Clansuite-Toolbar-Icon-64-error.png"'; $html .= ' style="border: 2px groove #000000;"/></div>'; // Open Error Table $html .= '<table width="80%"><tr><td>'; // Panel 1 - Errormessage $html .= '<div id="panel1" class="panel">'; $html .= '<h3>Error - ' . $errorname . ' (' . $errno . ')</h3> '; $html .= '<p style="font-weight: bold;">' . $errstr . '</p>'; $html .= '<p>in file "<span style="font-weight: bold;">' . $errfile_short . '</span>"'; $html .= ' on line #<span style="font-weight: bold;">' . $errline . '.</span></p>'; $html .= '</div>'; // Panel 2 - Error Context $html .= '<div id="panel2" class="panel">'; $html .= '<h3>Context</h3>'; $html .= '<p><span class="small">You are viewing the source code of the file "'; $html .= $errfile . '" around line ' . $errline . '.</span></p>'; $html .= Errorhandler::getErrorContext($errfile, $errline, 8) . '</div>'; // Panel 3 - Debug Backtracing $html .= Errorhandler::getDebugBacktrace($short_errorstring); // Panel 4 - Environmental Informations at Errortime $html .= '<div id="panel4" class="panel">'; $html .= '<h3>Server Environment</h3>'; $html .= '<p><table width="95%">'; $html .= '<tr><td colspan="2"></td></tr>'; $html .= '<tr><td><strong>Date: </strong></td><td>' . date('r') . '</td></tr>'; $html .= '<tr><td><strong>Remote: </strong></td><td>' . $_SERVER['REMOTE_ADDR'] . '</td></tr>'; $html .= '<tr><td><strong>Request: </strong></td><td>' . htmlentities($_SERVER['QUERY_STRING'], ENT_QUOTES); $html .= '</td></tr>'; $html .= '<tr><td><strong>PHP: </strong></td><td>' . PHP_VERSION . ' ' . PHP_EXTRA_VERSION . '</td></tr>'; $html .= '<tr><td><strong>Server: </strong></td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>'; $html .= '<tr><td><strong>Agent: </strong></td><td>' . $_SERVER['HTTP_USER_AGENT'] . '</td></tr>'; $html .= '<tr><td><strong>Clansuite: </strong></td><td>'; $html .= APPLICATION_VERSION . ' ' . APPLICATION_VERSION_STATE . ' (' . APPLICATION_VERSION_NAME . ')'; $html .= '</td></tr>'; $html .= '</table></p></div>'; // Panel 5 - Backlink to Bugtracker with Errormessage -> http://trac.clansuite.com/newticket $html .= Errorhandler::getBugtrackerBacklinks($errorname, $errfile, $errline, $errcontext); // Close Error Table $html .= '</table>'; // Add Footer with Support-Backlinks $html .= Errorhandler::getSupportBacklinks(); // Close all html elements $html .= '</fieldset><br /><br />'; $html .= '</body></html>'; return $html; }
/** * formatBacktraceArgument. * * Performs a type check on the backtrace argument and beautifies it. * * This formater is based on comments for debug-backtrace in the php manual * * @link http://de2.php.net/manual/en/function.debug-backtrace.php#30296 * @link http://de2.php.net/manual/en/function.debug-backtrace.php#47644 * * @param backtraceArgument mixed The argument for type identification and string formatting. * * @return array With keys 'arg' and 'type'. */ public static function formatBacktraceArgument($argument) { // do not throw a notice on PHP 5.3 - the constant was added with PHP 5.4 htmlspecialchars() defined('ENT_SUBSTITUTE') || define('ENT_SUBSTITUTE', 8); $result = []; $arg = ''; $type = ''; switch (gettype($argument)) { case 'boolean': $type .= '<span>bool</span>'; $arg .= $argument ? 'true' : 'false'; break; case 'integer': $type .= '<span>int</span>'; $arg .= $argument; break; case 'float': case 'double': $type .= '<span>float/double</span>'; $arg .= $argument; break; case 'string': $type .= '<span>string</span>'; $argument = htmlspecialchars($argument, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); $arg .= \Koch\Functions\Functions::shortenString($argument); break; case 'array': $type .= '<span>array</span>'; $arg .= count($argument); break; case 'object': $type .= '<span>object</span>'; $arg .= get_class($argument); /* @todo use self::getClassProperties($backtraceArgument) */ break; case 'resource': $type .= '<span>resource</span>'; if ($type === 'stream') { $type .= '(stream)'; $meta = stream_get_meta_data($argument); if (isset($meta['uri'])) { $type .= htmlspecialchars($meta['uri'], ENT_NOQUOTES, 'UTF-8'); } } $arg .= mb_strstr($argument, '#') . ' - ' . get_resource_type($argument); break; case 'NULL': $type .= '<span>null</span>'; $arg .= ''; break; default: $type .= 'Unknown'; $arg .= 'Unknown'; } return compact('arg', 'type'); }