error.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. //when exceptions where thrown we where getting a ErrorException [ Fatal Error ]: Call to undefined function __()
  3. //since i18n was not loaded yet. nasty but works...
  4. if (!function_exists('__'))
  5. {
  6. function __($message,$variables = NULL)
  7. {
  8. return is_array($variables) ? strtr($message, $variables):$message;
  9. }
  10. }
  11. // Unique error identifier
  12. $error_id = uniqid('error');
  13. ?>
  14. <style type="text/css">
  15. #kohana_error { background: #ddd; font-size: 1em; font-family:sans-serif; text-align: left; color: #111; }
  16. #kohana_error h1,
  17. #kohana_error h2 { margin: 0; padding: 1em; font-size: 1em; font-weight: normal; background: #911; color: #fff; }
  18. #kohana_error h1 a,
  19. #kohana_error h2 a { color: #fff; }
  20. #kohana_error h2 { background: #222; }
  21. #kohana_error h3 { margin: 0; padding: 0.4em 0 0; font-size: 1em; font-weight: normal; }
  22. #kohana_error p { margin: 0; padding: 0.2em 0; }
  23. #kohana_error a { color: #1b323b; }
  24. #kohana_error pre { overflow: auto; white-space: pre-wrap; }
  25. #kohana_error table { width: 100%; display: block; margin: 0 0 0.4em; padding: 0; border-collapse: collapse; background: #fff; }
  26. #kohana_error table td { border: solid 1px #ddd; text-align: left; vertical-align: top; padding: 0.4em; }
  27. #kohana_error div.content { padding: 0.4em 1em 1em; overflow: hidden; }
  28. #kohana_error pre.source { margin: 0 0 1em; padding: 0.4em; background: #fff; border: dotted 1px #b7c680; line-height: 1.2em; }
  29. #kohana_error pre.source span.line { display: block; }
  30. #kohana_error pre.source span.highlight { background: #f0eb96; }
  31. #kohana_error pre.source span.line span.number { color: #666; }
  32. #kohana_error ol.trace { display: block; margin: 0 0 0 2em; padding: 0; list-style: decimal; }
  33. #kohana_error ol.trace li { margin: 0; padding: 0; }
  34. .js .collapsed { display: none; }
  35. </style>
  36. <script type="text/javascript">
  37. document.documentElement.className = document.documentElement.className + ' js';
  38. function koggle(elem)
  39. {
  40. elem = document.getElementById(elem);
  41. if (elem.style && elem.style['display'])
  42. // Only works with the "style" attr
  43. var disp = elem.style['display'];
  44. else if (elem.currentStyle)
  45. // For MSIE, naturally
  46. var disp = elem.currentStyle['display'];
  47. else if (window.getComputedStyle)
  48. // For most other browsers
  49. var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
  50. // Toggle the state of the "display" style
  51. elem.style.display = disp == 'block' ? 'none' : 'block';
  52. return false;
  53. }
  54. </script>
  55. <div id="kohana_error">
  56. <h1><span class="type"><?php echo $class ?> [ <?php echo $code ?> ]:</span> <span class="message"><?php echo htmlspecialchars( (string) $message, ENT_QUOTES | ENT_IGNORE, Kohana::$charset, TRUE); ?></span></h1>
  57. <div id="<?php echo $error_id ?>" class="content">
  58. <p><span class="file"><?php echo Debug::path($file) ?> [ <?php echo $line ?> ]</span></p>
  59. <?php echo Debug::source($file, $line) ?>
  60. <ol class="trace">
  61. <?php foreach (Debug::trace($trace) as $i => $step): ?>
  62. <li>
  63. <p>
  64. <span class="file">
  65. <?php if ($step['file']): $source_id = $error_id.'source'.$i; ?>
  66. <a href="#<?php echo $source_id ?>" onclick="return koggle('<?php echo $source_id ?>')"><?php echo Debug::path($step['file']) ?> [ <?php echo $step['line'] ?> ]</a>
  67. <?php else: ?>
  68. {<?php echo __('PHP internal call') ?>}
  69. <?php endif ?>
  70. </span>
  71. &raquo;
  72. <?php echo $step['function'] ?>(<?php if ($step['args']): $args_id = $error_id.'args'.$i; ?><a href="#<?php echo $args_id ?>" onclick="return koggle('<?php echo $args_id ?>')"><?php echo __('arguments') ?></a><?php endif ?>)
  73. </p>
  74. <?php if (isset($args_id)): ?>
  75. <div id="<?php echo $args_id ?>" class="collapsed">
  76. <table cellspacing="0">
  77. <?php foreach ($step['args'] as $name => $arg): ?>
  78. <tr>
  79. <td><code><?php echo $name ?></code></td>
  80. <td><pre><?php echo Debug::dump($arg) ?></pre></td>
  81. </tr>
  82. <?php endforeach ?>
  83. </table>
  84. </div>
  85. <?php endif ?>
  86. <?php if (isset($source_id)): ?>
  87. <pre id="<?php echo $source_id ?>" class="source collapsed"><code><?php echo $step['source'] ?></code></pre>
  88. <?php endif ?>
  89. </li>
  90. <?php unset($args_id, $source_id); ?>
  91. <?php endforeach ?>
  92. </ol>
  93. </div>
  94. <h2><a href="#<?php echo $env_id = $error_id.'environment' ?>" onclick="return koggle('<?php echo $env_id ?>')"><?php echo __('Environment') ?></a></h2>
  95. <div id="<?php echo $env_id ?>" class="content collapsed">
  96. <?php $included = get_included_files() ?>
  97. <h3><a href="#<?php echo $env_id = $error_id.'environment_included' ?>" onclick="return koggle('<?php echo $env_id ?>')"><?php echo __('Included files') ?></a> (<?php echo count($included) ?>)</h3>
  98. <div id="<?php echo $env_id ?>" class="collapsed">
  99. <table cellspacing="0">
  100. <?php foreach ($included as $file): ?>
  101. <tr>
  102. <td><code><?php echo Debug::path($file) ?></code></td>
  103. </tr>
  104. <?php endforeach ?>
  105. </table>
  106. </div>
  107. <?php $included = get_loaded_extensions() ?>
  108. <h3><a href="#<?php echo $env_id = $error_id.'environment_loaded' ?>" onclick="return koggle('<?php echo $env_id ?>')"><?php echo __('Loaded extensions') ?></a> (<?php echo count($included) ?>)</h3>
  109. <div id="<?php echo $env_id ?>" class="collapsed">
  110. <table cellspacing="0">
  111. <?php foreach ($included as $file): ?>
  112. <tr>
  113. <td><code><?php echo Debug::path($file) ?></code></td>
  114. </tr>
  115. <?php endforeach ?>
  116. </table>
  117. </div>
  118. <?php foreach (['_SESSION', '_GET', '_POST', '_FILES', '_COOKIE', '_SERVER'] as $var): ?>
  119. <?php if (empty($GLOBALS[$var]) OR ! is_array($GLOBALS[$var])) continue ?>
  120. <h3><a href="#<?php echo $env_id = $error_id.'environment'.strtolower($var) ?>" onclick="return koggle('<?php echo $env_id ?>')">$<?php echo $var ?></a></h3>
  121. <div id="<?php echo $env_id ?>" class="collapsed">
  122. <table cellspacing="0">
  123. <?php foreach ($GLOBALS[$var] as $key => $value): ?>
  124. <tr>
  125. <td><code><?php echo htmlspecialchars( (string) $key, ENT_QUOTES, Kohana::$charset, TRUE); ?></code></td>
  126. <td><pre><?php echo Debug::dump($value) ?></pre></td>
  127. </tr>
  128. <?php endforeach ?>
  129. </table>
  130. </div>
  131. <?php endforeach ?>
  132. </div>
  133. </div>