|
@ -11,39 +11,39 @@ |
|
|
|
|
|
|
|
|
class ErrorHandler |
|
|
class ErrorHandler |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public function init() |
|
|
static public function init() |
|
|
{ |
|
|
{ |
|
|
set_error_handler(array('ErrorHandler', 'error_handler')); |
|
|
set_error_handler(array('ErrorHandler', 'error_handler')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static public function error_handler($errno, $errstr, $errfile, $errline ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public function error_handler($errno, $errstr, $errfile, $errline) |
|
|
{ |
|
|
{ |
|
|
ob_clean(); |
|
|
ob_clean(); |
|
|
throw new ErrorException($errstr, 0, $errno, $errfile, $errline); |
|
|
throw new ErrorException($errstr, 0, $errno, $errfile, $errline); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static protected function getSource($file, $hiline) |
|
|
static protected function getSource($file, $hiline) |
|
|
{ |
|
|
{ |
|
|
$code = array(); |
|
|
$code = array(); |
|
|
$i = 0; |
|
|
$i = 0; |
|
|
foreach(file($file) as $line) { |
|
|
|
|
|
|
|
|
foreach (file($file) as $line) { |
|
|
$i++; |
|
|
$i++; |
|
|
if($i >= $hiline - 10 && $i <= $hiline + 10) { |
|
|
|
|
|
|
|
|
if ($i >= $hiline - 10 && $i <= $hiline + 10) { |
|
|
if ($i == $hiline) { |
|
|
if ($i == $hiline) { |
|
|
$code[] = '<tr class="error"><th>' . $i . '</th><td><span class="specific">' . htmlentities($line, ENT_QUOTES, 'UTF-8') . '</span></td></tr>'; |
|
|
$code[] = '<tr class="error"><th>' . $i . '</th><td><span class="specific">' . htmlentities($line, ENT_QUOTES, 'UTF-8') . '</span></td></tr>'; |
|
|
}else{ |
|
|
|
|
|
|
|
|
} else { |
|
|
$code[] = '<tr><th>' . $i . '</th><td>' . htmlentities($line, ENT_QUOTES, 'UTF-8') . '</td></tr>'; |
|
|
$code[] = '<tr><th>' . $i . '</th><td>' . htmlentities($line, ENT_QUOTES, 'UTF-8') . '</td></tr>'; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if($i > $hiline + 10) { |
|
|
|
|
|
|
|
|
if ($i > $hiline + 10) { |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return implode('', $code); |
|
|
return implode('', $code); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static protected function wrapArray($array, $name) |
|
|
static protected function wrapArray($array, $name) |
|
|
{ |
|
|
{ |
|
|
if (!$array) { |
|
|
if (!$array) { |
|
@ -60,12 +60,12 @@ class ErrorHandler |
|
|
$text .= '</tbody></table>'; |
|
|
$text .= '</tbody></table>'; |
|
|
return $text; |
|
|
return $text; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static protected function wrapTrace($trace) |
|
|
static protected function wrapTrace($trace) |
|
|
{ |
|
|
{ |
|
|
return '<code>' . nl2br($trace) . '</code>'; |
|
|
return '<code>' . nl2br($trace) . '</code>'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param Exception $exception |
|
|
* @param Exception $exception |
|
|
*/ |
|
|
*/ |
|
@ -73,22 +73,22 @@ class ErrorHandler |
|
|
{ |
|
|
{ |
|
|
ob_clean(); |
|
|
ob_clean(); |
|
|
$class = get_class($exception); |
|
|
$class = get_class($exception); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$method = Env::Server('REQUEST_METHOD', ''); |
|
|
$method = Env::Server('REQUEST_METHOD', ''); |
|
|
$uri = Env::getRequestUri(); |
|
|
$uri = Env::getRequestUri(); |
|
|
$source = self::getSource($exception->getFile(), $exception->getLine()); |
|
|
$source = self::getSource($exception->getFile(), $exception->getLine()); |
|
|
$time = date('r', Env::Server('REQUEST_TIME', time())); |
|
|
$time = date('r', Env::Server('REQUEST_TIME', time())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$trace = nl2br($exception->getTraceAsString()); |
|
|
$trace = nl2br($exception->getTraceAsString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$get = self::wrapArray(Env::Get(), 'GET'); |
|
|
$get = self::wrapArray(Env::Get(), 'GET'); |
|
|
$post = self::wrapArray(Env::Post(), 'POST'); |
|
|
$post = self::wrapArray(Env::Post(), 'POST'); |
|
|
$session = self::wrapArray(Session::get(), 'SESSION'); |
|
|
$session = self::wrapArray(Session::get(), 'SESSION'); |
|
|
$files = self::wrapArray(Env::Files(), 'FILES'); |
|
|
$files = self::wrapArray(Env::Files(), 'FILES'); |
|
|
$cookies = self::wrapArray(Env::Cookie(), 'COOKIE'); |
|
|
$cookies = self::wrapArray(Env::Cookie(), 'COOKIE'); |
|
|
$server = self::wrapArray(Env::Server(), 'SERVER'); |
|
|
$server = self::wrapArray(Env::Server(), 'SERVER'); |
|
|
|
|
|
|
|
|
$message =<<<EOD |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$message = <<<EOD |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
|
<head> |
|
|
<head> |
|
|