Splitted the large "database details" page in parts

This commit is contained in:
Loïc Chapeaux
2002-05-01 17:14:45 +00:00
parent da47126935
commit 6b00b75f7d
9 changed files with 850 additions and 721 deletions

View File

@@ -22,6 +22,8 @@ $Source$
Kris Wood <kris at navi.net>.
* mosts scripts: optimization - do not call "mysql_numrows",
"mysql_results" and "mysql_fetch_array" on invalid queries.
* db_details*.php3; mult_submits.inc.php3; sql.php3: splitted the large
"database details" page in parts.
2002-04-30 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* lang/italian.inc.php3: updated thanks to Pietro Danesi.

View File

@@ -1,517 +1,10 @@
<?php
/* $Id$ */
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php3');
require('./libraries/common.lib.php3');
require('./libraries/bookmark.lib.php3');
require('./db_details_common.php3');
/**
* Defines the urls to return to in case of error in a sql statement
*/
$err_url_0 = 'main.php3'
. '?lang=' . $lang
. '&amp;server=' . $server;
$err_url = 'db_details.php3'
. '?lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db);
/**
* Ensures the database exists (else move to the "parent" script) and displays
* headers
*/
if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page
if (!empty($db)) {
$is_db = @mysql_select_db($db);
}
if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php3?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit();
}
} // end if (ensures db exists)
// Displays headers
if (!isset($message)) {
$js_to_run = 'functions.js';
include('./header.inc.php3');
// Reloads the navigation frame via JavaScript if required
if (isset($reload) && $reload) {
echo "\n";
?>
<script type="text/javascript" language="javascript1.2">
<!--
window.parent.frames['nav'].location.replace('./left.php3?lang=<?php echo $lang; ?>&server=<?php echo $server; ?>&db=<?php echo urlencode($db); ?>');
//-->
</script>
<?php
}
echo "\n";
} else {
PMA_showMessage($message);
}
/**
* Drop/delete multiple tables if required
*/
if ((!empty($submit_mult) && isset($selected_tbl))
|| isset($mult_btn)) {
$action = 'db_details.php3';
include('./mult_submits.inc.php3');
}
/**
* Gets the list of the table in the current db and informations about these
* tables if possible
*/
// staybyte: speedup view on locked tables - 11 June 2001
if (PMA_MYSQL_INT_VERSION >= 32303) {
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
$local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
$result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
// Blending out tables in use
if ($result != FALSE && mysql_num_rows($result) > 0) {
while ($tmp = mysql_fetch_row($result)) {
// if in use memorize tablename
if (eregi('in_use=[1-9]+', $tmp[1])) {
$sot_cache[$tmp[0]] = TRUE;
}
}
mysql_free_result($result);
if (isset($sot_cache)) {
$local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
$result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
if ($result != FALSE && mysql_num_rows($result) > 0) {
while ($tmp = mysql_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
$sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
$sts_tmp = mysql_fetch_array($sts_result);
$tables[] = $sts_tmp;
} else { // table in use
$tables[] = array('Name' => $tmp[0]);
}
}
mysql_free_result($result);
$sot_ready = TRUE;
}
}
}
}
if (!isset($sot_ready)) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
$result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
if ($result != FALSE && mysql_num_rows($result) > 0) {
while ($sts_tmp = mysql_fetch_array($result)) {
$tables[] = $sts_tmp;
}
mysql_free_result($result);
}
}
$num_tables = (isset($tables) ? count($tables) : 0);
} // end if (PMA_MYSQL_INT_VERSION >= 32303)
else {
$result = mysql_list_tables($db);
$num_tables = ($result) ? @mysql_numrows($result) : 0;
for ($i = 0; $i < $num_tables; $i++) {
$tables[] = mysql_tablename($result, $i);
}
mysql_free_result($result);
}
/**
* Displays an html table with all the tables contained into the current
* database
*/
?>
<!-- TABLE LIST -->
<?php
// 1. No tables
if ($num_tables == 0) {
echo $strNoTablesFound . "\n";
}
// 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
else if (PMA_MYSQL_INT_VERSION >= 32303) {
?>
<form method="post" action="db_details.php3" name="tablesForm">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<table border="<?php echo $cfg['Border']; ?>">
<tr>
<td></td>
<th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
<th colspan="6"><?php echo ucfirst($strAction); ?></th>
<th><?php echo ucfirst($strRecords); ?></th>
<th><?php echo ucfirst($strType); ?></th>
<?php
if ($cfg['ShowStats']) {
echo '<th>' . ucfirst($strSize) . '</th>';
}
echo "\n";
?>
</tr>
<?php
$i = $sum_entries = $sum_size = 0;
$checked = (!empty($checkall) ? ' checked="checked"' : '');
while (list($keyname, $sts_data) = each($tables)) {
$table = $sts_data['Name'];
$table_encoded = urlencode($table);
$table_name = htmlspecialchars($table);
// Sets parameters for links
$url_query = 'lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db)
. '&amp;table=' . $table_encoded
. '&amp;goto=db_details.php3';
$bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
echo "\n";
?>
<tr>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
</td>
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
&nbsp;<b><label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>&nbsp;
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php
if (!empty($sts_data['Rows'])) {
echo '<a href="sql.php3?' . $url_query . '&amp;sql_query='
. urlencode('SELECT * FROM ' . PMA_backquote($table))
. '&amp;pos=0">' . $strBrowse . '</a>';
} else {
echo $strBrowse;
}
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php
if (!empty($sts_data['Rows'])) {
echo '<a href="tbl_select.php3?' . $url_query . '">'
. $strSelect . '</a>';
} else {
echo $strSelect;
}
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_change.php3?<?php echo $url_query; ?>">
<?php echo $strInsert; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_properties.php3?<?php echo $url_query; ?>">
<?php echo $strProperties; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;reload=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
<?php echo $strDrop; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php
if (!empty($sts_data['Rows'])) {
echo '<a href="sql.php3?' . $url_query
. '&amp;sql_query=';
if (PMA_MYSQL_INT_VERSION >= 40000) {
echo urlencode('TRUNCATE ' . PMA_backquote($table))
. '&amp;zero_rows='
. urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
. '" onclick="return confirmLink(this, \'TRUNCATE ';
} else {
echo urlencode('DELETE FROM ' . PMA_backquote($table))
. '&amp;zero_rows='
. urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
. '" onclick="return confirmLink(this, \'DELETE FROM ';
}
echo PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
} else {
echo $strEmpty;
}
?>
</td>
<?php
echo "\n";
// loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
// statistics whatever is the table type
if (isset($sts_data['Rows'])) {
// MyISAM, ISAM or Heap table: Row count, data size and index size
// is accurate.
if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) {
if ($cfg['ShowStats']) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
}
$sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
}
// InnoDB table: Row count is not accurate but data and index
// sizes are.
else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
if ($cfg['ShowStats']) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
}
$display_rows = '&nbsp;-&nbsp;';
}
// Merge or BerkleyDB table: Only row count is accurate.
else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) {
if ($cfg['ShowStats']) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
}
$sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
}
// Unknown table type.
else {
if ($cfg['ShowStats']) {
$formated_size = 'unknown';
$unit = '';
}
$display_rows = 'unknown';
}
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
<?php
echo "\n" . ' ' . $display_rows . "\n";
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
&nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
</td>
<?php
if ($cfg['ShowStats']) {
echo "\n";
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
&nbsp;&nbsp;
<a href="tbl_properties.php3?<?php echo $url_query; ?>#showusage"><?php echo $formated_size . ' ' . $unit; ?></a>
</td>
<?php
echo "\n";
} // end if
} else {
?>
<td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php echo $strInUse . "\n"; ?>
</td>
<?php
}
echo "\n";
?>
</tr>
<?php
}
// Show Summary
if ($cfg['ShowStats']) {
list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
}
echo "\n";
?>
<tr>
<td></td>
<th align="center" nowrap="nowrap">
&nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
</th>
<th colspan="6" align="center">
<b><?php echo $strSum; ?></b>
</th>
<th align="right" nowrap="nowrap">
<b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
</th>
<th align="center">
<b>--</b>
</th>
<?php
if ($cfg['ShowStats']) {
echo "\n";
?>
<th align="right" nowrap="nowrap">
&nbsp;
<b><?php echo $sum_formated . ' ' . $unit; ?></b>
</th>
<?php
}
echo "\n";
?>
</tr>
<?php
// Check all tables url
$checkall_url = 'db_details.php3'
. '?lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db);
echo "\n";
?>
<tr>
<td colspan="<?php echo (($cfg['ShowStats']) ? '11' : '10'); ?>" valign="bottom">
<img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
<a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
<?php echo $strCheckAll; ?></a>
&nbsp;/&nbsp;
<a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
<?php echo $strUncheckAll; ?></a>
&nbsp;&nbsp;&nbsp;
<img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
<select name="submit_mult" dir="ltr" onchange="this.form.submit();">
<?php
echo "\n";
echo ' <option value="' . $strWithChecked . '" selected="selected">'
. $strWithChecked . '</option>' . "\n";
echo ' <option value="' . $strDrop . '" >'
. $strDrop . '</option>' . "\n";
echo ' <option value="' . $strEmpty . '" >'
. $strEmpty . '</option>' . "\n";
echo ' <option value="' . $strPrintView . '" >'
. $strPrintView . '</option>' . "\n";
echo ' <option value="' . $strOptimizeTable . '" >'
. $strOptimizeTable . '</option>' . "\n";
?>
</select>
<script type="text/javascript" language="javascript">
<!--
// Fake js to allow the use of the <noscript> tag
//-->
</script>
<noscript>
<input type="submit" value="<?php echo $strGo; ?>" />
</noscript>
</td>
</tr>
</table>
</form>
<?php
} // end case mysql >= 3.23.03
// 3. Shows tables list mysql < 3.23.03
else {
$i = 0;
echo "\n";
?>
<form action="db_details.php3">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<table border="<?php echo $cfg['Border']; ?>">
<tr>
<td></td>
<th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
<th colspan="6"><?php echo ucfirst($strAction); ?></th>
<th><?php echo ucfirst($strRecords); ?></th>
</tr>
<?php
$checked = (!empty($checkall) ? ' checked="checked"' : '');
while ($i < $num_tables) {
$table = $tables[$i];
$table_encoded = urlencode($table);
$table_name = htmlspecialchars($table);
// Sets parameters for links
$url_query = 'lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db)
. '&amp;table=' . $table_encoded
. '&amp;goto=db_details.php3';
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
echo "\n";
?>
<tr>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
</td>
<td bgcolor="<?php echo $bgcolor; ?>" class="data">
<b>&nbsp;<label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&amp;pos=0"><?php echo $strBrowse; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_select.php3?<?php echo $url_query; ?>"><?php echo $strSelect; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_change.php3?<?php echo $url_query; ?>"><?php echo $strInsert; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_properties.php3?<?php echo $url_query; ?>"><?php echo $strProperties; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;reload=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, $table_name)); ?>"><?php echo $strDrop; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('DELETE FROM ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenEmptied, $table_name)); ?>"><?php echo $strEmpty; ?></a>
</td>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
<?php PMA_countRecords($db, $table); echo "\n"; ?>
</td>
</tr>
<?php
$i++;
} // end while
echo "\n";
// Check all tables url
$checkall_url = 'db_details.php3'
. '?lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db);
?>
<tr>
<td colspan="9">
<img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
<a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
<?php echo $strCheckAll; ?></a>
&nbsp;/&nbsp;
<a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
<?php echo $strUncheckAll; ?></a>
</td>
</tr>
<tr>
<td colspan="9">
<img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
<i><?php echo $strWithChecked; ?></i>&nbsp;&nbsp;
<input type="submit" name="submit_mult" value="<?php echo $strDrop; ?>" />
&nbsp;<?php $strOr . "\n"; ?>&nbsp;
<input type="submit" name="submit_mult" value="<?php echo $strEmpty; ?>" />
</td>
</tr>
</table>
</form>
<?php
} // end case mysql < 3.23.03
echo "\n";
?>
<hr />
<?php
/**
* Database work
*/
@@ -534,17 +27,18 @@ if (isset($show_query) && $show_query == 'y') {
} else {
$query_to_display = '';
}
?>
<!-- DATABASE WORK -->
<ul>
<?php
if ($num_tables > 0) {
?>
<!-- Printable view of a table -->
<li>
<div style="margin-bottom: 10px"><a href="db_printview.php3?<?php echo $url_query; ?>"><?php echo $strPrintView; ?></a></div>
</li>
<?php
/**
* Gets informations about the database and, if it is empty, move to the
* "db_details_structure.php3" script where table can be created
*/
$sub_part = '';
require('./db_details_db_info.php3');
if ($num_tables == 0) {
$is_info = TRUE;
include('./db_details_structure.php3');
exit();
}
// loic1: defines wether file upload is available or not
@@ -552,8 +46,10 @@ $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
// loic1: php 3.0.15 and lower bug -> always enabled
: (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize')));
?>
?>
<!-- DATABASE WORK -->
<ul>
<!-- Query box, sql file loader and bookmark support -->
<li>
<a name="querybox"></a>
@@ -628,192 +124,9 @@ if ($num_tables > 0) {
<li>
<div style="margin-bottom: 10px"><a href="tbl_qbe.php3?<?php echo $url_query; ?>"><?php echo $strQBE; ?></a></div>
</li>
<?php
} // end if
<!-- Dump of a database -->
<li>
<a name="dumpdb"></a>
<form method="post" action="tbl_dump.php3" name="db_dump">
<?php echo $strViewDumpDB; ?><br />
<table>
<tr>
<?php
$colspan = '';
if ($num_tables > 1) {
$colspan = ' colspan="2"';
echo "\n";
?>
<td>
<select name="table_select[]" size="6" multiple="multiple">
<?php
$i = 0;
echo "\n";
$is_selected = (!empty($selectall) ? ' selected="selected"' : '');
while ($i < $num_tables) {
$table = htmlspecialchars((PMA_MYSQL_INT_VERSION >= 32303) ? $tables[$i]['Name'] : $tables[$i]);
echo ' <option value="' . $table . '"' . $is_selected . '>' . $table . '</option>' . "\n";
$i++;
}
?>
</select>
</td>
<?php
} // end if
echo "\n";
?>
<td valign="middle">
<input type="radio" name="what" value="structure" id="radio_dump_structure" checked="checked" />
<label for="radio_dump_structure"><?php echo $strStrucOnly; ?></label><br />
<input type="radio" name="what" id="radio_dump_data" value="data" />
<label for="radio_dump_data"><?php echo $strStrucData; ?></label><br />
<input type="radio" name="what" id="radio_dump_dataonly" value="dataonly" />
<label for="radio_dump_dataonly"><?php echo $strDataOnly; ?></label><br />
<input type="radio" name="what" id="radio_dump_xml" value="xml" />
<label for="radio_dump_xml"><?php echo $strExportToXML; ?></label>
<?php
if ($num_tables > 1) {
echo "\n";
?>
<br />
<a href="<?php echo $checkall_url; ?>&amp;selectall=1#dumpdb" onclick="setSelectOptions('db_dump', 'table_select[]', true); return false;"><?php echo $strSelectAll; ?></a>
&nbsp;/&nbsp;
<a href="<?php echo $checkall_url; ?>#dumpdb" onclick="setSelectOptions('db_dump', 'table_select[]', false); return false;"><?php echo $strUnselectAll; ?></a>
<?php
} // end if
echo "\n";
?>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="drop" value="1" id="checkbox_dump_drop" />
<label for="checkbox_dump_drop"><?php echo $strStrucDrop; ?></label>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" />
<label for="checkbox_dump_showcolumns"><?php echo $strCompleteInserts; ?></label>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" />
<label for="checkbox_dump_extended_ins"><?php echo $strExtendedInserts; ?></label>
</td>
</tr>
<?php
// Add backquotes checkbox
if (PMA_MYSQL_INT_VERSION >= 32306) {
?>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="use_backquotes" value="1" id="checkbox_dump_use_backquotes" />
<label for="checkbox_dump_use_backquotes"><?php echo $strUseBackquotes; ?></label>
</td>
</tr>
<?php
} // end backquotes feature
echo "\n";
?>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="asfile" value="sendit" id="checkbox_dump_asfile" onclick="return checkTransmitDump(this.form, 'transmit')" />
<label for="checkbox_dump_asfile"><?php echo $strSend; ?></label>
<?php
// gzip and bzip2 encode features
if (PMA_PHP_INT_VERSION >= 40004) {
$is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress'));
$is_gzip = (isset($cfg['GZipDump']) && $cfg['GZipDump'] && @function_exists('gzencode'));
$is_bzip = (isset($cfg['BZipDump']) && $cfg['BZipDump'] && @function_exists('bzcompress'));
if ($is_zip || $is_gzip || $is_bzip) {
echo "\n" . ' (' . "\n";
if ($is_zip) {
?>
<input type="checkbox" name="zip" value="zip" id="checkbox_dump_zip" onclick="return checkTransmitDump(this.form, 'zip')" />
<?php echo '<label for="checkbox_dump_zip">' . $strZip . '</label>' . (($is_gzip || $is_bzip) ? '&nbsp;' : '') . "\n"; ?>
<?php
}
if ($is_gzip) {
echo "\n"
?>
<input type="checkbox" name="gzip" value="gzip" id="checkbox_dump_gzip" onclick="return checkTransmitDump(this.form, 'gzip')" />
<?php echo '<label for="checkbox_dump_gzip">' . $strGzip . '</label>' . (($is_bzip) ? '&nbsp;' : '') . "\n"; ?>
<?php
}
if ($is_bzip) {
echo "\n"
?>
<input type="checkbox" name="bzip" value="bzip" id="checkbox_dump_bzip" onclick="return checkTransmitDump(this.form, 'bzip')" />
<?php echo '<label for="checkbox_dump_bzip">' . $strBzip . '</label>' . "\n"; ?>
<?php
}
echo "\n" . ' )';
}
}
echo "\n";
// Encoding setting form appended by Y.Kawada
if (function_exists('PMA_set_enc_form')) {
echo ' <br />' . "\n"
. PMA_set_enc_form(' ');
}
?>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="submit" value="<?php echo $strGo; ?>" />
</td>
</tr>
</table>
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="lang" value="<?php echo $lang;?>" />
<input type="hidden" name="db" value="<?php echo $db;?>" />
</form>
</li>
<?php
} // end of create dump if there is at least one table in the db
?>
<!-- Create a new table -->
<li>
<form method="post" action="tbl_create.php3"
onsubmit="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<?php
echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . '&nbsp;:<br />' . "\n";
echo ' ' . $strName . '&nbsp;:&nbsp;' . "\n";
echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
echo ' ' . '<br />' . "\n";
echo ' ' . $strFields . '&nbsp;:&nbsp;' . "\n";
echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
echo ' ' . '&nbsp;<input type="submit" value="' . $strGo . '" />' . "\n";
?>
</form>
</li>
<?php
// Check if the user is a Superuser
// TODO: set a global variable with this information
// loic1: optimized query
$result = @mysql_query('USE mysql');
$is_superuser = (!mysql_error());
// Display the DROP DATABASE link only if allowed to do so
if ($cfg['AllowUserDropDatabase'] || $is_superuser) {
?>
<!-- Drop database -->
<li>
<a href="sql.php3?server=<?php echo $server; ?>&amp;lang=<?php echo $lang; ?>&amp;db=<?php echo urlencode($db); ?>&amp;sql_query=<?php echo urlencode('DROP DATABASE ' . PMA_backquote($db)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strDatabaseHasBeenDropped, htmlspecialchars(PMA_backquote($db)))); ?>&amp;goto=main.php3&amp;back=db_details.php3&amp;reload=1"
onclick="return confirmLink(this, 'DROP DATABASE <?php echo PMA_jsFormat($db); ?>')">
<?php echo sprintf($strDropDB, htmlspecialchars($db)); ?></a>
<?php echo PMA_showDocuShort('D/R/DROP_DATABASE.html') . "\n"; ?>
</li>
<?php
}
echo "\n";
?>

68
db_details_common.php3 Normal file
View File

@@ -0,0 +1,68 @@
<?php
/* $Id$ */
/**
* Gets some core libraries
*/
require('./libraries/grab_globals.lib.php3');
require('./libraries/common.lib.php3');
require('./libraries/bookmark.lib.php3');
/**
* Defines the urls to return to in case of error in a sql statement
*/
$err_url_0 = 'main.php3'
. '?lang=' . $lang
. '&amp;server=' . $server;
$err_url = 'db_details.php3'
. '?lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db);
/**
* Ensures the database exists (else move to the "parent" script) and displays
* headers
*/
if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page
if (!empty($db)) {
$is_db = @mysql_select_db($db);
}
if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php3?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit();
}
} // end if (ensures db exists)
// Displays headers
if (!isset($message)) {
$js_to_run = 'functions.js';
include('./header.inc.php3');
// Reloads the navigation frame via JavaScript if required
if (isset($reload) && $reload) {
echo "\n";
?>
<script type="text/javascript" language="javascript1.2">
<!--
window.parent.frames['nav'].location.replace('./left.php3?lang=<?php echo $lang; ?>&server=<?php echo $server; ?>&db=<?php echo urlencode($db); ?>');
//-->
</script>
<?php
}
echo "\n";
} else {
PMA_showMessage($message);
}
/**
* Set parameters for links
*/
$url_query = 'lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db);
?>

