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 . '&convcharset=' . $convcharset
18 . '&server=' . $server
19 . '&db=' . urlencode($db);
23 * Gets the list of the table in the current db and informations about these
26 // staybyte: speedup view on locked tables - 11 June 2001
27 if (PMA_MYSQL_INT_VERSION
>= 32303) {
28 // Special speedup for newer MySQL Versions (in 4.0 format changed)
29 if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION
>= 32330) {
30 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
31 $result = PMA_mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
32 // Blending out tables in use
33 if ($result != FALSE && mysql_num_rows($result) > 0) {
34 while ($tmp = PMA_mysql_fetch_array($result)) {
35 // if in use memorize tablename
36 if (eregi('in_use=[1-9]+', $tmp)) {
37 $sot_cache[$tmp[0]] = TRUE;
40 mysql_free_result($result);
42 if (isset($sot_cache)) {
43 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
44 $result = PMA_mysql_query($query) or PMA_mysqlDie('', $local_query, '', $err_url);
45 if ($result != FALSE && mysql_num_rows($result) > 0) {
46 while ($tmp = PMA_mysql_fetch_array($result)) {
47 if (!isset($sot_cache[$tmp[0]])) {
48 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
49 $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
50 $sts_tmp = PMA_mysql_fetch_array($sts_result);
52 } else { // table in use
53 $tables[] = array('Name' => $tmp[0]);
56 mysql_free_result($result);
62 if (!isset($sot_ready)) {
63 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
64 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
65 if ($result != FALSE && mysql_num_rows($result) > 0) {
66 while ($sts_tmp = PMA_mysql_fetch_array($result)) {
69 mysql_free_result($result);
72 $num_tables = (isset($tables) ?
count($tables) : 0);
73 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
75 $result = PMA_mysql_list_tables($db);
76 $num_tables = ($result) ? @mysql_numrows
($result) : 0;
77 for ($i = 0; $i < $num_tables; $i++
) {
78 $tables[] = PMA_mysql_tablename($result, $i);
80 mysql_free_result($result);
85 * If there is at least one table, displays the printer friendly view, else
89 if ($num_tables == 0) {
90 echo $strNoTablesFound;
92 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
93 else if (PMA_MYSQL_INT_VERSION
>= 32303) {
96 <!-- The tables
list -->
97 <table border
="<?php echo $cfg['Border']; ?>">
99 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
100 <th
><?php
echo ucfirst($strRecords); ?
></th
>
101 <th
><?php
echo ucfirst($strType); ?
></th
>
103 if ($cfg['ShowStats']) {
104 echo '<th>' . ucfirst($strSize) . '</th>';
110 $i = $sum_entries = $sum_size = 0;
111 while (list($keyname, $sts_data) = each($tables)) {
112 $table = $sts_data['Name'];
113 $bgcolor = ($i++ %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
117 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
118  
;<b
><?php
echo htmlspecialchars($table); ?
> 
;</b
> 
;
124 if (isset($sts_data['Type'])) {
125 if ($sts_data['Type'] == 'MRG_MyISAM') {
127 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
132 if (isset($sts_data['Rows'])) {
133 if ($mergetable == FALSE) {
134 if ($cfg['ShowStats'] && $nonisam == FALSE) {
135 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
136 $sum_size +
= $tblsize;
138 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
140 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
142 } else if ($cfg['ShowStats']) {
143 $formated_size = ' - ';
146 $sum_entries +
= $sts_data['Rows'];
148 // MyISAM MERGE Table
149 else if ($cfg['ShowStats'] && $mergetable == TRUE) {
150 $formated_size = ' - ';
153 else if ($cfg['ShowStats']) {
154 $formated_size = 'unknown';
158 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
161 if ($mergetable == TRUE) {
162 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
164 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
168 <td nowrap
="nowrap" bgcolor
="<?php echo $bgcolor; ?>">
169  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
172 if ($cfg['ShowStats']) {
175 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
176  
;<?php
echo $formated_size . ' ' . $unit . "\n"; ?
>
183 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
184 <?php
echo $strInUse . "\n"; ?
>
194 if ($cfg['ShowStats']) {
195 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
201  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
203 <th align
="right" nowrap
="nowrap">
204 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
210 if ($cfg['ShowStats']) {
213 <th align
="right" nowrap
="nowrap">
214 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
223 } // end case mysql >= 3.23.03
225 // 3. Shows tables list mysql < 3.23.03
231 <!-- The tables
list -->
232 <table border
="<?php echo $cfg['Border']; ?>">
234 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
235 <th
><?php
echo ucfirst($strRecords); ?
></th
>
238 while ($i < $num_tables) {
239 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $bgcolor = $cfg['BgcolorTwo'];
243 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
244 <b
><?php
echo htmlspecialchars($tables[$i]); ?
> 
;</b
>
246 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
247  
;<?php
PMA_countRecords($db, $tables[$i]); ?
>
261 * Displays the footer
264 require('./footer.inc.php3');