lang
[phpmyadmin/crack.git] / db_printview.php3
blobfacda936ef19bfe89e223246c8402a0ae4b78968
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?' . PMA_generate_common_url($db);
18 /**
19 * Settings for relations stuff
21 require('./libraries/relation.lib.php3');
22 $cfgRelation = PMA_getRelationsParam();
24 /**
25 * Gets the list of the table in the current db and informations about these
26 * tables if possible
28 // staybyte: speedup view on locked tables - 11 June 2001
29 if (PMA_MYSQL_INT_VERSION >= 32303) {
30 // Special speedup for newer MySQL Versions (in 4.0 format changed)
31 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
32 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
33 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
34 // Blending out tables in use
35 if ($result != FALSE && mysql_num_rows($result) > 0) {
36 while ($tmp = PMA_mysql_fetch_array($result)) {
37 // if in use memorize tablename
38 if (eregi('in_use=[1-9]+', $tmp[0])) {
39 $sot_cache[$tmp[0]] = TRUE;
42 mysql_free_result($result);
44 if (isset($sot_cache)) {
45 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
46 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
47 if ($result != FALSE && mysql_num_rows($result) > 0) {
48 while ($tmp = PMA_mysql_fetch_array($result)) {
49 if (!isset($sot_cache[$tmp[0]])) {
50 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
51 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
52 $sts_tmp = PMA_mysql_fetch_array($sts_result);
53 $tables[] = $sts_tmp;
54 } else { // table in use
55 $tables[] = array('Name' => $tmp[0]);
58 mysql_free_result($result);
59 $sot_ready = TRUE;
64 if (!isset($sot_ready)) {
65 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
66 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
67 if ($result != FALSE && mysql_num_rows($result) > 0) {
68 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
69 $tables[] = $sts_tmp;
71 mysql_free_result($result);
74 $num_tables = (isset($tables) ? count($tables) : 0);
75 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
76 else {
77 $result = PMA_mysql_list_tables($db);
78 $num_tables = ($result) ? @mysql_numrows($result) : 0;
79 for ($i = 0; $i < $num_tables; $i++) {
80 $tables[] = PMA_mysql_tablename($result, $i);
82 mysql_free_result($result);
85 if ($cfgRelation['commwork']) {
86 $comment = PMA_getComments($db);
88 /**
89 * Displays DB comment
91 if (is_array($comment)) {
93 <!-- DB comment -->
94 <p><i>
95 <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
96 </i></p>
97 <?php
98 } // end if
102 * If there is at least one table, displays the printer friendly view, else
103 * an error message
105 // 1. No table
106 if ($num_tables == 0) {
107 echo $strNoTablesFound;
109 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
110 else if (PMA_MYSQL_INT_VERSION >= 32303) {
113 <!-- The tables list -->
114 <table border="<?php echo $cfg['Border']; ?>">
115 <tr>
116 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
117 <th><?php echo $strRecords; ?></th>
118 <th><?php echo $strType; ?></th>
119 <?php
120 if ($cfg['ShowStats']) {
121 echo '<th>' . $strSize . '</th>';
123 echo "\n";
125 <th><?php echo $strComments; ?></th>
126 </tr>
127 <?php
128 $i = $sum_entries = $sum_size = 0;
129 while (list($keyname, $sts_data) = each($tables)) {
130 $table = $sts_data['Name'];
131 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
132 echo "\n";
134 <tr>
135 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
136 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
137 </td>
138 <?php
139 echo "\n";
140 $mergetable = FALSE;
141 $nonisam = FALSE;
142 if (isset($sts_data['Type'])) {
143 if ($sts_data['Type'] == 'MRG_MyISAM') {
144 $mergetable = TRUE;
145 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
146 $nonisam = TRUE;
150 if (isset($sts_data['Rows'])) {
151 if ($mergetable == FALSE) {
152 if ($cfg['ShowStats'] && $nonisam == FALSE) {
153 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
154 $sum_size += $tblsize;
155 if ($tblsize > 0) {
156 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
157 } else {
158 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
160 } else if ($cfg['ShowStats']) {
161 $formated_size = '&nbsp;-&nbsp;';
162 $unit = '';
164 $sum_entries += $sts_data['Rows'];
166 // MyISAM MERGE Table
167 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
168 $formated_size = '&nbsp;-&nbsp;';
169 $unit = '';
171 else if ($cfg['ShowStats']) {
172 $formated_size = 'unknown';
173 $unit = '';
176 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
177 <?php
178 echo "\n" . ' ';
179 if ($mergetable == TRUE) {
180 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
181 } else {
182 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
185 </td>
186 <td nowrap="nowrap" bgcolor="<?php echo $bgcolor; ?>">
187 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
188 </td>
189 <?php
190 if ($cfg['ShowStats']) {
191 echo "\n";
193 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
194 &nbsp;<?php echo $formated_size . ' ' . $unit . "\n"; ?>
195 </td>
196 <?php
197 echo "\n";
198 } // end if
199 } else {
201 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
202 <?php echo $strInUse . "\n"; ?>
203 </td>
204 <?php
206 echo "\n";
208 <td bgcolor="<?php echo $bgcolor; ?>">
209 <?php echo $sts_data['Comment']; ?>
210 <?php
211 if (!empty($sts_data['Comment'])) {
212 $needs_break = '<br />';
213 } else {
214 $needs_break = '';
217 if ((isset($sts_data['Create_time']) && !empty($sts_data['Create_time']))
218 || (isset($sts_data['Update_time']) && !empty($sts_data['Update_time']))
219 || (isset($sts_data['Check_time']) && !empty($sts_data['Check_time']))) {
220 echo $needs_break;
222 <table border="0" cellpadding="1" cellspacing="1" width="100%">
223 <?php
225 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
227 <tr>
228 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCreateTime . ': '; ?></td>
229 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
230 </tr>
231 <?php
234 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
236 <tr>
237 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
238 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
239 </tr>
240 <?php
243 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
245 <tr>
246 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo $strStatCheckTime . ': '; ?></td>
247 <td style="font-size: <?php echo $font_smaller; ?>" align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
248 </tr>
249 <?php
252 </table>
253 <?php
256 </td>
257 </tr>
258 <?php
260 // Show Summary
261 if ($cfg['ShowStats']) {
262 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
264 echo "\n";
266 <tr>
267 <th align="center">
268 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
269 </th>
270 <th align="right" nowrap="nowrap">
271 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
272 </th>
273 <th align="center">
274 <b>--</b>
275 </th>
276 <?php
277 if ($cfg['ShowStats']) {
278 echo "\n";
280 <th align="right" nowrap="nowrap">
281 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
282 </th>
283 <?php
285 echo "\n";
287 <th>&nbsp;</th>
288 </tr>
289 </table>
290 <?php
291 } // end case mysql >= 3.23.03
293 // 3. Shows tables list mysql < 3.23.03
294 else {
295 $i = 0;
296 echo "\n";
299 <!-- The tables list -->
300 <table border="<?php echo $cfg['Border']; ?>">
301 <tr>
302 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
303 <th><?php echo $strRecords; ?></th>
304 </tr>
305 <?php
306 while ($i < $num_tables) {
307 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
308 echo "\n";
310 <tr>
311 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
312 <b><?php echo htmlspecialchars($tables[$i]); ?>&nbsp;</b>
313 </td>
314 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
315 &nbsp;<?php PMA_countRecords($db, $tables[$i]); ?>
316 </td>
317 </tr>
318 <?php
319 $i++;
320 } // end while
321 echo "\n";
323 </table>
324 <?php
325 } // end if
329 * Displays the footer
331 echo "\n";
333 <script type="text/javascript" language="javascript1.2">
334 <!--
335 function printPage()
337 document.all.print.style.visibility = 'hidden';
338 // Do print the page
339 if (typeof(window.print) != 'undefined') {
340 window.print();
342 document.all.print.style.visibility = '';
344 //-->
345 </script>
346 <?php
347 echo '<br /><br />&nbsp;<input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
349 require('./footer.inc.php3');