mirror of
https://github.com/vrana/adminer.git
synced 2025-08-15 02:54:28 +02:00
Comments
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@729 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
if ($_POST && !$error && !$_POST["add_x"]) {
|
||||
if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
|
||||
if ($_POST["drop"]) {
|
||||
unset($_SESSION["databases"][$_GET["server"]]);
|
||||
query_redirect("DROP DATABASE " . idf_escape($_GET["db"]), substr(preg_replace('~db=[^&]*&~', '', $SELF), 0, -1), lang('Database has been dropped.'));
|
||||
} elseif ($_GET["db"] !== $_POST["name"]) {
|
||||
unset($_SESSION["databases"][$_GET["server"]]);
|
||||
// create or rename database
|
||||
unset($_SESSION["databases"][$_GET["server"]]); // clear cache
|
||||
$dbs = explode("\n", str_replace("\r", "", $_POST["name"]));
|
||||
$failed = false;
|
||||
foreach ($dbs as $db) {
|
||||
if (count($dbs) == 1 || strlen($db)) {
|
||||
if (count($dbs) == 1 || strlen($db)) { // ignore empty lines but always try to create single database
|
||||
if (!queries("CREATE DATABASE " . idf_escape($db) . ($_POST["collation"] ? " COLLATE '" . $dbh->escape_string($_POST["collation"]) . "'" : ""))) {
|
||||
$failed = true;
|
||||
}
|
||||
@@ -29,6 +30,7 @@ if ($_POST && !$error && !$_POST["add_x"]) {
|
||||
query_redirect(queries(), preg_replace('~db=[^&]*&~', '', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'), !$row, false, $row);
|
||||
}
|
||||
} else {
|
||||
// alter database
|
||||
if (!$_POST["collation"]) {
|
||||
redirect(substr($SELF, 0, -1));
|
||||
}
|
||||
@@ -43,25 +45,25 @@ $collate = array();
|
||||
if ($_POST) {
|
||||
$name = $_POST["name"];
|
||||
$collate = $_POST["collation"];
|
||||
} else {
|
||||
if (!strlen($_GET["db"])) {
|
||||
$result = $dbh->query("SHOW GRANTS");
|
||||
while ($row = $result->fetch_row()) {
|
||||
if (preg_match('~ ON (`(([^\\\\`]+|``|\\\\.)*)%`\\.\\*)?~', $row[0], $match) && $match[1]) {
|
||||
$name = stripcslashes(idf_unescape($match[2]));
|
||||
break;
|
||||
}
|
||||
} elseif (!strlen($_GET["db"])) {
|
||||
// propose database name with limited privileges
|
||||
$result = $dbh->query("SHOW GRANTS");
|
||||
while ($row = $result->fetch_row()) {
|
||||
if (preg_match('~ ON (`(([^\\\\`]+|``|\\\\.)*)%`\\.\\*)?~', $row[0], $match) && $match[1]) {
|
||||
$name = stripcslashes(idf_unescape($match[2]));
|
||||
break;
|
||||
}
|
||||
$result->free();
|
||||
} elseif (($result = $dbh->query("SHOW CREATE DATABASE " . idf_escape($_GET["db"])))) {
|
||||
$create = $dbh->result($result, 1);
|
||||
if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) {
|
||||
$collate = $match[1];
|
||||
} elseif (preg_match('~ CHARACTER SET ([^ ]+)~', $create, $match)) {
|
||||
$collate = $collations[$match[1]][0];
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
$result->free();
|
||||
} elseif (($result = $dbh->query("SHOW CREATE DATABASE " . idf_escape($_GET["db"])))) {
|
||||
$create = $dbh->result($result, 1);
|
||||
if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) {
|
||||
$collate = $match[1];
|
||||
} elseif (preg_match('~ CHARACTER SET ([^ ]+)~', $create, $match)) {
|
||||
// default collation
|
||||
$collate = $collations[$match[1]][0];
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
?>
|
||||
|
||||
|
Reference in New Issue
Block a user