data = $data; } /** * @return string */ public function renderErrorPage() { $data = $this->data->getData(); $title = $this->data->getTitle(); $content = $this->renderPageHeader(); $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
'; $content .= '

' . htmlspecialchars($title, ENT_QUOTES) . '

'; $content .= '

' . htmlspecialchars($data['exception']['message'], ENT_QUOTES) . '

'; $content .= '
' . $this->renderInformationData($data['information']) . '' . $this->renderExceptionData($data['exception']) . '
'; $content .= $this->renderPageFooter(); return $content; } /** * @return string */ private function renderPageHeader() { return << Unerwarteter Fehler HTML; } /** * @return string */ private function renderPageFooter() { return ''; } /** * @param array $exception * * @return string */ private function renderExceptionData($exception) { $content = ''; $content .= '

' . $this->renderExceptionHeadline($exception['class']) . '

'; $content .= ''; $content .= ''; if (!empty($exception['trace'])) { $content .= ''; } $content .= '
'; $content .= '

' . htmlspecialchars($exception['message'], ENT_QUOTES) . '

'; $content .= "
"; $content .= "{$exception['file']}:{$exception['line']}"; $content .= '
'; $content .= '
'; $content .= $this->renderStackTrace($exception['trace']); $content .= '
'; // Render previous exceptions at the end if ($exception['previous'] !== null) { $content .= $this->renderExceptionData($exception['previous']); } return $content; } /** * @param string $className Full-qualified class name * * @return string */ private function renderExceptionHeadline($className) { $classNameParts = explode('\\', $className); $partsSize = count($classNameParts) - 1; $headline = ''; foreach ($classNameParts as $index => $part) { if ($index === $partsSize) { $headline .= "{$part}"; } else { $headline .= "{$part}"; $headline .= " \ "; } } return $headline; } /** * @param $stackTrace * * @return string */ private function renderStackTrace($stackTrace) { $traceSize = count($stackTrace); $content = ''; foreach ($stackTrace as $index => $trace) { // @todo Einkommentieren wenn ErrorHandler erprobt und stabil //if (isset($trace['class']) && $trace['class'] === ErrorHandler::class) { // continue; //} $number = $traceSize - $index; $editorLink = 'editor://open?file=' . urlencode($trace['file']) . '&line=' . urlencode($trace['line']); $content .= ''; $content .= ''; $content .= ''; } $content .= '
'; $content .= '
'; $content .= "{$number}"; $content .= "{$trace['class']}"; $content .= "{$trace['function']}()"; $content .= '
'; if (!empty($trace['file'])) { $content .= "'; } $content .= '
'; return $content; } /** * @param array $data * * @return string */ private function renderInformationData($data) { $content = "

Systeminformationen

\n"; $software = $data['software']; $content .= "

Software

\n"; $content .= '

Xentral-Revision: '; $content .= !empty($software['xentral_revision']) ? $software['xentral_revision'] : '--'; $content .= "

\n"; $content .= '

Xentral-Version: '; $content .= !empty($software['xentral_version']) ? $software['xentral_version'] : '--'; $content .= "\n"; $content .= '

FPDF-Version: '; $content .= !empty($software['fpdf_version']) ? $software['fpdf_version'] : '--'; $content .= "\n"; $general = $data['php']['general']; $content .= "

PHP

\n"; $version = "{$general['version_major']}.{$general['version_minor']}.{$general['version_release']}"; $content .= "

Version: {$version} ({$general['version']})

\n"; $content .= "

Server-API: {$general['server_api']}

\n"; $content .= "

Binary-Pfad: {$general['binary_dir']}

\n"; $content .= "

php.ini: {$general['php_ini_dir']}

\n"; $settings = $data['php']['settings']; $content .= "

PHP-Einstellungen:

\n"; foreach ($settings as $setting) { switch ($setting['setting']) { case 'max_execution_time': $cssClass = $setting['int_value'] <= 0 || $setting['int_value'] >= 30 ? '' : 'warning'; break; case 'max_input_time': $cssClass = $setting['int_value'] <= 0 || $setting['int_value'] >= 30 ? '' : 'warning'; break; case 'post_max_size': $cssClass = $setting['int_value'] >= 8 * 1024 * 1024 ? '' : 'warning'; break; case 'upload_max_filesize': $cssClass = $setting['int_value'] >= 8 * 1024 * 1024 ? '' : 'warning'; break; case 'memory_limit': $cssClass = $setting['int_value'] >= 256 * 1024 * 1024 ? '' : 'warning'; break; default: $cssClass = ''; break; } $content .= sprintf( '

%s = %s

' . "\n", $cssClass, $setting['setting'], $setting['raw_value'] ); } $content .= "

PHP-Erweiterungen

\n"; $defined = $data['php']['extensions']['defined']; $content .= '
Benötigt

'; foreach ($defined as $extension => $isAvailable) { $failedCssClass = in_array($extension, self::REQUIRED_PHP_EXTENSIONS, true) ? 'error' : 'warning'; $cssClass = $isAvailable === true ? '' : $failedCssClass; $content .= sprintf('%s', $cssClass, $extension) . ', '; } $content = substr_replace($content, '', -2); $content .= "

\n"; /*$other = $data['php']['extensions']['other']; $content .= "
Sonstige

"; foreach ($other as $extension => $available) { $content .= sprintf('%s', $extension) . ', '; } $content = substr_replace($content, '', -2); $content .= "

\n";*/ $env = $data['env']; $content .= "

Umgebung

\n"; $content .= "

Username: {$env['username']}

\n"; $content .= "

Home-Directory: {$env['home_dir']}

\n"; $content .= "

Document-Root: {$env['document_root']}

\n"; $content .= "

Script-Filename: {$env['script_filename']}

\n"; if ($env['script_owner'] !== null) { $content .= "

Script-Owner/-Group: {$env['script_owner']}:{$env['script_group']}

\n"; } $server = $data['server']; $content .= "

Webserver

\n"; $content .= '

Software: ' . (!empty($server['software']) ? $server['software'] : '--') . "

\n"; $content .= '

Signatur: ' . (!empty($server['signature']) ? $server['signature'] : '--') . "

\n"; $content .= "

Host: {$server['name']} ({$server['addr']}:{$server['port']})

\n"; $request = $data['request']; $content .= "

Request

\n"; $content .= "

Schema: {$request['scheme']}

\n"; $content .= "

Method/Uri: {$request['method']} " . htmlspecialchars($request['uri']) . "

\n"; $content .= '

Referer: ' . (!empty($request['referer']) ? htmlspecialchars($request['referer']) : '--') . "

\n"; $content .= '

UserAgent: ' . (!empty($request['user_agent']) ? $request['user_agent'] : '--') . "

\n"; $content .= '

AJAX-Request: ' . ($request['is_ajax'] === true ? 'true' : 'false') . "

\n"; $content .= '

HTTPS-Request: ' . ($request['is_https'] === true ? 'true' : 'false') . "

\n"; $content .= "

Timestamp: {$request['time']}

\n"; return $content; } }