Integrate port to server

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@358 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2007-11-08 12:20:18 +00:00
parent a6e54b58ed
commit 76f6daa04b
5 changed files with 8 additions and 13 deletions

View file

@ -5,9 +5,10 @@ if (extension_loaded("mysqli")) {
$this->init();
}
function connect($server, $username, $password, $port) {
function connect($server, $username, $password) {
list($host, $port) = explode(":", $server, 2);
return @$this->real_connect(
(strlen($server) ? $server : ini_get("mysqli.default_host")),
(strlen($server) ? $host : ini_get("mysqli.default_host")),
(strlen("$server$username") ? $username : ini_get("mysqli.default_user")),
(strlen("$server$username$password") ? $password : ini_get("mysqli.default_pw")),
null,
@ -27,9 +28,9 @@ if (extension_loaded("mysqli")) {
class Min_MySQL {
var $_link, $_result, $server_info, $affected_rows, $error;
function connect($server, $username, $password, $port) {
function connect($server, $username, $password) {
$this->_link = @mysql_connect(
(strlen($server) ? $server : ini_get("mysql.default_host")) . (strlen($port) ? ":$port" : ""),
(strlen($server) ? $server : ini_get("mysql.default_host")),
(strlen("$server$username") ? $username : ini_get("mysql.default_user")),
(strlen("$server$username$password") ? $password : ini_get("mysql.default_password")),
131072 // CLIENT_MULTI_RESULTS for CALL
@ -115,9 +116,9 @@ if (extension_loaded("mysqli")) {
function __construct() {
}
function connect($server, $username, $password, $port) {
function connect($server, $username, $password) {
set_exception_handler('auth_error'); // try/catch is not compatible with PHP 4
parent::__construct("mysql:host=$server" . (strlen($port) ? ";port=$port" : ""), $username, $password);
parent::__construct("mysql:host=" . str_replace(":", ";port=", $server), $username, $password);
restore_exception_handler();
$this->setAttribute(13, array('Min_PDOStatement')); // PDO::ATTR_STATEMENT_CLASS
$this->server_info = $this->result($this->query("SELECT VERSION()"));

View file

@ -8,7 +8,6 @@ if (isset($_POST["server"])) {
session_regenerate_id();
$_SESSION["usernames"][$_POST["server"]] = $_POST["username"];
$_SESSION["passwords"][$_POST["server"]] = $_POST["password"];
$_SESSION["ports"][$_POST["server"]] = $_POST["port"];
if (count($_POST) == count($ignore)) {
if ((string) $_GET["server"] === $_POST["server"]) {
$location = remove_from_uri();
@ -26,7 +25,6 @@ if (isset($_POST["server"])) {
} elseif (isset($_GET["logout"])) {
unset($_SESSION["usernames"][$_GET["server"]]);
unset($_SESSION["passwords"][$_GET["server"]]);
unset($_SESSION["ports"][$_GET["server"]]);
unset($_SESSION["databases"][$_GET["server"]]);
$_SESSION["tokens"][$_GET["server"]] = array();
redirect(substr($SELF, 0, -1), lang('Logout successful.'));
@ -53,7 +51,6 @@ function auth_error() {
<tr><th><?php echo lang('Server'); ?>:</th><td><input name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>" /></td></tr>
<tr><th><?php echo lang('Username'); ?>:</th><td><input name="username" value="<?php echo htmlspecialchars($username); ?>" /></td></tr>
<tr><th><?php echo lang('Password'); ?>:</th><td><input type="password" name="password" /></td></tr>
<tr><th><?php echo lang('Port'); ?>:</th><td><input name="port" size="4" value="<?php echo htmlspecialchars($_SESSION["ports"][$_GET["server"]]); ?>" /></td></tr>
</table>
<p>
<?php
@ -79,7 +76,7 @@ function auth_error() {
}
$username = $_SESSION["usernames"][$_GET["server"]];
if (!isset($username) || !$mysql->connect($_GET["server"], $username, $_SESSION["passwords"][$_GET["server"]], $_SESSION["ports"][$_GET["server"]])) {
if (!isset($username) || !$mysql->connect($_GET["server"], $username, $_SESSION["passwords"][$_GET["server"]])) {
auth_error();
exit;
}

View file

@ -162,5 +162,4 @@ $translations = array(
'Routine' => 'Procedura',
'Grant' => 'Povolit',
'Revoke' => 'Zakázat',
'Port' => 'Port',
);

View file

@ -162,5 +162,4 @@ $translations = array(
'Routine' => 'Routine',
'Grant' => 'Toekennen',
'Revoke' => 'Intrekken',
'Port' => 'Poort',
);

View file

@ -162,5 +162,4 @@ $translations = array(
'Routine' => 'Procedúra',
'Grant' => 'Povoliť',
'Revoke' => 'Zakázať',
'Port' => 'Port',
);