update
[phpmyadmin/crack.git] / db_printview.php3
blob11aa7c6c9c9fc8bfbb429b2a47bfeef9d8230e81
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'
17 . '?lang=' . $lang
18 . '&amp;convcharset=' . $convcharset
19 . '&amp;server=' . $server
20 . '&amp;db=' . urlencode($db);
23 /**
24 * Gets the list of the table in the current db and informations about these
25 * tables if possible
27 // staybyte: speedup view on locked tables - 11 June 2001
28 if (PMA_MYSQL_INT_VERSION >= 32303) {
29 // Special speedup for newer MySQL Versions (in 4.0 format changed)
30 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
31 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
32 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
33 // Blending out tables in use
34 if ($result != FALSE && mysql_num_rows($result) > 0) {
35 while ($tmp = PMA_mysql_fetch_array($result)) {
36 // if in use memorize tablename
37 if (eregi('in_use=[1-9]+', $tmp[0])) {
38 $sot_cache[$tmp[0]] = TRUE;
41 mysql_free_result($result);
43 if (isset($sot_cache)) {
44 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
45 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
46 if ($result != FALSE && mysql_num_rows($result) > 0) {
47 while ($tmp = PMA_mysql_fetch_array($result)) {
48 if (!isset($sot_cache[$tmp[0]])) {
49 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
50 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
51 $sts_tmp = PMA_mysql_fetch_array($sts_result);
52 $tables[] = $sts_tmp;
53 } else { // table in use
54 $tables[] = array('Name' => $tmp[0]);
57 mysql_free_result($result);
58 $sot_ready = TRUE;
63 if (!isset($sot_ready)) {
64 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
65 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
66 if ($result != FALSE && mysql_num_rows($result) > 0) {
67 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
68 $tables[] = $sts_tmp;
70 mysql_free_result($result);
73 $num_tables = (isset($tables) ? count($tables) : 0);
74 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
75 else {
76 $result = PMA_mysql_list_tables($db);
77 $num_tables = ($result) ? @mysql_numrows($result) : 0;
78 for ($i = 0; $i < $num_tables; $i++) {
79 $tables[] = PMA_mysql_tablename($result, $i);
81 mysql_free_result($result);
85 /**
86 * If there is at least one table, displays the printer friendly view, else
87 * an error message
89 // 1. No table
90 if ($num_tables == 0) {
91 echo $strNoTablesFound;
93 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
94 else if (PMA_MYSQL_INT_VERSION >= 32303) {
97 <!-- The tables list -->
98 <table border="<?php echo $cfg['Border']; ?>">
99 <tr>
100 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
101 <th><?php echo ucfirst($strRecords); ?></th>
102 <th><?php echo ucfirst($strType); ?></th>
103 <?php
104 if ($cfg['ShowStats']) {
105 echo '<th>' . ucfirst($strSize) . '</th>';
107 echo "\n";
109 </tr>
110 <?php
111 $i = $sum_entries = $sum_size = 0;
112 while (list($keyname, $sts_data) = each($tables)) {
113 $table = $sts_data['Name'];
114 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
115 echo "\n";
117 <tr>
118 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
119 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
120 </td>
121 <?php
122 echo "\n";
123 $mergetable = FALSE;
124 $nonisam = FALSE;
125 if (isset($sts_data['Type'])) {
126 if ($sts_data['Type'] == 'MRG_MyISAM') {
127 $mergetable = TRUE;
128 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
129 $nonisam = TRUE;
133 if (isset($sts_data['Rows'])) {
134 if ($mergetable == FALSE) {
135 if ($cfg['ShowStats'] && $nonisam == FALSE) {
136 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
137 $sum_size += $tblsize;
138 if ($tblsize > 0) {
139 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
140 } else {
141 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
143 } else if ($cfg['ShowStats']) {
144 $formated_size = '&nbsp;-&nbsp;';
145 $unit = '';
147 $sum_entries += $sts_data['Rows'];
149 // MyISAM MERGE Table
150 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
151 $formated_size = '&nbsp;-&nbsp;';
152 $unit = '';
154 else if ($cfg['ShowStats']) {
155 $formated_size = 'unknown';
156 $unit = '';
159 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
160 <?php
161 echo "\n" . ' ';
162 if ($mergetable == TRUE) {
163 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
164 } else {
165 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
168 </td>
169 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
170 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
171 </td>
172 <?php
173 if ($cfg['ShowStats']) {
174 echo "\n";
176 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
177 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
178 </td>
179 <?php
180 echo "\n";
181 } // end if
182 } else {
184 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
185 <?php echo $strInUse . "\n"; ?>
186 </td>
187 <?php
189 echo "\n";
191 </tr>
192 <?php
194 // Show Summary
195 if ($cfg['ShowStats']) {
196 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
198 echo "\n";
200 <tr>
201 <th align="center">
202 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
203 </th>
204 <th align="right" nowrap="nowrap">
205 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
206 </th>
207 <th align="center">
208 <b>--</b>
209 </th>
210 <?php
211 if ($cfg['ShowStats']) {
212 echo "\n";
214 <th align="right" nowrap="nowrap">
215 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
216 </th>
217 <?php
219 echo "\n";
221 </tr>
222 </table>
223 <?php
224 } // end case mysql >= 3.23.03
226 // 3. Shows tables list mysql < 3.23.03
227 else {
228 $i = 0;
229 echo "\n";
232 <!-- The tables list -->
233 <table border="<?php echo $cfg['Border']; ?>">
234 <tr>
235 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
236 <th><?php echo ucfirst($strRecords); ?></th>
237 </tr>
238 <?php
239 while ($i < $num_tables) {
240 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
241 echo "\n";
243 <tr>
244 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
245 <b><?php echo htmlspecialchars($tables[$i]); ?>&nbsp;</b>
246 </td>
247 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
248 &nbsp;<?php PMA_countRecords($db, $tables[$i]); ?>
249 </td>
250 </tr>
251 <?php
252 $i++;
253 } // end while
254 echo "\n";
256 </table>
257 <?php
258 } // end if
262 * Displays the footer
264 echo "\n";
265 require('./footer.inc.php3');