コード例 #1
0
/**
 * Builds the context vars list for display
 * @var array $vars an array of vars to output
 * @var int $level the level in the context vars (prevent infinite recursion)
 * @return string the output to display
 */
function buildVarList($vars, $level = 0)
{
    $output = '';
    $indent = str_repeat('	', 6 + $level * 2);
    $prefix = $level == 0 ? '$' : '\'';
    $suffix = $level == 0 ? '' : '\'';
    foreach ($vars as $key => $value) {
        if ($level == 0) {
            $key = $prefix . $key;
        } elseif (!is_numeric($key)) {
            $key = $prefix . $key . $suffix;
        }
        if (is_array($value)) {
            $length = count($value);
            $output .= '<li class="close">' . "\n" . $indent;
            $output .= '	<b class="toggle"></b>' . "\n" . $indent;
            $output .= '	<span><b>' . $key . ':</b> array(' . $length . ')</span>' . "\n" . $indent;
            $output .= '	<ul>' . "\n" . $indent;
            if ($level > 5) {
                // Prevent infinite recursion
                $output .= '		<li><span><em>(too much levels)</em></span></li>' . "\n" . $indent;
            } elseif ($length > 0) {
                $output .= '		' . buildVarList($value, $level + 1) . "\n" . $indent;
            } else {
                $output .= '	<li><span><em>(empty)</em></span></li>' . "\n" . $indent;
            }
            $output .= '	</ul>' . "\n" . $indent;
            $output .= '</li>' . "\n" . $indent;
        } else {
            $output .= '<li><span><b>' . $key . ':</b> ' . describeVar($value) . '</span></li>' . "\n" . $indent;
        }
    }
    return rtrim($output);
}
コード例 #2
0
$stackDesc = array();
if (is_array($stack) and count($stack) > 0) {
    $stackDesc[] = '<ul class="picto-list icon-top with-line-spacing">';
    foreach ($stack as $level) {
        // Check infos
        $file = isset($level['file']) ? $level['file'] : '(unknown file)';
        $line = isset($level['line']) ? $level['line'] : 0;
        $function = isset($level['function']) ? $level['function'] : '(unknown function)';
        if (isset($level['class']) and strlen($level['class']) > 0) {
            $function = $level['class'] . '::' . $function;
        }
        // Arguments
        $args = array();
        if (isset($level['args'])) {
            foreach ($level['args'] as $arg) {
                $args[] = describeVar($arg);
            }
        }
        $stackDesc[] = '	<li><b>' . htmlspecialchars(trimDocumentRoot($file, 40)) . '</b> @ line <b>' . $line . '</b>: ' . $function . '(' . implode(', ', $args) . ')</li>';
    }
    $stackDesc[] = '</ul>';
}
// Compose data for error reporting
$report = array('time' => time(), 'type' => $exception ? 'exception' : 'error', 'url' => isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '', 'number' => $errno, 'message' => $errno, 'file' => $errno, 'line' => $errno, 'context' => '<ul>' . buildSimpleVarList($errcontext) . '</ul>', 'stack' => implode("\n", $stackDesc));
// Session identifier
if (session_id() == '') {
    session_start();
}
// Encoded data for reporting
$encodedReport = encode(json_encode($report), session_id());
?>