diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 8e5b8a47..83bd54c6 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -1,5 +1,13 @@ homepage()) { - if ($_GET["ns"] !== "") { + if (isset($_GET["ns"]) === false || $_GET["ns"] !== "") { echo "

" . lang('Tables and views') . "

\n"; $tables_list = tables_list(); if (!$tables_list) { @@ -56,7 +64,7 @@ if ($adminer->homepage()) { echo "
\n"; if (support("table")) { echo "
" . lang('Search data in tables') . "
"; - echo ""; + echo ""; echo script("qsl('input').onkeydown = partialArg(bodyKeydown, 'search');", ""); echo " \n"; if ($adminer->operator_regexp !== null) { @@ -64,7 +72,7 @@ if ($adminer->homepage()) { echo doc_link(array('sql' => 'regexp.html', 'pgsql' => 'functions-matching.html#FUNCTIONS-POSIX-REGEXP')) . "

\n"; } echo "
\n"; - if ($_POST["search"] && $_POST["query"] != "") { + if (isset($_POST["search"]) && $_POST["query"] != "") { $_GET["where"][0]["op"] = $adminer->operator_regexp === null || empty($_POST['regexp']) ? "LIKE %%" : $adminer->operator_regexp; search_tables(); } @@ -143,7 +151,7 @@ if ($adminer->homepage()) { echo "

" . lang('Move to other database') . ": "; echo ($databases ? html_select("target", $databases, $db) : ''); echo " "; - echo (support("copy") ? " " . checkbox("overwrite", 1, $_POST["overwrite"], lang('overwrite')) : ""); + echo (support("copy") ? " " . checkbox("overwrite", 1, isset($_POST["overwrite"]), lang('overwrite')) : ""); echo "\n"; } echo ""; // used by trCheck() diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 50da1292..25d3e7f6 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -15,7 +15,11 @@ if (!defined("DRIVER")) { function connect($server = "", $username = "", $password = "", $database = null, $port = null, $socket = null) { global $adminer; mysqli_report(MYSQLI_REPORT_OFF); // stays between requests, not required since PHP 5.3.4 - list($host, $port) = explode(":", $server, 2); // part after : is used for port or socket + if (strpos($server, ':') !== false) { + list($host, $port) = explode(":", $server, 2); // part after : is used for port or socket + } else { + $host = $server; + } $ssl = $adminer->connectSsl(); if ($ssl) { $this->ssl_set($ssl['key'], $ssl['cert'], $ssl['ca'], '', ''); diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index e87b7c35..8781496c 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -939,13 +939,13 @@ class Adminer { */ function homepage() { $links = []; - if ($_GET["ns"] == "" && support("database")) { + if (isset($_GET["ns"]) && $_GET["ns"] == "" && support("database")) { $links[] = '' . lang('Alter database') . ''; } if (support("scheme")) { $links[] = "" . ($_GET["ns"] != "" ? lang('Alter schema') : lang('Create schema')) . ""; } - if ($_GET["ns"] !== "") { + if (isset($_GET["ns"]) && $_GET["ns"] !== "") { $links[] = '' . lang('Database schema') . ''; } if (support("privileges")) { @@ -987,7 +987,7 @@ class Adminer { } } else { $tables = array(); - if ($_GET["ns"] !== "" && !$missing && DB != "") { + if (isset($_GET["ns"]) === false || $_GET["ns"] !== "" && !$missing && DB != "") { $connection->select_db(DB); $tables = table_status('', true); } @@ -1024,13 +1024,13 @@ bodyLoad('" . lang('Import') . ""; } if (support("dump")) { - $links[] = "" . lang('Export') . ""; + $links[] = "" . lang('Export') . ""; } } echo generate_linksbar($links); - if ($_GET["ns"] !== "" && !$missing && DB != "") { - echo generate_linksbar(['" . lang('Create table') . ""]); + if (isset($_GET["ns"]) === false || $_GET["ns"] !== "" && !$missing && DB != "") { + echo generate_linksbar(['" . lang('Create table') . ""]); if (!$tables) { echo "

" . lang('No tables.') . "\n"; } else { @@ -1090,13 +1090,20 @@ bodyLoad(' $status) { $name = $this->tableName($status); if ($name != "") { + $array = []; + if (isset($_GET["table"])) $array[] = $_GET["table"]; + if (isset($_GET["create"])) $array[] = $_GET["create"]; + if (isset($_GET["indexes"])) $array[] = $_GET["indexes"]; + if (isset($_GET["foreign"])) $array[] = $_GET["foreign"]; + if (isset($_GET["trigger"])) $array[] = $_GET["trigger"]; + if (isset($_GET["select"])) $array[] = $_GET["select"]; echo '

  • " . lang('select') . " " ; echo (support("table") || support("indexes") ? '$name" : "$name" ) . "\n"; diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 3183b51a..fb0fb82b 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -40,12 +40,17 @@ function add_invalid_login() { function check_invalid_login() { global $adminer; - $invalids = unserialize(@file_get_contents(get_temp_dir() . "/adminer.invalid")); // @ - may not exist + $filename = get_temp_dir() . "/adminer.invalid"; + if (file_exists($filename)) { + $invalids = unserialize(file_get_contents(get_temp_dir() . "/adminer.invalid")); + } else { + $invalids = []; + } $invalid = ($invalids ? $invalids[$adminer->bruteForceKey()] : array()); if ($invalid === null) { return; } - $next_attempt = ($invalid[1] > 29 ? $invalid[0] - time() : 0); // allow 30 invalid attempts + $next_attempt = (isset($invalid[1]) && $invalid[1] > 29 ? $invalid[0] - time() : 0); // allow 30 invalid attempts if ($next_attempt > 0) { //! do the same with permanent login auth_error(lang('Too many unsuccessful logins, try again in %d minute(s).', ceil($next_attempt / 60))); } @@ -158,7 +163,12 @@ if (isset($_GET["username"]) && !class_exists("Min_DB")) { stop_session(true); if (isset($_GET["username"]) && is_string(get_password())) { - list($host, $port) = explode(":", SERVER, 2); + if (strpos(SERVER, ':') !== false) { + list($host, $port) = explode(":", SERVER, 2); + } else { + $host = SERVER; + $port = null; + } if (preg_match('~^\s*([-+]?\d+)~', $port, $match) && ($match[1] < 1024 || $match[1] > 65535)) { // is_numeric('80#') would still connect to port 80 auth_error(lang('Connecting to privileged ports is not allowed.')); } @@ -173,7 +183,7 @@ if (!is_object($connection) || ($login = $adminer->login($_GET["username"], get_ auth_error($error . (preg_match('~^ | $~', get_password()) ? '
    ' . lang('There is a space in the input password which might be the cause.') : '')); } -if ($_POST["logout"] && $has_token && !verify_token()) { +if (isset($_POST["logout"]) && $_POST["logout"] && $has_token && !verify_token()) { page_header(lang('Logout'), lang('Invalid CSRF token. Send the form again.')); page_footer("db"); exit; diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 399471cd..7f41829b 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -76,7 +76,7 @@ var thousandsSeparator = ''; echo "$server\n"; } else { echo "$server » "; - if ($_GET["ns"] != "" || (DB != "" && is_array($breadcrumb))) { + if ((isset($_GET["ns"]) && $_GET["ns"] != "") || (DB != "" && is_array($breadcrumb))) { echo '' . h(DB) . ' » '; } if (is_array($breadcrumb)) {