A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
5.7 KiB

13 years ago
  1. <?php
  2. require('../../../includes/prepend.inc.php');
  3. $intDatabaseIndex = $_POST['intDatabaseIndex'];
  4. $strProfileData = $_POST['strProfileData'];
  5. $strReferrer = $_POST['strReferrer'];
  6. $objProfileArray = unserialize(base64_decode($strProfileData));
  7. $objProfileArray = QType::Cast($objProfileArray, QType::ArrayType);
  8. if ((count($objProfileArray) % 2) != 0)
  9. throw new Exception('Database Profiling data appears to have been corrupted.');
  10. ?>
  11. <html>
  12. <head>
  13. <title>Qcodo Development Framework - Database Profiling Tool</title>
  14. <style>
  15. body { font-family: 'Arial' 'Helvetica' 'sans-serif'; font-size: 14px; }
  16. a:link, a:visited { text-decoration: none; }
  17. a:hover { text-decoration: underline; }
  18. pre { font-family: 'Lucida Console' 'Courier New' 'Courier' 'monospaced'; font-size: 11px; line-height: 13px; }
  19. .page { padding: 10px; }
  20. .headingLeft {
  21. background-color: #446644;
  22. color: #ffffff;
  23. padding: 10px 0px 10px 10px;
  24. font-family: 'Verdana' 'Arial' 'Helvetica' 'sans-serif';
  25. font-size: 18px;
  26. font-weight: bold;
  27. width: 70%;
  28. vertical-align: middle;
  29. }
  30. .headingLeftSmall { font-size: 10px; }
  31. .headingRight {
  32. background-color: #446644;
  33. color: #ffffff;
  34. padding: 0px 10px 10px 10px;
  35. font-family: 'Verdana' 'Arial' 'Helvetica' 'sans-serif';
  36. font-size: 10px;
  37. width: 30%;
  38. vertical-align: middle;
  39. text-align: right;
  40. }
  41. .title { font-family: 'Verdana' 'Arial' 'Helvetica' 'sans-serif'; font-size: 19px; font-style: italic; color: #330055; }
  42. .code { background-color: #f4eeff; padding: 1px 10px 1px 10px; }
  43. .function { font-family: 'Verdana' 'Arial' 'Helvetica' 'sans-serif'; font-size: 12px; font-weight: bold; }
  44. .function_details { font-family: 'Verdana' 'Arial' 'Helvetica' 'sans-serif'; font-size: 10px; color: #777777; }
  45. </style>
  46. <script type="text/javascript">
  47. function Toggle(spanId) {
  48. var obj = document.getElementById(spanId);
  49. if (obj) {
  50. if (obj.style.display == "block") {
  51. // Make INVISIBLE
  52. obj.style.display = "none";
  53. } else {
  54. // Make VISIBLE
  55. obj.style.display = "block";
  56. }
  57. }
  58. }
  59. function ShowAll() {
  60. for (var intIndex = 1; intIndex < <?php _p(count($objProfileArray)); ?>; intIndex = intIndex + 2) {
  61. var obj = document.getElementById('query' + intIndex);
  62. obj.style.display = "block";
  63. }
  64. }
  65. function HideAll() {
  66. for (var intIndex = 1; intIndex < <?php _p(count($objProfileArray)); ?>; intIndex = intIndex + 2) {
  67. var obj = document.getElementById('query' + intIndex);
  68. obj.style.display = "none";
  69. }
  70. }
  71. </script>
  72. </head>
  73. <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
  74. <table border="0" cellspacing="0" width="100%">
  75. <tr>
  76. <td nowrap="nowrap" class="headingLeft"><span class="headingLeftSmall">Qcodo Development Framework <?= QCODO_VERSION ?><br /></span>Database Profiling Tool</div></td>
  77. <td nowrap="nowrap" class="headingRight">
  78. <b>Database Index:</b> <?php _p($intDatabaseIndex); ?>;&nbsp;&nbsp;<b>Database Type:</b> <?php _p(QApplication::$Database[$intDatabaseIndex]->Adapter); ?><br />
  79. <b>Database Server:</b> <?php _p(QApplication::$Database[$intDatabaseIndex]->Server); ?>;&nbsp;&nbsp;<b>Database Name:</b> <?php _p(QApplication::$Database[$intDatabaseIndex]->Database); ?><br />
  80. <b>Profile Generated From:</b> <?php _p($strReferrer); ?>
  81. </td>
  82. </tr>
  83. </table><br />
  84. <div class="page">
  85. <?php
  86. $intCount = count($objProfileArray) / 2;
  87. if ($intCount == 0)
  88. _p('<b>There were no queries that were performed.</b>', false);
  89. else if ($intCount == 1)
  90. _p('<b>There was 1 query that was performed.</b>', false);
  91. else
  92. printf('<b>There were %s queries that were performed.</b>', $intCount);
  93. ?>
  94. <br />
  95. <a href="javascript: ShowAll()" class="function_details">Show All</a>
  96. &nbsp;&nbsp;|&nbsp;&nbsp;
  97. <a href="javascript: HideAll()" class="function_details">Hide All</a>
  98. <br /><br /><br />
  99. <?php
  100. for ($intIndex = 0; $intIndex < count($objProfileArray); $intIndex++) {
  101. if ((count($objProfileArray[$intIndex]) > 3) &&
  102. (array_key_exists('function', $objProfileArray[$intIndex][2])) &&
  103. (($objProfileArray[$intIndex][2]['function'] == 'QueryArray') ||
  104. ($objProfileArray[$intIndex][2]['function'] == 'QuerySingle') ||
  105. ($objProfileArray[$intIndex][2]['function'] == 'QueryCount')))
  106. $objDebugBacktrace = $objProfileArray[$intIndex][3];
  107. else
  108. $objDebugBacktrace = $objProfileArray[$intIndex][2];
  109. $intIndex++;
  110. $strQuery = $objProfileArray[$intIndex];
  111. $objArgs = (array_key_exists('args', $objDebugBacktrace)) ? $objDebugBacktrace['args'] : array();
  112. $strClass = (array_key_exists('class', $objDebugBacktrace)) ? $objDebugBacktrace['class'] : null;
  113. $strType = (array_key_exists('type', $objDebugBacktrace)) ? $objDebugBacktrace['type'] : null;
  114. $strFunction = (array_key_exists('function', $objDebugBacktrace)) ? $objDebugBacktrace['function'] : null;
  115. $strFile = (array_key_exists('file', $objDebugBacktrace)) ? $objDebugBacktrace['file'] : null;
  116. $strLine = (array_key_exists('line', $objDebugBacktrace)) ? $objDebugBacktrace['line'] : null;
  117. ?>
  118. <span class="function">
  119. Called by <?php _p($strClass . $strType . $strFunction . '(' . implode(', ', $objArgs) . ')'); ?>
  120. </span>
  121. &nbsp;&nbsp;|&nbsp;&nbsp;
  122. <a href="javascript: Toggle('query<?php _p($intIndex); ?>')" class="function_details">Show/Hide</a>
  123. <br />
  124. <span class="function_details"><b>File: </b><?php _p($strFile); ?>; &nbsp;&nbsp;<b>Line: </b><?php _p($strLine); ?>
  125. </span><br />
  126. <div class="code" id="query<?php _p($intIndex); ?>" style="display: none"><pre><?php _p($strQuery); ?></pre></div>
  127. <br /><br />
  128. <?php
  129. }
  130. ?>
  131. </div>
  132. </body>
  133. </html>