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 * 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);
19 * Settings for relations stuff
21 require('./libraries/relation.lib.php3');
22 $cfgRelation = PMA_getRelationsParam();
25 * Gets the list of the table in the current db and informations about these
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);
54 } else { // table in use
55 $tables[] = array('Name' => $tmp[0]);
58 mysql_free_result($result);
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)) {
71 mysql_free_result($result);
74 $num_tables = (isset($tables) ?
count($tables) : 0);
75 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
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);
91 if (is_array($comment)) {
95 <?php
echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?
>
102 * If there is at least one table, displays the printer friendly view, else
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']; ?>">
116 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
117 <th
><?php
echo $strRecords; ?
></th
>
118 <th
><?php
echo $strType; ?
></th
>
120 if ($cfg['ShowStats']) {
121 echo '<th>' . $strSize . '</th>';
125 <th
><?php
echo $strComments; ?
></th
>
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'];
135 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
136  
;<b
><?php
echo htmlspecialchars($table); ?
> 
;</b
> 
;
142 if (isset($sts_data['Type'])) {
143 if ($sts_data['Type'] == 'MRG_MyISAM') {
145 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
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;
156 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
158 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
160 } else if ($cfg['ShowStats']) {
161 $formated_size = ' - ';
164 $sum_entries +
= $sts_data['Rows'];
166 // MyISAM MERGE Table
167 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
168 $formated_size = ' - ';
171 else if ($cfg['ShowStats']) {
172 $formated_size = 'unknown';
176 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
179 if ($mergetable == TRUE) {
180 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
182 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
186 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>">
187  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
190 if ($cfg['ShowStats']) {
193 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
194  
;<?php
echo $formated_size . ' ' . $unit . "\n"; ?
>
201 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
202 <?php
echo $strInUse . "\n"; ?
>
208 <td bgcolor
="<?php echo $bgcolor; ?>">
209 <?php
echo $sts_data['Comment']; ?
>
211 if (!empty($sts_data['Comment'])) {
212 $needs_break = '<br />';
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']))) {
222 <table border
="0" cellpadding
="1" cellspacing
="1" width
="100%">
225 if (isset($sts_data['Create_time']) && !empty($sts_data['Create_time'])) {
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
>
234 if (isset($sts_data['Update_time']) && !empty($sts_data['Update_time'])) {
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
>
243 if (isset($sts_data['Check_time']) && !empty($sts_data['Check_time'])) {
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
>
261 if ($cfg['ShowStats']) {
262 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
268  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
270 <th align
="right" nowrap
="nowrap">
271 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
277 if ($cfg['ShowStats']) {
280 <th align
="right" nowrap
="nowrap">
281 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
291 } // end case mysql >= 3.23.03
293 // 3. Shows tables list mysql < 3.23.03
299 <!-- The tables
list -->
300 <table border
="<?php echo $cfg['Border']; ?>">
302 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
303 <th
><?php
echo $strRecords; ?
></th
>
306 while ($i < $num_tables) {
307 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
311 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
312 <b
><?php
echo htmlspecialchars($tables[$i]); ?
> 
;</b
>
314 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
315  
;<?php
PMA_countRecords($db, $tables[$i]); ?
>
329 * Displays the footer
333 <script type
="text/javascript" language
="javascript1.2">
337 document
.all
.print.style
.visibility
= 'hidden';
339 if (typeof(window
.print) != 'undefined') {
342 document
.all
.print.style
.visibility
= '';
347 echo '<br /><br /> <input type="button" style="visibility: ; width: 100px; height: 25px" name="print" value="' . $strPrint . '" onclick="printPage()">' . "\n";
349 require('./footer.inc.php3');