73
db_details_db_info.php3 Normal file
View File

@@ -0,0 +1,73 @@
<?php
/* $Id$ */
/**
* Gets the list of the table in the current db and informations about these
* tables if possible
*/
// staybyte: speedup view on locked tables - 11 June 2001
if (PMA_MYSQL_INT_VERSION >= 32303) {
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
$local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
$result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
// Blending out tables in use
if ($result != FALSE && mysql_num_rows($result) > 0) {
while ($tmp = mysql_fetch_row($result)) {
// if in use memorize tablename
if (eregi('in_use=[1-9]+', $tmp[1])) {
$sot_cache[$tmp[0]] = TRUE;
}
}
mysql_free_result($result);
if (isset($sot_cache)) {
$local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
$result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
if ($result != FALSE && mysql_num_rows($result) > 0) {
while ($tmp = mysql_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
$sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
$sts_tmp = mysql_fetch_array($sts_result);
$tables[] = $sts_tmp;
} else { // table in use
$tables[] = array('Name' => $tmp[0]);
}
}
mysql_free_result($result);
$sot_ready = TRUE;
}
}
}
}
if (!isset($sot_ready)) {
$local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
$result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
if ($result != FALSE && mysql_num_rows($result) > 0) {
while ($sts_tmp = mysql_fetch_array($result)) {
$tables[] = $sts_tmp;
}
mysql_free_result($result);
}
}
$num_tables = (isset($tables) ? count($tables) : 0);
} // end if (PMA_MYSQL_INT_VERSION >= 32303)
else {
$result = mysql_list_tables($db);
$num_tables = ($result) ? @mysql_numrows($result) : 0;
for ($i = 0; $i < $num_tables; $i++) {
$tables[] = mysql_tablename($result, $i);
}
mysql_free_result($result);
}
/**
* Displays top menu links
*/
echo '<!-- Top menu links -->' . "\n";
require('./db_details_links.php3');
?>

