* optimisation round;
* the 'location' header must be above any output! * $reload has now true boolean values
This commit is contained in:
101
db_details.php3
101
db_details.php3
@@ -3,14 +3,25 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the variables sent to this script and displays headers
|
* Gets some core libraries, ensures the database exists (else move to the
|
||||||
|
* "parent" script) and diplays headers
|
||||||
*/
|
*/
|
||||||
require('./grab_globals.inc.php3');
|
require('./grab_globals.inc.php3');
|
||||||
|
require('./lib.inc.php3');
|
||||||
|
// 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: ' . $cfgPmaAbsoluteUri . 'main.php3?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
// Displays headers
|
||||||
if (!isset($message)) {
|
if (!isset($message)) {
|
||||||
$js_to_run = 'functions.js';
|
$js_to_run = 'functions.js';
|
||||||
include('./header.inc.php3');
|
include('./header.inc.php3');
|
||||||
// Reloads the navigation frame via JavaScript if required
|
// Reloads the navigation frame via JavaScript if required
|
||||||
if (!empty($reload) && $reload == 'true') {
|
if (isset($reload) && $reload) {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" language="javascript1.2">
|
<script type="text/javascript" language="javascript1.2">
|
||||||
@@ -37,20 +48,11 @@ if ((!empty($submit_mult) && isset($selected_tbl))
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays an html table with all the tables contained into the current
|
* Gets the list of the table in the current db and informations about these
|
||||||
* database
|
* tables if possible
|
||||||
*/
|
*/
|
||||||
// 1. Gets the list of the tables
|
// staybyte: speedup view on locked tables - 11 June 2001
|
||||||
$tables = mysql_list_tables($db);
|
if (MYSQL_INT_VERSION >= 32303) {
|
||||||
$num_tables = @mysql_numrows($tables);
|
|
||||||
// Not a valid db name -> back to the welcome page
|
|
||||||
if (mysql_error() != '') {
|
|
||||||
header('Location: ' . $cfgPmaAbsoluteUri . 'main.php3?lang=' . $lang . '&server=' . $server . '&reload=true');
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// speedup view on locked tables - staybyte - 11 June 2001
|
|
||||||
if ($num_tables > 0 && MYSQL_INT_VERSION >= 32303) {
|
|
||||||
// Special speedup for newer MySQL Versions (in 4.0 format changed)
|
// Special speedup for newer MySQL Versions (in 4.0 format changed)
|
||||||
if ($cfgSkipLockedTables == TRUE && MYSQL_INT_VERSION >= 32330) {
|
if ($cfgSkipLockedTables == TRUE && MYSQL_INT_VERSION >= 32330) {
|
||||||
$local_query = 'SHOW OPEN TABLES FROM ' . backquote($db);
|
$local_query = 'SHOW OPEN TABLES FROM ' . backquote($db);
|
||||||
@@ -73,10 +75,10 @@ if ($num_tables > 0 && MYSQL_INT_VERSION >= 32303) {
|
|||||||
if (!isset($sot_cache[$tmp[0]])) {
|
if (!isset($sot_cache[$tmp[0]])) {
|
||||||
$local_query = 'SHOW TABLE STATUS FROM ' . backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
|
$local_query = 'SHOW TABLE STATUS FROM ' . backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
|
||||||
$sts_result = mysql_query($local_query) or mysql_die('', $local_query);
|
$sts_result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||||
$sts_tmp = mysql_fetch_array($sts_result) or mysql_die('', $local_query);
|
$sts_tmp = mysql_fetch_array($sts_result);
|
||||||
$tbl_cache[] = $sts_tmp;
|
$tables[] = $sts_tmp;
|
||||||
} else { // table in use
|
} else { // table in use
|
||||||
$tbl_cache[] = array('Name' => $tmp[0]);
|
$tables[] = array('Name' => $tmp[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mysql_free_result($result);
|
mysql_free_result($result);
|
||||||
@@ -90,25 +92,40 @@ if ($num_tables > 0 && MYSQL_INT_VERSION >= 32303) {
|
|||||||
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
$result = mysql_query($local_query) or mysql_die('', $local_query);
|
||||||
if ($result != FALSE && mysql_num_rows($result) > 0) {
|
if ($result != FALSE && mysql_num_rows($result) > 0) {
|
||||||
while ($sts_tmp = mysql_fetch_array($result)) {
|
while ($sts_tmp = mysql_fetch_array($result)) {
|
||||||
$tbl_cache[] = $sts_tmp;
|
$tables[] = $sts_tmp;
|
||||||
}
|
}
|
||||||
mysql_free_result($result);
|
mysql_free_result($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$num_tables = (isset($tables) ? count($tables) : 0);
|
||||||
|
} // end if (MYSQL_INT_VERSION >= 32303)
|
||||||
|
else {
|
||||||
|
$result = mysql_list_tables($db);
|
||||||
|
$num_tables = @mysql_numrows($result);
|
||||||
|
for ($i = 0; $i < $num_tables; $i++) {
|
||||||
|
$tables[] = mysql_tablename($result, $i);
|
||||||
|
}
|
||||||
|
mysql_free_result($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Displays tables
|
|
||||||
if ($num_tables == 0) {
|
|
||||||
echo $strNoTablesFound . "\n";
|
|
||||||
}
|
|
||||||
// show table size on mysql >= 3.23 - staybyte - 11 June 2001
|
|
||||||
else if (MYSQL_INT_VERSION >= 32300 && isset($tbl_cache)) {
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays an html table with all the tables contained into the current
|
||||||
|
* database
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
|
||||||
<!-- TABLE LIST -->
|
<!-- TABLE LIST -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// 1. No tables
|
||||||
|
if ($num_tables == 0) {
|
||||||
|
echo $strNoTablesFound . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Shows table informations on mysql >= 3.23 - staybyte - 11 June 2001
|
||||||
|
else if (MYSQL_INT_VERSION >= 32300) {
|
||||||
|
?>
|
||||||
<form action="db_details.php3">
|
<form action="db_details.php3">
|
||||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||||
@@ -125,7 +142,7 @@ else if (MYSQL_INT_VERSION >= 32300 && isset($tbl_cache)) {
|
|||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
$i = $sum_entries = $sum_size = 0;
|
$i = $sum_entries = $sum_size = 0;
|
||||||
while (list($keyname, $sts_data) = each($tbl_cache)) {
|
while (list($keyname, $sts_data) = each($tables)) {
|
||||||
$table = $sts_data['Name'];
|
$table = $sts_data['Name'];
|
||||||
// Sets parameters for links
|
// Sets parameters for links
|
||||||
$url_query = 'lang=' . $lang
|
$url_query = 'lang=' . $lang
|
||||||
@@ -160,7 +177,7 @@ else if (MYSQL_INT_VERSION >= 32300 && isset($tbl_cache)) {
|
|||||||
<?php echo $strProperties; ?></a>
|
<?php echo $strProperties; ?></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="sql.php3?<?php echo $url_query; ?>&reload=true&sql_query=<?php echo urlencode('DROP TABLE ' . backquote($table)); ?>&zero_rows=<?php echo urlencode($strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenDropped); ?>"
|
<a href="sql.php3?<?php echo $url_query; ?>&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . backquote($table)); ?>&zero_rows=<?php echo urlencode($strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenDropped); ?>"
|
||||||
onclick="return confirmLink(this, 'DROP TABLE <?php echo js_format($table); ?>')">
|
onclick="return confirmLink(this, 'DROP TABLE <?php echo js_format($table); ?>')">
|
||||||
<?php echo $strDrop; ?></a>
|
<?php echo $strDrop; ?></a>
|
||||||
</td>
|
</td>
|
||||||
@@ -277,15 +294,11 @@ else if (MYSQL_INT_VERSION >= 32300 && isset($tbl_cache)) {
|
|||||||
<?php
|
<?php
|
||||||
} // end case mysql >= 3.23
|
} // end case mysql >= 3.23
|
||||||
|
|
||||||
|
// 3. Shows tables list mysql < 3.23
|
||||||
else {
|
else {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- TABLE LIST -->
|
|
||||||
|
|
||||||
<form action="db_details.php3">
|
<form action="db_details.php3">
|
||||||
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||||
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||||
@@ -300,25 +313,24 @@ else {
|
|||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
while ($i < $num_tables) {
|
while ($i < $num_tables) {
|
||||||
$table = mysql_tablename($tables, $i);
|
|
||||||
// Sets parameters for links
|
// Sets parameters for links
|
||||||
$url_query = 'lang=' . $lang
|
$url_query = 'lang=' . $lang
|
||||||
. '&server=' . $server
|
. '&server=' . $server
|
||||||
. '&db=' . urlencode($db)
|
. '&db=' . urlencode($db)
|
||||||
. '&table=' . urlencode($table)
|
. '&table=' . urlencode($tables[$i])
|
||||||
. '&goto=db_details.php3';
|
. '&goto=db_details.php3';
|
||||||
$bgcolor = ($i % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
|
$bgcolor = ($i % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
<tr bgcolor="<?php echo $bgcolor; ?>">
|
<tr bgcolor="<?php echo $bgcolor; ?>">
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<input type="checkbox" name="selected_tbl[]" value="<?php echo urlencode($table); ?>" />
|
<input type="checkbox" name="selected_tbl[]" value="<?php echo urlencode($tables[$i]); ?>" />
|
||||||
</td>
|
</td>
|
||||||
<td class="data">
|
<td class="data">
|
||||||
<b> <?php echo $table; ?> </b>
|
<b> <?php echo $tables[$i]; ?> </b>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . backquote($table)); ?>&pos=0"><?php echo $strBrowse; ?></a>
|
<a href="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . backquote($tables[$i])); ?>&pos=0"><?php echo $strBrowse; ?></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="tbl_select.php3?<?php echo $url_query; ?>"><?php echo $strSelect; ?></a>
|
<a href="tbl_select.php3?<?php echo $url_query; ?>"><?php echo $strSelect; ?></a>
|
||||||
@@ -330,13 +342,13 @@ else {
|
|||||||
<a href="tbl_properties.php3?<?php echo $url_query; ?>"><?php echo $strProperties; ?></a>
|
<a href="tbl_properties.php3?<?php echo $url_query; ?>"><?php echo $strProperties; ?></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="sql.php3?<?php echo $url_query; ?>&reload=true&sql_query=<?php echo urlencode('DROP TABLE ' . backquote($table)); ?>&zero_rows=<?php echo urlencode($strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenDropped); ?>"><?php echo $strDrop; ?></a>
|
<a href="sql.php3?<?php echo $url_query; ?>&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . backquote($tables[$i])); ?>&zero_rows=<?php echo urlencode($strTable . ' ' . htmlspecialchars($tables[$i]) . ' ' . $strHasBeenDropped); ?>"><?php echo $strDrop; ?></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('DELETE FROM ' . backquote($table)); ?>&zero_rows=<?php echo urlencode($strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenEmptied); ?>"><?php echo $strEmpty; ?></a>
|
<a href="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('DELETE FROM ' . backquote($tables[$i])); ?>&zero_rows=<?php echo urlencode($strTable . ' ' . htmlspecialchars($tables[$i]) . ' ' . $strHasBeenEmptied); ?>"><?php echo $strEmpty; ?></a>
|
||||||
</td>
|
</td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<?php count_records($db, $table); echo "\n"; ?>
|
<?php count_records($db, $tables[$i]); echo "\n"; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
@@ -484,7 +496,7 @@ if ($num_tables > 0) {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
while ($i < $num_tables) {
|
while ($i < $num_tables) {
|
||||||
$table = mysql_tablename($tables, $i);
|
$table = ((MYSQL_INT_VERSION >= 32300) ? $tables[$i]['Name'] : $tables[$i]);
|
||||||
echo ' <option value="' . $table . '">' . $table . '</option>' . "\n";
|
echo ' <option value="' . $table . '">' . $table . '</option>' . "\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@@ -493,7 +505,6 @@ if ($num_tables > 0) {
|
|||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
} // end if
|
} // end if
|
||||||
mysql_free_result($tables);
|
|
||||||
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
@@ -615,7 +626,7 @@ if ($cfgAllowUserDropDatabase || $is_superuser) {
|
|||||||
?>
|
?>
|
||||||
<!-- Drop database -->
|
<!-- Drop database -->
|
||||||
<li>
|
<li>
|
||||||
<a href="sql.php3?server=<?php echo $server; ?>&lang=<?php echo $lang; ?>&db=<?php echo urlencode($db); ?>&sql_query=<?php echo urlencode('DROP DATABASE ' . backquote($db)); ?>&zero_rows=<?php echo urlencode($strDatabase . ' ' . htmlspecialchars(backquote($db)) . ' ' . $strHasBeenDropped); ?>&goto=main.php3&back=db_details.php3&reload=true"
|
<a href="sql.php3?server=<?php echo $server; ?>&lang=<?php echo $lang; ?>&db=<?php echo urlencode($db); ?>&sql_query=<?php echo urlencode('DROP DATABASE ' . backquote($db)); ?>&zero_rows=<?php echo urlencode($strDatabase . ' ' . htmlspecialchars(backquote($db)) . ' ' . $strHasBeenDropped); ?>&goto=main.php3&back=db_details.php3&reload=1"
|
||||||
onclick="return confirmLink(this, 'DROP DATABASE <?php echo js_format($db); ?>')">
|
onclick="return confirmLink(this, 'DROP DATABASE <?php echo js_format($db); ?>')">
|
||||||
<?php echo $strDropDB . ' ' . htmlspecialchars($db); ?></a>
|
<?php echo $strDropDB . ' ' . htmlspecialchars($db); ?></a>
|
||||||
<?php echo show_docu('manual_Reference.html#DROP_DATABASE') . "\n"; ?>
|
<?php echo show_docu('manual_Reference.html#DROP_DATABASE') . "\n"; ?>
|
||||||
|
Reference in New Issue
Block a user