Exemplo n.º 1
0
 public static function render($e)
 {
     if (is_null($e->getTemplatePath())) {
         header('HTTP/1.0 500 Server Error');
         echo '<h1>Symphony Fatal Error</h1><p>' . $e->getMessage() . '</p>';
         exit;
     }
     $xml = new DOMDocument('1.0', 'utf-8');
     $xml->formatOutput = true;
     $root = $xml->createElement('data');
     $xml->appendChild($root);
     $root->appendChild($xml->createElement('heading', General::sanitize($e->getHeading())));
     $root->appendChild($xml->createElement('message', General::sanitize($e->getMessageObject() instanceof SymphonyDOMElement ? (string) $e->getMessageObject() : trim($e->getMessage()))));
     if (!is_null($e->getDescription())) {
         $root->appendChild($xml->createElement('description', General::sanitize($e->getDescription())));
     }
     header('HTTP/1.0 500 Server Error');
     header('Content-Type: text/html; charset=UTF-8');
     header('Symphony-Error-Type: ' . $e->getErrorType());
     foreach ($e->getHeaders() as $header) {
         header($header);
     }
     $output = parent::__transform($xml, basename($e->getTemplatePath()));
     header(sprintf('Content-Length: %d', strlen($output)));
     echo $output;
     exit;
 }
Exemplo n.º 2
0
 public static function render($e)
 {
     require_once 'class.xslproc.php';
     $xml = new DOMDocument('1.0', 'utf-8');
     $xml->formatOutput = true;
     $root = $xml->createElement('data');
     $xml->appendChild($root);
     $details = $xml->createElement('details');
     $details->appendChild($xml->createElement('message', General::sanitize($e->getDatabaseErrorMessage())));
     if (!is_null($e->getQuery())) {
         $details->appendChild($xml->createElement('query', General::sanitize($e->getQuery())));
     }
     $root->appendChild($details);
     $trace = $xml->createElement('backtrace');
     foreach ($e->getTrace() as $t) {
         $item = $xml->createElement('item');
         if (isset($t['file'])) {
             $item->setAttribute('file', General::sanitize($t['file']));
         }
         if (isset($t['line'])) {
             $item->setAttribute('line', $t['line']);
         }
         if (isset($t['class'])) {
             $item->setAttribute('class', General::sanitize($t['class']));
         }
         if (isset($t['type'])) {
             $item->setAttribute('type', $t['type']);
         }
         $item->setAttribute('function', General::sanitize($t['function']));
         $trace->appendChild($item);
     }
     $root->appendChild($trace);
     if (is_object(Symphony::Database()) && method_exists(Symphony::Database(), 'log')) {
         $query_log = Symphony::Database()->log();
         if (count($query_log) > 0) {
             $queries = $xml->createElement('query-log');
             $query_log = array_reverse($query_log);
             foreach ($query_log as $q) {
                 $item = $xml->createElement('item', General::sanitize(trim($q->query)));
                 if (isset($q->time)) {
                     $item->setAttribute('time', number_format($q->time, 5));
                 }
                 $queries->appendChild($item);
             }
             $root->appendChild($queries);
         }
     }
     return parent::__transform($xml, 'exception.database.xsl');
 }
Exemplo n.º 3
0
 public static function render($e)
 {
     $xml = new DOMDocument('1.0', 'utf-8');
     $xml->formatOutput = true;
     $root = $xml->createElement('data');
     $xml->appendChild($root);
     $details = $xml->createElement('details', $e->getMessage());
     $details->setAttribute('type', $e->getType() == XSLProc::ERROR_XML ? 'XML' : $e->getFile());
     $details->setAttribute('file', General::sanitize($e->getFile()));
     $details->setAttribute('line', $e->getLine());
     $root->appendChild($details);
     $nearby_lines = self::__nearByLines($e->getLine(), $e->getFile(), $e->getType() == XSLProc::ERROR_XML, 6);
     $lines = $xml->createElement('nearby-lines');
     $markdown .= "\t" . $e->getMessage() . "\n";
     $markdown .= "\t" . $e->getFile() . " line " . $e->getLine() . "\n\n";
     foreach ($nearby_lines as $line_number => $string) {
         $markdown .= "\t{$string}";
         $string = trim(str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', General::sanitize($string)));
         $item = $xml->createElement('item');
         $item->setAttribute('number', $line_number + 1);
         $cdata = $xml->createCDATASection(strlen($string) == 0 ? '&nbsp;' : $string);
         $item->appendChild($cdata);
         $lines->appendChild($item);
     }
     $root->appendChild($lines);
     $element = $xml->createElement('markdown');
     //, General::sanitize($markdown)));
     $element->appendChild($xml->createCDATASection($markdown));
     $root->appendChild($element);
     $processing_errors = $xml->createElement('processing-errors');
     if (XSLProc::getErrors() instanceof MessageStack) {
         foreach (XSLProc::getErrors() as $error) {
             $error->file = str_replace(WORKSPACE . '/', NULL, $error->file);
             $item = $xml->createElement('item', trim(General::sanitize($error->message)));
             if (strlen(trim($error->file)) == 0) {
                 $item->setAttribute('file', General::sanitize($error->file));
             }
             if (strlen(trim($error->line)) == 0) {
                 $item->setAttribute('line', $error->line);
             }
             $processing_errors->appendChild($item);
         }
     }
     $root->appendChild($processing_errors);
     return parent::__transform($xml, 'exception.xslt.xsl');
 }