164
db_details_export.php3 Normal file
View File

@@ -0,0 +1,164 @@
<?php
/* $Id$ */
/**
* Gets some core libraries
*/
$sub_part = '_export';
require('./db_details_common.php3');
require('./db_details_db_info.php3');
/**
* Displays the form
*/
?>
<!-- Dump of a database -->
<form method="post" action="tbl_dump.php3" name="db_dump">
<?php echo $strViewDumpDB; ?><br />
<table>
<tr>
<?php
$colspan = '';
if ($num_tables > 1) {
$colspan = ' colspan="2"';
?>
<td>
<select name="table_select[]" size="6" multiple="multiple">
<?php
$i = 0;
echo "\n";
$is_selected = (!empty($selectall) ? ' selected="selected"' : '');
while ($i < $num_tables) {
$table = htmlspecialchars((PMA_MYSQL_INT_VERSION >= 32303) ? $tables[$i]['Name'] : $tables[$i]);
echo ' <option value="' . $table . '"' . $is_selected . '>' . $table . '</option>' . "\n";
$i++;
} // end while
?>
</select>
</td>
<?php
} // end if
echo "\n";
?>
<td valign="middle">
<input type="radio" name="what" value="structure" id="radio_dump_structure" checked="checked" />
<label for="radio_dump_structure"><?php echo $strStrucOnly; ?></label><br />
<input type="radio" name="what" id="radio_dump_data" value="data" />
<label for="radio_dump_data"><?php echo $strStrucData; ?></label><br />
<input type="radio" name="what" id="radio_dump_dataonly" value="dataonly" />
<label for="radio_dump_dataonly"><?php echo $strDataOnly; ?></label><br />
<input type="radio" name="what" id="radio_dump_xml" value="xml" />
<label for="radio_dump_xml"><?php echo $strExportToXML; ?></label>
<?php
if ($num_tables > 1) {
?>
<br />
<a href="<?php echo $checkall_url; ?>&amp;selectall=1#dumpdb" onclick="setSelectOptions('db_dump', 'table_select[]', true); return false;"><?php echo $strSelectAll; ?></a>
&nbsp;/&nbsp;
<a href="<?php echo $checkall_url; ?>#dumpdb" onclick="setSelectOptions('db_dump', 'table_select[]', false); return false;"><?php echo $strUnselectAll; ?></a>
<?php
} // end if
echo "\n";
?>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="drop" value="1" id="checkbox_dump_drop" />
<label for="checkbox_dump_drop"><?php echo $strStrucDrop; ?></label>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="showcolumns" value="yes" id="checkbox_dump_showcolumns" />
<label for="checkbox_dump_showcolumns"><?php echo $strCompleteInserts; ?></label>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="extended_ins" value="yes" id="checkbox_dump_extended_ins" />
<label for="checkbox_dump_extended_ins"><?php echo $strExtendedInserts; ?></label>
</td>
</tr>
<?php
// Add backquotes checkbox
if (PMA_MYSQL_INT_VERSION >= 32306) {
?>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="use_backquotes" value="1" id="checkbox_dump_use_backquotes" />
<label for="checkbox_dump_use_backquotes"><?php echo $strUseBackquotes; ?></label>
</td>
</tr>
<?php
} // end backquotes feature
echo "\n";
?>
<tr>
<td<?php echo $colspan; ?>>
<input type="checkbox" name="asfile" value="sendit" id="checkbox_dump_asfile" onclick="return checkTransmitDump(this.form, 'transmit')" />
<label for="checkbox_dump_asfile"><?php echo $strSend; ?></label>
<?php
// zip, gzip and bzip2 encode features
if (PMA_PHP_INT_VERSION >= 40004) {
$is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress'));
$is_gzip = (isset($cfg['GZipDump']) && $cfg['GZipDump'] && @function_exists('gzencode'));
$is_bzip = (isset($cfg['BZipDump']) && $cfg['BZipDump'] && @function_exists('bzcompress'));
if ($is_zip || $is_gzip || $is_bzip) {
echo "\n" . ' (' . "\n";
if ($is_zip) {
?>
<input type="checkbox" name="zip" value="zip" id="checkbox_dump_zip" onclick="return checkTransmitDump(this.form, 'zip')" />
<?php
echo '<label for="checkbox_dump_zip">' . $strZip . '</label>'
. (($is_gzip || $is_bzip) ? '&nbsp;' : '') . "\n";
}
if ($is_gzip) {
echo "\n"
?>
<input type="checkbox" name="gzip" value="gzip" id="checkbox_dump_gzip" onclick="return checkTransmitDump(this.form, 'gzip')" />
<?php
echo '<label for="checkbox_dump_gzip">' . $strGzip . '</label>'
. (($is_bzip) ? '&nbsp;' : '') . "\n";
}
if ($is_bzip) {
echo "\n"
?>
<input type="checkbox" name="bzip" value="bzip" id="checkbox_dump_bzip" onclick="return checkTransmitDump(this.form, 'bzip')" />
<?php
echo '<label for="checkbox_dump_bzip">' . $strBzip . '</label>' . "\n";
}
echo "\n" . ' )';
}
} // end *zip feature
echo "\n";
// Encoding setting form appended by Y.Kawada
if (function_exists('PMA_set_enc_form')) {
echo ' <br />' . "\n"
. PMA_set_enc_form(' ');
}
?>
</td>
</tr>
<tr>
<td<?php echo $colspan; ?>>
<input type="submit" value="<?php echo $strGo; ?>" />
</td>
</tr>
</table>
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="lang" value="<?php echo $lang;?>" />
<input type="hidden" name="db" value="<?php echo $db;?>" />
</form>
<?php
/**
* Displays the footer
*/
require('./footer.inc.php3');
?>

