Permalink
Browse files

Report connection error

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@650 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent fbebb08 commit 6563b5ed1e68ea728431f72eecf67ad69b55b352 jakubvrana committed Jun 3, 2009
Showing with 11 additions and 9 deletions.
  1. +11 −9 include/auth.inc.php
View
@@ -1,17 +1,18 @@
<?php
$ignore = array("server", "username", "password");
-if (ini_get("session.use_trans_sid") && isset($_POST[session_name()])) {
- $ignore[] = session_name();
+$session_name = session_name();
+if (ini_get("session.use_trans_sid") && isset($_POST[$session_name])) {
+ $ignore[] = $session_name;
}
if (isset($_POST["server"])) {
- if (isset($_COOKIE[session_name()]) || isset($_POST[session_name()])) {
+ if (isset($_COOKIE[$session_name]) || isset($_POST[$session_name])) {
session_regenerate_id();
$_SESSION["usernames"][$_POST["server"]] = $_POST["username"];
$_SESSION["passwords"][$_POST["server"]] = $_POST["password"];
$_SESSION["tokens"][$_POST["server"]] = rand(1, 1e6);
if (count($_POST) == count($ignore)) {
$location = ((string) $_GET["server"] === $_POST["server"] ? remove_from_uri() : preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . (strlen($_POST["server"]) ? '?server=' . urlencode($_POST["server"]) : ''));
- if (!isset($_COOKIE[session_name()])) {
+ if (!isset($_COOKIE[$session_name])) {
$location .= (strpos($location, "?") === false ? "?" : "&") . SID;
}
header("Location: " . (strlen($location) ? $location : "."));
@@ -36,11 +37,11 @@
}
}
-function auth_error() {
- global $ignore;
+function auth_error($exception = null) {
+ global $ignore, $dbh;
$username = $_SESSION["usernames"][$_GET["server"]];
unset($_SESSION["usernames"][$_GET["server"]]);
- page_header(lang('Login'), (isset($username) ? lang('Invalid credentials.') : (isset($_POST["server"]) ? lang('Sessions must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null);
+ page_header(lang('Login'), (isset($username) ? htmlspecialchars($exception ? $exception->getMessage() : ($dbh ? $dbh : lang('Invalid credentials.'))) : (isset($_POST["server"]) ? lang('Sessions must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null);
?>
<form action="" method="post">
<table cellspacing="0">
@@ -66,8 +67,9 @@ function auth_error() {
if (!isset($username)) {
$username = $_GET["username"];
}
-if (!isset($username) || !$dbh->connect($_GET["server"], $username, $_SESSION["passwords"][$_GET["server"]])) {
+$dbh = (isset($username) ? connect() : '');
+unset($username);
+if (is_string($dbh)) {
auth_error();
exit;
}
-unset($username);

0 comments on commit 6563b5e

Please sign in to comment.