error.htm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <?php
  2. if(!function_exists('parse_padding')){
  3. function parse_padding($source)
  4. {
  5. $length = strlen(strval(count($source['source']) + $source['first']));
  6. return 40 + ($length - 1) * 8;
  7. }
  8. }
  9. if(!function_exists('parse_class')){
  10. function parse_class($name)
  11. {
  12. $names = explode('\\', $name);
  13. return '<abbr title="'.$name.'">'.end($names).'</abbr>';
  14. }
  15. }
  16. if(!function_exists('parse_file')){
  17. function parse_file($file, $line)
  18. {
  19. return '<a class="toggle" title="'."{$file} line {$line}".'">'.basename($file)." line {$line}".'</a>';
  20. }
  21. }
  22. if(!function_exists('parse_args')){
  23. function parse_args($args)
  24. {
  25. $result = [];
  26. foreach ($args as $key => $item) {
  27. switch (true) {
  28. case is_object($item):
  29. $value = sprintf('<em>object</em>(%s)', parse_class(get_class($item)));
  30. break;
  31. case is_array($item):
  32. if(count($item) > 3){
  33. $value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3)));
  34. } else {
  35. $value = sprintf('[%s]', parse_args($item));
  36. }
  37. break;
  38. case is_string($item):
  39. if(strlen($item) > 20){
  40. $value = sprintf(
  41. '\'<a class="toggle" title="%s">%s...</a>\'',
  42. htmlentities($item),
  43. htmlentities(substr($item, 0, 20))
  44. );
  45. } else {
  46. $value = sprintf("'%s'", htmlentities($item));
  47. }
  48. break;
  49. case is_int($item):
  50. case is_float($item):
  51. $value = $item;
  52. break;
  53. case is_null($item):
  54. $value = '<em>null</em>';
  55. break;
  56. case is_bool($item):
  57. $value = '<em>' . ($item ? 'true' : 'false') . '</em>';
  58. break;
  59. case is_resource($item):
  60. $value = '<em>resource</em>';
  61. break;
  62. default:
  63. $value = htmlentities(str_replace("\n", '', var_export(strval($item), true)));
  64. break;
  65. }
  66. $result[] = is_int($key) ? $value : "'{$key}' => {$value}";
  67. }
  68. return implode(', ', $result);
  69. }
  70. }
  71. ?>
  72. <!DOCTYPE html>
  73. <html>
  74. <head>
  75. <meta charset="UTF-8">
  76. <title><?php echo \think\Lang::get('System Error'); ?></title>
  77. <meta name="robots" content="noindex,nofollow" />
  78. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  79. <style>
  80. /* Base */
  81. body {
  82. color: #333;
  83. font: 14px Verdana, "Helvetica Neue", helvetica, Arial, 'Microsoft YaHei', sans-serif;
  84. margin: 0;
  85. padding: 0 20px 20px;
  86. word-break: break-word;
  87. }
  88. h1{
  89. margin: 10px 0 0;
  90. font-size: 28px;
  91. font-weight: 500;
  92. line-height: 32px;
  93. }
  94. h2{
  95. color: #4288ce;
  96. font-weight: 400;
  97. padding: 6px 0;
  98. margin: 6px 0 0;
  99. font-size: 18px;
  100. border-bottom: 1px solid #eee;
  101. }
  102. h3.subheading {
  103. color: #4288ce;
  104. margin: 6px 0 0;
  105. font-weight: 400;
  106. }
  107. h3{
  108. margin: 12px;
  109. font-size: 16px;
  110. font-weight: bold;
  111. }
  112. abbr{
  113. cursor: help;
  114. text-decoration: underline;
  115. text-decoration-style: dotted;
  116. }
  117. a{
  118. color: #868686;
  119. cursor: pointer;
  120. }
  121. a:hover{
  122. text-decoration: underline;
  123. }
  124. .line-error{
  125. background: #f8cbcb;
  126. }
  127. .echo table {
  128. width: 100%;
  129. }
  130. .echo pre {
  131. padding: 16px;
  132. overflow: auto;
  133. font-size: 85%;
  134. line-height: 1.45;
  135. background-color: #f7f7f7;
  136. border: 0;
  137. border-radius: 3px;
  138. font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  139. }
  140. .echo pre > pre {
  141. padding: 0;
  142. margin: 0;
  143. }
  144. /* Layout */
  145. .col-md-3 {
  146. width: 25%;
  147. }
  148. .col-md-9 {
  149. width: 75%;
  150. }
  151. [class^="col-md-"] {
  152. float: left;
  153. }
  154. .clearfix {
  155. clear:both;
  156. }
  157. @media only screen
  158. and (min-device-width : 375px)
  159. and (max-device-width : 667px) {
  160. .col-md-3,
  161. .col-md-9 {
  162. width: 100%;
  163. }
  164. }
  165. /* Exception Info */
  166. .exception {
  167. margin-top: 20px;
  168. }
  169. .exception .message{
  170. padding: 12px;
  171. border: 1px solid #ddd;
  172. border-bottom: 0 none;
  173. line-height: 18px;
  174. font-size:16px;
  175. border-top-left-radius: 4px;
  176. border-top-right-radius: 4px;
  177. font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
  178. }
  179. .exception .code{
  180. float: left;
  181. text-align: center;
  182. color: #fff;
  183. margin-right: 12px;
  184. padding: 16px;
  185. border-radius: 4px;
  186. background: #999;
  187. }
  188. .exception .source-code{
  189. padding: 6px;
  190. border: 1px solid #ddd;
  191. background: #f9f9f9;
  192. overflow-x: auto;
  193. }
  194. .exception .source-code pre{
  195. margin: 0;
  196. }
  197. .exception .source-code pre ol{
  198. margin: 0;
  199. color: #4288ce;
  200. display: inline-block;
  201. min-width: 100%;
  202. box-sizing: border-box;
  203. font-size:14px;
  204. font-family: "Century Gothic",Consolas,"Liberation Mono",Courier,Verdana;
  205. padding-left: <?php echo (isset($source) && !empty($source)) ? parse_padding($source) : 40; ?>px;
  206. }
  207. .exception .source-code pre li{
  208. border-left: 1px solid #ddd;
  209. height: 18px;
  210. line-height: 18px;
  211. }
  212. .exception .source-code pre code{
  213. color: #333;
  214. height: 100%;
  215. display: inline-block;
  216. border-left: 1px solid #fff;
  217. font-size:14px;
  218. font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
  219. }
  220. .exception .trace{
  221. padding: 6px;
  222. border: 1px solid #ddd;
  223. border-top: 0 none;
  224. line-height: 16px;
  225. font-size:14px;
  226. font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
  227. }
  228. .exception .trace ol{
  229. margin: 12px;
  230. }
  231. .exception .trace ol li{
  232. padding: 2px 4px;
  233. }
  234. .exception div:last-child{
  235. border-bottom-left-radius: 4px;
  236. border-bottom-right-radius: 4px;
  237. }
  238. /* Copyright Info */
  239. .copyright{
  240. margin-top: 24px;
  241. padding: 12px 0;
  242. border-top: 1px solid #eee;
  243. }
  244. /* SPAN elements with the classes below are added by prettyprint. */
  245. pre.prettyprint .pln { color: #000 } /* plain text */
  246. pre.prettyprint .str { color: #080 } /* string content */
  247. pre.prettyprint .kwd { color: #008 } /* a keyword */
  248. pre.prettyprint .com { color: #800 } /* a comment */
  249. pre.prettyprint .typ { color: #606 } /* a type name */
  250. pre.prettyprint .lit { color: #066 } /* a literal value */
  251. /* punctuation, lisp open bracket, lisp close bracket */
  252. pre.prettyprint .pun, pre.prettyprint .opn, pre.prettyprint .clo { color: #660 }
  253. pre.prettyprint .tag { color: #008 } /* a markup tag name */
  254. pre.prettyprint .atn { color: #606 } /* a markup attribute name */
  255. pre.prettyprint .atv { color: #080 } /* a markup attribute value */
  256. pre.prettyprint .dec, pre.prettyprint .var { color: #606 } /* a declaration; a variable name */
  257. pre.prettyprint .fun { color: red } /* a function name */
  258. </style>
  259. <link rel="stylesheet" type="text/css" href="/statics/layui/css/layui.css">
  260. <style type="text/css">
  261. body {
  262. line-height: 1.6;
  263. }
  264. .page-404 {
  265. color: #afb5bf;
  266. padding-top: 60px;
  267. padding-bottom: 90px;
  268. }
  269. .text-c {
  270. text-align: center;
  271. }
  272. .ml-20 {
  273. margin-left: 20px;
  274. }
  275. .va-m {
  276. vertical-align: middle!important;
  277. }
  278. .page-404 .error-title {
  279. font-size: 80px;
  280. }
  281. .page-404 .error-description {
  282. font-size: 24px;
  283. }
  284. .page-404 .error-info {
  285. font-size: 14px;
  286. }
  287. .c-primary{
  288. color:#5a98de
  289. }
  290. .c-primary:hover{
  291. text-decoration: underline;
  292. color:#5a98de
  293. }
  294. p {
  295. margin-bottom: 10px;
  296. }
  297. </style>
  298. </head>
  299. <body>
  300. <div class="echo">
  301. <?php echo $echo;?>
  302. </div>
  303. <?php if(\think\App::$debug) { ?>
  304. <div class="exception">
  305. <div class="message">
  306. <div class="info">
  307. <div>
  308. <h2>[<?php echo $code; ?>] <?php echo sprintf('%s in %s', parse_class($name), parse_file($file, $line)); ?></h2>
  309. </div>
  310. <div><h1><?php echo nl2br(htmlentities($message)); ?></h1></div>
  311. </div>
  312. </div>
  313. <?php if(!empty($source)){?>
  314. <div class="source-code">
  315. <pre class="prettyprint lang-php"><ol start="<?php echo $source['first']; ?>"><?php foreach ((array) $source['source'] as $key => $value) { ?><li class="line-<?php echo $key + $source['first']; ?>"><code><?php echo htmlentities($value); ?></code></li><?php } ?></ol></pre>
  316. </div>
  317. <?php }?>
  318. </div>
  319. <?php } else { ?>
  320. <div class="page-404 text-c">
  321. <p class="error-title">
  322. <span class="va-m"> ERROR</span>
  323. </p>
  324. <p class="error-description"><?php echo nl2br(htmlentities($message)); ?></p>
  325. <p class="error-info">您可以:
  326. <a href="javascript:;" onclick="history.go(-1)" class="c-primary">&lt; 返回上一页</a>
  327. <span class="ml-20">|</span>
  328. <a href="/" class="c-primary ml-20">去首页 &gt;</a>
  329. <span class="ml-20">|</span>
  330. <a href="http://www.yunucms.com/Help/index.html" target="_blank" class="c-primary ml-20">寻求帮助 &gt;</a>
  331. </p>
  332. </div>
  333. <?php } ?>
  334. <?php if(!empty($datas)){ ?>
  335. <div class="exception-var">
  336. <h2>Exception Datas</h2>
  337. <?php foreach ((array) $datas as $label => $value) { ?>
  338. <table>
  339. <?php if(empty($value)){ ?>
  340. <caption><?php echo $label; ?><small>empty</small></caption>
  341. <?php } else { ?>
  342. <caption><?php echo $label; ?></caption>
  343. <tbody>
  344. <?php foreach ((array) $value as $key => $val) { ?>
  345. <tr>
  346. <td><?php echo htmlentities($key); ?></td>
  347. <td>
  348. <?php
  349. if(is_array($val) || is_object($val)){
  350. echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
  351. } else if(is_bool($val)) {
  352. echo $val ? 'true' : 'false';
  353. } else if(is_scalar($val)) {
  354. echo htmlentities($val);
  355. } else {
  356. echo 'Resource';
  357. }
  358. ?>
  359. </td>
  360. </tr>
  361. <?php } ?>
  362. </tbody>
  363. <?php } ?>
  364. </table>
  365. <?php } ?>
  366. </div>
  367. <?php } ?>
  368. <?php if(\think\App::$debug) { ?>
  369. <script>
  370. var LINE = <?php echo $line; ?>;
  371. function $(selector, node){
  372. var elements;
  373. node = node || document;
  374. if(document.querySelectorAll){
  375. elements = node.querySelectorAll(selector);
  376. } else {
  377. switch(selector.substr(0, 1)){
  378. case '#':
  379. elements = [node.getElementById(selector.substr(1))];
  380. break;
  381. case '.':
  382. if(document.getElementsByClassName){
  383. elements = node.getElementsByClassName(selector.substr(1));
  384. } else {
  385. elements = get_elements_by_class(selector.substr(1), node);
  386. }
  387. break;
  388. default:
  389. elements = node.getElementsByTagName();
  390. }
  391. }
  392. return elements;
  393. function get_elements_by_class(search_class, node, tag) {
  394. var elements = [], eles,
  395. pattern = new RegExp('(^|\\s)' + search_class + '(\\s|$)');
  396. node = node || document;
  397. tag = tag || '*';
  398. eles = node.getElementsByTagName(tag);
  399. for(var i = 0; i < eles.length; i++) {
  400. if(pattern.test(eles[i].className)) {
  401. elements.push(eles[i])
  402. }
  403. }
  404. return elements;
  405. }
  406. }
  407. $.getScript = function(src, func){
  408. var script = document.createElement('script');
  409. script.async = 'async';
  410. script.src = src;
  411. script.onload = func || function(){};
  412. $('head')[0].appendChild(script);
  413. }
  414. ;(function(){
  415. var files = $('.toggle');
  416. var ol = $('ol', $('.prettyprint')[0]);
  417. var li = $('li', ol[0]);
  418. // 短路径和长路径变换
  419. for(var i = 0; i < files.length; i++){
  420. files[i].ondblclick = function(){
  421. var title = this.title;
  422. this.title = this.innerHTML;
  423. this.innerHTML = title;
  424. }
  425. }
  426. // 设置出错行
  427. var err_line = $('.line-' + LINE, ol[0])[0];
  428. err_line.className = err_line.className + ' line-error';
  429. $.getScript('//cdn.bootcss.com/prettify/r298/prettify.min.js', function(){
  430. prettyPrint();
  431. // 解决Firefox浏览器一个很诡异的问题
  432. // 当代码高亮后,ol的行号莫名其妙的错位
  433. // 但是只要刷新li里面的html重新渲染就没有问题了
  434. if(window.navigator.userAgent.indexOf('Firefox') >= 0){
  435. ol[0].innerHTML = ol[0].innerHTML;
  436. }
  437. });
  438. })();
  439. </script>
  440. <?php } ?>
  441. </body>
  442. </html>