MMCache
[phpmyadmin/crack.git] / db_printview.php3
blob8acca9c3c091e476381f7654a112906f35489e94
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');
12 // Check parameters
14 if (!defined('PMA_COMMON_LIB_INCLUDED')) {
15 include('./libraries/common.lib.php3');
18 PMA_checkParameters(array('db'));
20 /**
21 * Defines the url to return to in case of error in a sql statement
23 $err_url = 'db_details.php3?' . PMA_generate_common_url($db);
25 /**
26 * Settings for relations stuff
28 require('./libraries/relation.lib.php3');
29 $cfgRelation = PMA_getRelationsParam();
31 /**
32 * Gets the list of the table in the current db and informations about these
33 * tables if possible
35 // staybyte: speedup view on locked tables - 11 June 2001
36 if (PMA_MYSQL_INT_VERSION >= 32303) {
37 // Special speedup for newer MySQL Versions (in 4.0 format changed)
38 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
39 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
40 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
41 // Blending out tables in use
42 if ($result != FALSE && mysql_num_rows($result) > 0) {
43 while ($tmp = PMA_mysql_fetch_array($result)) {
44 // if in use memorize tablename
45 if (eregi('in_use=[1-9]+', $tmp[0])) {
46 $sot_cache[$tmp[0]] = TRUE;
49 mysql_free_result($result);
51 if (isset($sot_cache)) {
52 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
53 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
54 if ($result != FALSE && mysql_num_rows($result) > 0) {
55 while ($tmp = PMA_mysql_fetch_array($result)) {
56 if (!isset($sot_cache[$tmp[0]])) {
57 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
58 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
59 $sts_tmp = PMA_mysql_fetch_array($sts_result);
60 $tables[] = $sts_tmp;
61 } else { // table in use
62 $tables[] = array('Name' => $tmp[0]);
65 mysql_free_result($result);
66 $sot_ready = TRUE;
71 if (!isset($sot_ready)) {
72 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
73 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
74 if ($result != FALSE && mysql_num_rows($result) > 0) {
75 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
76 $tables[] = $sts_tmp;
78 mysql_free_result($result);
81 $num_tables = (isset($tables) ? count($tables) : 0);
82 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
83 else {
84 $result = PMA_mysql_list_tables($db);
85 $num_tables = ($result) ? @mysql_numrows($result) : 0;
86 for ($i = 0; $i < $num_tables; $i++) {
87 $tables[] = PMA_mysql_tablename($result, $i);
89 mysql_free_result($result);
92 if ($cfgRelation['commwork']) {
93 $comment = PMA_getComments($db);
95 /**
96 * Displays DB comment
98 if (is_array($comment)) {
100 <!-- DB comment -->
101 <p><i>
102 <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
103 </i></p>
104 <?php
105 } // end if
109 * If there is at least one table, displays the printer friendly view, else
110 * an error message
112 // 1. No table
113 if ($num_tables == 0) {
114 echo $strNoTablesFound;
116 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
117 else if (PMA_MYSQL_INT_VERSION >= 32303) {
120 <!-- The tables list -->
121 <table border="<?php echo $cfg['Border']; ?>">
122 <tr>
123 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
124 <th><?php echo $strRecords; ?></th>
125 <th><?php echo $strType; ?></th>
126 <?php
127 if ($cfg['ShowStats']) {
128 echo '<th>' . $strSize . '</th>';
130 echo "\n";
132 <th><?php echo $strComments; ?></th>
133 </tr>
134 <?php
135 $i = $sum_entries = $sum_size = 0;
136 while (list($keyname, $sts_data) = each($tables)) {
137 $table = $sts_data['Name'];
138 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
139 echo "\n";
141 <tr>
142 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
143 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
144 </td>
145 <?php
146 echo "\n";
147 $mergetable = FALSE;
148 $nonisam = FALSE;
149 if (isset($sts_data['Type'])) {
150 if ($sts_data['Type'] == 'MRG_MyISAM') {
151 $mergetable = TRUE;
152 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
153 $nonisam = TRUE;
157 if (isset($sts_data['Rows'])) {
158 if ($mergetable == FALSE) {
159 if ($cfg['ShowStats'] && $nonisam == FALSE) {
160 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
161 $sum_size += $tblsize;
162 if ($tblsize > 0) {
163 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
164 } else {
165 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
167 } else if ($cfg['ShowStats']) {
168 $formated_size = '&nbsp;-&nbsp;';
169 $unit = '';
171 $sum_entries += $sts_data['Rows'];
173 // MyISAM MERGE Table
174 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
175 $formated_size = '&nbsp;-&nbsp;';
176 $unit = '';
178 else if ($cfg['ShowStats']) {
179 $formated_size = 'unknown';
180 $unit = '';
183 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
184 <?php
185 echo "\n" . ' ';
186 if ($mergetable == TRUE) {
187 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
188 } else {
189 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
192 </td>
193 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
194 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
195 </td>
196 <?php
197 if ($cfg['ShowStats']) {
198 echo "\n";
200 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
201 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
202 </td>
203 <?php
204 echo "\n";
205 } // end if
206 } else {
208 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
209 <?php echo $strInUse . "\n"; ?>
210 </td>
211 <?php
213 echo "\n";
215 <td bgcolor="<?php echo $bgcolor; ?>">
216 <?php echo $sts_data['Comment']; ?>
217 <?php
218 if (!empty($sts_data['Comment'])) {
219 $needs_break = '<br />';
220 } else {
221 $needs_break = '';
224 if ((isset($sts_data['Create_time']) && !empty($sts_data['Create_time']))
225 || (isset($sts_data['Update_time']) && !empty($sts_data['Update_time']))
226 || (isset($sts_data['Check_time']) && !empty($sts_data['Check_time']))) {
227 echo $needs_break;
229 <table border="0" cellpadding="1" cellspacing="1" width="100%">
230 <?php
232 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
234 <tr>
235 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCreateTime . ': '; ?></td>
236 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
237 </tr>
238 <?php
241 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
243 <tr>
244 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
245 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
246 </tr>
247 <?php
250 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
252 <tr>
253 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCheckTime . ': '; ?></td>
254 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
255 </tr>
256 <?php
259 </table>
260 <?php
263 </td>
264 </tr>
265 <?php
267 // Show Summary
268 if ($cfg['ShowStats']) {
269 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
271 echo "\n";
273 <tr>
274 <th align="center">
275 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
276 </th>
277 <th align="right" nowrap="nowrap">
278 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
279 </th>
280 <th align="center">
281 <b>--</b>
282 </th>
283 <?php
284 if ($cfg['ShowStats']) {
285 echo "\n";
287 <th align="right" nowrap="nowrap">
288 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
289 </th>
290 <?php
292 echo "\n";
294 <th>&nbsp;</th>
295 </tr>
296 </table>
297 <?php
298 } // end case mysql >= 3.23.03
300 // 3. Shows tables list mysql < 3.23.03
301 else {
302 $i = 0;
303 echo "\n";
306 <!-- The tables list -->
307 <table border="<?php echo $cfg['Border']; ?>">
308 <tr>
309 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
310 <th><?php echo $strRecords; ?></th>
311 </tr>
312 <?php
313 while ($i < $num_tables) {
314 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
315 echo "\n";
317 <tr>
318 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
319 <b><?php echo htmlspecialchars($tables[$i]); ?>&nbsp;</b>
320 </td>
321 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
322 &nbsp;<?php PMA_countRecords($db, $tables[$i]); ?>
323 </td>
324 </tr>
325 <?php
326 $i++;
327 } // end while
328 echo "\n";
330 </table>
331 <?php
332 } // end if
336 * Displays the footer
338 echo "\n";
340 <script type="text/javascript" language="javascript1.2">
341 <!--
342 function printPage()
344 document.all.print.style.visibility = 'hidden';
345 // Do print the page
346 if (typeof(window.print) != 'undefined') {
347 window.print();
349 document.all.print.style.visibility = '';
351 //-->
352 </script>
353 <?php
354 echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
356 require('./footer.inc.php3');