update
[phpmyadmin/crack.git] / db_printview.php3
blob50d47fe0e6095215f661c06e3ca4e160a13362de
1 <?php
2 /* $Id$ */
5 /**
6 * Gets the variables sent or posted to this script, then displays headers
7 */
8 require('./libraries/grab_globals.lib.php3');
9 require('./header.inc.php3');
12 /**
13 * Defines the url to return to in case of error in a sql statement
15 $err_url = 'db_details.php3'
16 . '?lang=' . $lang
17 . '&amp;convcharset=' . $convcharset
18 . '&amp;server=' . $server
19 . '&amp;db=' . urlencode($db);
22 /**
23 * Gets the list of the table in the current db and informations about these
24 * tables if possible
26 // staybyte: speedup view on locked tables - 11 June 2001
27 if (PMA_MYSQL_INT_VERSION >= 32303) {
28 // Special speedup for newer MySQL Versions (in 4.0 format changed)
29 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
30 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
31 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
32 // Blending out tables in use
33 if ($result != FALSE && mysql_num_rows($result) > 0) {
34 while ($tmp = PMA_mysql_fetch_array($result)) {
35 // if in use memorize tablename
36 if (eregi('in_use=[1-9]+', $tmp[0])) {
37 $sot_cache[$tmp[0]] = TRUE;
40 mysql_free_result($result);
42 if (isset($sot_cache)) {
43 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
44 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
45 if ($result != FALSE && mysql_num_rows($result) > 0) {
46 while ($tmp = PMA_mysql_fetch_array($result)) {
47 if (!isset($sot_cache[$tmp[0]])) {
48 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
49 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
50 $sts_tmp = PMA_mysql_fetch_array($sts_result);
51 $tables[] = $sts_tmp;
52 } else { // table in use
53 $tables[] = array('Name' => $tmp[0]);
56 mysql_free_result($result);
57 $sot_ready = TRUE;
62 if (!isset($sot_ready)) {
63 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
64 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
65 if ($result != FALSE && mysql_num_rows($result) > 0) {
66 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
67 $tables[] = $sts_tmp;
69 mysql_free_result($result);
72 $num_tables = (isset($tables) ? count($tables) : 0);
73 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
74 else {
75 $result = PMA_mysql_list_tables($db);
76 $num_tables = ($result) ? @mysql_numrows($result) : 0;
77 for ($i = 0; $i < $num_tables; $i++) {
78 $tables[] = PMA_mysql_tablename($result, $i);
80 mysql_free_result($result);
84 /**
85 * If there is at least one table, displays the printer friendly view, else
86 * an error message
88 // 1. No table
89 if ($num_tables == 0) {
90 echo $strNoTablesFound;
92 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
93 else if (PMA_MYSQL_INT_VERSION >= 32303) {
96 <!-- The tables list -->
97 <table border="<?php echo $cfg['Border']; ?>">
98 <tr>
99 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
100 <th><?php echo ucfirst($strRecords); ?></th>
101 <th><?php echo ucfirst($strType); ?></th>
102 <?php
103 if ($cfg['ShowStats']) {
104 echo '<th>' . ucfirst($strSize) . '</th>';
106 echo "\n";
108 </tr>
109 <?php
110 $i = $sum_entries = $sum_size = 0;
111 while (list($keyname, $sts_data) = each($tables)) {
112 $table = $sts_data['Name'];
113 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
114 echo "\n";
116 <tr>
117 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
118 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
119 </td>
120 <?php
121 echo "\n";
122 $mergetable = FALSE;
123 $nonisam = FALSE;
124 if (isset($sts_data['Type'])) {
125 if ($sts_data['Type'] == 'MRG_MyISAM') {
126 $mergetable = TRUE;
127 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
128 $nonisam = TRUE;
132 if (isset($sts_data['Rows'])) {
133 if ($mergetable == FALSE) {
134 if ($cfg['ShowStats'] && $nonisam == FALSE) {
135 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
136 $sum_size += $tblsize;
137 if ($tblsize > 0) {
138 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
139 } else {
140 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
142 } else if ($cfg['ShowStats']) {
143 $formated_size = '&nbsp;-&nbsp;';
144 $unit = '';
146 $sum_entries += $sts_data['Rows'];
148 // MyISAM MERGE Table
149 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
150 $formated_size = '&nbsp;-&nbsp;';
151 $unit = '';
153 else if ($cfg['ShowStats']) {
154 $formated_size = 'unknown';
155 $unit = '';
158 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
159 <?php
160 echo "\n" . ' ';
161 if ($mergetable == TRUE) {
162 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
163 } else {
164 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
167 </td>
168 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
169 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
170 </td>
171 <?php
172 if ($cfg['ShowStats']) {
173 echo "\n";
175 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
176 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
177 </td>
178 <?php
179 echo "\n";
180 } // end if
181 } else {
183 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
184 <?php echo $strInUse . "\n"; ?>
185 </td>
186 <?php
188 echo "\n";
190 </tr>
191 <?php
193 // Show Summary
194 if ($cfg['ShowStats']) {
195 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
197 echo "\n";
199 <tr>
200 <th align="center">
201 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
202 </th>
203 <th align="right" nowrap="nowrap">
204 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
205 </th>
206 <th align="center">
207 <b>--</b>
208 </th>
209 <?php
210 if ($cfg['ShowStats']) {
211 echo "\n";
213 <th align="right" nowrap="nowrap">
214 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
215 </th>
216 <?php
218 echo "\n";
220 </tr>
221 </table>
222 <?php
223 } // end case mysql >= 3.23.03
225 // 3. Shows tables list mysql < 3.23.03
226 else {
227 $i = 0;
228 echo "\n";
231 <!-- The tables list -->
232 <table border="<?php echo $cfg['Border']; ?>">
233 <tr>
234 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
235 <th><?php echo ucfirst($strRecords); ?></th>
236 </tr>
237 <?php
238 while ($i < $num_tables) {
239 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
240 echo "\n";
242 <tr>
243 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
244 <b><?php echo htmlspecialchars($tables[$i]); ?>&nbsp;</b>
245 </td>
246 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
247 &nbsp;<?php PMA_countRecords($db, $tables[$i]); ?>
248 </td>
249 </tr>
250 <?php
251 $i++;
252 } // end while
253 echo "\n";
255 </table>
256 <?php
257 } // end if
261 * Displays the footer
263 echo "\n";
264 require('./footer.inc.php3');