sorry, wrong version checked in
[phpmyadmin/arisferyanto.git] / db_printview.php
blob9b35fb610de16619bc6dd674c86404fdc568bced
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once('./libraries/common.lib.php');
7 /**
8 * Gets the variables sent or posted to this script, then displays headers
9 */
10 $print_view = TRUE;
11 require_once('./header.inc.php');
14 PMA_checkParameters(array('db'));
16 /**
17 * Defines the url to return to in case of error in a sql statement
19 $err_url = 'db_details.php?' . PMA_generate_common_url($db);
21 /**
22 * Settings for relations stuff
24 require_once('./libraries/relation.lib.php');
25 $cfgRelation = PMA_getRelationsParam();
27 /**
28 * Gets the list of the table in the current db and informations about these
29 * tables if possible
31 // staybyte: speedup view on locked tables - 11 June 2001
32 // Special speedup for newer MySQL Versions (in 4.0 format changed)
33 if ($cfg['SkipLockedTables'] == TRUE) {
34 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
35 // Blending out tables in use
36 if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
37 while ($tmp = PMA_DBI_fetch_row($result)) {
38 // if in use memorize tablename
39 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
40 $sot_cache[$tmp[0]] = TRUE;
43 PMA_DBI_free_result($result);
44 unset($result);
46 if (isset($sot_cache)) {
47 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
48 if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
49 while ($tmp = PMA_DBI_fetch_row($result)) {
50 if (!isset($sot_cache[$tmp[0]])) {
51 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
52 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
53 $tables[] = $sts_tmp;
54 } else { // table in use
55 $tables[] = array('Name' => $tmp[0]);
58 PMA_DBI_free_result($result);
59 unset($result);
60 $sot_ready = TRUE;
65 if (!isset($sot_ready)) {
66 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
67 if (PMA_DBI_num_rows($result) > 0) {
68 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
69 $tables[] = $sts_tmp;
71 PMA_DBI_free_result($result);
72 unset($res);
75 $num_tables = (isset($tables) ? count($tables) : 0);
77 if ($cfgRelation['commwork']) {
78 $comment = PMA_getComments($db);
80 /**
81 * Displays DB comment
83 if (is_array($comment)) {
85 <!-- DB comment -->
86 <p><i>
87 <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
88 </i></p>
89 <?php
90 } // end if
93 /**
94 * If there is at least one table, displays the printer friendly view, else
95 * an error message
97 // 1. No table
98 if ($num_tables == 0) {
99 echo $strNoTablesFound;
101 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
102 else {
105 <!-- The tables list -->
106 <table border="<?php echo $cfg['Border']; ?>">
107 <tr>
108 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
109 <th><?php echo $strRecords; ?></th>
110 <th><?php echo $strType; ?></th>
111 <?php
112 if ($cfg['ShowStats']) {
113 echo '<th>' . $strSize . '</th>';
115 echo "\n";
117 <th><?php echo $strComments; ?></th>
118 </tr>
119 <?php
120 $i = $sum_entries = $sum_size = 0;
121 foreach ($tables AS $keyname => $sts_data) {
122 $table = $sts_data['Name'];
123 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
124 echo "\n";
126 <tr>
127 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
128 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
129 </td>
130 <?php
131 echo "\n";
132 $mergetable = FALSE;
133 $nonisam = FALSE;
134 if (isset($sts_data['Type'])) {
135 if ($sts_data['Type'] == 'MRG_MyISAM') {
136 $mergetable = TRUE;
137 } else if (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) {
138 $nonisam = TRUE;
142 if (isset($sts_data['Rows'])) {
143 if ($mergetable == FALSE) {
144 if ($cfg['ShowStats'] && $nonisam == FALSE) {
145 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
146 $sum_size += $tblsize;
147 if ($tblsize > 0) {
148 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
149 } else {
150 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
152 } else if ($cfg['ShowStats']) {
153 $formated_size = '&nbsp;-&nbsp;';
154 $unit = '';
156 $sum_entries += $sts_data['Rows'];
158 // MyISAM MERGE Table
159 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
160 $formated_size = '&nbsp;-&nbsp;';
161 $unit = '';
163 else if ($cfg['ShowStats']) {
164 $formated_size = 'unknown';
165 $unit = '';
168 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
169 <?php
170 echo "\n" . ' ';
171 if ($mergetable == TRUE) {
172 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
173 } else {
174 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
177 </td>
178 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
179 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
180 </td>
181 <?php
182 if ($cfg['ShowStats']) {
183 echo "\n";
185 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
186 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
187 </td>
188 <?php
189 echo "\n";
190 } // end if
191 } else {
193 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
194 <?php echo $strInUse . "\n"; ?>
195 </td>
196 <?php
198 echo "\n";
200 <td bgcolor="<?php echo $bgcolor; ?>">
201 <?php echo $sts_data['Comment']; ?>
202 <?php
203 if (!empty($sts_data['Comment'])) {
204 $needs_break = '<br />';
205 } else {
206 $needs_break = '';
209 if ((isset($sts_data['Create_time']) && !empty($sts_data['Create_time']))
210 || (isset($sts_data['Update_time']) && !empty($sts_data['Update_time']))
211 || (isset($sts_data['Check_time']) && !empty($sts_data['Check_time']))) {
212 echo $needs_break;
214 <table border="0" cellpadding="1" cellspacing="1" width="100%" class="noborder">
215 <?php
217 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
219 <tr>
220 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCreateTime . ': '; ?></td>
221 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
222 </tr>
223 <?php
226 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
228 <tr>
229 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
230 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
231 </tr>
232 <?php
235 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
237 <tr>
238 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCheckTime . ': '; ?></td>
239 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
240 </tr>
241 <?php
244 </table>
245 <?php
248 </td>
249 </tr>
250 <?php
252 // Show Summary
253 if ($cfg['ShowStats']) {
254 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
256 echo "\n";
258 <tr>
259 <th align="center">
260 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
261 </th>
262 <th align="right" nowrap="nowrap">
263 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
264 </th>
265 <th align="center">
266 <b>--</b>
267 </th>
268 <?php
269 if ($cfg['ShowStats']) {
270 echo "\n";
272 <th align="right" nowrap="nowrap">
273 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
274 </th>
275 <?php
277 echo "\n";
279 <th>&nbsp;</th>
280 </tr>
281 </table>
282 <?php
286 * Displays the footer
288 echo "\n";
290 <script type="text/javascript" language="javascript1.2">
291 <!--
292 function printPage()
294 // Do print the page
295 if (typeof(window.print) != 'undefined') {
296 window.print();
299 //-->
300 </script>
301 <?php
302 echo '<br /><br />&nbsp;<input type="button" class="print_ignore" style="width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()" />' . "\n";
304 require_once('./footer.inc.php');