3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Gets the variables sent or posted to this script, then displays headers
9 require_once('./libraries/grab_globals.lib.php');
10 require_once('./header.inc.php');
13 require_once('./libraries/common.lib.php');
15 PMA_checkParameters(array('db'));
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);
23 * Settings for relations stuff
25 require_once('./libraries/relation.lib.php');
26 $cfgRelation = PMA_getRelationsParam();
29 * Gets the list of the table in the current db and informations about these
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 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
36 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
37 // Blending out tables in use
38 if ($result != FALSE && mysql_num_rows($result) > 0) {
39 while ($tmp = PMA_mysql_fetch_array($result)) {
40 // if in use memorize tablename
41 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
42 $sot_cache[$tmp[0]] = TRUE;
45 mysql_free_result($result);
47 if (isset($sot_cache)) {
48 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
49 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
50 if ($result != FALSE && mysql_num_rows($result) > 0) {
51 while ($tmp = PMA_mysql_fetch_array($result)) {
52 if (!isset($sot_cache[$tmp[0]])) {
53 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
54 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
55 $sts_tmp = PMA_mysql_fetch_array($sts_result);
57 } else { // table in use
58 $tables[] = array('Name' => $tmp[0]);
61 mysql_free_result($result);
67 if (!isset($sot_ready)) {
68 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
69 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
70 if ($result != FALSE && mysql_num_rows($result) > 0) {
71 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
74 mysql_free_result($result);
77 $num_tables = (isset($tables) ?
count($tables) : 0);
79 if ($cfgRelation['commwork']) {
80 $comment = PMA_getComments($db);
85 if (is_array($comment)) {
89 <?php
echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?
>
96 * If there is at least one table, displays the printer friendly view, else
100 if ($num_tables == 0) {
101 echo $strNoTablesFound;
103 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
107 <!-- The tables
list -->
108 <table border
="<?php echo $cfg['Border']; ?>">
110 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
111 <th
><?php
echo $strRecords; ?
></th
>
112 <th
><?php
echo $strType; ?
></th
>
114 if ($cfg['ShowStats']) {
115 echo '<th>' . $strSize . '</th>';
119 <th
><?php
echo $strComments; ?
></th
>
122 $i = $sum_entries = $sum_size = 0;
123 foreach($tables AS $keyname => $sts_data) {
124 $table = $sts_data['Name'];
125 $bgcolor = ($i++ %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
129 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
130  
;<b
><?php
echo htmlspecialchars($table); ?
> 
;</b
> 
;
136 if (isset($sts_data['Type'])) {
137 if ($sts_data['Type'] == 'MRG_MyISAM') {
139 } else if (!preg_match('@ISAM|HEAP@i', $sts_data['Type'])) {
144 if (isset($sts_data['Rows'])) {
145 if ($mergetable == FALSE) {
146 if ($cfg['ShowStats'] && $nonisam == FALSE) {
147 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
148 $sum_size +
= $tblsize;
150 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
152 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
154 } else if ($cfg['ShowStats']) {
155 $formated_size = ' - ';
158 $sum_entries +
= $sts_data['Rows'];
160 // MyISAM MERGE Table
161 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
162 $formated_size = ' - ';
165 else if ($cfg['ShowStats']) {
166 $formated_size = 'unknown';
170 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
173 if ($mergetable == TRUE) {
174 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
176 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
180 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>">
181  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
184 if ($cfg['ShowStats']) {
187 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
188  
;<?php
echo $formated_size . ' ' . $unit . "\n"; ?
>
195 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
196 <?php
echo $strInUse . "\n"; ?
>
202 <td bgcolor
="<?php echo $bgcolor; ?>">
203 <?php
echo $sts_data['Comment']; ?
>
205 if (!empty($sts_data['Comment'])) {
206 $needs_break = '<br />';
211 if ((isset($sts_data['Create_time']) && !empty($sts_data['Create_time']))
212 ||
(isset($sts_data['Update_time']) && !empty($sts_data['Update_time']))
213 ||
(isset($sts_data['Check_time']) && !empty($sts_data['Check_time']))) {
216 <table border
="0" cellpadding
="1" cellspacing
="1" width
="100%">
219 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
222 <td style
="font-size: <?php echo $font_smaller; ?>" align
="right"><?php
echo $strStatCreateTime . ': '; ?
></td
>
223 <td style
="font-size: <?php echo $font_smaller; ?>" align
="right"><?php
echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?
></td
>
228 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
231 <td style
="font-size: <?php echo $font_smaller; ?>" align
="right"><?php
echo $strStatUpdateTime . ': '; ?
></td
>
232 <td style
="font-size: <?php echo $font_smaller; ?>" align
="right"><?php
echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?
></td
>
237 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
240 <td style
="font-size: <?php echo $font_smaller; ?>" align
="right"><?php
echo $strStatCheckTime . ': '; ?
></td
>
241 <td style
="font-size: <?php echo $font_smaller; ?>" align
="right"><?php
echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?
></td
>
255 if ($cfg['ShowStats']) {
256 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
262  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
264 <th align
="right" nowrap
="nowrap">
265 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
271 if ($cfg['ShowStats']) {
274 <th align
="right" nowrap
="nowrap">
275 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
288 * Displays the footer
292 <script type
="text/javascript" language
="javascript1.2">
296 document
.getElementById('print').style
.visibility
= 'hidden';
298 if (typeof(window
.print) != 'undefined') {
301 document
.getElementById('print').style
.visibility
= '';
306 echo '<br /><br /> <input type="button" style="visibility: ; width: 100px; height: 25px" id="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
308 require_once('./footer.inc.php');