61
db_details_links.php3 Normal file
View File

@@ -0,0 +1,61 @@
<?php
/* $Id$ */
/**
* Prepares links
*/
// Export link if there is at least one table
if ($num_tables > 0) {
$lnk3 = '<a href="db_details_export.php3?' . $url_query . '">';
}
else {
$lnk3 = '';
}
// Drop link if allowed
if (!$cfg['AllowUserDropDatabase']) {
// Check if the user is a Superuser
$result = @mysql_query('USE mysql');
$cfg['AllowUserDropDatabase'] = (!mysql_error());
}
if ($cfg['AllowUserDropDatabase']) {
$lnk4 = '<a href="sql.php3?' . $url_query . '&amp;sql_query='
. urlencode('DROP DATABASE ' . PMA_backquote($db))
. '&amp;zero_rows='
. urlencode(sprintf($strDatabaseHasBeenDropped, htmlspecialchars(PMA_backquote($db))))
. '&amp;goto=main.php3&amp;back=db_details' . $sub_part . '.php3&amp;reload=1"' . "\n"
. ' class="drop" '
. 'onclick="return confirmLink(this, \'DROP DATABASE ' . PMA_jsFormat($db) . '\')">';
}
else {
$lnk4 = '';
}
/**
* Displays links
*/
?>
<p>
[&nbsp;
<a href="db_details.php3?<?php echo $url_query; ?>">
<b><?php echo $strHome; ?></b></a>&nbsp;|
<a href="db_details_structure.php3?<?php echo $url_query; ?>">
<b><?php echo $strStructure; ?></b></a>&nbsp;|
<?php echo $lnk3 . "\n"; ?>
<b><?php echo $strExport; ?></b><?php if ($lnk3) echo '</a>'; echo "\n"; ?>
&nbsp;]&nbsp;&nbsp;&nbsp;
<?php
if ($lnk4) {
?>
[&nbsp;
<?php echo $lnk4 . "\n"; ?>
<b><?php echo $strDrop; ?></b></a>
&nbsp;]
<?php
} // end if
echo "\n";
?>
</p>
<hr />

