You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

398 lines
15KB

  1. <?php $error_id = uniqid('error', true); ?>
  2. <!doctype html>
  3. <html>
  4. <head>
  5. <meta charset="UTF-8">
  6. <meta name="robots" content="noindex">
  7. <title><?= esc($title) ?></title>
  8. <style type="text/css">
  9. <?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
  10. </style>
  11. <script type="text/javascript">
  12. <?= file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.js') ?>
  13. </script>
  14. </head>
  15. <body onload="init()">
  16. <!-- Header -->
  17. <div class="header">
  18. <div class="container">
  19. <h1><?= esc($title), esc($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1>
  20. <p>
  21. <?= nl2br(esc($exception->getMessage())) ?>
  22. <a href="https://www.duckduckgo.com/?q=<?= urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>"
  23. rel="noreferrer" target="_blank">search &rarr;</a>
  24. </p>
  25. </div>
  26. </div>
  27. <!-- Source -->
  28. <div class="container">
  29. <p><b><?= esc(clean_path($file)) ?></b> at line <b><?= esc($line) ?></b></p>
  30. <?php if (is_file($file)) : ?>
  31. <div class="source">
  32. <?= static::highlightFile($file, $line, 15); ?>
  33. </div>
  34. <?php endif; ?>
  35. </div>
  36. <div class="container">
  37. <ul class="tabs" id="tabs">
  38. <li><a href="#backtrace">Backtrace</a></li>
  39. <li><a href="#server">Server</a></li>
  40. <li><a href="#request">Request</a></li>
  41. <li><a href="#response">Response</a></li>
  42. <li><a href="#files">Files</a></li>
  43. <li><a href="#memory">Memory</a></li>
  44. </ul>
  45. <div class="tab-content">
  46. <!-- Backtrace -->
  47. <div class="content" id="backtrace">
  48. <ol class="trace">
  49. <?php foreach ($trace as $index => $row) : ?>
  50. <li>
  51. <p>
  52. <!-- Trace info -->
  53. <?php if (isset($row['file']) && is_file($row['file'])) :?>
  54. <?php
  55. if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true)) {
  56. echo esc($row['function'] . ' ' . clean_path($row['file']));
  57. } else {
  58. echo esc(clean_path($row['file']) . ' : ' . $row['line']);
  59. }
  60. ?>
  61. <?php else: ?>
  62. {PHP internal code}
  63. <?php endif; ?>
  64. <!-- Class/Method -->
  65. <?php if (isset($row['class'])) : ?>
  66. &nbsp;&nbsp;&mdash;&nbsp;&nbsp;<?= esc($row['class'] . $row['type'] . $row['function']) ?>
  67. <?php if (! empty($row['args'])) : ?>
  68. <?php $args_id = $error_id . 'args' . $index ?>
  69. ( <a href="#" onclick="return toggle('<?= esc($args_id, 'attr') ?>');">arguments</a> )
  70. <div class="args" id="<?= esc($args_id, 'attr') ?>">
  71. <table cellspacing="0">
  72. <?php
  73. $params = null;
  74. // Reflection by name is not available for closure function
  75. if (substr($row['function'], -1) !== '}') {
  76. $mirror = isset($row['class']) ? new \ReflectionMethod($row['class'], $row['function']) : new \ReflectionFunction($row['function']);
  77. $params = $mirror->getParameters();
  78. }
  79. foreach ($row['args'] as $key => $value) : ?>
  80. <tr>
  81. <td><code><?= esc(isset($params[$key]) ? '$' . $params[$key]->name : "#{$key}") ?></code></td>
  82. <td><pre><?= esc(print_r($value, true)) ?></pre></td>
  83. </tr>
  84. <?php endforeach ?>
  85. </table>
  86. </div>
  87. <?php else : ?>
  88. ()
  89. <?php endif; ?>
  90. <?php endif; ?>
  91. <?php if (! isset($row['class']) && isset($row['function'])) : ?>
  92. &nbsp;&nbsp;&mdash;&nbsp;&nbsp; <?= esc($row['function']) ?>()
  93. <?php endif; ?>
  94. </p>
  95. <!-- Source? -->
  96. <?php if (isset($row['file']) && is_file($row['file']) && isset($row['class'])) : ?>
  97. <div class="source">
  98. <?= static::highlightFile($row['file'], $row['line']) ?>
  99. </div>
  100. <?php endif; ?>
  101. </li>
  102. <?php endforeach; ?>
  103. </ol>
  104. </div>
  105. <!-- Server -->
  106. <div class="content" id="server">
  107. <?php foreach (['_SERVER', '_SESSION'] as $var) : ?>
  108. <?php
  109. if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
  110. continue;
  111. } ?>
  112. <h3>$<?= esc($var) ?></h3>
  113. <table>
  114. <thead>
  115. <tr>
  116. <th>Key</th>
  117. <th>Value</th>
  118. </tr>
  119. </thead>
  120. <tbody>
  121. <?php foreach ($GLOBALS[$var] as $key => $value) : ?>
  122. <tr>
  123. <td><?= esc($key) ?></td>
  124. <td>
  125. <?php if (is_string($value)) : ?>
  126. <?= esc($value) ?>
  127. <?php else: ?>
  128. <pre><?= esc(print_r($value, true)) ?></pre>
  129. <?php endif; ?>
  130. </td>
  131. </tr>
  132. <?php endforeach; ?>
  133. </tbody>
  134. </table>
  135. <?php endforeach ?>
  136. <!-- Constants -->
  137. <?php $constants = get_defined_constants(true); ?>
  138. <?php if (! empty($constants['user'])) : ?>
  139. <h3>Constants</h3>
  140. <table>
  141. <thead>
  142. <tr>
  143. <th>Key</th>
  144. <th>Value</th>
  145. </tr>
  146. </thead>
  147. <tbody>
  148. <?php foreach ($constants['user'] as $key => $value) : ?>
  149. <tr>
  150. <td><?= esc($key) ?></td>
  151. <td>
  152. <?php if (is_string($value)) : ?>
  153. <?= esc($value) ?>
  154. <?php else: ?>
  155. <pre><?= esc(print_r($value, true)) ?></pre>
  156. <?php endif; ?>
  157. </td>
  158. </tr>
  159. <?php endforeach; ?>
  160. </tbody>
  161. </table>
  162. <?php endif; ?>
  163. </div>
  164. <!-- Request -->
  165. <div class="content" id="request">
  166. <?php $request = \Config\Services::request(); ?>
  167. <table>
  168. <tbody>
  169. <tr>
  170. <td style="width: 10em">Path</td>
  171. <td><?= esc($request->getUri()) ?></td>
  172. </tr>
  173. <tr>
  174. <td>HTTP Method</td>
  175. <td><?= esc(strtoupper($request->getMethod())) ?></td>
  176. </tr>
  177. <tr>
  178. <td>IP Address</td>
  179. <td><?= esc($request->getIPAddress()) ?></td>
  180. </tr>
  181. <tr>
  182. <td style="width: 10em">Is AJAX Request?</td>
  183. <td><?= $request->isAJAX() ? 'yes' : 'no' ?></td>
  184. </tr>
  185. <tr>
  186. <td>Is CLI Request?</td>
  187. <td><?= $request->isCLI() ? 'yes' : 'no' ?></td>
  188. </tr>
  189. <tr>
  190. <td>Is Secure Request?</td>
  191. <td><?= $request->isSecure() ? 'yes' : 'no' ?></td>
  192. </tr>
  193. <tr>
  194. <td>User Agent</td>
  195. <td><?= esc($request->getUserAgent()->getAgentString()) ?></td>
  196. </tr>
  197. </tbody>
  198. </table>
  199. <?php $empty = true; ?>
  200. <?php foreach (['_GET', '_POST', '_COOKIE'] as $var) : ?>
  201. <?php
  202. if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) {
  203. continue;
  204. } ?>
  205. <?php $empty = false; ?>
  206. <h3>$<?= esc($var) ?></h3>
  207. <table style="width: 100%">
  208. <thead>
  209. <tr>
  210. <th>Key</th>
  211. <th>Value</th>
  212. </tr>
  213. </thead>
  214. <tbody>
  215. <?php foreach ($GLOBALS[$var] as $key => $value) : ?>
  216. <tr>
  217. <td><?= esc($key) ?></td>
  218. <td>
  219. <?php if (is_string($value)) : ?>
  220. <?= esc($value) ?>
  221. <?php else: ?>
  222. <pre><?= esc(print_r($value, true)) ?></pre>
  223. <?php endif; ?>
  224. </td>
  225. </tr>
  226. <?php endforeach; ?>
  227. </tbody>
  228. </table>
  229. <?php endforeach ?>
  230. <?php if ($empty) : ?>
  231. <div class="alert">
  232. No $_GET, $_POST, or $_COOKIE Information to show.
  233. </div>
  234. <?php endif; ?>
  235. <?php $headers = $request->getHeaders(); ?>
  236. <?php if (! empty($headers)) : ?>
  237. <h3>Headers</h3>
  238. <table>
  239. <thead>
  240. <tr>
  241. <th>Header</th>
  242. <th>Value</th>
  243. </tr>
  244. </thead>
  245. <tbody>
  246. <?php foreach ($headers as $value) : ?>
  247. <?php
  248. if (empty($value)) {
  249. continue;
  250. }
  251. if (! is_array($value)) {
  252. $value = [$value];
  253. } ?>
  254. <?php foreach ($value as $h) : ?>
  255. <tr>
  256. <td><?= esc($h->getName(), 'html') ?></td>
  257. <td><?= esc($h->getValueLine(), 'html') ?></td>
  258. </tr>
  259. <?php endforeach; ?>
  260. <?php endforeach; ?>
  261. </tbody>
  262. </table>
  263. <?php endif; ?>
  264. </div>
  265. <!-- Response -->
  266. <?php
  267. $response = \Config\Services::response();
  268. $response->setStatusCode(http_response_code());
  269. ?>
  270. <div class="content" id="response">
  271. <table>
  272. <tr>
  273. <td style="width: 15em">Response Status</td>
  274. <td><?= esc($response->getStatusCode() . ' - ' . $response->getReasonPhrase()) ?></td>
  275. </tr>
  276. </table>
  277. <?php $headers = $response->getHeaders(); ?>
  278. <?php if (! empty($headers)) : ?>
  279. <?php natsort($headers) ?>
  280. <h3>Headers</h3>
  281. <table>
  282. <thead>
  283. <tr>
  284. <th>Header</th>
  285. <th>Value</th>
  286. </tr>
  287. </thead>
  288. <tbody>
  289. <?php foreach ($headers as $name => $value) : ?>
  290. <tr>
  291. <td><?= esc($name, 'html') ?></td>
  292. <td><?= esc($response->getHeaderLine($name), 'html') ?></td>
  293. </tr>
  294. <?php endforeach; ?>
  295. </tbody>
  296. </table>
  297. <?php endif; ?>
  298. </div>
  299. <!-- Files -->
  300. <div class="content" id="files">
  301. <?php $files = get_included_files(); ?>
  302. <ol>
  303. <?php foreach ($files as $file) :?>
  304. <li><?= esc(clean_path($file)) ?></li>
  305. <?php endforeach ?>
  306. </ol>
  307. </div>
  308. <!-- Memory -->
  309. <div class="content" id="memory">
  310. <table>
  311. <tbody>
  312. <tr>
  313. <td>Memory Usage</td>
  314. <td><?= esc(static::describeMemory(memory_get_usage(true))) ?></td>
  315. </tr>
  316. <tr>
  317. <td style="width: 12em">Peak Memory Usage:</td>
  318. <td><?= esc(static::describeMemory(memory_get_peak_usage(true))) ?></td>
  319. </tr>
  320. <tr>
  321. <td>Memory Limit:</td>
  322. <td><?= esc(ini_get('memory_limit')) ?></td>
  323. </tr>
  324. </tbody>
  325. </table>
  326. </div>
  327. </div> <!-- /tab-content -->
  328. </div> <!-- /container -->
  329. <div class="footer">
  330. <div class="container">
  331. <p>
  332. Displayed at <?= esc(date('H:i:sa')) ?> &mdash;
  333. PHP: <?= esc(PHP_VERSION) ?> &mdash;
  334. CodeIgniter: <?= esc(\CodeIgniter\CodeIgniter::CI_VERSION) ?>
  335. </p>
  336. </div>
  337. </div>
  338. </body>
  339. </html>