2007-07-02 05:51:26 +00:00
|
|
|
<?php
|
2008-03-18 10:29:20 +00:00
|
|
|
/** phpMinAdmin - Compact MySQL management
|
2009-05-31 13:03:45 +00:00
|
|
|
* @link http://www.phpminadmin.net/
|
|
|
|
* @author Jakub Vrana, http://php.vrana.cz/
|
2007-08-06 09:27:41 +00:00
|
|
|
* @copyright 2007 Jakub Vrana
|
|
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
|
|
|
*/
|
2007-07-05 10:34:19 +00:00
|
|
|
|
2007-07-02 05:51:26 +00:00
|
|
|
error_reporting(E_ALL & ~E_NOTICE);
|
2008-05-22 10:46:31 +00:00
|
|
|
if (!ini_get("session.auto_start")) {
|
|
|
|
session_name("phpMinAdmin_SID");
|
2008-12-12 14:03:02 +00:00
|
|
|
session_set_cookie_params(0, preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]));
|
2008-05-22 10:46:31 +00:00
|
|
|
session_start();
|
|
|
|
}
|
2008-10-02 16:42:55 +00:00
|
|
|
if (isset($_SESSION["coverage"])) {
|
|
|
|
function save_coverage() {
|
|
|
|
foreach (xdebug_get_code_coverage() as $filename => $lines) {
|
|
|
|
foreach ($lines as $l => $val) {
|
|
|
|
if (!$_SESSION["coverage"][$filename][$l] || $val > 0) {
|
|
|
|
$_SESSION["coverage"][$filename][$l] = $val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
|
|
|
|
register_shutdown_function('save_coverage');
|
2008-10-03 16:32:11 +00:00
|
|
|
if ($_GET["start"]) {
|
|
|
|
return;
|
|
|
|
}
|
2008-10-02 16:42:55 +00:00
|
|
|
}
|
2008-08-16 09:27:51 +00:00
|
|
|
if (get_magic_quotes_gpc()) {
|
|
|
|
$process = array(&$_GET, &$_POST);
|
|
|
|
while (list($key, $val) = each($process)) {
|
|
|
|
foreach ($val as $k => $v) {
|
|
|
|
unset($process[$key][$k]);
|
|
|
|
if (is_array($v)) {
|
|
|
|
$process[$key][stripslashes($k)] = $v;
|
|
|
|
$process[] = &$process[$key][stripslashes($k)];
|
|
|
|
} else {
|
|
|
|
$process[$key][stripslashes($k)] = stripslashes($v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($process);
|
|
|
|
}
|
2009-03-31 15:01:40 +00:00
|
|
|
set_magic_quotes_runtime(false);
|
2007-07-02 20:21:30 +00:00
|
|
|
$SELF = preg_replace('~^[^?]*/([^?]*).*~', '\\1?', $_SERVER["REQUEST_URI"]) . (strlen($_GET["server"]) ? 'server=' . urlencode($_GET["server"]) . '&' : '') . (strlen($_GET["db"]) ? 'db=' . urlencode($_GET["db"]) . '&' : '');
|
2008-08-16 09:27:51 +00:00
|
|
|
|
2009-05-29 20:19:13 +00:00
|
|
|
include "./include/version.inc.php";
|
|
|
|
include "./include/functions.inc.php";
|
|
|
|
include "./include/lang.inc.php";
|
2007-07-26 16:47:28 +00:00
|
|
|
include "./lang/$LANG.inc.php";
|
2009-06-03 09:17:20 +00:00
|
|
|
include "./include/design.inc.php";
|
2009-05-29 20:19:13 +00:00
|
|
|
include "./include/pdo.inc.php";
|
|
|
|
include "./include/mysql.inc.php";
|
|
|
|
include "./include/auth.inc.php";
|
|
|
|
include "./include/connect.inc.php";
|
|
|
|
include "./include/editing.inc.php";
|
|
|
|
include "./include/export.inc.php";
|
2007-07-02 05:51:26 +00:00
|
|
|
|
2008-06-20 14:13:37 +00:00
|
|
|
if (isset($_GET["download"])) {
|
2007-07-09 06:12:22 +00:00
|
|
|
include "./download.inc.php";
|
2007-07-16 11:41:25 +00:00
|
|
|
} else { // outputs footer
|
2007-07-13 13:37:07 +00:00
|
|
|
$on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION");
|
2007-07-16 13:38:45 +00:00
|
|
|
$enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"';
|
2007-07-16 13:56:34 +00:00
|
|
|
$inout = array("IN", "OUT", "INOUT");
|
2008-10-09 14:13:17 +00:00
|
|
|
$confirm = " onclick=\"return confirm('" . lang('Are you sure?') . "');\"";
|
2007-07-15 10:48:22 +00:00
|
|
|
|
2008-07-10 15:39:24 +00:00
|
|
|
$error = "";
|
2007-07-06 18:08:17 +00:00
|
|
|
if (isset($_GET["table"])) {
|
2007-07-05 10:45:23 +00:00
|
|
|
include "./table.inc.php";
|
|
|
|
} elseif (isset($_GET["view"])) {
|
|
|
|
include "./view.inc.php";
|
2007-07-17 07:23:17 +00:00
|
|
|
} elseif (isset($_GET["schema"])) {
|
|
|
|
include "./schema.inc.php";
|
2008-06-20 14:13:37 +00:00
|
|
|
} elseif (isset($_GET["dump"])) {
|
|
|
|
include "./dump.inc.php";
|
2007-08-09 15:03:39 +00:00
|
|
|
} elseif (isset($_GET["privileges"])) {
|
|
|
|
include "./privileges.inc.php";
|
2007-07-16 11:41:25 +00:00
|
|
|
} else { // uses CSRF token
|
2009-05-08 05:13:51 +00:00
|
|
|
$token = $_SESSION["tokens"][$_GET["server"]];
|
2007-07-06 18:08:17 +00:00
|
|
|
if ($_POST) {
|
2009-05-08 05:13:51 +00:00
|
|
|
if ($_POST["token"] != $token) {
|
2008-03-18 10:29:20 +00:00
|
|
|
$error = lang('Invalid CSRF token. Send the form again.');
|
|
|
|
}
|
|
|
|
} elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
|
|
$error = lang('Too big POST data. Reduce the data or increase the "post_max_size" configuration directive.');
|
2007-07-06 18:08:17 +00:00
|
|
|
}
|
2007-07-09 14:48:46 +00:00
|
|
|
if (isset($_GET["default"])) {
|
|
|
|
$_GET["edit"] = $_GET["default"];
|
|
|
|
}
|
2008-12-30 15:19:35 +00:00
|
|
|
if (isset($_GET["select"]) && $_POST && (!$_POST["delete"] && !$_POST["export"] && !$_POST["import"] && !$_POST["save"])) {
|
2008-10-01 11:39:13 +00:00
|
|
|
$_GET["edit"] = $_GET["select"];
|
|
|
|
}
|
2007-07-09 14:48:46 +00:00
|
|
|
if (isset($_GET["callf"])) {
|
|
|
|
$_GET["call"] = $_GET["callf"];
|
|
|
|
}
|
2007-07-16 22:40:55 +00:00
|
|
|
if (isset($_GET["function"])) {
|
|
|
|
$_GET["procedure"] = $_GET["function"];
|
2007-07-16 14:28:32 +00:00
|
|
|
}
|
2008-10-09 13:23:54 +00:00
|
|
|
if (isset($_GET["clone"])) {
|
|
|
|
$_GET["edit"] = $_GET["clone"];
|
|
|
|
}
|
2007-07-06 18:08:17 +00:00
|
|
|
if (isset($_GET["sql"])) {
|
|
|
|
include "./sql.inc.php";
|
|
|
|
} elseif (isset($_GET["edit"])) {
|
|
|
|
include "./edit.inc.php";
|
|
|
|
} elseif (isset($_GET["create"])) {
|
|
|
|
include "./create.inc.php";
|
|
|
|
} elseif (isset($_GET["indexes"])) {
|
|
|
|
include "./indexes.inc.php";
|
|
|
|
} elseif (isset($_GET["database"])) {
|
|
|
|
include "./database.inc.php";
|
2007-07-09 07:29:02 +00:00
|
|
|
} elseif (isset($_GET["call"])) {
|
|
|
|
include "./call.inc.php";
|
2007-07-11 16:02:57 +00:00
|
|
|
} elseif (isset($_GET["foreign"])) {
|
|
|
|
include "./foreign.inc.php";
|
2007-07-16 12:17:16 +00:00
|
|
|
} elseif (isset($_GET["createv"])) {
|
|
|
|
include "./createv.inc.php";
|
2008-09-01 16:49:38 +00:00
|
|
|
} elseif (isset($_GET["event"])) {
|
|
|
|
include "./event.inc.php";
|
2007-07-16 22:40:55 +00:00
|
|
|
} elseif (isset($_GET["procedure"])) {
|
|
|
|
include "./procedure.inc.php";
|
2007-07-23 15:23:42 +00:00
|
|
|
} elseif (isset($_GET["trigger"])) {
|
|
|
|
include "./trigger.inc.php";
|
2007-08-09 15:03:39 +00:00
|
|
|
} elseif (isset($_GET["user"])) {
|
|
|
|
include "./user.inc.php";
|
2007-07-16 13:26:37 +00:00
|
|
|
} elseif (isset($_GET["processlist"])) {
|
|
|
|
include "./processlist.inc.php";
|
2008-01-08 14:02:55 +00:00
|
|
|
} elseif (isset($_GET["select"])) {
|
|
|
|
include "./select.inc.php";
|
2007-07-06 18:08:17 +00:00
|
|
|
} else {
|
2008-09-25 14:27:19 +00:00
|
|
|
if ($_POST["tables"] && !$error) {
|
|
|
|
$result = true;
|
|
|
|
$message = "";
|
|
|
|
if (isset($_POST["truncate"])) {
|
|
|
|
foreach ($_POST["tables"] as $table) {
|
|
|
|
if (!queries("TRUNCATE " . idf_escape($table))) {
|
|
|
|
$result = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$message = lang('Tables have been truncated.');
|
2008-09-25 20:50:08 +00:00
|
|
|
} elseif (isset($_POST["move"])) {
|
|
|
|
$rename = array();
|
|
|
|
foreach ($_POST["tables"] as $table) {
|
|
|
|
$rename[] = idf_escape($table) . " TO " . idf_escape($_POST["target"]) . "." . idf_escape($table);
|
|
|
|
}
|
|
|
|
$result = queries("RENAME TABLE " . implode(", ", $rename));
|
|
|
|
$message = lang('Tables have been moved.');
|
2008-09-25 14:54:28 +00:00
|
|
|
} elseif ($result = queries((isset($_POST["optimize"]) ? "OPTIMIZE" : (isset($_POST["check"]) ? "CHECK" : (isset($_POST["repair"]) ? "REPAIR" : (isset($_POST["drop"]) ? "DROP" : "ANALYZE")))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) {
|
2008-10-02 14:13:58 +00:00
|
|
|
if (isset($_POST["drop"])) {
|
|
|
|
$message = lang('Tables have been dropped.');
|
|
|
|
} else {
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
|
|
|
$message .= htmlspecialchars("$row[Table]: $row[Msg_text]") . "<br />";
|
|
|
|
}
|
2008-09-25 14:27:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
query_redirect(queries(), substr($SELF, 0, -1), $message, $result, false, !$result);
|
|
|
|
}
|
|
|
|
|
2008-04-10 14:37:10 +00:00
|
|
|
page_header(lang('Database') . ": " . htmlspecialchars($_GET["db"]), $error, false);
|
2007-07-06 18:08:17 +00:00
|
|
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'database=">' . lang('Alter database') . "</a></p>\n";
|
2007-07-17 07:23:17 +00:00
|
|
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'schema=">' . lang('Database schema') . "</a></p>\n";
|
2008-09-25 14:27:19 +00:00
|
|
|
|
|
|
|
echo "<h3>" . lang('Tables and views') . "</h3>\n";
|
2009-05-08 05:23:03 +00:00
|
|
|
$result = $dbh->query("SHOW TABLE STATUS");
|
2008-09-25 14:27:19 +00:00
|
|
|
if (!$result->num_rows) {
|
|
|
|
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
|
|
|
} else {
|
|
|
|
echo "<form action='' method='post'>\n";
|
2009-05-01 10:41:33 +00:00
|
|
|
echo "<table cellspacing='0'>\n";
|
2009-06-01 13:06:11 +00:00
|
|
|
echo '<thead><tr><td><input id="check-all" type="checkbox" onclick="form_check(this, /^tables\[/);" /></td><th>' . lang('Table') . '</th><td>' . lang('Engine') . '</td><td>' . lang('Comment') . '</td><td>' . lang('Collation') . '</td><td>' . lang('Data Length') . '</td><td>' . lang('Index Length') . '</td><td>' . lang('Data Free') . '</td><td>' . lang('Auto Increment') . '</td><td>' . lang('Rows') . "</td></tr></thead>\n";
|
2008-09-25 14:27:19 +00:00
|
|
|
while ($row = $result->fetch_assoc()) {
|
2008-10-03 12:40:20 +00:00
|
|
|
table_comment($row);
|
2009-06-01 13:06:11 +00:00
|
|
|
echo '<tr class="nowrap' . odd(' odd') . '"><td>' . (isset($row["Rows"]) ? '<input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . '"' . (in_array($row["Name"], (array) $_POST["tables"], true) ? ' checked="checked"' : '') . ' onclick="form_uncheck(\'check-all\');" /></td><th><a href="' . htmlspecialchars($SELF) . 'table=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th><td>$row[Engine]</td><td>" . (strlen(trim($row["Comment"])) ? htmlspecialchars($row["Comment"]) : " ") . "</td><td>$row[Collation]" : ' </td><th><a href="' . htmlspecialchars($SELF) . 'view=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . '</a></th><td colspan="8"><a href="' . htmlspecialchars($SELF) . "select=" . urlencode($row["Name"]) . '">' . lang('View') . '</a>');
|
2009-01-13 15:22:36 +00:00
|
|
|
foreach ((isset($row["Rows"]) ? array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") : array()) as $key => $link) {
|
|
|
|
$val = number_format($row[$key], 0, '.', lang(','));
|
2009-05-25 11:56:05 +00:00
|
|
|
echo '</td><td align="right">' . (strlen($row[$key]) ? '<a href="' . htmlspecialchars("$SELF$link=") . urlencode($row["Name"]) . '">' . ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val) . '</a>' : ' ');
|
2008-09-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
echo "</td></tr>\n";
|
2008-09-25 14:27:19 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2008-10-09 14:13:17 +00:00
|
|
|
echo "<p><input type='hidden' name='token' value='$token' /><input type='submit' value='" . lang('Analyze') . "' /> <input type='submit' name='optimize' value='" . lang('Optimize') . "' /> <input type='submit' name='check' value='" . lang('Check') . "' /> <input type='submit' name='repair' value='" . lang('Repair') . "' /> <input type='submit' name='truncate' value='" . lang('Truncate') . "'$confirm /> <input type='submit' name='drop' value='" . lang('Drop') . "'$confirm /></p>\n";
|
2009-05-30 09:03:20 +00:00
|
|
|
$dbs = get_databases();
|
|
|
|
if (count($dbs) != 1) {
|
|
|
|
$db = (isset($_POST["target"]) ? $_POST["target"] : $_GET["db"]);
|
|
|
|
echo "<p>" . lang('Move to other database') . ($dbs ? ": <select name='target'>" . optionlist($dbs, $db) . "</select>" : ': <input name="target" value="' . htmlspecialchars($db) . '" />') . " <input type='submit' name='move' value='" . lang('Move') . "' /></p>\n";
|
|
|
|
}
|
2008-09-25 14:27:19 +00:00
|
|
|
echo "</form>\n";
|
|
|
|
}
|
|
|
|
$result->free();
|
|
|
|
|
2009-05-08 05:23:03 +00:00
|
|
|
if ($dbh->server_info >= 5) {
|
2007-07-26 10:45:49 +00:00
|
|
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'createv=">' . lang('Create view') . "</a></p>\n";
|
2007-07-17 07:23:17 +00:00
|
|
|
echo "<h3>" . lang('Routines') . "</h3>\n";
|
2009-05-08 05:23:03 +00:00
|
|
|
$result = $dbh->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = '" . $dbh->escape_string($_GET["db"]) . "'");
|
2007-07-10 13:30:42 +00:00
|
|
|
if ($result->num_rows) {
|
2009-05-01 10:41:33 +00:00
|
|
|
echo "<table cellspacing='0'>\n";
|
2007-07-10 13:30:42 +00:00
|
|
|
while ($row = $result->fetch_assoc()) {
|
2007-07-16 14:28:32 +00:00
|
|
|
echo "<tr>";
|
2007-08-09 15:03:39 +00:00
|
|
|
echo "<td>" . htmlspecialchars($row["ROUTINE_TYPE"]) . "</td>";
|
2008-09-27 08:52:18 +00:00
|
|
|
echo '<th><a href="' . htmlspecialchars($SELF) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . htmlspecialchars($row["ROUTINE_NAME"]) . '</a></th>';
|
|
|
|
echo '<td><a href="' . htmlspecialchars($SELF) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a></td>";
|
2007-07-06 18:08:17 +00:00
|
|
|
echo "</tr>\n";
|
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2007-07-06 09:55:51 +00:00
|
|
|
}
|
2007-07-10 13:30:42 +00:00
|
|
|
$result->free();
|
2007-07-17 09:12:15 +00:00
|
|
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . htmlspecialchars($SELF) . 'function=">' . lang('Create function') . "</a></p>\n";
|
2007-07-05 10:45:23 +00:00
|
|
|
}
|
2008-09-25 14:27:19 +00:00
|
|
|
|
2009-05-08 05:23:03 +00:00
|
|
|
if ($dbh->server_info >= 5.1 && ($result = $dbh->query("SHOW EVENTS"))) {
|
2008-09-01 16:49:38 +00:00
|
|
|
echo "<h3>" . lang('Events') . "</h3>\n";
|
|
|
|
if ($result->num_rows) {
|
2009-05-01 10:41:33 +00:00
|
|
|
echo "<table cellspacing='0'>\n";
|
2008-09-01 16:49:38 +00:00
|
|
|
echo "<thead><tr><th>" . lang('Name') . "</th><td>" . lang('Schedule') . "</td><td>" . lang('Start') . "</td><td>" . lang('End') . "</td></tr></thead>\n";
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo '<th><a href="' . htmlspecialchars($SELF) . 'event=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th>";
|
|
|
|
echo "<td>" . ($row["Execute at"] ? lang('At given time') . "</td><td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "</td><td>$row[Starts]") . "</td>";
|
|
|
|
echo "<td>$row[Ends]</td>";
|
|
|
|
echo "</tr>\n";
|
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
}
|
|
|
|
$result->free();
|
|
|
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'event=">' . lang('Create event') . "</a></p>\n";
|
|
|
|
}
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-05 10:45:23 +00:00
|
|
|
page_footer();
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|