6 * Gets the variables sent or posted to this script, then displays headers
8 require('./libraries/grab_globals.lib.php3');
9 require('./header.inc.php3');
13 * Defines the url to return to in case of error in a sql statement
15 $err_url = 'db_details.php3'
17 . '&server=' . $server
18 . '&db=' . urlencode($db);
22 * Gets the list of the table in the current db and informations about these
25 // staybyte: speedup view on locked tables - 11 June 2001
26 if (PMA_MYSQL_INT_VERSION
>= 32303) {
27 // Special speedup for newer MySQL Versions (in 4.0 format changed)
28 if ($cfgSkipLockedTables == TRUE && PMA_MYSQL_INT_VERSION
>= 32330) {
29 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
30 $result = mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
31 // Blending out tables in use
32 if ($result != FALSE && mysql_num_rows($result) > 0) {
33 while ($tmp = mysql_fetch_array($result)) {
34 // if in use memorize tablename
35 if (eregi('in_use=[1-9]+', $tmp)) {
36 $sot_cache[$tmp[0]] = TRUE;
39 mysql_free_result($result);
41 if (isset($sot_cache)) {
42 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
43 $result = mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
44 if ($result != FALSE && mysql_num_rows($result) > 0) {
45 while ($tmp = mysql_fetch_array($result)) {
46 if (!isset($sot_cache[$tmp[0]])) {
47 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
48 $sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
49 $sts_tmp = mysql_fetch_array($sts_result);
51 } else { // table in use
52 $tables[] = array('Name' => $tmp[0]);
55 mysql_free_result($result);
61 if (!isset($sot_ready)) {
62 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
63 $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
64 if ($result != FALSE && mysql_num_rows($result) > 0) {
65 while ($sts_tmp = mysql_fetch_array($result)) {
68 mysql_free_result($result);
71 $num_tables = (isset($tables) ?
count($tables) : 0);
72 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
74 $result = mysql_list_tables($db);
75 $num_tables = @mysql_numrows
($result);
76 for ($i = 0; $i < $num_tables; $i++
) {
77 $tables[] = mysql_tablename($result, $i);
79 mysql_free_result($result);
84 * If there is at least one table, displays the printer friendly view, else
88 if ($num_tables == 0) {
89 echo $strNoTablesFound;
91 // 2. Shows table informations on mysql >= 3.23 - staybyte - 11 June 2001
92 else if (PMA_MYSQL_INT_VERSION
>= 32300) {
95 <!-- The tables
list -->
96 <table border
="<?php echo $cfgBorder; ?>">
98 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
99 <th
><?php
echo ucfirst($strRecords); ?
></th
>
100 <th
><?php
echo ucfirst($strType); ?
></th
>
103 echo '<th>' . ucfirst($strSize) . '</th>';
109 $i = $sum_entries = $sum_size = 0;
110 while (list($keyname, $sts_data) = each($tables)) {
111 $table = $sts_data['Name'];
112 $bgcolor = ($i++ %
2) ?
$cfgBgcolorOne : $cfgBgcolorTwo;
116 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
117  
;<b
><?php
echo htmlspecialchars($table); ?
> 
;</b
> 
;
123 if (isset($sts_data['Type'])) {
124 if ($sts_data['Type'] == 'MRG_MyISAM') {
126 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
131 if (isset($sts_data['Rows'])) {
132 if ($mergetable == FALSE) {
133 if ($cfgShowStats && $nonisam == FALSE) {
134 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
135 $sum_size +
= $tblsize;
137 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
139 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
141 } else if ($cfgShowStats) {
142 $formated_size = ' - ';
145 $sum_entries +
= $sts_data['Rows'];
147 // MyISAM MERGE Table
148 else if ($cfgShowStats && $mergetable == TRUE) {
149 $formated_size = ' - ';
152 else if ($cfgShowStats) {
153 $formated_size = 'unknown';
157 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
160 if ($mergetable == TRUE) {
161 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
163 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
167 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>">
168  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
174 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
175  
;<?php
echo $formated_size . ' ' . $unit . "\n"; ?
>
182 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
183 <?php
echo $strInUse . "\n"; ?
>
194 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
200  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
202 <th align
="right" nowrap
="nowrap">
203 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
212 <th align
="right" nowrap
="nowrap">
213 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
222 } // end case mysql >= 3.23
224 // 3. Shows tables list mysql < 3.23
230 <!-- The tables
list -->
231 <table border
="<?php echo $cfgBorder; ?>">
233 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
234 <th
><?php
echo ucfirst($strRecords); ?
></th
>
237 while ($i < $num_tables) {
238 $bgcolor = ($i %
2) ?
$cfgBgcolorOne : $bgcolor = $cfgBgcolorTwo;
242 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
243 <b
><?php
echo htmlspecialchars($tables[$i]); ?
> 
;</b
>
245 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
246  
;<?php
PMA_countRecords($db, $tables[$i]); ?
>
260 * Displays the footer
263 require('./footer.inc.php3');