PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/app/Views/errors/html/error_exception.php

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