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);
20 * Gets the list of the table in the current db and informations about these
23 // staybyte: speedup view on locked tables - 11 June 2001
24 if (PMA_MYSQL_INT_VERSION
>= 32303) {
25 // Special speedup for newer MySQL Versions (in 4.0 format changed)
26 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION
>= 32330) {
27 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
28 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
29 // Blending out tables in use
30 if ($result != FALSE && mysql_num_rows($result) > 0) {
31 while ($tmp = PMA_mysql_fetch_array($result)) {
32 // if in use memorize tablename
33 if (eregi('in_use=[1-9]+', $tmp[0])) {
34 $sot_cache[$tmp[0]] = TRUE;
37 mysql_free_result($result);
39 if (isset($sot_cache)) {
40 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
41 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
42 if ($result != FALSE && mysql_num_rows($result) > 0) {
43 while ($tmp = PMA_mysql_fetch_array($result)) {
44 if (!isset($sot_cache[$tmp[0]])) {
45 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
46 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
47 $sts_tmp = PMA_mysql_fetch_array($sts_result);
49 } else { // table in use
50 $tables[] = array('Name' => $tmp[0]);
53 mysql_free_result($result);
59 if (!isset($sot_ready)) {
60 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
61 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
62 if ($result != FALSE && mysql_num_rows($result) > 0) {
63 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
66 mysql_free_result($result);
69 $num_tables = (isset($tables) ?
count($tables) : 0);
70 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
72 $result = PMA_mysql_list_tables($db);
73 $num_tables = ($result) ? @mysql_numrows
($result) : 0;
74 for ($i = 0; $i < $num_tables; $i++
) {
75 $tables[] = PMA_mysql_tablename($result, $i);
77 mysql_free_result($result);
82 * If there is at least one table, displays the printer friendly view, else
86 if ($num_tables == 0) {
87 echo $strNoTablesFound;
89 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
90 else if (PMA_MYSQL_INT_VERSION
>= 32303) {
93 <!-- The tables
list -->
94 <table border
="<?php echo $cfg['Border']; ?>">
96 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
97 <th
><?php
echo $strRecords; ?
></th
>
98 <th
><?php
echo $strType; ?
></th
>
100 if ($cfg['ShowStats']) {
101 echo '<th>' . $strSize . '</th>';
107 $i = $sum_entries = $sum_size = 0;
108 while (list($keyname, $sts_data) = each($tables)) {
109 $table = $sts_data['Name'];
110 $bgcolor = ($i++ %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
114 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
115  
;<b
><?php
echo htmlspecialchars($table); ?
> 
;</b
> 
;
121 if (isset($sts_data['Type'])) {
122 if ($sts_data['Type'] == 'MRG_MyISAM') {
124 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
129 if (isset($sts_data['Rows'])) {
130 if ($mergetable == FALSE) {
131 if ($cfg['ShowStats'] && $nonisam == FALSE) {
132 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
133 $sum_size +
= $tblsize;
135 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
137 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
139 } else if ($cfg['ShowStats']) {
140 $formated_size = ' - ';
143 $sum_entries +
= $sts_data['Rows'];
145 // MyISAM MERGE Table
146 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
147 $formated_size = ' - ';
150 else if ($cfg['ShowStats']) {
151 $formated_size = 'unknown';
155 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
158 if ($mergetable == TRUE) {
159 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
161 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
165 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>">
166  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
169 if ($cfg['ShowStats']) {
172 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
173  
;<?php
echo $formated_size . ' ' . $unit . "\n"; ?
>
180 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
181 <?php
echo $strInUse . "\n"; ?
>
191 if ($cfg['ShowStats']) {
192 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
198  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
200 <th align
="right" nowrap
="nowrap">
201 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
207 if ($cfg['ShowStats']) {
210 <th align
="right" nowrap
="nowrap">
211 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
220 } // end case mysql >= 3.23.03
222 // 3. Shows tables list mysql < 3.23.03
228 <!-- The tables
list -->
229 <table border
="<?php echo $cfg['Border']; ?>">
231 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
232 <th
><?php
echo $strRecords; ?
></th
>
235 while ($i < $num_tables) {
236 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
240 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
241 <b
><?php
echo htmlspecialchars($tables[$i]); ?
> 
;</b
>
243 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
244  
;<?php
PMA_countRecords($db, $tables[$i]); ?
>
258 * Displays the footer
261 require('./footer.inc.php3');