error.php 8.3 KB

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