Source for file bluescreen.phtml

Documentation is available at bluescreen.phtml

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework - Debugger bluescreen template.
  5. 5:  *
  6. 6:  * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
  7. 7:  *
  8. 8:  * This source file is subject to the "Nette license" that is bundled
  9. 9:  * with this package in the file license.txt.
  10. 10:  *
  11. 11:  * For more information please see https://nette.org
  12. 12:  *
  13. 13:  * @author     David Grudl
  14. 14:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  15. 15:  * @license    https://nette.org/license  Nette license
  16. 16:  * @link       https://nette.org
  17. 17:  * @category   Nette
  18. 18:  * @package    Nette
  19. 19:  * @version    $Id$
  20. 20:  *
  21. 21:  * @param      array     $exception 
  22. 22:  * @param      array     $colophons 
  23. 23:  * @param      array     $keyFilter 
  24. 24:  * @param      array     $internals 
  25. 25:  * @return     void 
  26. 26:  */
  27. 27:  
  28. 28:  
  29. 29:  
  30. 30: if (!function_exists('_netteDebugPrintCode')) {
  31. 31:  
  32. 32: /**
  33. 33:  * Prints source code.
  34. 34:  * @param  string 
  35. 35:  * @param  int 
  36. 36:  * @param  int 
  37. 37:  * @return void 
  38. 38:  */
  39. 39: function _netteDebugPrintCode($file$line$count 15)
  40. 40: {
  41. 41:     if (function_exists('ini_set')) {
  42. 42:         ini_set('highlight.comment''#999; font-style: italic');
  43. 43:         ini_set('highlight.default''#000');
  44. 44:         ini_set('highlight.html''#06b');
  45. 45:         ini_set('highlight.keyword''#d24; font-weight: bold');
  46. 46:         ini_set('highlight.string''#080');
  47. 47:     }
  48. 48:  
  49. 49:     $start max(1$line floor($count 2));
  50. 50:  
  51. 51:     $source explode("\n"@highlight_file($fileTRUE));
  52. 52:     echo $source[0]// <code><span color=highlight.html>
  53. 53:     $source explode('<br />'$source[1]);
  54. 54:     array_unshift($sourceNULL);
  55. 55:  
  56. 56:     $i $start// find last highlighted block
  57. 57:     while (--$i >= 1{
  58. 58:         if (preg_match('#.*(</?span[^>]*>)#'$source[$i]$m)) {
  59. 59:             if ($m[1!== '</span>'echo $m[1];
  60. 60:             break;
  61. 61:         }
  62. 62:     }
  63. 63:  
  64. 64:     $source array_slice($source$start$countTRUE);
  65. 65:     end($source);
  66. 66:     $numWidth strlen((string) key($source));
  67. 67:  
  68. 68:     foreach ($source as $n => $s{
  69. 69:         $s str_replace(array("\r""\n")array('''')$s);
  70. 70:         if ($n === $line{
  71. 71:             printf(
  72. 72:                 "<span class='highlight'>Line %{$numWidth}s:    %s\n</span>%s",
  73. 73:                 $n,
  74. 74:                 strip_tags($s),
  75. 75:                 preg_replace('#[^>]*(<[^>]+>)[^<]*#''$1'$s)
  76. 76:             );
  77. 77:         else {
  78. 78:             printf("<span class='line'>Line %{$numWidth}s:</span>    %s\n"$n$s);
  79. 79:         }
  80. 80:     }
  81. 81:     echo '</span></span></code>';
  82. 82: }
  83. 83:  
  84. 84:  
  85. 85:  
  86. 86: /**
  87. 87:  * Opens panel.
  88. 88:  * @param  string 
  89. 89:  * @param  bool 
  90. 90:  * @return void 
  91. 91:  */
  92. 92: function _netteOpenPanel($name$collapsed)
  93. 93: {
  94. 94:     static $id;
  95. 95:     $id++;
  96. 96:     ?>
  97. 97:     <div class="panel">
  98. 98:         <h2><a href="#" onclick="return !netteToggle(this, 'pnl<?php echo $id ?>')"><?php echo htmlSpecialChars($name?> <span><?php echo $collapsed '&#x25ba;' '&#x25bc;' ?></span></a></h2>
  99. 99:  
  100. 100:         <div id="pnl<?php echo $id ?>" class="<?php echo $collapsed 'collapsed ' '' ?>inner">
  101. 101:     <?php
  102. 103:  
  103. 104:  
  104. 105:  
  105. 106: /**
  106. 107:  * Closes panel.
  107. 108:  * @return void 
  108. 109:  */
  109. 110: function _netteClosePanel()
  110. 112:     ?>
  111. 113:         </div>
  112. 114:     </div>
  113. 115:     <?php
  114. 117:  
  115. 119:  
  116. 120:  
  117. 121: /**
  118. 122:  * Page title.
  119. 123:  */
  120. 124: static $errorTypes array(
  121. 125:     E_ERROR => 'Fatal Error',
  122. 126:     E_USER_ERROR => 'User Error',
  123. 127:     E_RECOVERABLE_ERROR => 'Recoverable Error',
  124. 128:     E_CORE_ERROR => 'Core Error',
  125. 129:     E_COMPILE_ERROR => 'Compile Error',
  126. 130:     E_PARSE => 'Parse Error',
  127. 131: );
  128. 132: $title ($exception instanceof FatalErrorException && isset($errorTypes[$exception->getSeverity()])) $errorTypes[$exception->getSeverity()get_class($exception);
  129. 133:  
  130. 134:  
  131. 135: if (headers_sent()) {
  132. 136:     echo '</pre></xmp></table>';
  133. 138:  
  134. 139: ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  135. 140: <html lang="en">
  136. 141: <head>
  137. 142:     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  138. 143:     <meta name="robots" content="noindex,noarchive">
  139. 144:     <meta name="generator" content="Nette Framework">
  140. 145:  
  141. 146:     <title><?php echo htmlspecialchars($title?></title>
  142. 147:  
  143. 148:     <style type="text/css">
  144. 149:     /* <![CDATA[ */
  145. 150:         body {
  146. 151:             margin: 0 0 2em;
  147. 152:             padding: 0;
  148. 153:         }
  149. 154:  
  150. 155:         #netteBluescreen {
  151. 156:             font: 9pt/1.5 Verdana, sans-serif;
  152. 157:             background: white;
  153. 158:             color: #333;
  154. 159:             position: absolute;
  155. 160:             left: 0;
  156. 161:             top: 0;
  157. 162:             width: 100%;
  158. 163:             z-index: 23178;
  159. 164:             text-align: left;
  160. 165:         }
  161. 166:  
  162. 167:         #netteBluescreen * {
  163. 168:             color: inherit;
  164. 169:             background: inherit;
  165. 170:             text-align: inherit;
  166. 171:         }
  167. 172:  
  168. 173:         #netteBluescreenIcon {
  169. 174:             position: absolute;
  170. 175:             right: .5em;
  171. 176:             top: .5em;
  172. 177:             z-index: 23179;
  173. 178:             color: black;
  174. 179:             text-decoration: none;
  175. 180:             background: red;
  176. 181:             padding: 3px;
  177. 182:         }
  178. 183:  
  179. 184:         #netteBluescreen h1 {
  180. 185:             font: 18pt/1.5 Verdana, sans-serif !important;
  181. 186:             margin: .6em 0;
  182. 187:         }
  183. 188:  
  184. 189:         #netteBluescreen h2 {
  185. 190:             font: 14pt/1.5 sans-serif !important;
  186. 191:             color: #888;
  187. 192:             margin: .6em 0;
  188. 193:         }
  189. 194:  
  190. 195:         #netteBluescreen a {
  191. 196:             text-decoration: none;
  192. 197:             color: #4197E3;
  193. 198:         }
  194. 199:  
  195. 200:         #netteBluescreen a span {
  196. 201:             font-family: sans-serif;
  197. 202:             color: #999;
  198. 203:         }
  199. 204:  
  200. 205:         #netteBluescreen h3 {
  201. 206:             font: bold 10pt/1.5 Verdana, sans-serif !important;
  202. 207:             margin: 1em 0;
  203. 208:             padding: 0;
  204. 209:         }
  205. 210:  
  206. 211:         #netteBluescreen p {
  207. 212:             margin: .8em 0
  208. 213:         }
  209. 214:  
  210. 215:         #netteBluescreen pre, #netteBluescreen code, #netteBluescreen table {
  211. 216:             font: 9pt/1.5 Consolas, monospace !important;
  212. 217:         }
  213. 218:  
  214. 219:         #netteBluescreen pre, #netteBluescreen table {
  215. 220:             background: #ffffcc;
  216. 221:             padding: .4em .7em;
  217. 222:             border: 1px dotted silver;
  218. 223:         }
  219. 224:  
  220. 225:         #netteBluescreen table pre {
  221. 226:             padding: 0;
  222. 227:             margin: 0;
  223. 228:             border: none;
  224. 229:         }
  225. 230:  
  226. 231:         #netteBluescreen pre.dump span {
  227. 232:             color: #c16549;
  228. 233:         }
  229. 234:  
  230. 235:         #netteBluescreen div.panel {
  231. 236:             border-bottom: 1px solid #eee;
  232. 237:             padding: 1px 2em;
  233. 238:         }
  234. 239:  
  235. 240:         #netteBluescreen div.inner {
  236. 241:             padding: 0.1em 1em 1em;
  237. 242:             background: #f5f5f5;
  238. 243:         }
  239. 244:  
  240. 245:         #netteBluescreen table {
  241. 246:             border-collapse: collapse;
  242. 247:             width: 100%;
  243. 248:         }
  244. 249:  
  245. 250:         #netteBluescreen td, #netteBluescreen th {
  246. 251:             vertical-align: top;
  247. 252:             padding: 2px 3px;
  248. 253:             border: 1px solid #eeeebb;
  249. 254:         }
  250. 255:  
  251. 256:         #netteBluescreen ul {
  252. 257:             font: 7pt/1.5 Verdana, sans-serif !important;
  253. 258:             padding: 1em 2em 50px;
  254. 259:         }
  255. 260:  
  256. 261:         #netteBluescreen .highlight, #netteBluescreenError {
  257. 262:             background: red;
  258. 263:             color: white;
  259. 264:             font-weight: bold;
  260. 265:             font-style: normal;
  261. 266:             display: block;
  262. 267:         }
  263. 268:  
  264. 269:         #netteBluescreen .line {
  265. 270:             color: #9e9e7e;
  266. 271:             font-weight: normal;
  267. 272:             font-style: normal;
  268. 273:         }
  269. 274:  
  270. 275:     /* ]]> */
  271. 276:     </style>
  272. 277:  
  273. 278:  
  274. 279:     <script type="text/javascript">
  275. 280:     /* <![CDATA[ */
  276. 281:         document.write('<style> .collapsed { display: none; } </style>');
  277. 282:  
  278. 283:         function netteToggle(link, panelId)
  279. 284:         {
  280. 285:             var span = link.getElementsByTagName('span')[0];
  281. 286:             var panel = document.getElementById(panelId);
  282. 287:             var collapsed = panel.currentStyle ? panel.currentStyle.display == 'none' : getComputedStyle(panel, null).display == 'none';
  283. 288:  
  284. 289:             span.innerHTML = String.fromCharCode(collapsed ? 0x25bc : 0x25ba);
  285. 290:             panel.style.display = collapsed ? 'block' : 'none';
  286. 291:  
  287. 292:             return true;
  288. 293:         }
  289. 294:     /* ]]> */
  290. 295:     </script>
  291. 296: </head>
  292. 297:  
  293. 298:  
  294. 299:  
  295. 300: <body>
  296. 301:     <div>
  297. 302:         <a id="netteBluescreenIcon" href="#" onclick="return !netteToggle(this, 'netteBluescreen')"><span>&#x25bc;</span></a>
  298. 303:     </div>
  299. 304:  
  300. 305:     <div id="netteBluescreen">
  301. 306:         <div id="netteBluescreenError" class="panel">
  302. 307:             <h1><?php echo htmlspecialchars($title)($exception->getCode(' #' $exception->getCode(''?></h1>
  303. 308:  
  304. 309:             <p><?php echo htmlspecialchars($exception->getMessage()) ?></p>
  305. 310:         </div>
  306. 311:  
  307. 312:  
  308. 313:  
  309. 314:         <?php $ex $exception$level 0?>
  310. 315:         <?php do ?>
  311. 316:  
  312. 317:             <?php if ($level++)?>
  313. 318:                 <?php _netteOpenPanel('Caused by'TRUE?>
  314. 319:                 <div class="panel">
  315. 320:                     <h1><?php echo htmlspecialchars(get_class($ex))($ex->getCode(' #' $ex->getCode(''?></h1>
  316. 321:  
  317. 322:                     <p><?php echo htmlspecialchars($ex->getMessage()) ?></p>
  318. 323:                 </div>
  319. 324:             <?php endif ?>
  320. 325:  
  321. 326:             <?php $collapsed isset($internals[$ex->getFile()])?>
  322. 327:             <?php if (is_file($ex->getFile()))?>
  323. 328:             <?php _netteOpenPanel('Source file'$collapsed?>
  324. 329:                 <p><strong>File:</strong> <?php echo htmlspecialchars($ex->getFile()) ?> &nbsp; <strong>Line:</strong> <?php echo $ex->getLine(?></p>
  325. 330:                 <pre><?php _netteDebugPrintCode($ex->getFile()$ex->getLine()) ?></pre>
  326. 331:             <?php _netteClosePanel(?>
  327. 332:             <?php endif?>
  328. 333:  
  329. 334:  
  330. 335:  
  331. 336:             <?php _netteOpenPanel('Call stack'FALSE?>
  332. 337:                 <ol>
  333. 338:                     <?php foreach ($ex->getTrace(as $key => $row)?>
  334. 339:                     <li><p>
  335. 340:  
  336. 341:                     <?php if (isset($row['file']))?>
  337. 342:                         <span title="<?php echo htmlSpecialChars($row['file'])?>"><?php echo htmlSpecialChars(basename(dirname($row['file'])))'/<b>'htmlSpecialChars(basename($row['file']))'</b></span> ('$row['line']')' ?>
  338. 343:                     <?php else?>
  339. 344:                         &lt;PHP inner-code&gt;
  340. 345:                     <?php endif ?>
  341. 346:  
  342. 347:                     <?php if (isset($row['file']&& is_file($row['file']))?><a href="#" onclick="return !netteToggle(this, 'src<?php echo "$level-$key?>')">source <span>&#x25ba;</span></a> &nbsp; <?php endif ?>
  343. 348:  
  344. 349:                     <?php if (isset($row['class'])) echo $row['class'$row['type'?>
  345. 350:                     <?php echo $row['function'?>
  346. 351:  
  347. 352:                     (<?php if (!empty($row['args']))?><a href="#" onclick="return !netteToggle(this, 'args<?php echo "$level-$key?>')">arguments <span>&#x25ba;</span></a><?php endif ?>)
  348. 353:                     </p>
  349. 354:  
  350. 355:                     <?php if (!empty($row['args']))?>
  351. 356:                         <div class="collapsed" id="args<?php echo "$level-$key?>">
  352. 357:                         <table>
  353. 358:                         <?php
  354. 359:                         try {
  355. 360:                             $r isset($row['class']new ReflectionMethod($row['class']$row['function']new ReflectionFunction($row['function']);
  356. 361:                             $params $r->getParameters();
  357. 362:                         catch (Exception $e{
  358. 363:                             $params array();
  359. 364:                         }
  360. 365:                         foreach ($row['args'as $k => $v{
  361. 366:                             echo '<tr><td>'(isset($params[$k]'$' $params[$k]->name "#$k")'</td><td>';
  362. 367:                             if (isset($params[$k]&& isset($keyFilter[strtolower($params[$k]->name)])) {
  363. 368:                                 echo '<i>*** hidden ***</i>';
  364. 369:                             else {
  365. 370:                                 echo Debug::dump($vTRUE);
  366. 371:                             }
  367. 372:                             echo "</td></tr>\n";
  368. 373:                         }
  369. 374:                         ?>
  370. 375:                         </table>
  371. 376:                         </div>
  372. 377:                     <?php endif ?>
  373. 378:  
  374. 379:  
  375. 380:                     <?php if (isset($row['file']&& is_file($row['file']))?>
  376. 381:                         <pre <?php if (!$collapsed || isset($internals[$row['file']])) echo 'class="collapsed"'else $collapsed FALSE ?> id="src<?php echo "$level-$key?>"><?php _netteDebugPrintCode($row['file']$row['line']?></pre>
  377. 382:                     <?php endif ?>
  378. 383:  
  379. 384:                     </li>
  380. 385:                     <?php endforeach ?>
  381. 386:  
  382. 387:                     <?php if (!isset($row)):?>
  383. 388:                     <li><i>empty</i></li>
  384. 389:                     <?php endif ?>
  385. 390:                 </ol>
  386. 391:             <?php _netteClosePanel(?>
  387. 392:  
  388. 393:  
  389. 394:  
  390. 395:             <?php if ($ex instanceof IDebuggable)?>
  391. 396:             <?php foreach ($ex->getPanels(as $name => $panel)?>
  392. 397:             <?php _netteOpenPanel($nameempty($panel['expanded'])) ?>
  393. 398:                 <?php echo $panel['content'?>
  394. 399:             <?php _netteClosePanel(?>
  395. 400:             <?php endforeach ?>
  396. 401:             <?php endif ?>
  397. 402:  
  398. 403:  
  399. 404:  
  400. 405:             <?php if (isset($ex->context&& is_array($ex->context)):?>
  401. 406:             <?php _netteOpenPanel('Variables'TRUE?>
  402. 407:             <table>
  403. 408:             <?php
  404. 409:             foreach ($ex->context as $k => $v{
  405. 410:                 echo '<tr><td>$'htmlspecialchars($k)'</td>';
  406. 411:                 echo '<td>'(isset($keyFilter[strtolower($k)]'<i>*** hidden ***</i>' Debug::dump($vTRUE))"</td></tr>\n";
  407. 412:             }
  408. 413:             ?>
  409. 414:             </table>
  410. 415:             <?php _netteClosePanel(?>
  411. 416:             <?php endif ?>
  412. 417:  
  413. 418:         <?php while ((method_exists($ex'getPrevious'&& $ex $ex->getPrevious()) || (isset($ex->previous&& $ex $ex->previous))?>
  414. 419:         <?php while (--$level_netteClosePanel(?>
  415. 420:  
  416. 421:  
  417. 422:  
  418. 423:         <?php _netteOpenPanel('Environment'TRUE?>
  419. 424:             <?php
  420. 425:             $list get_defined_constants(TRUE);
  421. 426:             if (!empty($list['user'])):?>
  422. 427:             <h3><a href="#" onclick="return !netteToggle(this, 'pnl-env-const')">Constants <span>&#x25bc;</span></a></h3>
  423. 428:             <table id="pnl-env-const">
  424. 429:             <?php
  425. 430:             foreach ($list['user'as $k => $v{
  426. 431:                 echo '<tr><td>'htmlspecialchars($k)'</td>';
  427. 432:                 echo '<td>'(isset($keyFilter[strtolower($k)]'<i>*** hidden ***</i>' Debug::dump($vTRUE))"</td></tr>\n";
  428. 433:             }
  429. 434:             ?>
  430. 435:             </table>
  431. 436:             <?php endif ?>
  432. 437:  
  433. 438:  
  434. 439:             <h3><a href="#" onclick="return !netteToggle(this, 'pnl-env-files')">Included files <span>&#x25ba;</span></a> (<?php echo count(get_included_files()) ?>)</h3>
  435. 440:             <table id="pnl-env-files" class="collapsed">
  436. 441:             <?php
  437. 442:             foreach (get_included_files(as $v{
  438. 443:                 echo '<tr><td>'htmlspecialchars($v)"</td></tr>\n";
  439. 444:             }
  440. 445:             ?>
  441. 446:             </table>
  442. 447:  
  443. 448:  
  444. 449:             <h3>$_SERVER</h3>
  445. 450:             <?php if (empty($_SERVER)):?>
  446. 451:             <p><i>empty</i></p>
  447. 452:             <?php else?>
  448. 453:             <table>
  449. 454:             <?php
  450. 455:             foreach ($_SERVER as $k => $vecho '<tr><td>'htmlspecialchars($k)'</td><td>'Debug::dump($vTRUE)"</td></tr>\n";
  451. 456:             ?>
  452. 457:             </table>
  453. 458:             <?php endif ?>
  454. 459:         <?php _netteClosePanel(?>
  455. 460:  
  456. 461:  
  457. 462:  
  458. 463:         <?php _netteOpenPanel('HTTP request'TRUE?>
  459. 464:             <?php if (function_exists('apache_request_headers'))?>
  460. 465:             <h3>Headers</h3>
  461. 466:             <table>
  462. 467:             <?php
  463. 468:             foreach (apache_request_headers(as $k => $vecho '<tr><td>'htmlspecialchars($k)'</td><td>'htmlspecialchars($v)"</td></tr>\n";
  464. 469:             ?>
  465. 470:             </table>
  466. 471:             <?php endif ?>
  467. 472:  
  468. 473:  
  469. 474:             <?php foreach (array('_GET''_POST''_COOKIE'as $name)?>
  470. 475:             <h3>$<?php echo $name ?></h3>
  471. 476:             <?php if (empty($GLOBALS[$name])):?>
  472. 477:             <p><i>empty</i></p>
  473. 478:             <?php else?>
  474. 479:             <table>
  475. 480:             <?php
  476. 481:             foreach ($GLOBALS[$nameas $k => $vecho '<tr><td>'htmlspecialchars($k)'</td><td>'Debug::dump($vTRUE)"</td></tr>\n";
  477. 482:             ?>
  478. 483:             </table>
  479. 484:             <?php endif ?>
  480. 485:             <?php endforeach ?>
  481. 486:         <?php _netteClosePanel(?>
  482. 487:  
  483. 488:  
  484. 489:  
  485. 490:         <?php _netteOpenPanel('HTTP response'TRUE?>
  486. 491:             <h3>Headers</h3>
  487. 492:             <?php if (headers_list())?>
  488. 493:             <pre><?php
  489. 494:             foreach (headers_list(as $secho htmlspecialchars($s)'<br>';
  490. 495:             ?></pre>
  491. 496:             <?php else?>
  492. 497:             <p><i>no headers</i></p>
  493. 498:             <?php endif ?>
  494. 499:         <?php _netteClosePanel(?>
  495. 500:  
  496. 501:  
  497. 502:         <ul>
  498. 503:             <?php foreach ($colophons as $callback)?>
  499. 504:             <?php foreach ((array) call_user_func($callback'bluescreen'as $line)?><li><?php echo $line"\n" ?></li><?php endforeach ?>
  500. 505:             <?php endforeach ?>
  501. 506:         </ul>
  502. 507:     </div>
  503. 508: </body>
  504. 509: </html>