bug #682161
[phpmyadmin/crack.git] / db_printview.php3
blob6fee56658f11be9d8b0baed221bceecbb33b6752
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Gets the variables sent or posted to this script, then displays headers
8 */
9 require('./libraries/grab_globals.lib.php3');
10 require('./header.inc.php3');
13 /**
14 * Defines the url to return to in case of error in a sql statement
16 $err_url = 'db_details.php3?' . PMA_generate_common_url($db);
19 /**
20 * Gets the list of the table in the current db and informations about these
21 * tables if possible
23 // staybyte: speedup view on locked tables - 11 June 2001
24 if (PMA_MYSQL_INT_VERSION >= 32303) {
25 // Special speedup for newer MySQL Versions (in 4.0 format changed)
26 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
27 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
28 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
29 // Blending out tables in use
30 if ($result != FALSE && mysql_num_rows($result) > 0) {
31 while ($tmp = PMA_mysql_fetch_array($result)) {
32 // if in use memorize tablename
33 if (eregi('in_use=[1-9]+', $tmp[0])) {
34 $sot_cache[$tmp[0]] = TRUE;
37 mysql_free_result($result);
39 if (isset($sot_cache)) {
40 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
41 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
42 if ($result != FALSE && mysql_num_rows($result) > 0) {
43 while ($tmp = PMA_mysql_fetch_array($result)) {
44 if (!isset($sot_cache[$tmp[0]])) {
45 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
46 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
47 $sts_tmp = PMA_mysql_fetch_array($sts_result);
48 $tables[] = $sts_tmp;
49 } else { // table in use
50 $tables[] = array('Name' => $tmp[0]);
53 mysql_free_result($result);
54 $sot_ready = TRUE;
59 if (!isset($sot_ready)) {
60 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
61 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
62 if ($result != FALSE && mysql_num_rows($result) > 0) {
63 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
64 $tables[] = $sts_tmp;
66 mysql_free_result($result);
69 $num_tables = (isset($tables) ? count($tables) : 0);
70 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
71 else {
72 $result = PMA_mysql_list_tables($db);
73 $num_tables = ($result) ? @mysql_numrows($result) : 0;
74 for ($i = 0; $i < $num_tables; $i++) {
75 $tables[] = PMA_mysql_tablename($result, $i);
77 mysql_free_result($result);
81 /**
82 * If there is at least one table, displays the printer friendly view, else
83 * an error message
85 // 1. No table
86 if ($num_tables == 0) {
87 echo $strNoTablesFound;
89 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
90 else if (PMA_MYSQL_INT_VERSION >= 32303) {
93 <!-- The tables list -->
94 <table border="<?php echo $cfg['Border']; ?>">
95 <tr>
96 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
97 <th><?php echo $strRecords; ?></th>
98 <th><?php echo $strType; ?></th>
99 <?php
100 if ($cfg['ShowStats']) {
101 echo '<th>' . $strSize . '</th>';
103 echo "\n";
105 </tr>
106 <?php
107 $i = $sum_entries = $sum_size = 0;
108 while (list($keyname, $sts_data) = each($tables)) {
109 $table = $sts_data['Name'];
110 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
111 echo "\n";
113 <tr>
114 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
115 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
116 </td>
117 <?php
118 echo "\n";
119 $mergetable = FALSE;
120 $nonisam = FALSE;
121 if (isset($sts_data['Type'])) {
122 if ($sts_data['Type'] == 'MRG_MyISAM') {
123 $mergetable = TRUE;
124 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
125 $nonisam = TRUE;
129 if (isset($sts_data['Rows'])) {
130 if ($mergetable == FALSE) {
131 if ($cfg['ShowStats'] && $nonisam == FALSE) {
132 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
133 $sum_size += $tblsize;
134 if ($tblsize > 0) {
135 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
136 } else {
137 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
139 } else if ($cfg['ShowStats']) {
140 $formated_size = '&nbsp;-&nbsp;';
141 $unit = '';
143 $sum_entries += $sts_data['Rows'];
145 // MyISAM MERGE Table
146 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
147 $formated_size = '&nbsp;-&nbsp;';
148 $unit = '';
150 else if ($cfg['ShowStats']) {
151 $formated_size = 'unknown';
152 $unit = '';
155 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
156 <?php
157 echo "\n" . ' ';
158 if ($mergetable == TRUE) {
159 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
160 } else {
161 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
164 </td>
165 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
166 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
167 </td>
168 <?php
169 if ($cfg['ShowStats']) {
170 echo "\n";
172 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
173 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
174 </td>
175 <?php
176 echo "\n";
177 } // end if
178 } else {
180 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
181 <?php echo $strInUse . "\n"; ?>
182 </td>
183 <?php
185 echo "\n";
187 </tr>
188 <?php
190 // Show Summary
191 if ($cfg['ShowStats']) {
192 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
194 echo "\n";
196 <tr>
197 <th align="center">
198 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
199 </th>
200 <th align="right" nowrap="nowrap">
201 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
202 </th>
203 <th align="center">
204 <b>--</b>
205 </th>
206 <?php
207 if ($cfg['ShowStats']) {
208 echo "\n";
210 <th align="right" nowrap="nowrap">
211 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
212 </th>
213 <?php
215 echo "\n";
217 </tr>
218 </table>
219 <?php
220 } // end case mysql >= 3.23.03
222 // 3. Shows tables list mysql < 3.23.03
223 else {
224 $i = 0;
225 echo "\n";
228 <!-- The tables list -->
229 <table border="<?php echo $cfg['Border']; ?>">
230 <tr>
231 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
232 <th><?php echo $strRecords; ?></th>
233 </tr>
234 <?php
235 while ($i < $num_tables) {
236 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
237 echo "\n";
239 <tr>
240 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
241 <b><?php echo htmlspecialchars($tables[$i]); ?>&nbsp;</b>
242 </td>
243 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
244 &nbsp;<?php PMA_countRecords($db, $tables[$i]); ?>
245 </td>
246 </tr>
247 <?php
248 $i++;
249 } // end while
250 echo "\n";
252 </table>
253 <?php
254 } // end if
258 * Displays the footer
260 echo "\n";
261 require('./footer.inc.php3');