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'
18 . '&convcharset=' . $convcharset
19 . '&server=' . $server
20 . '&db=' . urlencode($db);
24 * Gets the list of the table in the current db and informations about these
27 // staybyte: speedup view on locked tables - 11 June 2001
28 if (PMA_MYSQL_INT_VERSION
>= 32303) {
29 // Special speedup for newer MySQL Versions (in 4.0 format changed)
30 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION
>= 32330) {
31 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
32 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
33 // Blending out tables in use
34 if ($result != FALSE && mysql_num_rows($result) > 0) {
35 while ($tmp = PMA_mysql_fetch_array($result)) {
36 // if in use memorize tablename
37 if (eregi('in_use=[1-9]+', $tmp[0])) {
38 $sot_cache[$tmp[0]] = TRUE;
41 mysql_free_result($result);
43 if (isset($sot_cache)) {
44 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
45 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
46 if ($result != FALSE && mysql_num_rows($result) > 0) {
47 while ($tmp = PMA_mysql_fetch_array($result)) {
48 if (!isset($sot_cache[$tmp[0]])) {
49 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
50 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
51 $sts_tmp = PMA_mysql_fetch_array($sts_result);
53 } else { // table in use
54 $tables[] = array('Name' => $tmp[0]);
57 mysql_free_result($result);
63 if (!isset($sot_ready)) {
64 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
65 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
66 if ($result != FALSE && mysql_num_rows($result) > 0) {
67 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
70 mysql_free_result($result);
73 $num_tables = (isset($tables) ?
count($tables) : 0);
74 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
76 $result = PMA_mysql_list_tables($db);
77 $num_tables = ($result) ? @mysql_numrows
($result) : 0;
78 for ($i = 0; $i < $num_tables; $i++
) {
79 $tables[] = PMA_mysql_tablename($result, $i);
81 mysql_free_result($result);
86 * If there is at least one table, displays the printer friendly view, else
90 if ($num_tables == 0) {
91 echo $strNoTablesFound;
93 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
94 else if (PMA_MYSQL_INT_VERSION
>= 32303) {
97 <!-- The tables
list -->
98 <table border
="<?php echo $cfg['Border']; ?>">
100 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
101 <th
><?php
echo ucfirst($strRecords); ?
></th
>
102 <th
><?php
echo ucfirst($strType); ?
></th
>
104 if ($cfg['ShowStats']) {
105 echo '<th>' . ucfirst($strSize) . '</th>';
111 $i = $sum_entries = $sum_size = 0;
112 while (list($keyname, $sts_data) = each($tables)) {
113 $table = $sts_data['Name'];
114 $bgcolor = ($i++ %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
118 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
119  
;<b
><?php
echo htmlspecialchars($table); ?
> 
;</b
> 
;
125 if (isset($sts_data['Type'])) {
126 if ($sts_data['Type'] == 'MRG_MyISAM') {
128 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
133 if (isset($sts_data['Rows'])) {
134 if ($mergetable == FALSE) {
135 if ($cfg['ShowStats'] && $nonisam == FALSE) {
136 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
137 $sum_size +
= $tblsize;
139 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
141 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
143 } else if ($cfg['ShowStats']) {
144 $formated_size = ' - ';
147 $sum_entries +
= $sts_data['Rows'];
149 // MyISAM MERGE Table
150 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
151 $formated_size = ' - ';
154 else if ($cfg['ShowStats']) {
155 $formated_size = 'unknown';
159 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
162 if ($mergetable == TRUE) {
163 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
165 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
169 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>">
170  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
173 if ($cfg['ShowStats']) {
176 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
177  
;<?php
echo $formated_size . ' ' . $unit . "\n"; ?
>
184 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
185 <?php
echo $strInUse . "\n"; ?
>
195 if ($cfg['ShowStats']) {
196 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
202  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
204 <th align
="right" nowrap
="nowrap">
205 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
211 if ($cfg['ShowStats']) {
214 <th align
="right" nowrap
="nowrap">
215 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
224 } // end case mysql >= 3.23.03
226 // 3. Shows tables list mysql < 3.23.03
232 <!-- The tables
list -->
233 <table border
="<?php echo $cfg['Border']; ?>">
235 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
236 <th
><?php
echo ucfirst($strRecords); ?
></th
>
239 while ($i < $num_tables) {
240 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
244 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
245 <b
><?php
echo htmlspecialchars($tables[$i]); ?
> 
;</b
>
247 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
248  
;<?php
PMA_countRecords($db, $tables[$i]); ?
>
262 * Displays the footer
265 require('./footer.inc.php3');