- <?php
- /**
- * Print a document error (startup) and halts script execution
- *
- * @param string The message to show
- * @return void No value is returned
- */
- function doc_error($e)
- {
- static $called;
- global $arictos, $configuration;
- if(!is_null($called))
- {
- return;
- }
- $called = true;
- $buffer = ob_get_clean();
- $exception = ($e instanceof Exception);
- $message = ($exception ? $e->getMessage() : (string) $e);
- $errors = Arictos::globals('errors');
- $application = ($configuration['application']['name'] ? $configuration['application']['name'] . ($configuration['application']['version'] ? ' ' . $configuration['application']['version'] : '') : false);
- if($exception && $arictos->db && $e instanceof SQL_Exception)
- {
- $message = 'An error occured while querying the database';
- if(DEBUG)
- {
- $message .= ':' . PHP_EOL .
- '<code>Error Code: ' . $e->getCode() . PHP_EOL .
- $e->getMessage() . '</code>' . PHP_EOL .
- '<strong>Database driver:</strong> ' . constant(get_class($arictos->db) . '::DRIVER_NAME') . '';
- }
- }
- else if(empty($message))
- {
- $message = 'An unknown error occured!';
- }
- else if(function_exists('utf8_encode'))
- {
- $message = utf8_encode($message);
- }
- header('HTTP/1.1 500 Internal Server Error');
- header('Content-Type: text/html');
- echo(
- '<!DOCTYPE html> ' . PHP_EOL .
- '<html lang="es">' . PHP_EOL .
- ' <head>' . PHP_EOL .
- ' <title>A fatal error has occured.</title>' . PHP_EOL .
- ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . PHP_EOL .
- ' <style type="text/css">' . PHP_EOL .
- ' html {' . PHP_EOL .
- ' height: 100%;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' body {' . PHP_EOL .
- ' background: #cccccc;' . PHP_EOL .
- ' margin: 0;' . PHP_EOL .
- ' padding: 0;' . PHP_EOL .
- ' height: 100%;' . PHP_EOL .
- ' font: normal normal 13px/20px Lucida, \'Lucida Grande\', \'Trebuchet MS\', Tahoma, Verdana, sans-serif;' . PHP_EOL .
- ' color: #333333;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' h1 {' . PHP_EOL .
- ' margin: 0;' . PHP_EOL .
- ' padding: 20px 40px;' . PHP_EOL .
- ' font-size: 20px;' . PHP_EOL .
- ' font-weight: normal;' . PHP_EOL .
- ' letter-spacing: -1px;' . PHP_EOL .
- ' ' . PHP_EOL .
- ' /* css 3 styles */' . PHP_EOL .
- ' text-shadow: 0px 1px 0px #ffffff;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' #wrapper {' . PHP_EOL .
- ' background:-webkit-gradient(' . PHP_EOL .
- ' linear,' . PHP_EOL .
- ' left bottom,' . PHP_EOL .
- ' left top,' . PHP_EOL .
- ' color-stop(1, rgb(247,247,247)),' . PHP_EOL .
- ' color-stop(0, rgb(204,204,204))' . PHP_EOL .
- ' );' . PHP_EOL .
- ' background: -moz-linear-gradient(' . PHP_EOL .
- ' center bottom,' . PHP_EOL .
- ' rgb(204,204,204) 0%,' . PHP_EOL .
- ' rgb(247,247,247) 100%' . PHP_EOL .
- ' );' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content {' . PHP_EOL .
- ' background-color: #f4f4f4;' . PHP_EOL .
- ' border: 1px solid #ffffff;' . PHP_EOL .
- ' margin: 0 30px;' . PHP_EOL .
- ' ' . PHP_EOL .
- ' /* css 3 styles */' . PHP_EOL .
- ' border-radius: 5px;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block {' . PHP_EOL .
- ' background-color: #ffffff;' . PHP_EOL .
- ' border: 1px solid #dddddd;' . PHP_EOL .
- ' border-top: 1px solid #cccccc;' . PHP_EOL .
- ' border-bottom: 1px solid #eeeeee;' . PHP_EOL .
- ' margin: 9px;' . PHP_EOL .
- ' ' . PHP_EOL .
- ' /* css 3 styles */' . PHP_EOL .
- ' border-radius: 3px;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block h2 {' . PHP_EOL .
- ' background-color: #f4f4f4;' . PHP_EOL .
- ' padding: 4px 8px 5px;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block p {' . PHP_EOL .
- ' margin: 0;' . PHP_EOL .
- ' padding: 19px;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block table {' . PHP_EOL .
- ' margin: 0;' . PHP_EOL .
- ' padding: 10px 10px 20px;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block table thead tr td {' . PHP_EOL .
- ' background-color: #f0f0f0;' . PHP_EOL .
- ' border-top: 1px dashed #cccccc;' . PHP_EOL .
- ' border-bottom: 1px dashed #cccccc;' . PHP_EOL .
- ' margin: 0;' . PHP_EOL .
- ' padding: 5px 7px;' . PHP_EOL .
- ' font-weight: bold;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block table tbody tr td {' . PHP_EOL .
- ' margin: 0;' . PHP_EOL .
- ' padding: 3px 7px;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block table tbody tr:nth-child(odd) td {' . PHP_EOL .
- ' padding: 14px 7px 5px;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' .content .block table tbody tr:nth-child(even) td {' . PHP_EOL .
- ' background-color: #f1f1f1;' . PHP_EOL .
- ' border: 1px dashed #cccccc;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' #footer {' . PHP_EOL .
- ' margin: 6px 40px;' . PHP_EOL .
- ' font-size: 11px;' . PHP_EOL .
- ' color: #909090;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' #footer p {' . PHP_EOL .
- ' margin: 0;' . PHP_EOL .
- ' padding: 0;' . PHP_EOL .
- ' }' . PHP_EOL .
- ' </style>' . PHP_EOL .
- ' </head>' . PHP_EOL .
- ' <body>' . PHP_EOL .
- ' <div id="wrapper">' . PHP_EOL .
- ' <h1>A fatal error has occured.</h1>' . PHP_EOL .
- ' <div class="content">' . PHP_EOL .
- ' <div class="block">' . PHP_EOL .
- ' <p>' . nl2br($message) . '</p>' . PHP_EOL .
- ' </div>' . PHP_EOL .
- ' </div>' . PHP_EOL
- );
- if(DEBUG)
- {
- global $arictos;
- $bt = ($exception ? arictos_debug_backtrace($e) : arictos_debug_backtrace());
- if(sizeof($bt))
- {
- echo(
- ' <h1>Debug backtrace</h1>' . PHP_EOL .
- ' <div class="content">' . PHP_EOL .
- ' <div class="block">' . PHP_EOL .
- ' <table width="100%" cellspacing="0" cellpadding="0">' . PHP_EOL .
- ' <thead>' . PHP_EOL .
- ' <tr>' . PHP_EOL .
- ' <td width="15px"> </td>' . PHP_EOL .
- ' <td>Call</td>' . PHP_EOL .
- ' <td>File</td>' . PHP_EOL .
- ' <td>Line</td>' . PHP_EOL .
- ' <td>Notes</td>' . PHP_EOL .
- ' </tr>' . PHP_EOL .
- ' </thead>' . PHP_EOL .
- ' <tbody>' . PHP_EOL
- );
- foreach($bt as $n=> $trace)
- {
- echo(
- ' <tr>' . PHP_EOL .
- ' <td rowspan="2">' . ++$n . '</td>' . PHP_EOL .
- ' <td>' . $trace->call . '</td>' . PHP_EOL .
- ' <td>' . $trace->file . '</td>' . PHP_EOL .
- ' <td>' . $trace->line . '</td>' . PHP_EOL .
- ' <td>' . $trace->notes . '</td>' . PHP_EOL .
- ' </tr>' . PHP_EOL
- );
- if(!empty($trace->callargs))
- {
- echo(
- ' <tr>' . PHP_EOL .
- ' <td colspan="4">' . $trace->callargs . '</td>' . PHP_EOL .
- ' </tr> ' . PHP_EOL
- );
- }
- }
- echo(
- ' </tbody>' . PHP_EOL .
- ' </table>' . PHP_EOL .
- ' </div>' . PHP_EOL .
- ' </div>' . PHP_EOL
- );
- }
- }
- echo(
- ' <div id="footer">' . PHP_EOL .
- ' <p>Generated by ' . ($application ? $application . ' (' : '') . 'Arictos ' . Arictos::VERSION_STRING . ($application ? ')' : '') . ' on ' . TIMENOW_UTC . ' (UTC)</p>' . PHP_EOL .
- ' </div> ' . PHP_EOL .
- ' </div>' . PHP_EOL .
- ' </body>' . PHP_EOL .
- '</html>' . PHP_EOL
- );
- exit;
- }
- ?>