Redirect function
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@15 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
01f528efe5
commit
42bc448e3c
|
@ -2,7 +2,7 @@
|
||||||
if (isset($_POST["server"])) {
|
if (isset($_POST["server"])) {
|
||||||
$_SESSION["username"] = $_POST["username"];
|
$_SESSION["username"] = $_POST["username"];
|
||||||
$_SESSION["password"] = $_POST["password"];
|
$_SESSION["password"] = $_POST["password"];
|
||||||
header("Location: " . ((string) $_GET["server"] === $_POST["server"] ? preg_replace('~(\\?)logout=&|[?&]logout=~', '\\1', $_SERVER["REQUEST_URI"]) : preg_replace('~^[^?]*/([^?]*).*~', '\\1' . (strlen($_POST["server"]) ? '?server=' . urlencode($_POST["server"]) : '') . (SID ? (strlen($_POST["server"]) ? "&" : "?") . SID : ""), $_SERVER["REQUEST_URI"])));
|
header("Location: " . ((string) $_GET["server"] === $_POST["server"] ? preg_replace('~(\\?)logout=&|[?&]logout=~', '\\1', $_SERVER["REQUEST_URI"]) : preg_replace('~^[^?]*/([^?]*).*~', '\\1' . (strlen($_POST["server"]) ? '?server=' . urlencode($_POST["server"]) : '') . (strlen(SID) ? (strlen($_POST["server"]) ? "&" : "?") . SID : ""), $_SERVER["REQUEST_URI"])));
|
||||||
exit;
|
exit;
|
||||||
} elseif (isset($_GET["logout"])) {
|
} elseif (isset($_GET["logout"])) {
|
||||||
unset($_SESSION["username"]);
|
unset($_SESSION["username"]);
|
||||||
|
|
|
@ -23,9 +23,7 @@ if ($_POST) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mysql_query($query)) {
|
if (mysql_query($query)) {
|
||||||
$_SESSION["message"] = $message;
|
redirect(($_POST["drop"] ? substr($SELF, 0, -1) : $SELF . "table=" . urlencode($_POST["name"])), $message);
|
||||||
header("Location: " . ($_POST["drop"] ? substr($SELF, 0, -1) : $SELF . "table=" . urlencode($_POST["name"])) . (SID ? "&" . SID : ""));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$error = mysql_error();
|
$error = mysql_error();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,12 @@
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
if (mysql_query("DROP DATABASE " . idf_escape($_GET["db"]))) {
|
if (mysql_query("DROP DATABASE " . idf_escape($_GET["db"]))) {
|
||||||
$_SESSION["message"] = lang('Database has been dropped.');
|
redirect(substr(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF), 0, -1), lang('Database has been dropped.'));
|
||||||
$location = substr(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . (SID ? SID . "&" : ""), 0, -1);
|
|
||||||
header("Location: " . (strlen($location) ? $location : "."));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
} elseif ($_GET["db"] !== $_POST["name"]) {
|
} elseif ($_GET["db"] !== $_POST["name"]) {
|
||||||
if (mysql_query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . mysql_real_escape_string($_POST["collation"]) . "'" : ""))) {
|
if (mysql_query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . mysql_real_escape_string($_POST["collation"]) . "'" : ""))) {
|
||||||
if (!strlen($_GET["db"])) {
|
if (!strlen($_GET["db"])) {
|
||||||
$_SESSION["message"] = lang('Database has been created.');
|
redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
|
||||||
header("Location: " . substr(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]) . "&" . (SID ? SID . "&" : ""), 0, -1));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$result = mysql_query("SHOW TABLES");
|
$result = mysql_query("SHOW TABLES");
|
||||||
while ($row = mysql_fetch_row($result)) {
|
while ($row = mysql_fetch_row($result)) {
|
||||||
|
@ -23,15 +18,11 @@ if ($_POST) {
|
||||||
mysql_free_result($result);
|
mysql_free_result($result);
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
mysql_query("DROP DATABASE " . idf_escape($_GET["db"]));
|
mysql_query("DROP DATABASE " . idf_escape($_GET["db"]));
|
||||||
$_SESSION["message"] = lang('Database has been renamed.');
|
redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'));
|
||||||
header("Location: " . substr(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]) . "&" . (SID ? SID . "&" : ""), 0, -1));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (!$_POST["collation"] || mysql_query("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE '" . mysql_real_escape_string($_POST["collation"]) . "'")) {
|
} elseif (!$_POST["collation"] || mysql_query("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE '" . mysql_real_escape_string($_POST["collation"]) . "'")) {
|
||||||
$_SESSION["message"] = ($_POST["collation"] ? lang('Database has been altered.') : '');
|
redirect(substr($SELF, 0, -1), ($_POST["collation"] ? lang('Database has been altered.') : null));
|
||||||
header("Location: " . substr($SELF . (SID ? SID . "&" : ""), 0, -1));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$eror = mysql_error();
|
$eror = mysql_error();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,7 @@ if ($_POST) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mysql_query($query)) {
|
if (mysql_query($query)) {
|
||||||
$_SESSION["message"] = $message;
|
redirect($SELF . "select=" . urlencode($_GET["edit"]), $message);
|
||||||
header("Location: " . $SELF . "select=" . urlencode($_GET["edit"]) . (SID ? "&" . SID : ""));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$error = mysql_error();
|
$error = mysql_error();
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,17 @@ function engines() {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function redirect($location, $message = null) {
|
||||||
|
if (isset($message)) {
|
||||||
|
$_SESSION["message"] = $message;
|
||||||
|
}
|
||||||
|
if (strlen(SID)) {
|
||||||
|
$location .= (strpos($location, "?") === false ? "?" : "&") . SID;
|
||||||
|
}
|
||||||
|
header("Location: " . (strlen($location) ? $location : "."));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (get_magic_quotes_gpc()) {
|
if (get_magic_quotes_gpc()) {
|
||||||
$process = array(&$_GET, &$_POST);
|
$process = array(&$_GET, &$_POST);
|
||||||
while (list($key, $val) = each($process)) {
|
while (list($key, $val) = each($process)) {
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$result = mysql_query($_POST["query"]); //! multiple commands
|
$result = mysql_query($_POST["query"]); //! multiple commands
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$_SESSION["message"] = sprintf(lang('Query executed OK, %d row(s) affected.'), mysql_affected_rows());
|
redirect($SELF . "sql=", sprintf(lang('Query executed OK, %d row(s) affected.'), mysql_affected_rows()));
|
||||||
header("Location: " . $SELF . "sql=" . (SID ? "&" . SID : ""));
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$error = mysql_error();
|
$error = mysql_error();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue