3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Gets the variables sent or posted to this script, then displays headers
9 require('./libraries/grab_globals.lib.php3');
10 require('./header.inc.php3');
14 if (!defined('PMA_COMMON_LIB_INCLUDED')) {
15 include('./libraries/common.lib.php3');
18 PMA_checkParameters(array('db'));
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);
26 * Settings for relations stuff
28 require('./libraries/relation.lib.php3');
29 $cfgRelation = PMA_getRelationsParam();
32 * Gets the list of the table in the current db and informations about these
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);
61 } else { // table in use
62 $tables[] = array('Name' => $tmp[0]);
65 mysql_free_result($result);
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)) {
78 mysql_free_result($result);
81 $num_tables = (isset($tables) ?
count($tables) : 0);
82 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
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);
98 if (is_array($comment)) {
102 <?php
echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?
>
109 * If there is at least one table, displays the printer friendly view, else
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']; ?>">
123 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
124 <th
><?php
echo $strRecords; ?
></th
>
125 <th
><?php
echo $strType; ?
></th
>
127 if ($cfg['ShowStats']) {
128 echo '<th>' . $strSize . '</th>';
132 <th
><?php
echo $strComments; ?
></th
>
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'];
142 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
143  
;<b
><?php
echo htmlspecialchars($table); ?
> 
;</b
> 
;
149 if (isset($sts_data['Type'])) {
150 if ($sts_data['Type'] == 'MRG_MyISAM') {
152 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
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;
163 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
165 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
167 } else if ($cfg['ShowStats']) {
168 $formated_size = ' - ';
171 $sum_entries +
= $sts_data['Rows'];
173 // MyISAM MERGE Table
174 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
175 $formated_size = ' - ';
178 else if ($cfg['ShowStats']) {
179 $formated_size = 'unknown';
183 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
186 if ($mergetable == TRUE) {
187 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
189 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
193 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>">
194  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
197 if ($cfg['ShowStats']) {
200 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
201  
;<?php
echo $formated_size . ' ' . $unit . "\n"; ?
>
208 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
209 <?php
echo $strInUse . "\n"; ?
>
215 <td bgcolor
="<?php echo $bgcolor; ?>">
216 <?php
echo $sts_data['Comment']; ?
>
218 if (!empty($sts_data['Comment'])) {
219 $needs_break = '<br />';
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']))) {
229 <table border
="0" cellpadding
="1" cellspacing
="1" width
="100%">
232 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
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
>
241 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
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
>
250 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
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
>
268 if ($cfg['ShowStats']) {
269 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
275  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
277 <th align
="right" nowrap
="nowrap">
278 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
284 if ($cfg['ShowStats']) {
287 <th align
="right" nowrap
="nowrap">
288 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
298 } // end case mysql >= 3.23.03
300 // 3. Shows tables list mysql < 3.23.03
306 <!-- The tables
list -->
307 <table border
="<?php echo $cfg['Border']; ?>">
309 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
310 <th
><?php
echo $strRecords; ?
></th
>
313 while ($i < $num_tables) {
314 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
318 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
319 <b
><?php
echo htmlspecialchars($tables[$i]); ?
> 
;</b
>
321 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
322  
;<?php
PMA_countRecords($db, $tables[$i]); ?
>
336 * Displays the footer
340 <script type
="text/javascript" language
="javascript1.2">
344 document
.all
.print.style
.visibility
= 'hidden';
346 if (typeof(window
.print) != 'undefined') {
349 document
.all
.print.style
.visibility
= '';
354 echo '<br /><br /> <input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
356 require('./footer.inc.php3');