Fix left frame reloading after dropping table (bug #1034531).
[phpmyadmin/crack.git] / db_printview.php
blobdcf9ad77841329fa44bb0ae25e5e3d547fe51dc3
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_once('./libraries/grab_globals.lib.php');
10 require_once('./header.inc.php');
12 // Check parameters
13 require_once('./libraries/common.lib.php');
15 PMA_checkParameters(array('db'));
17 /**
18 * Defines the url to return to in case of error in a sql statement
20 $err_url = 'db_details.php?' . PMA_generate_common_url($db);
22 /**
23 * Settings for relations stuff
25 require_once('./libraries/relation.lib.php');
26 $cfgRelation = PMA_getRelationsParam();
28 /**
29 * Gets the list of the table in the current db and informations about these
30 * tables if possible
32 // staybyte: speedup view on locked tables - 11 June 2001
33 // Special speedup for newer MySQL Versions (in 4.0 format changed)
34 if ($cfg['SkipLockedTables'] == TRUE) {
35 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
36 // Blending out tables in use
37 if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
38 while ($tmp = PMA_DBI_fetch_row($result)) {
39 // if in use memorize tablename
40 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
41 $sot_cache[$tmp[0]] = TRUE;
44 PMA_DBI_free_result($result);
45 unset($result);
47 if (isset($sot_cache)) {
48 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
49 if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
50 while ($tmp = PMA_DBI_fetch_row($result)) {
51 if (!isset($sot_cache[$tmp[0]])) {
52 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
53 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
54 $tables[] = $sts_tmp;
55 } else { // table in use
56 $tables[] = array('Name' => $tmp[0]);
59 PMA_DBI_free_result($result);
60 unset($result);
61 $sot_ready = TRUE;
66 if (!isset($sot_ready)) {
67 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
68 if (PMA_DBI_num_rows($result) > 0) {
69 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
70 $tables[] = $sts_tmp;
72 PMA_DBI_free_result($result);
73 unset($res);
76 $num_tables = (isset($tables) ? count($tables) : 0);
78 if ($cfgRelation['commwork']) {
79 $comment = PMA_getComments($db);
81 /**
82 * Displays DB comment
84 if (is_array($comment)) {
86 <!-- DB comment -->
87 <p><i>
88 <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
89 </i></p>
90 <?php
91 } // end if
94 /**
95 * If there is at least one table, displays the printer friendly view, else
96 * an error message
98 // 1. No table
99 if ($num_tables == 0) {
100 echo $strNoTablesFound;
102 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
103 else {
106 <!-- The tables list -->
107 <table border="<?php echo $cfg['Border']; ?>">
108 <tr>
109 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
110 <th><?php echo $strRecords; ?></th>
111 <th><?php echo $strType; ?></th>
112 <?php
113 if ($cfg['ShowStats']) {
114 echo '<th>' . $strSize . '</th>';
116 echo "\n";
118 <th><?php echo $strComments; ?></th>
119 </tr>
120 <?php
121 $i = $sum_entries = $sum_size = 0;
122 foreach ($tables AS $keyname => $sts_data) {
123 $table = $sts_data['Name'];
124 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
125 echo "\n";
127 <tr>
128 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
129 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
130 </td>
131 <?php
132 echo "\n";
133 $mergetable = FALSE;
134 $nonisam = FALSE;
135 if (isset($sts_data['Type'])) {
136 if ($sts_data['Type'] == 'MRG_MyISAM') {
137 $mergetable = TRUE;
138 } else if (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) {
139 $nonisam = TRUE;
143 if (isset($sts_data['Rows'])) {
144 if ($mergetable == FALSE) {
145 if ($cfg['ShowStats'] && $nonisam == FALSE) {
146 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
147 $sum_size += $tblsize;
148 if ($tblsize > 0) {
149 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
150 } else {
151 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
153 } else if ($cfg['ShowStats']) {
154 $formated_size = '&nbsp;-&nbsp;';
155 $unit = '';
157 $sum_entries += $sts_data['Rows'];
159 // MyISAM MERGE Table
160 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
161 $formated_size = '&nbsp;-&nbsp;';
162 $unit = '';
164 else if ($cfg['ShowStats']) {
165 $formated_size = 'unknown';
166 $unit = '';
169 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
170 <?php
171 echo "\n" . ' ';
172 if ($mergetable == TRUE) {
173 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
174 } else {
175 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
178 </td>
179 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
180 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
181 </td>
182 <?php
183 if ($cfg['ShowStats']) {
184 echo "\n";
186 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
187 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
188 </td>
189 <?php
190 echo "\n";
191 } // end if
192 } else {
194 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
195 <?php echo $strInUse . "\n"; ?>
196 </td>
197 <?php
199 echo "\n";
201 <td bgcolor="<?php echo $bgcolor; ?>">
202 <?php echo $sts_data['Comment']; ?>
203 <?php
204 if (!empty($sts_data['Comment'])) {
205 $needs_break = '<br />';
206 } else {
207 $needs_break = '';
210 if ((isset($sts_data['Create_time']) && !empty($sts_data['Create_time']))
211 || (isset($sts_data['Update_time']) && !empty($sts_data['Update_time']))
212 || (isset($sts_data['Check_time']) && !empty($sts_data['Check_time']))) {
213 echo $needs_break;
215 <table border="0" cellpadding="1" cellspacing="1" width="100%">
216 <?php
218 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
220 <tr>
221 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCreateTime . ': '; ?></td>
222 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
223 </tr>
224 <?php
227 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
229 <tr>
230 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
231 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
232 </tr>
233 <?php
236 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
238 <tr>
239 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCheckTime . ': '; ?></td>
240 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
241 </tr>
242 <?php
245 </table>
246 <?php
249 </td>
250 </tr>
251 <?php
253 // Show Summary
254 if ($cfg['ShowStats']) {
255 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
257 echo "\n";
259 <tr>
260 <th align="center">
261 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
262 </th>
263 <th align="right" nowrap="nowrap">
264 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
265 </th>
266 <th align="center">
267 <b>--</b>
268 </th>
269 <?php
270 if ($cfg['ShowStats']) {
271 echo "\n";
273 <th align="right" nowrap="nowrap">
274 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
275 </th>
276 <?php
278 echo "\n";
280 <th>&nbsp;</th>
281 </tr>
282 </table>
283 <?php
287 * Displays the footer
289 echo "\n";
291 <script type="text/javascript" language="javascript1.2">
292 <!--
293 function printPage()
295 document.getElementById('print').style.visibility = 'hidden';
296 // Do print the page
297 if (typeof(window.print) != 'undefined') {
298 window.print();
300 document.getElementById('print').style.visibility = '';
302 //-->
303 </script>
304 <?php
305 echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
307 require_once('./footer.inc.php');