misc_debug.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: misc_debug.php 25889 2011-11-24 09:52:20Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(DISCUZ_DEBUG && ckfounder($_G['uid'])) {
  12. print<<<EOF
  13. <style>
  14. .tclass, .tclass2 {
  15. text-align:left;width:900px;border:0;border-collapse:collapse;margin-bottom:5px;table-layout: fixed; word-wrap: break-word;background:#FFF;}
  16. .tclass table, .tclass2 table {width:100%;border:0;table-layout: fixed; word-wrap: break-word;}
  17. .tclass table td, .tclass2 table td {border-bottom:0;border-right:0;border-color: #ADADAD;}
  18. .tclass th, .tclass2 th {border:1px solid #000;background:#CCC;padding: 2px;font-family: Courier New, Arial;font-size: 11px;}
  19. .tclass td, .tclass2 td {border:1px solid #000;background:#FFFCCC;padding: 2px;font-family: Courier New, Arial;font-size: 11px;}
  20. .tclass2 th {background:#D5EAEA;}
  21. .tclass2 td {background:#FFFFFF;}
  22. .firsttr td {border-top:0;}
  23. .firsttd {border-left:none !important;}
  24. .bold {font-weight:bold;}
  25. </style>
  26. <div id="uchome_debug" style="display:;">
  27. EOF;
  28. $class = 'tclass2';
  29. if(empty($_G['debug_query'])) $_G['debug_query'] = array();
  30. foreach ($_G['debug_query'] as $dkey => $debug) {
  31. ($class == 'tclass')?$class = 'tclass2':$class = 'tclass';
  32. echo '<table cellspacing="0" class="'.$class.'"><tr><th rowspan="2" width="20">'.($dkey+1).'</th><td width="60">'.$debug['time'].' ms</td><td class="bold">'. dhtmlspecialchars($debug['sql']).'</td></tr>';
  33. if(!empty($debug['info'])) {
  34. echo '<tr><td>Info</th><td>'.$debug['info'].'</td></tr>';
  35. }
  36. if(!empty($debug['explain'])) {
  37. echo '<tr><td>Explain</td><td><table cellspacing="0"><tr class="firsttr"><td width="5%" class="firsttd">id</td><td width="10%">select_type</td><td width="12%">table</td><td width="5%">type</td><td width="20%">possible_keys</td><td width="10%">key</td><td width="8%">key_len</td><td width="5%">ref</td><td width="5%">rows</td><td width="20%">Extra</td></tr><tr>';
  38. foreach ($debug['explain'] as $ekey => $explain) {
  39. ($ekey == 'id')?$tdclass = ' class="firsttd"':$tdclass='';
  40. if(empty($explain)) $explain = '-';
  41. echo '<td'.$tdclass.'>'.$explain.'</td>';
  42. }
  43. echo '</tr></table></td></tr>';
  44. }
  45. echo '</table>';
  46. }
  47. if($values = $_COOKIE) {
  48. ($class == 'tclass')?$class = 'tclass2':$class = 'tclass';
  49. $i = 1;
  50. echo '<table class="'.$class.'">';
  51. foreach ($values as $ckey => $cookie) {
  52. echo '<tr><th width="20">'.$i.'</th><td width="250">$_COOKIE[\''.$ckey.'\']</td><td>'.$cookie.'</td></tr>';
  53. $i++;
  54. }
  55. echo '</table>';
  56. }
  57. if($files = get_included_files()) {
  58. ($class == 'tclass')?$class = 'tclass2':$class = 'tclass';
  59. echo '<table class="'.$class.'">';
  60. foreach ($files as $fkey => $file) {
  61. echo '<tr><th width="20">'.($fkey+1).'</th><td>'.$file.'</td></tr>';
  62. }
  63. echo '</table>';
  64. }
  65. if($values = $_SERVER) {
  66. ($class == 'tclass')?$class = 'tclass2':$class = 'tclass';
  67. $i = 1;
  68. echo '<table class="'.$class.'">';
  69. foreach ($values as $ckey => $cookie) {
  70. echo '<tr><th width="20">'.$i.'</th><td width="250">$_SERVER[\''.$ckey.'\']</td><td>'.$cookie.'</td></tr>';
  71. $i++;
  72. }
  73. echo '</table>';
  74. }
  75. echo '</div>';
  76. }
  77. ?>