Esempio n. 1
0
 public function __toString()
 {
     try {
         return (string) $this->render();
     } catch (\Exception $e) {
         return render_exception($e);
     }
 }
Esempio n. 2
0
 /**
  * Renders the cells of the columns.
  *
  * The method returns an array with the following layout:
  *
  *     [<column_id>][] => <cell_content>
  *
  * @return array
  */
 protected function render_cells()
 {
     $rendered_cells = [];
     foreach ($this->columns as $id => $column) {
         foreach ($this->records as $record) {
             try {
                 $content = (string) $column->render_cell($record);
             } catch (\Exception $e) {
                 $content = render_exception($e);
             }
             $rendered_cells[$id][] = $content;
         }
     }
     return $rendered_cells;
 }
Esempio n. 3
0
function render_error_report($report)
{
    ob_start();
    echo '<div>';
    if (isset($report->title)) {
        echo "<h1>" . (isset($report->title) ? htmlspecialchars($report->title) : '(no title)') . "</h1>";
    }
    //echo '<button onclick="jQuery(\'.extra-information\').show();">Show everything</button>';
    echo "<h1>General info</h1>";
    echo "<pre>";
    ob_start();
    if (isset($report->exception->message)) {
        echo "Message: " . $report->exception->message . "\r\n";
    } else {
        echo "No message\r\n";
    }
    if (isset($report->request->url)) {
        echo "URL" . (isset($report->request->method) ? ' (' . strtoupper($report->request->method) . ')' : '') . ': ' . $report->request->url . "\r\n";
    }
    if (isset($report->request->referer)) {
        echo "URL Referer: " . $report->request->referer . "\r\n";
    }
    if (isset($report->request->id) || isset($report->request->session)) {
        echo (isset($report->request->id) ? "Request" : '') . (isset($report->request->id) && isset($report->request->session) ? '/' : '') . (isset($report->request->session) ? 'Session' : '') . ' id: ' . (isset($report->request->id) ? $report->request->id : '') . (isset($report->request->id) && isset($report->request->session) ? '/' : '') . (isset($report->request->session) ? $report->request->session : '') . "\r\n";
    }
    echo "Time: " . date('Y-m-d H:i:s', $report->time) . " (" . date('r', $report->time) . ")" . "\r\n";
    if (isset($report->exception->types)) {
        echo "Exception types: " . implode(", ", $report->exception->types) . "\r\n";
    }
    if (isset($report->rawData->post) || isset($report->rawData->session)) {
        if (isset($report->rawData->post)) {
            echo "POST " . (count($report->rawData->post) == 0 ? 'is empty' : 'is not empty');
        }
        if (isset($report->rawData->post) && isset($report->rawData->session)) {
            echo ", ";
        }
        if (isset($report->rawData->session)) {
            echo "SESSION " . (count($report->rawData->session) == 0 ? 'is empty' : 'is not empty');
        }
        echo "\r\n";
    }
    echo htmlspecialchars(ob_get_clean());
    echo "</pre>";
    echo "<h1>Trace</h1>";
    echo render_exception($report->exception);
    /*
      echo "<ul>";
      $firstItem = true;
      foreach (array_merge(array($report->exception), $report->exception->trace) as $traceItem) {
        $isLibrary = isset($traceItem->isLibrary) && $traceItem->isLibrary;
        echo '<li class="' . (!$isLibrary ? '' : 'outside-base-path extra-information') . '">';
        $traceItemId = randomKey(24);
        echo '<a href="#' . $traceItemId . '" onclick="jQuery(\'.' . $traceItemId . '\').toggle(); return false;">'
          . (isset($traceItem->file) ? htmlspecialchars($traceItem->file . ':' . $traceItem->line) : '[internal function]')
          . '</a>';
        echo '<div class="' . $traceItemId . '" style="' . (!$isLibrary && $firstItem ? '' : 'display: none;') . '">';
    
        echo "<pre><h2>";
        ob_start();
        if (isset($traceItem->{'function'})) {
          echo (isset($traceItem->{'class'}) ? $traceItem->{'class'} . $traceItem->{'type'} : '')
            . $traceItem->{'function'} . '(';
          $arguments = array();
          foreach ($traceItem->arguments as $argument) {
            $arguments[] = dumpArgument($argument);
          }
          echo implode(', ', $arguments);
          echo ')';
        }
        echo htmlspecialchars(ob_get_clean());
        echo "</h2></pre>";
    
        if (isset($traceItem->snippet->content)) {
          echo '<pre class="snippet">';
          $content = htmlspecialchars($traceItem->snippet->content);
          $lines = explode("\n", $content);
          $lines[$traceItem->line - $traceItem->snippet->beginLine - 1] = "<strong>"
            . $lines[$traceItem->line - $traceItem->snippet->beginLine - 1] . "</strong>\r";
          echo implode("\n", $lines);
          echo "</pre>";
        }
        echo '</div>';
        echo "</li>";
    
        if (!$isLibrary && $firstItem)
          $problemTraceItem = $traceItem;
    
        if (!$isLibrary)
          $firstItem = false;
      }
      echo "</ul>";
      /**/
    if (isset($report->debug)) {
        echo "<h1>Debug</h1>";
        echo '<ul>';
        foreach ($report->debug as $debugEntry) {
            echo "<li>";
            if (is_string($debugEntry)) {
                echo $debugEntry;
            } else {
                echo "<div" . (isset($problemTraceItem, $problemTraceItem->file, $debugEntry->file) && $problemTraceItem->file == $debugEntry->file ? ' style="color: red;" ' : '') . ">";
                echo "[" . date("Y-m-d H:i:s", $debugEntry->time) . "." . substr(round($debugEntry->time - floor($debugEntry->time), 6), 2) . "]" . (isset($debugEntry->file) ? " ({$debugEntry->file}:{$debugEntry->line})" : '') . (isset($debugEntry->type) ? " {$debugEntry->type}" : '') . "<br />" . "  " . (isset($debugEntry->call) ? htmlentities($debugEntry->call) . ': ' : '') . htmlentities($debugEntry->message) . "\n";
                echo "</div>";
            }
            echo "</li>";
        }
        echo '</ul>';
    }
    if (isset($report->rawData->get)) {
        echo "<h1>GET</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->rawData->get);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    if (isset($report->rawData->post)) {
        echo "<h1>POST</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->rawData->post);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    if (isset($report->rawData->session)) {
        echo "<h1>SESSION</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->rawData->session);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    if (isset($report->rawData->cookie)) {
        echo "<h1>COOKIE</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->rawData->cookie);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    if (isset($report->additional->request)) {
        echo "<h1>Request</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->additional->request);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    if (isset($report->additional->parameters)) {
        echo "<h1>Parameters</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->additional->parameters);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    if (isset($report->rawData->files)) {
        echo "<h1>FILES</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->rawData->files);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    if (isset($report->rawData->server)) {
        echo "<h1>SERVER</h1>";
        echo "<pre>";
        ob_start();
        print_r($report->rawData->server);
        echo htmlspecialchars(ob_get_clean());
        echo "</pre>";
    }
    echo "<h1>Server info</h1>";
    echo "<pre>";
    ob_start();
    echo "Uname: " . $report->serverInformation->uname . "\r\n";
    if (function_exists('gethostname')) {
        echo "Hostname: " . $report->serverInformation->hostname . "\r\n";
    }
    echo "PHP version: " . $report->serverInformation->phpVersion . "\r\n";
    if (isset($report->code->basePath)) {
        echo "Base code path: " . $report->code->basePath . "\r\n";
    }
    echo htmlspecialchars(ob_get_clean());
    echo "</pre>";
    echo '</div>';
    return ob_get_clean();
}