From ddc3a58ac2db72a6122c8d347af9ca894669604f Mon Sep 17 00:00:00 2001
From: jakubvrana
Date: Mon, 2 Jul 2007 15:52:29 +0000
Subject: [PATCH] Logout
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@11 7c3ca157-0c34-0410-bff1-cbf682f78f5c
---
auth.inc.php | 11 ++++++++---
design.inc.php | 5 +++--
edit.inc.php | 2 +-
index.php | 3 ++-
4 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/auth.inc.php b/auth.inc.php
index 70069b94..66f1857d 100644
--- a/auth.inc.php
+++ b/auth.inc.php
@@ -2,16 +2,21 @@
if (isset($_POST["server"])) {
$_SESSION["username"] = $_POST["username"];
$_SESSION["password"] = $_POST["password"];
- header("Location: " . ($_GET["server"] == $_POST["server"] ? $_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"]) : '') . (SID ? (strlen($_POST["server"]) ? "&" : "?") . SID : ""), $_SERVER["REQUEST_URI"])));
exit;
+} elseif (isset($_GET["logout"])) {
+ unset($_SESSION["username"]);
+ unset($_SESSION["password"]);
}
-if (!@mysql_connect($_GET["server"], $_SESSION["username"], $_SESSION["password"])) {
+if (isset($_GET["logout"]) || !@mysql_connect($_GET["server"], $_SESSION["username"], $_SESSION["password"])) {
page_header(lang('Login'), "auth");
?>
" . lang('Logout successful.') . "
\n";
+ } elseif (isset($_GET["server"])) {
echo "" . lang('Invalid credentials.') . "
\n";
}
?>
diff --git a/design.inc.php b/design.inc.php
index 2ce9e0f6..c1ce957d 100644
--- a/design.inc.php
+++ b/design.inc.php
@@ -32,11 +32,12 @@ H2 { font-size: 150%; margin-top: 0; }
+