【php开源代码栏目提醒】:本文主要为网学会员提供server_databases.php,希望对需要server_databases.php网友有所帮助,学习一下!
<?php
/* $Id: server_databases.php,v 2.35.2.3 2006/03/14 17:53:44 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Does the common work
*/
require_once('./libraries/common.lib.php');
$js_to_run = 'functions.js';
require('./libraries/server_common.inc.php');
/**
* Sorts the databases array according to the user's choice
*
* @param array a record associated to a database
* @param array a record associated to a database
*
* @return integer a value representing whether $a should be before $b in the
* sorted array or not
*
* @global string the column the array shall be sorted by
* @global string the sorting order ('asc' or 'desc')
*
* @access private
*/
function PMA_dbCmp($a, $b) {
global $sort_by, $sort_order;
if ($GLOBALS['cfg']['NaturalOrder']) {
$sorter = 'strnatcmp';
} else {
$sorter = 'strcasecmp';
}
if ($sort_by == 'SCHEMA_NAME') {
return ($sort_order == 'asc' ? 1 : -1) * $sorter($a['SCHEMA_NAME'], $b['SCHEMA_NAME']);
} elseif ($a[$sort_by] == $b[$sort_by]) {
return $sorter($a['SCHEMA_NAME'], $b['SCHEMA_NAME']);
} else {
return ($sort_order == 'asc' ? 1 : -1) * ((int)$a[$sort_by] > (int)$b[$sort_by] ? 1 : -1);
}
} // end of the 'PMA_dbCmp()' function
/**
* avoids 'undefined index' errors
*/
if (empty($sort_by)) {
$sort_by = 'SCHEMA_NAME';
} else {
$sort_by = PMA_sanitize($sort_by);
}
if (empty($sort_order)) {
if ($sort_by == 'SCHEMA_NAME') {
$sort_order = 'asc';
} else {
$sort_order = 'desc';
}
} else {
$sort_order = PMA_sanitize($sort_order);
}
$dbstats = empty( $dbstats ) ? 0 : 1;
/**
* Drops multiple databases
*/
// workaround for IE behavior (it returns some coordinates based on where
// the mouse was on the Drop image):
if (isset($drop_selected_dbs_x)) {
$drop_selected_dbs = 'Drop';
}
if ((!empty($drop_selected_dbs) || isset($query_type)) && ($is_superuser || $cfg['AllowUserDropDatabase'])) {
if (! isset($selected_db) && ! isset($query_type)) {
$message = $strNoDatabasesSelected;
} else {
$action = 'server_databases.php';
$submit_mult = 'drop_db' ;
$err_url = 'server_databases.php?' . PMA_generate_common_url();
require('./libraries/mult_submits.inc.php');
if ($mult_btn == $strYes) {
$message = sprintf($strDatabasesDropped, count($selected));
} else {
$message = sprintf($strDatabasesDropped, 0);
}
}
}
/**
* Displays the links
*/
require('./libraries/server_links.inc.php');
/**
* Displays the sub-page heading
*/
echo '<h2>' . "\n"
. ( $GLOBALS['cfg']['MainPageIconic']
? '<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
.' height="16" alt="" />'
: '' )
. ( $dbstats ? $strDatabasesStats : $strDatabases ) . "\n"
.'</h2>' . "\n";
/**
* Gets the databases list
*/
if ($server > 0) {
$databases = PMA_DBI_get_databases_full(null, $dbstats);
} else {
$databases = array();
}
/**
* Displays the page
*/
$tmp_count = count($databases);
if ($tmp_count > 0) {
if ($tmp_count > 1) {
// sorts the array
usort( $databases, 'PMA_dbCmp' );
} else {
// when there is only one database, the sort would not happen and
// the index would not become numeric (reproduced in MySQL 3.23.52)
$tmp_each = each($databases);
$databases = array();
$databases[0] = $tmp_each['value'];
unset($tmp_each);
}
// table col order
// there is no db specific collation or charset prior 4.1.0
if (PMA_MYSQL_INT_VERSION >= 40100) {
$column_order['DEFAULT_COLLATION_NAME'] = array(
'disp_name' => $strCollation,
'description_function' => 'PMA_getCollationDescr',
'format' => 'string',
'footer' => PMA_getServerCollation(),
);
}
$column_order['SCHEMA_TABLES'] = array(
'disp_name' => $strNumTables,
'format' => 'number',
'footer' => 0,
);
$column_order['SCHEMA_TABLE_ROWS'] = array(
'disp_name' => $strRows,
'format' => 'number',
'footer' => 0,
);
$column_order['SCHEMA_DATA_LENGTH'] = array(
'disp_name' => $strData,
'format' => 'byte',
'footer' => 0,
);
$column_order['SCHEMA_INDEX_LENGTH'] = array(
'disp_name' => $strIndexes,
'format' => 'byte',
'footer' => 0,
);
$column_order['SCHEMA_LENGTH'] = array(
'disp_name' => $strTotalUC,
'format' => 'byte',
'footer' => 0,
);
$column_order['SCHEMA_DATA_FREE'] = array(
'disp_name' => $strOverhead,
'format' => 'byte',
'footer' => 0,
);
echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
. PMA_generate_common_hidden_inputs('', '', 1)
. '<input type="hidden" name="dbstats" value="' . $dbstats . '" />' . "\n"
. '<input type="hidden" name="sort_by" value="' . $sort_by . '" />' . "\n"
. '<input type="hidden" name="sort_order" value="' . $sort_order . '" />' . "\n"
. '<table id="tabledatabases" class="data">' . "\n"
. '<thead>' . "\n"
. '<tr>' . "\n"
. ($is_superuser || $cfg['AllowUserDropDatabase'] ? ' <th> </th>' . "\n" : '')
. ' <th><a href="./server_