protected static function _get_exception_html(Exception $ex) { $message = $ex->getMessage(); $id_type = 0; $type_name = array_key_exists($id_type, self::$_error_types_names) ? self::$_error_types_names[$id_type] : null; $trace = self::_get_trace_array($ex->getTraceAsString()); $file_lines = file($ex->getFile()); $error_line = $ex->getLine(); foreach ($file_lines as $index => $line) { $file_lines[$index] = rtrim($line); } $file_lines_count = count($file_lines); if ($file_lines_count > self::FILE_OUT_PADDING * 2 + 1) { $start_line = $ex->getLine() - self::FILE_OUT_PADDING; $end_line = $ex->getLine() + self::FILE_OUT_PADDING; if ($start_line < 0) { $start_line = 0; } else { if ($end_line >= $file_lines_count) { $start_line = $file_lines_count - $end_line; } } if ($start_line < 1) { $start_line = 1; } $new_file_lines = array(); for ($i = 0; $i <= self::FILE_OUT_PADDING * 2 + 1; $i++) { $new_file_lines[$i + $start_line] = $file_lines[$start_line + $i - 1]; } $file_lines = $new_file_lines; } $trace_odd_item_background = '#DDD'; $trace_even_item_background = '#EEE'; $trace_item_style = "list-style-type: none; font-size: 10pt; padding: 7px 10px;"; $trace_item_file_style = "font-weight: bold; "; $trace_item_function_style = ""; $line_number_style = "display: inline-block; width: 50px; color: #888;"; $selected_line_number_style = "color: #EEE;"; $line_style = "font-family: mono;font-size: 10pt; font-weight: bold;"; $stack_trace_file_style = "font-weight: bold;"; $stack_trace_line_style = ""; $stack_trace_line_number_style = "font-weight: bold; color: #555; padding-right: 10px; padding-left: 5px;"; $stack_trace_line_index_style = "display: inline-block; width: 30px; color: #555; "; $current_line_style = "background: #FF7070 !important; font-weight: bold; color: #FFF !important;"; $header_row_style = "padding: 3px 0;"; $link_style = "color: #FFF; text-decoration: underline; "; $box_style = "box-shadow: 2px 2px 1px 1px rgba(0,0,0,0.5); border: solid 1px #111; border-radius: 5px; margin-bottom: 40px !important; "; $red_box_style = "box-shadow: 2px 2px 1px 1px rgba(0,0,0,0.5); border: solid 1px #EEE; border-radius: 5px; margin-bottom: 40px !important; "; $list_style = "border-radius: 5px;"; $first_list_item_style = "border-radius: 5px 5px 0 0;"; $last_list_item_style = "border-radius: 0 0 5px 5px;"; $list_item_style = "border-radius: 0;"; $html = '<div style="padding: 20px; background: #F2F2F2;"> <div style="background: #F00; padding: 10px 15px; border: solid 1px #A88; font-size: 12pt; ' . $red_box_style . '"> <div style="text-transform: uppercase; font-weight: bold; padding-right: 5px; color: #FFF; text-decoration: underline; padding-bottom: 8px;"> Error </div> <div style="' . $header_row_style . '"> <span style="color: #FFF; font-weight: bold; padding-right: 5px;"> Site: </span> <span style="color: #FFF"> ' . env('APP_NAME', '') . ' <span style="padding-left: 10px;">[ <a target="_blank" style="' . $link_style . '" href="' . \ZPHP\ZPHP::get_app_url() . '">' . \ZPHP\ZPHP::get_app_url() . '</a> ]</span> </span> </div> <div style="' . $header_row_style . '"> <span style="color: #FFF; font-weight: bold; padding-right: 5px;"> Request URL: </span> <span style="color: #FFF"> ' . $_SERVER['REQUEST_URI'] . ' </span> </div> <div style="' . $header_row_style . '"> <span style="color: #FFF; font-weight: bold; "> Message: </span> <span style="color: #FFF"> ' . $message . ' </span> </div></div>'; if ($type_name) { $html .= '<div style="' . $header_row_style . '"> <span style="color: #FFF; font-weight: bold; "> Error Type: </span> <span style="color: #FFF"> ' . $type_name . ' </span> </div>'; } if (!empty($trace)) { $html .= '<div style="margin: 20px 0 0;' . $box_style . ';max-height:300px;overflow-y:auto;"> <ul style="list-style-type: none; width: 100%; list-style-position: inside;margin:0;padding:0;' . $list_style . '"> <li style="margin-left: 0; padding: 10px 10px; background: ' . $trace_odd_item_background . ';background: #F00;"> <span style="color: #DDD; ' . $trace_item_file_style . '"> Stack Trace </span> </li> '; foreach ($trace as $index => $line) { $html .= '<li style="margin-left: 0;background: ' . ($index % 2 == 0 ? $trace_even_item_background : $trace_odd_item_background) . ' !important;' . $trace_item_style . ($index == count($trace) - 1 ? $last_list_item_style : $list_item_style) . '"> <span style="' . $stack_trace_line_index_style . '"> #' . ($index + 1) . ' </span> <span style="' . $stack_trace_file_style . '">' . $line['file'] . ' </span><span style="' . $stack_trace_line_number_style . '">[' . $line['line'] . '] </span> <span style="' . $stack_trace_line_style . '"> ' . $line['code'] . ' </span> </li>'; } $html .= '</ul></div>'; } $html .= ' <div style="margin: 20px 0 0;' . $box_style . '"> <ul style="list-style-type: none; width: 100%; list-style-position: inside;margin:0;padding:0;border: solid 1px #555;' . $list_style . '"> <li style="margin-left: 0; padding: 10px 10px; background: ' . $trace_odd_item_background . ';background: #F00;"> <span style="color: #DDD; ' . $trace_item_file_style . '"> ' . $ex->getFile() . ' </span> <span style="color: #FFF; padding-left: 5px; font-weight: bold;"> [' . $ex->getLine() . '] </span> </li> '; $index = 0; foreach ((array) $file_lines as $line_number => $lines) { if ($line_number == 0) { continue; } $lines = HTMLHelper::escape($lines); $html .= '<li style="margin-left: 0;' . ($index == 0 ? ' padding-top: 10px !important; ' : '') . 'background: ' . ($index % 2 == 0 ? $trace_even_item_background : $trace_odd_item_background) . ' !important;' . $trace_item_style . ($line_number == $error_line ? $current_line_style : '') . ($index == count($file_lines) - 1 ? $last_list_item_style : $list_item_style) . '"> <span style="' . $line_number_style . ($line_number == $error_line ? $selected_line_number_style : '') . '"> # ' . $line_number . ' </span> <span style="' . $line_style . '"> <!--<pre style="display: inline; border: 0; background: transparent;">' . $lines . '</pre>--> ' . str_replace("\t", ' ', $lines) . ' </span> </li>'; $index++; } $html .= '</ul></div>'; foreach (self::$_debug_vars as $debug_var) { $var = isset($GLOBALS[$debug_var]) ? $GLOBALS[$debug_var] : array(); $html .= '<div style="' . $box_style . '"> <div style="margin: 0px; border: solid 1px #333; background: #777; font-weight: bold; padding: 10px; color: #FFF;"> ' . $debug_var . ' </div> ' . VariableHelper::var_export_html($var, true) . ' </div>'; } return $html; }
public static function get_site_url() { return \ZPHP\ZPHP::get_app_url(); }