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  Copyright (c) 2004, 2010 David Grudl
  7. 7:  * @license    http://nettephp.com/license  Nette license
  8. 8:  * @link       http://nettephp.com
  9. 9:  * @category   Nette
  10. 10:  * @package    Nette
  11. 11:  *
  12. 12:  * @param      array     $exception 
  13. 13:  * @param      array     $colophons 
  14. 14:  * @param      array     $internals 
  15. 15:  * @param      Application $application 
  16. 16:  * @return     void 
  17. 17:  */
  18. 18:  
  19. 19:  
  20. 20:  
  21. 21: if (!function_exists('_netteDebugPrintCode')) {
  22. 22:  
  23. 23: /**
  24. 24:  * Prints source code.
  25. 25:  * @param  string 
  26. 26:  * @param  int 
  27. 27:  * @param  int 
  28. 28:  * @return void 
  29. 29:  */
  30. 30: function _netteDebugPrintCode($file$line$count 15)
  31. 31: {
  32. 32:     if (function_exists('ini_set')) {
  33. 33:         ini_set('highlight.comment''#999; font-style: italic');
  34. 34:         ini_set('highlight.default''#000');
  35. 35:         ini_set('highlight.html''#06b');
  36. 36:         ini_set('highlight.keyword''#d24; font-weight: bold');
  37. 37:         ini_set('highlight.string''#080');
  38. 38:     }
  39. 39:  
  40. 40:     $start max(1$line floor($count 2));
  41. 41:  
  42. 42:     $source @file_get_contents($file);
  43. 43:     if (!$sourcereturn;
  44. 44:     $source explode("\n"highlight_string($sourceTRUE));
  45. 45:     $spans 1;
  46. 46:     echo $source[0]// <code><span color=highlight.html>
  47. 47:     $source explode('<br />'$source[1]);
  48. 48:     array_unshift($sourceNULL);
  49. 49:  
  50. 50:     $i $start// find last highlighted block
  51. 51:     while (--$i >= 1{
  52. 52:         if (preg_match('#.*(</?span[^>]*>)#'$source[$i]$m)) {
  53. 53:             if ($m[1!== '</span>'$spans++echo $m[1]}
  54. 54:             break;
  55. 55:         }
  56. 56:     }
  57. 57:  
  58. 58:     $source array_slice($source$start$countTRUE);
  59. 59:     end($source);
  60. 60:     $numWidth strlen((string) key($source));
  61. 61:  
  62. 62:     foreach ($source as $n => $s{
  63. 63:         $spans += substr_count($s'<span'substr_count($s'</span');
  64. 64:         $s str_replace(array("\r""\n")array('''')$s);
  65. 65:         if ($n === $line{
  66. 66:             printf(
  67. 67:                 "<span class='highlight'>Line %{$numWidth}s:    %s\n</span>%s",
  68. 68:                 $n,
  69. 69:                 strip_tags($s),
  70. 70:                 preg_replace('#[^>]*(<[^>]+>)[^<]*#''$1'$s)
  71. 71:             );
  72. 72:         else {
  73. 73:             printf("<span class='line'>Line %{$numWidth}s:</span>    %s\n"$n$s);
  74. 74:         }
  75. 75:     }
  76. 76:     echo str_repeat('</span>'$spans)'</code>';
  77. 77: }
  78. 78:  
  79. 79:  
  80. 80:  
  81. 81: /**
  82. 82:  * Dumps variable.
  83. 83:  * @param  string 
  84. 84:  * @return string 
  85. 85:  */
  86. 86: function _netteDump($dump)
  87. 87: {
  88. 88:     return '<pre class="dump">' preg_replace_callback('#(^|\s+)?(.*)\((\d+)\) <code>#''_netteDumpCb'$dump'</pre>';
  89. 89: }
  90. 90:  
  91. 91: function _netteDumpCb($m)
  92. 92: {
  93. 93:     return "$m[1]<a href='#' onclick='return !netteToggle(this)'>$m[2]($m[3](trim($m[1]|| $m[3'<abbr>&#x25bc;</abbr> </a><code>' '<abbr>&#x25ba;</abbr> </a><code class="collapsed">');
  94. 94: }
  95. 95:  
  96. 96:  
  97. 97:  
  98. 98: /**
  99. 99:  * Opens panel.
  100. 100:  * @param  string 
  101. 101:  * @param  bool 
  102. 102:  * @return void 
  103. 103:  */
  104. 104: function _netteOpenPanel($name$collapsed)
  105. 106:     static $id;
  106. 107:     $id++;
  107. 108:     ?>
  108. 109:     <div class="panel">
  109. 110:         <h2><a href="#" onclick="return !netteToggle(this, 'pnl<?php echo $id ?>')"><?php echo htmlSpecialChars($name?> <abbr><?php echo $collapsed '&#x25ba;' '&#x25bc;' ?></abbr></a></h2>
  110. 111:  
  111. 112:         <div id="pnl<?php echo $id ?>" class="<?php echo $collapsed 'collapsed ' '' ?>inner">
  112. 113:     <?php
  113. 115:  
  114. 116:  
  115. 117:  
  116. 118: /**
  117. 119:  * Closes panel.
  118. 120:  * @return void 
  119. 121:  */
  120. 122: function _netteClosePanel()
  121. 124:     ?>
  122. 125:         </div>
  123. 126:     </div>
  124. 127:     <?php
  125. 129:  
  126. 131:  
  127. 132:  
  128. 133: /**
  129. 134:  * Page title.
  130. 135:  */
  131. 136: static $errorTypes array(
  132. 137:     E_ERROR => 'Fatal Error',
  133. 138:     E_USER_ERROR => 'User Error',
  134. 139:     E_RECOVERABLE_ERROR => 'Recoverable Error',
  135. 140:     E_CORE_ERROR => 'Core Error',
  136. 141:     E_COMPILE_ERROR => 'Compile Error',
  137. 142:     E_PARSE => 'Parse Error',
  138. 143:     E_WARNING => 'Warning',
  139. 144:     E_CORE_WARNING => 'Core Warning',
  140. 145:     E_COMPILE_WARNING => 'Compile Warning',
  141. 146:     E_USER_WARNING => 'User Warning',
  142. 147:     E_NOTICE => 'Notice',
  143. 148:     E_USER_NOTICE => 'User Notice',
  144. 149:     E_STRICT => 'Strict',
  145. 150:     E_DEPRECATED => 'Deprecated',
  146. 151:     E_USER_DEPRECATED => 'User Deprecated',
  147. 152: );
  148. 153: $title ($exception instanceof FatalErrorException && isset($errorTypes[$exception->getSeverity()])) $errorTypes[$exception->getSeverity()get_class($exception);
  149. 154: $rn 0;
  150. 155:  
  151. 156: if (headers_sent()) {
  152. 157:     echo '</pre></xmp></table>';
  153. 159:  
  154. 160: ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  155. 161: <html lang="en">
  156. 162: <head>
  157. 163:     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  158. 164:     <meta name="robots" content="noindex,noarchive">
  159. 165:     <meta name="generator" content="Nette Framework">
  160. 166:  
  161. 167:     <title><?php echo htmlspecialchars($title?></title><!-- <?php echo $exception->getMessage()($exception->getCode(' #' $exception->getCode(''?> -->
  162. 168:  
  163. 169:     <style type="text/css">body{margin:0 0 2em;padding:0}#netteBluescreen{font:9pt/1.5 Verdana,sans-serif;background:white;color:#333;position:absolute;left:0;top:0;width:100%;z-index:23178;text-align:left}#netteBluescreen *{color:inherit;background:inherit;text-align:inherit}#netteBluescreenIcon{position:absolute;right:.5em;top:.5em;z-index:23179;text-decoration:none;background:red;padding:3px}#netteBluescreenIcon abbr{color:black!important}#netteBluescreen h1{font:18pt/1.5 Verdana,sans-serif!important;margin:.6em 0}#netteBluescreen h2{font:14pt/1.5 sans-serif!important;color:#888;margin:.6em 0}#netteBluescreen a{text-decoration:none;color:#4197E3}#netteBluescreen a abbr{font-family:sans-serif;color:#999}#netteBluescreen h3{font:bold 10pt/1.5 Verdana,sans-serif!important;margin:1em 0;padding:0}#netteBluescreen p{margin:.8em 0}#netteBluescreen pre,#netteBluescreen code,#netteBluescreen table{font:9pt/1.5 Consolas,monospace!important}#netteBluescreen pre,#netteBluescreen table{background:#fffbcc;padding:.4em .7em;border:1px dotted silver}#netteBluescreen table pre{padding:0;margin:0;border:none}#netteBluescreen pre.dump span{color:#c16549}#netteBluescreen pre.dump a{color:#333}#netteBluescreen div.panel{border-bottom:1px solid #eee;padding:1px 2em}#netteBluescreen div.inner{padding:.1em 1em 1em;background:#f5f5f5}#netteBluescreen table{border-collapse:collapse;width:100%}#netteBluescreen td,#netteBluescreen th{vertical-align:top;text-align:left;padding:2px 3px;border:1px solid #eeb}#netteBluescreen th{width:10%;font-weight:bold}#netteBluescreen .odd,#netteBluescreen .odd pre{background-color:#faf5c3}#netteBluescreen ul{font:7pt/1.5 Verdana,sans-serif!important;padding:1em 2em 50px}#netteBluescreen .highlight,#netteBluescreenError{background:red;color:white;font-weight:bold;font-style:normal;display:block}#netteBluescreen .line{color:#9e9e7e;font-weight:normal;font-style:normal}</style>
  164. 170:  
  165. 171:  
  166. 172:     <script type="text/javascript">/*<![CDATA[*/document.write("<style> .collapsed { display: none; } </style>");function netteToggle(a,b){var c=a.getElementsByTagName("abbr")[0];for(a=b?document.getElementById(b):a.nextSibling;a.nodeType!==1;)a=a.nextSibling;b=a.currentStyle?a.currentStyle.display=="none":getComputedStyle(a,null).display=="none";c.innerHTML=String.fromCharCode(b?9660:9658);a.style.display=b?a.tagName.toLowerCase()==="code"?"inline":"block":"none";return true};/*]]>*/</script>
  167. 173: </head>
  168. 174:  
  169. 175:  
  170. 176:  
  171. 177: <body>
  172. 178: <div id="netteBluescreen">
  173. 179:     <a id="netteBluescreenIcon" href="#" onclick="return !netteToggle(this)"><abbr>&#x25bc;</abbr></a
  174. 180:  
  175. 181:     ><div>
  176. 182:         <div id="netteBluescreenError" class="panel">
  177. 183:             <h1><?php echo htmlspecialchars($title)($exception->getCode(' #' $exception->getCode(''?></h1>
  178. 184:  
  179. 185:             <p><?php echo htmlspecialchars($exception->getMessage()) ?></p>
  180. 186:         </div>
  181. 187:  
  182. 188:  
  183. 189:  
  184. 190:         <?php $ex $exception$level 0?>
  185. 191:         <?php do ?>
  186. 192:  
  187. 193:             <?php if ($level++)?>
  188. 194:                 <?php _netteOpenPanel('Caused by'$level 2?>
  189. 195:                 <div class="panel">
  190. 196:                     <h1><?php echo htmlspecialchars(get_class($ex))($ex->getCode(' #' $ex->getCode(''?></h1>
  191. 197:  
  192. 198:                     <p><?php echo htmlspecialchars($ex->getMessage()) ?></p>
  193. 199:                 </div>
  194. 200:             <?php endif ?>
  195. 201:  
  196. 202:             <?php $collapsed isset($internals[$ex->getFile()])?>
  197. 203:             <?php if (is_file($ex->getFile()))?>
  198. 204:             <?php _netteOpenPanel('Source file'$collapsed?>
  199. 205:                 <p><strong>File:</strong> <?php echo htmlspecialchars($ex->getFile()) ?> &nbsp; <strong>Line:</strong> <?php echo $ex->getLine(?></p>
  200. 206:                 <pre><?php _netteDebugPrintCode($ex->getFile()$ex->getLine()) ?></pre>
  201. 207:             <?php _netteClosePanel(?>
  202. 208:             <?php endif?>
  203. 209:  
  204. 210:  
  205. 211:  
  206. 212:             <?php _netteOpenPanel('Call stack'FALSE?>
  207. 213:                 <ol>
  208. 214:                     <?php foreach ($ex->getTrace(as $key => $row)?>
  209. 215:                     <li><p>
  210. 216:  
  211. 217:                     <?php if (isset($row['file']))?>
  212. 218:                         <span title="<?php echo htmlSpecialChars($row['file'])?>"><?php echo htmlSpecialChars(basename(dirname($row['file'])))'/<b>'htmlSpecialChars(basename($row['file']))'</b></span> ('$row['line']')' ?>
  213. 219:                     <?php else?>
  214. 220:                         &lt;PHP inner-code&gt;
  215. 221:                     <?php endif ?>
  216. 222:  
  217. 223:                     <?php if (isset($row['file']&& is_file($row['file']))?><a href="#" onclick="return !netteToggle(this, 'src<?php echo "$level-$key?>')">source <abbr>&#x25ba;</abbr></a>&nbsp; <?php endif ?>
  218. 224:  
  219. 225:                     <?php if (isset($row['class'])) echo $row['class'$row['type'?>
  220. 226:                     <?php echo $row['function'?>
  221. 227:  
  222. 228:                     (<?php if (!empty($row['args']))?><a href="#" onclick="return !netteToggle(this, 'args<?php echo "$level-$key?>')">arguments <abbr>&#x25ba;</abbr></a><?php endif ?>)
  223. 229:                     </p>
  224. 230:  
  225. 231:                     <?php if (!empty($row['args']))?>
  226. 232:                         <div class="collapsed" id="args<?php echo "$level-$key?>">
  227. 233:                         <table>
  228. 234:                         <?php
  229. 235:                         try {
  230. 236:                             $r isset($row['class']new ReflectionMethod($row['class']$row['function']new ReflectionFunction($row['function']);
  231. 237:                             $params $r->getParameters();
  232. 238:                         catch (Exception $e{
  233. 239:                             $params array();
  234. 240:                         }
  235. 241:                         foreach ($row['args'as $k => $v{
  236. 242:                             echo '<tr><th>'(isset($params[$k]'$' $params[$k]->name "#$k")'</th><td>';
  237. 243:                             echo _netteDump(self::_dump($v0));
  238. 244:                             echo "</td></tr>\n";
  239. 245:                         }
  240. 246:                         ?>
  241. 247:                         </table>
  242. 248:                         </div>
  243. 249:                     <?php endif ?>
  244. 250:  
  245. 251:  
  246. 252:                     <?php if (isset($row['file']&& is_file($row['file']))?>
  247. 253:                         <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>
  248. 254:                     <?php endif ?>
  249. 255:  
  250. 256:                     </li>
  251. 257:                     <?php endforeach ?>
  252. 258:  
  253. 259:                     <?php if (!isset($row)):?>
  254. 260:                     <li><i>empty</i></li>
  255. 261:                     <?php endif ?>
  256. 262:                 </ol>
  257. 263:             <?php _netteClosePanel(?>
  258. 264:  
  259. 265:  
  260. 266:  
  261. 267:             <?php if ($ex instanceof IDebuggable)?>
  262. 268:             <?php foreach ($ex->getPanels(as $name => $panel)?>
  263. 269:             <?php _netteOpenPanel($nameempty($panel['expanded'])) ?>
  264. 270:                 <?php echo $panel['content'?>
  265. 271:             <?php _netteClosePanel(?>
  266. 272:             <?php endforeach ?>
  267. 273:             <?php endif ?>
  268. 274:  
  269. 275:  
  270. 276:  
  271. 277:             <?php if (isset($ex->context&& is_array($ex->context)):?>
  272. 278:             <?php _netteOpenPanel('Variables'TRUE?>
  273. 279:             <table>
  274. 280:             <?php
  275. 281:             foreach ($ex->context as $k => $v{
  276. 282:                 echo '<tr><th>$'htmlspecialchars($k)'</th><td>'_netteDump(self::_dump($v0))"</td></tr>\n";
  277. 283:             }
  278. 284:             ?>
  279. 285:             </table>
  280. 286:             <?php _netteClosePanel(?>
  281. 287:             <?php endif ?>
  282. 288:  
  283. 289:         <?php while ((method_exists($ex'getPrevious'&& $ex $ex->getPrevious()) || (isset($ex->previous&& $ex $ex->previous))?>
  284. 290:         <?php while (--$level_netteClosePanel(?>
  285. 291:  
  286. 292:  
  287. 293:  
  288. 294:         <?php if (!empty($application)):?>
  289. 295:         <?php _netteOpenPanel('Nette Application'TRUE?>
  290. 296:             <h3>Requests</h3>
  291. 297:             <?php $tmp $application->getRequests()echo _netteDump(self::_dump($tmp0)) ?>
  292. 298:  
  293. 299:             <h3>Presenter</h3>
  294. 300:             <?php $tmp $application->getPresenter()echo _netteDump(self::_dump($tmp0)) ?>
  295. 301:         <?php _netteClosePanel(?>
  296. 302:         <?php endif ?>
  297. 303:  
  298. 304:  
  299. 305:  
  300. 306:         <?php _netteOpenPanel('Environment'TRUE?>
  301. 307:             <?php
  302. 308:             $list get_defined_constants(TRUE);
  303. 309:             if (!empty($list['user'])):?>
  304. 310:             <h3><a href="#" onclick="return !netteToggle(this, 'pnl-env-const')">Constants <abbr>&#x25bc;</abbr></a></h3>
  305. 311:             <table id="pnl-env-const">
  306. 312:             <?php
  307. 313:             foreach ($list['user'as $k => $v{
  308. 314:                 echo '<tr'.($rn++%2?' class="odd"':'').'><th>'htmlspecialchars($k)'</th>';
  309. 315:                 echo '<td>'_netteDump(self::_dump($v0))"</td></tr>\n";
  310. 316:             }
  311. 317:             ?>
  312. 318:             </table>
  313. 319:             <?php endif ?>
  314. 320:  
  315. 321:  
  316. 322:             <h3><a href="#" onclick="return !netteToggle(this, 'pnl-env-files')">Included files <abbr>&#x25ba;</abbr></a>(<?php echo count(get_included_files()) ?>)</h3>
  317. 323:             <table id="pnl-env-files" class="collapsed">
  318. 324:             <?php
  319. 325:             foreach (get_included_files(as $v{
  320. 326:                 echo '<tr'.($rn++%2?' class="odd"':'').'><td>'htmlspecialchars($v)"</td></tr>\n";
  321. 327:             }
  322. 328:             ?>
  323. 329:             </table>
  324. 330:  
  325. 331:  
  326. 332:             <h3>$_SERVER</h3>
  327. 333:             <?php if (empty($_SERVER)):?>
  328. 334:             <p><i>empty</i></p>
  329. 335:             <?php else?>
  330. 336:             <table>
  331. 337:             <?php
  332. 338:             foreach ($_SERVER as $k => $vecho '<tr'.($rn++%2?' class="odd"':'').'><th>'htmlspecialchars($k)'</th><td>'_netteDump(self::_dump($v0))"</td></tr>\n";
  333. 339:             ?>
  334. 340:             </table>
  335. 341:             <?php endif ?>
  336. 342:         <?php _netteClosePanel(?>
  337. 343:  
  338. 344:  
  339. 345:  
  340. 346:         <?php _netteOpenPanel('HTTP request'TRUE?>
  341. 347:             <?php if (function_exists('apache_request_headers'))?>
  342. 348:             <h3>Headers</h3>
  343. 349:             <table>
  344. 350:             <?php
  345. 351:             foreach (apache_request_headers(as $k => $vecho '<tr'.($rn++%2?' class="odd"':'').'><th>'htmlspecialchars($k)'</th><td>'htmlspecialchars($v)"</td></tr>\n";
  346. 352:             ?>
  347. 353:             </table>
  348. 354:             <?php endif ?>
  349. 355:  
  350. 356:  
  351. 357:             <?php foreach (array('_GET''_POST''_COOKIE'as $name)?>
  352. 358:             <h3>$<?php echo $name ?></h3>
  353. 359:             <?php if (empty($GLOBALS[$name])):?>
  354. 360:             <p><i>empty</i></p>
  355. 361:             <?php else?>
  356. 362:             <table>
  357. 363:             <?php
  358. 364:             foreach ($GLOBALS[$nameas $k => $vecho '<tr'.($rn++%2?' class="odd"':'').'><th>'htmlspecialchars($k)'</th><td>'_netteDump(self::_dump($v0))"</td></tr>\n";
  359. 365:             ?>
  360. 366:             </table>
  361. 367:             <?php endif ?>
  362. 368:             <?php endforeach ?>
  363. 369:         <?php _netteClosePanel(?>
  364. 370:  
  365. 371:  
  366. 372:  
  367. 373:         <?php _netteOpenPanel('HTTP response'TRUE?>
  368. 374:             <h3>Headers</h3>
  369. 375:             <?php if (headers_list())?>
  370. 376:             <pre><?php
  371. 377:             foreach (headers_list(as $secho htmlspecialchars($s)'<br>';
  372. 378:             ?></pre>
  373. 379:             <?php else?>
  374. 380:             <p><i>no headers</i></p>
  375. 381:             <?php endif ?>
  376. 382:         <?php _netteClosePanel(?>
  377. 383:  
  378. 384:  
  379. 385:         <ul>
  380. 386:             <?php foreach ($colophons as $callback)?>
  381. 387:             <?php foreach ((array) call_user_func($callback'bluescreen'as $line)?><li><?php echo $line"\n" ?></li><?php endforeach ?>
  382. 388:             <?php endforeach ?>
  383. 389:         </ul>
  384. 390:     </div>
  385. 391: </div>
  386. 392:  
  387. 393: <script type="text/javascript">document.body.appendChild(document.getElementById("netteBluescreen"));</script>
  388. 394: </body>
  389. 395: </html>