454
db_details_structure.php3 Normal file
View File

@@ -0,0 +1,454 @@
<?php
/* $Id$ */
/**
* Prepares the tables list
*/
if (empty($is_info)) {
include('./db_details_common.php3');
//Drop/delete multiple tables if required
if ((!empty($submit_mult) && isset($selected_tbl))
|| isset($mult_btn)) {
$action = 'db_details_structure.php3';
include('./mult_submits.inc.php3');
}
// Gets the database structure
$sub_part = '_structure';
include('./db_details_db_info.php3');
echo "\n";
}
/**
* Displays the tables list
*/
?>
<!-- TABLE LIST -->
<?php
// 1. No tables
if ($num_tables == 0) {
echo $strNoTablesFound . "\n";
}
// 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
else if (PMA_MYSQL_INT_VERSION >= 32303) {
?>
<form method="post" action="db_details_structure.php3" name="tablesForm">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<table border="<?php echo $cfg['Border']; ?>">
<tr>
<td></td>
<th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
<th colspan="6"><?php echo ucfirst($strAction); ?></th>
<th><?php echo ucfirst($strRecords); ?></th>
<th><?php echo ucfirst($strType); ?></th>
<?php
if ($cfg['ShowStats']) {
echo '<th>' . ucfirst($strSize) . '</th>';
}
echo "\n";
?>
</tr>
<?php
$i = $sum_entries = $sum_size = 0;
$checked = (!empty($checkall) ? ' checked="checked"' : '');
while (list($keyname, $sts_data) = each($tables)) {
$table = $sts_data['Name'];
$table_encoded = urlencode($table);
$table_name = htmlspecialchars($table);
// Sets parameters for links
$url_query = 'lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db)
. '&amp;table=' . $table_encoded
. '&amp;goto=db_details_structure.php3';
$bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
echo "\n";
?>
<tr>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
</td>
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
&nbsp;<b><label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>&nbsp;
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php
if (!empty($sts_data['Rows'])) {
echo '<a href="sql.php3?' . $url_query . '&amp;sql_query='
. urlencode('SELECT * FROM ' . PMA_backquote($table))
. '&amp;pos=0">' . $strBrowse . '</a>';
} else {
echo $strBrowse;
}
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php
if (!empty($sts_data['Rows'])) {
echo '<a href="tbl_select.php3?' . $url_query . '">'
. $strSelect . '</a>';
} else {
echo $strSelect;
}
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_change.php3?<?php echo $url_query; ?>">
<?php echo $strInsert; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_properties.php3?<?php echo $url_query; ?>">
<?php echo $strProperties; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;reload=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
<?php echo $strDrop; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php
if (!empty($sts_data['Rows'])) {
echo '<a href="sql.php3?' . $url_query
. '&amp;sql_query=';
if (PMA_MYSQL_INT_VERSION >= 40000) {
echo urlencode('TRUNCATE ' . PMA_backquote($table))
. '&amp;zero_rows='
. urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
. '" onclick="return confirmLink(this, \'TRUNCATE ';
} else {
echo urlencode('DELETE FROM ' . PMA_backquote($table))
. '&amp;zero_rows='
. urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
. '" onclick="return confirmLink(this, \'DELETE FROM ';
}
echo PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
} else {
echo $strEmpty;
}
?>
</td>
<?php
echo "\n";
// loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
// statistics whatever is the table type
if (isset($sts_data['Rows'])) {
// MyISAM, ISAM or Heap table: Row count, data size and index size
// is accurate.
if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) {
if ($cfg['ShowStats']) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
}
$sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
}
// InnoDB table: Row count is not accurate but data and index
// sizes are.
else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
if ($cfg['ShowStats']) {
$tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
$sum_size += $tblsize;
list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
}
$display_rows = '&nbsp;-&nbsp;';
}
// Merge or BerkleyDB table: Only row count is accurate.
else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) {
if ($cfg['ShowStats']) {
$formated_size = '&nbsp;-&nbsp;';
$unit = '';
}
$sum_entries += $sts_data['Rows'];
$display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
}
// Unknown table type.
else {
if ($cfg['ShowStats']) {
$formated_size = 'unknown';
$unit = '';
}
$display_rows = 'unknown';
}
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
<?php
echo "\n" . ' ' . $display_rows . "\n";
?>
</td>
<td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
&nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
</td>
<?php
if ($cfg['ShowStats']) {
echo "\n";
?>
<td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
&nbsp;&nbsp;
<a href="tbl_properties.php3?<?php echo $url_query; ?>#showusage"><?php echo $formated_size . ' ' . $unit; ?></a>
</td>
<?php
echo "\n";
} // end if
} else {
?>
<td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php echo $strInUse . "\n"; ?>
</td>
<?php
}
echo "\n";
?>
</tr>
<?php
}
// Show Summary
if ($cfg['ShowStats']) {
list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
}
echo "\n";
?>
<tr>
<td></td>
<th align="center" nowrap="nowrap">
&nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
</th>
<th colspan="6" align="center">
<b><?php echo $strSum; ?></b>
</th>
<th align="right" nowrap="nowrap">
<b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
</th>
<th align="center">
<b>--</b>
</th>
<?php
if ($cfg['ShowStats']) {
echo "\n";
?>
<th align="right" nowrap="nowrap">
&nbsp;
<b><?php echo $sum_formated . ' ' . $unit; ?></b>
</th>
<?php
}
echo "\n";
?>
</tr>
<?php
// Check all tables url
$checkall_url = 'db_details_structure.php3'
. '?lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db);
echo "\n";
?>
<tr>
<td colspan="<?php echo (($cfg['ShowStats']) ? '11' : '10'); ?>" valign="bottom">
<img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
<a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
<?php echo $strCheckAll; ?></a>
&nbsp;/&nbsp;
<a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
<?php echo $strUncheckAll; ?></a>
&nbsp;&nbsp;&nbsp;
<img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
<select name="submit_mult" dir="ltr" onchange="this.form.submit();">
<?php
echo "\n";
echo ' <option value="' . $strWithChecked . '" selected="selected">'
. $strWithChecked . '</option>' . "\n";
echo ' <option value="' . $strDrop . '" >'
. $strDrop . '</option>' . "\n";
echo ' <option value="' . $strEmpty . '" >'
. $strEmpty . '</option>' . "\n";
echo ' <option value="' . $strPrintView . '" >'
. $strPrintView . '</option>' . "\n";
echo ' <option value="' . $strOptimizeTable . '" >'
. $strOptimizeTable . '</option>' . "\n";
?>
</select>
<script type="text/javascript" language="javascript">
<!--
// Fake js to allow the use of the <noscript> tag
//-->
</script>
<noscript>
<input type="submit" value="<?php echo $strGo; ?>" />
</noscript>
</td>
</tr>
</table>
</form>
<?php
} // end case mysql >= 3.23.03
// 3. Shows tables list mysql < 3.23.03
else {
$i = 0;
echo "\n";
?>
<form action="db_details_structure.php3">
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<table border="<?php echo $cfg['Border']; ?>">
<tr>
<td></td>
<th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
<th colspan="6"><?php echo ucfirst($strAction); ?></th>
<th><?php echo ucfirst($strRecords); ?></th>
</tr>
<?php
$checked = (!empty($checkall) ? ' checked="checked"' : '');
while ($i < $num_tables) {
$table = $tables[$i];
$table_encoded = urlencode($table);
$table_name = htmlspecialchars($table);
// Sets parameters for links
$url_query = 'lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db)
. '&amp;table=' . $table_encoded
. '&amp;goto=db_details_structure.php3';
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
echo "\n";
?>
<tr>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
</td>
<td bgcolor="<?php echo $bgcolor; ?>" class="data">
<b>&nbsp;<label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&amp;pos=0"><?php echo $strBrowse; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_select.php3?<?php echo $url_query; ?>"><?php echo $strSelect; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_change.php3?<?php echo $url_query; ?>"><?php echo $strInsert; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="tbl_properties.php3?<?php echo $url_query; ?>"><?php echo $strProperties; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;reload=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, $table_name)); ?>"><?php echo $strDrop; ?></a>
</td>
<td bgcolor="<?php echo $bgcolor; ?>">
<a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('DELETE FROM ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenEmptied, $table_name)); ?>"><?php echo $strEmpty; ?></a>
</td>
<td align="right" bgcolor="<?php echo $bgcolor; ?>">
<?php PMA_countRecords($db, $table); echo "\n"; ?>
</td>
</tr>
<?php
$i++;
} // end while
echo "\n";
// Check all tables url
$checkall_url = 'db_details_structure.php3'
. '?lang=' . $lang
. '&amp;server=' . $server
. '&amp;db=' . urlencode($db);
?>
<tr>
<td colspan="9">
<img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
<a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
<?php echo $strCheckAll; ?></a>
&nbsp;/&nbsp;
<a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
<?php echo $strUncheckAll; ?></a>
</td>
</tr>
<tr>
<td colspan="9">
<img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
<i><?php echo $strWithChecked; ?></i>&nbsp;&nbsp;
<input type="submit" name="submit_mult" value="<?php echo $strDrop; ?>" />
&nbsp;<?php $strOr . "\n"; ?>&nbsp;
<input type="submit" name="submit_mult" value="<?php echo $strEmpty; ?>" />
</td>
</tr>
</table>
</form>
<?php
} // end case mysql < 3.23.03
echo "\n";
?>
<hr />
<?php
/**
* Work on the database
*/
?>
<!-- DATABASE WORK -->
<ul>
<?php
if ($num_tables > 0) {
?>
<!-- Printable view of a table -->
<li>
<div style="margin-bottom: 10px"><a href="db_printview.php3?<?php echo $url_query; ?>"><?php echo $strPrintView; ?></a></div>
</li>
<?php
} // end if
?>
<!-- Create a new table -->
<li>
<form method="post" action="tbl_create.php3"
onsubmit="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
<input type="hidden" name="db" value="<?php echo $db; ?>" />
<?php
echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . '&nbsp;:<br />' . "\n";
echo ' ' . $strName . '&nbsp;:&nbsp;' . "\n";
echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
echo ' ' . '<br />' . "\n";
echo ' ' . $strFields . '&nbsp;:&nbsp;' . "\n";
echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
echo ' ' . '&nbsp;<input type="submit" value="' . $strGo . '" />' . "\n";
?>
</form>
</li>
</ul>
<?php
/**
* Displays the footer
*/
echo "\n";
require('./footer.inc.php3');
?>

View File

@@ -67,13 +67,6 @@ if (!empty($submit_mult) && !empty($what)) {
. (($i == $selected_cnt - 1) ? ';<br />' : '');
break;
// loic1: removed confirmation stage for "OPTIMIZE" statements
// case 'optimize_tbl':
// $full_query .= (empty($full_query) ? 'OPTIMIZE TABLE ' : ', ')
// . PMA_backquote(htmlspecialchars(urldecode($selected[$i])))
// . (($i == $selected_cnt - 1) ? ';<br />' : '');
// break;
case 'empty_tbl':
if (PMA_MYSQL_INT_VERSION >= 40000) {
$full_query .= 'TRUNCATE ';
@@ -112,9 +105,9 @@ if (!empty($submit_mult) && !empty($what)) {
<input type="hidden" name="server" value="<?php echo $server; ?>" />
<?php
echo "\n";
if ($action == 'db_details.php3') {
if (strpos(' ' . $action, 'db_details') == 1) {
echo ' <input type="hidden" name="db" value="' . $db . '" />' . "\n";
} else if ($action == 'tbl_properties.php3') {
} else if (strpos(' ' . $action, 'tbl_properties') == 1) {
echo ' <input type="hidden" name="db" value="' . $db . '" />' . "\n";
echo ' <input type="hidden" name="table" value="' . $table . '" />' . "\n";
}

View File

@@ -27,11 +27,11 @@ if (empty($goto)) {
$is_gotofile = TRUE;
}
if (!isset($err_url)) {
$err_url = $goto
$err_url = (!empty($back) ? $back : $goto)
. '?lang=' . $lang
. '&amp;server=' . $server
. (isset($db) ? '&amp;db=' . urlencode($db) : '')
. (($goto != 'db_details.php3' && isset($table)) ? '&amp;table=' . urlencode($table) : '');
. ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ? '&amp;table=' . urlencode($table) : '');
}
@@ -122,7 +122,7 @@ if (isset($btnDrop) && $btnDrop == $strNo) {
$goto = $back;
}
if ($is_gotofile) {
if ($goto == 'db_details.php3' && !empty($table)) {
if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) {
unset($table);
}
include('./' . ereg_replace('\.\.*', '.', $goto));
@@ -340,7 +340,7 @@ else {
unset($db);
}
$is_db = $is_table = FALSE;
if ($goto == 'tbl_properties.php3') {
if (strpos(' ' . $goto, 'tbl_properties') == 1) {
if (!isset($table)) {
$goto = 'db_details.php3';
} else {
@@ -351,7 +351,7 @@ else {
}
} // end if... else...
}
if ($goto == 'db_details.php3') {
if (strpos(' ' . $goto, 'db_details.php3') == 1) {
if (isset($table)) {
unset($table);
}
@@ -366,7 +366,8 @@ else {
} // end if... else...
}
// Loads to target script
if ($goto == 'db_details.php3' || $goto == 'tbl_properties.php3') {
if (strpos(' ' . $goto, 'db_details') == 1
|| strpos(' ' . $goto, 'tbl_properties') == 1) {
$js_to_run = 'functions.js';
}
if ($goto != 'main.php3') {