PageRenderTime 29ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/db/db_printview.php

https://gitlab.com/a.loskutnikov/sitimobile
PHP | 264 lines | 222 code | 15 blank | 27 comment | 59 complexity | 64fc834fd49edd5da7258c5d64a752dc MD5 | raw file
  1. <?php
  2. /* $Id: db_printview.php,v 1.18 2002/02/27 20:54:12 loic1 Exp $ */
  3. /**
  4. * Gets the variables sent or posted to this script, then displays headers
  5. */
  6. require('./libraries/grab_globals.lib.php');
  7. require('./header.inc.php');
  8. /**
  9. * Defines the url to return to in case of error in a sql statement
  10. */
  11. $err_url = 'db_details.php'
  12. . '?lang=' . $lang
  13. . '&amp;server=' . $server
  14. . '&amp;db=' . urlencode($db);
  15. /**
  16. * Gets the list of the table in the current db and informations about these
  17. * tables if possible
  18. */
  19. // staybyte: speedup view on locked tables - 11 June 2001
  20. if (PMA_MYSQL_INT_VERSION >= 32303) {
  21. // Special speedup for newer MySQL Versions (in 4.0 format changed)
  22. if ($cfgSkipLockedTables == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
  23. $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
  24. $result = mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
  25. // Blending out tables in use
  26. if ($result != FALSE && mysql_num_rows($result) > 0) {
  27. while ($tmp = mysql_fetch_array($result)) {
  28. // if in use memorize tablename
  29. if (eregi('in_use=[1-9]+', $tmp)) {
  30. $sot_cache[$tmp[0]] = TRUE;
  31. }
  32. }
  33. mysql_free_result($result);
  34. if (isset($sot_cache)) {
  35. $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
  36. $result = mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
  37. if ($result != FALSE && mysql_num_rows($result) > 0) {
  38. while ($tmp = mysql_fetch_array($result)) {
  39. if (!isset($sot_cache[$tmp[0]])) {
  40. $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
  41. $sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
  42. $sts_tmp = mysql_fetch_array($sts_result);
  43. $tables[] = $sts_tmp;
  44. } else { // table in use
  45. $tables[] = array('Name' => $tmp[0]);
  46. }
  47. }
  48. mysql_free_result($result);
  49. $sot_ready = TRUE;
  50. }
  51. }
  52. }
  53. }
  54. if (!isset($sot_ready)) {
  55. $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
  56. $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
  57. if ($result != FALSE && mysql_num_rows($result) > 0) {
  58. while ($sts_tmp = mysql_fetch_array($result)) {
  59. $tables[] = $sts_tmp;
  60. }
  61. mysql_free_result($result);
  62. }
  63. }
  64. $num_tables = (isset($tables) ? count($tables) : 0);
  65. } // end if (PMA_MYSQL_INT_VERSION >= 32303)
  66. else {
  67. $result = mysql_list_tables($db);
  68. $num_tables = @mysql_numrows($result);
  69. for ($i = 0; $i < $num_tables; $i++) {
  70. $tables[] = mysql_tablename($result, $i);
  71. }
  72. mysql_free_result($result);
  73. }
  74. /**
  75. * If there is at least one table, displays the printer friendly view, else
  76. * an error message
  77. */
  78. // 1. No table
  79. if ($num_tables == 0) {
  80. echo $strNoTablesFound;
  81. }
  82. // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
  83. else if (PMA_MYSQL_INT_VERSION >= 32303) {
  84. ?>
  85. <!-- The tables list -->
  86. <table border="<?php echo $cfgBorder; ?>">
  87. <tr>
  88. <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
  89. <th><?php echo ucfirst($strRecords); ?></th>
  90. <th><?php echo ucfirst($strType); ?></th>
  91. <?php
  92. if ($cfgShowStats) {
  93. echo '<th>' . ucfirst($strSize) . '</th>';
  94. }
  95. echo "\n";
  96. ?>
  97. </tr>
  98. <?php
  99. $i = $sum_entries = $sum_size = 0;
  100. while (list($keyname, $sts_data) = each($tables)) {
  101. $table = $sts_data['Name'];
  102. $bgcolor = ($i++ % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
  103. echo "\n";
  104. ?>
  105. <tr>
  106. <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  107. &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
  108. </td>
  109. <?php
  110. echo "\n";
  111. $mergetable = FALSE;
  112. $nonisam = FALSE;
  113. if (isset($sts_data['Type'])) {
  114. if ($sts_data['Type'] == 'MRG_MyISAM') {
  115. $mergetable = TRUE;
  116. } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
  117. $nonisam = TRUE;
  118. }
  119. }
  120. if (isset($sts_data['Rows'])) {
  121. if ($mergetable == FALSE) {
  122. if ($cfgShowStats && $nonisam == FALSE) {
  123. $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
  124. $sum_size += $tblsize;
  125. if ($tblsize > 0) {
  126. list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
  127. } else {
  128. list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
  129. }
  130. } else if ($cfgShowStats) {
  131. $formated_size = '&nbsp;-&nbsp;';
  132. $unit = '';
  133. }
  134. $sum_entries += $sts_data['Rows'];
  135. }
  136. // MyISAM MERGE Table
  137. else if ($cfgShowStats && $mergetable == TRUE) {
  138. $formated_size = '&nbsp;-&nbsp;';
  139. $unit = '';
  140. }
  141. else if ($cfgShowStats) {
  142. $formated_size = 'unknown';
  143. $unit = '';
  144. }
  145. ?>
  146. <td align="right" bgcolor="<?php echo $bgcolor; ?>">
  147. <?php
  148. echo "\n" . ' ';
  149. if ($mergetable == TRUE) {
  150. echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
  151. } else {
  152. echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
  153. }
  154. ?>
  155. </td>
  156. <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
  157. &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
  158. </td>
  159. <?php
  160. if ($cfgShowStats) {
  161. echo "\n";
  162. ?>
  163. <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  164. &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
  165. </td>
  166. <?php
  167. echo "\n";
  168. } // end if
  169. } else {
  170. ?>
  171. <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
  172. <?php echo $strInUse . "\n"; ?>
  173. </td>
  174. <?php
  175. }
  176. echo "\n";
  177. ?>
  178. </tr>
  179. <?php
  180. }
  181. // Show Summary
  182. if ($cfgShowStats) {
  183. list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
  184. }
  185. echo "\n";
  186. ?>
  187. <tr>
  188. <th align="center">
  189. &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
  190. </th>
  191. <th align="right" nowrap="nowrap">
  192. <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
  193. </th>
  194. <th align="center">
  195. <b>--</b>
  196. </th>
  197. <?php
  198. if ($cfgShowStats) {
  199. echo "\n";
  200. ?>
  201. <th align="right" nowrap="nowrap">
  202. <b><?php echo $sum_formated . ' ' . $unit; ?></b>
  203. </th>
  204. <?php
  205. }
  206. echo "\n";
  207. ?>
  208. </tr>
  209. </table>
  210. <?php
  211. } // end case mysql >= 3.23.03
  212. // 3. Shows tables list mysql < 3.23.03
  213. else {
  214. $i = 0;
  215. echo "\n";
  216. ?>
  217. <!-- The tables list -->
  218. <table border="<?php echo $cfgBorder; ?>">
  219. <tr>
  220. <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
  221. <th><?php echo ucfirst($strRecords); ?></th>
  222. </tr>
  223. <?php
  224. while ($i < $num_tables) {
  225. $bgcolor = ($i % 2) ? $cfgBgcolorOne : $bgcolor = $cfgBgcolorTwo;
  226. echo "\n";
  227. ?>
  228. <tr>
  229. <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  230. <b><?php echo htmlspecialchars($tables[$i]); ?>&nbsp;</b>
  231. </td>
  232. <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  233. &nbsp;<?php PMA_countRecords($db, $tables[$i]); ?>
  234. </td>
  235. </tr>
  236. <?php
  237. $i++;
  238. } // end while
  239. echo "\n";
  240. ?>
  241. </table>
  242. <?php
  243. } // end if
  244. /**
  245. * Displays the footer
  246. */
  247. echo "\n";
  248. require('./footer.inc.php');
  249. ?>