/** * Print errors */ static function print_errors() { $default_error_tpl = "errors/default.tpl"; $smarty = new add_smarty(); foreach (static::$errors as $error_index => $errors) { $error_tpl = "errors/" . strtolower($error_index) . ".tpl"; if (!$smarty->templateExists($error_tpl)) { $error_tpl = $default_error_tpl; } foreach ($errors as $error) { # The chunk of code on the location of the error if (!add::is_live()) { $code_on_error = ""; $file_codes = file($error['file']); $code_on_error_padding = 3; $code_on_error_start = max($error['line'] - 3, 1); $smarty->assign('code_on_error_start', $code_on_error_start); for ($code_on_error_x = $code_on_error_start; $code_on_error_x <= $error['line'] + $code_on_error_padding; $code_on_error_x++) { $code_on_error .= $file_codes[$code_on_error_x - 1]; } $smarty->assign('code_on_error', highlight_string($code_on_error, true)); $smarty->assign('code_on_error_end', $code_on_error_x); } $error['file'] = basename($error['file']); $compiled_tpl_preg = '/[\\da-f]{40}\\.file\\.(.*\\.tpl)\\.php/'; if (preg_match($compiled_tpl_preg, $error['file'])) { $error['file'] = "*" . preg_replace($compiled_tpl_preg, '$1', $error['file']); } $error['file_lines'] = array(); foreach ($error['backtrace'] as $backtrace_data) { $error['file_lines'][] = array('file' => basename($backtrace_data['file']), 'line' => $backtrace_data['line']); } if ($smarty->templateExists($error_tpl)) { $smarty->assign("error", $error); $smarty->display($error_tpl); } else { echo "<div>{$error['type']} : {$error['file']}:{$error['line']} : <b>{$error['message']}</b></div>"; } } } }
/** * Print errors */ static function print_errors() { static $error_code_strings = array(E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', E_NOTICE => 'E_NOTICE', E_STRICT => 'E_STRICT', E_DEPRECATED => 'E_DEPRECATED', E_CORE_ERROR => 'E_CORE_ERROR', E_CORE_WARNING => 'E_CORE_WARNING', E_COMPILE_ERROR => 'E_COMPILE_ERROR', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_USER_ERROR => 'E_USER_ERROR', E_USER_WARNING => 'E_USER_WARNING', E_USER_NOTICE => 'E_USER_NOTICE'); $default_error_tpl = "errors/e_default.tpl"; $smarty = new add_smarty(); foreach (static::$errors as $error_index => $errors) { $error_string_index = isset($error_code_strings[$error_index]) ? $error_code_strings[$error_index] : $error_index; $error_tpl = "errors/" . strtolower($error_string_index) . ".tpl"; if (!$smarty->templateExists($error_tpl)) { $error_tpl = $default_error_tpl; } foreach ($errors as $error) { # The chunk of code on the location of the error if (!add::is_live()) { $code_on_error = ""; $file_codes = preg_split('/<br\\s*\\/>/', highlight_file($error['file'], true)); $code_on_error_padding = 6; $code_on_error_start = max($error['line'] - $code_on_error_padding, 1); $smarty->assign('code_on_error_start', $code_on_error_start); $code_on_error_end = min($error['line'] + $code_on_error_padding, count($file_codes)); for ($code_on_error_x = $code_on_error_start; $code_on_error_x <= $code_on_error_end; $code_on_error_x++) { $code_on_error .= $file_codes[$code_on_error_x - 1] . "<br />"; } preg_match('/^(\\ \\;)+?/m', $code_on_error, $code_white_space); $code_on_error = preg_replace('/^' . preg_quote($code_white_space[0], '/') . '/', '', $code_on_error); $smarty->assign('code_on_error', $code_on_error); $smarty->assign('code_on_error_end', $code_on_error_end); } $error['filepathname'] = $error['file']; $error['file'] = basename($error['file']); $compiled_tpl_preg = '/[\\da-f]{40}\\.file\\.(.*\\.tpl)\\.php/'; if (preg_match($compiled_tpl_preg, $error['file'])) { $error['file'] = "*" . preg_replace($compiled_tpl_preg, '$1', $error['file']); } $error['file_lines'] = array(); foreach ($error['backtrace'] as $backtrace_data) { $error['file_lines'][] = array('file' => basename($backtrace_data['file']), 'line' => $backtrace_data['line'], 'filepathname' => $backtrace_data['file']); } if ($smarty->templateExists($error_tpl)) { $smarty->assign("error", $error); $smarty->display($error_tpl); } else { echo "<div>{$error['type']} : {$error['file']}:{$error['line']} : <b>{$error['message']}</b></div>"; } } } }