diff --git a/auth.inc.php b/auth.inc.php index 31aa90ff..1b5f8430 100644 --- a/auth.inc.php +++ b/auth.inc.php @@ -9,11 +9,7 @@ if (isset($_POST["server"])) { $_SESSION["usernames"][$_POST["server"]] = $_POST["username"]; $_SESSION["passwords"][$_POST["server"]] = $_POST["password"]; if (count($_POST) == count($ignore)) { - if ((string) $_GET["server"] === $_POST["server"]) { - $location = remove_from_uri(); - } else { - $location = preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . (strlen($_POST["server"]) ? '?server=' . urlencode($_POST["server"]) : ''); - } + $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()])) { $location .= (strpos($location, "?") === false ? "?" : "&") . SID; } diff --git a/createv.inc.php b/createv.inc.php index feef4781..3281b30f 100644 --- a/createv.inc.php +++ b/createv.inc.php @@ -15,13 +15,12 @@ if ($_POST && !$error) { page_header((strlen($_GET["createv"]) ? lang('Alter view') : lang('Create view')), $error, array("view" => $_GET["createv"]), $_GET["createv"]); +$row = array(); if ($_POST) { $row = $_POST; } elseif (strlen($_GET["createv"])) { $row = view($_GET["createv"]); $row["name"] = $_GET["createv"]; -} else { - $row = array(); } ?> diff --git a/database.inc.php b/database.inc.php index e4ab8860..3ac4eeb6 100644 --- a/database.inc.php +++ b/database.inc.php @@ -31,12 +31,12 @@ if ($_POST && !$error) { page_header(strlen($_GET["db"]) ? lang('Alter database') : lang('Create database'), $error, array(), $_GET["db"]); $collations = collations(); +$name = $_GET["db"]; +$collate = array(); if ($_POST) { $name = $_POST["name"]; $collate = $_POST["collation"]; } else { - $name = $_GET["db"]; - $collate = array(); if (!strlen($_GET["db"])) { $result = $mysql->query("SHOW GRANTS"); while ($row = $result->fetch_row()) { diff --git a/dump.inc.php b/dump.inc.php index f6d953ec..5c19e984 100644 --- a/dump.inc.php +++ b/dump.inc.php @@ -1,6 +1,6 @@ query("SHOW CREATE TABLE " . idf_escape($table)); if ($result) { echo $mysql->result($result, 1) . ";\n\n"; diff --git a/edit.inc.php b/edit.inc.php index 56efbfc3..12bdb0db 100644 --- a/edit.inc.php +++ b/edit.inc.php @@ -7,12 +7,12 @@ foreach ($fields as $name => $field) { } } if ($_POST && !$error) { + $set = array(); if (isset($_POST["delete"])) { $set = true; $query = "DELETE FROM " . idf_escape($_GET["edit"]) . " WHERE " . implode(" AND ", $where) . " LIMIT 1"; $message = lang('Item has been deleted.'); } else { - $set = array(); foreach ($fields as $name => $field) { $val = process_input($name, $field); if ($val !== false) { @@ -43,6 +43,7 @@ if ($_POST && !$error) { } page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]); +unset($row); if ($_POST) { $row = (array) $_POST["fields"]; foreach ((array) $_POST["null"] as $key => $val) { @@ -61,8 +62,6 @@ if ($_POST) { } else { $row = array(); } -} else { - unset($row); } ?> diff --git a/functions.inc.php b/functions.inc.php index e4d7cd99..022cd754 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -215,14 +215,14 @@ function select($result) { echo "

" . lang('No rows.') . "

\n"; } else { echo "\n"; + $links = array(); + $indexes = array(); + $columns = array(); + $blobs = array(); + $types = array(); for ($i=0; $row = $result->fetch_row(); $i++) { if (!$i) { echo ""; - $links = array(); - $indexes = array(); - $columns = array(); - $blobs = array(); - $types = array(); for ($j=0; $j < count($row); $j++) { $field = $result->fetch_field(); if (strlen($field->orgtable)) { diff --git a/index.php b/index.php index 8f6b3ea9..57788663 100644 --- a/index.php +++ b/index.php @@ -42,6 +42,7 @@ if (isset($_GET["download"])) { $enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"'; $inout = array("IN", "OUT", "INOUT"); + $error = ""; if (isset($_GET["table"])) { include "./table.inc.php"; } elseif (isset($_GET["view"])) { @@ -53,7 +54,6 @@ if (isset($_GET["download"])) { } elseif (isset($_GET["privileges"])) { include "./privileges.inc.php"; } else { // uses CSRF token - $error = ""; if ($_POST) { if (!in_array($_POST["token"], (array) $TOKENS)) { $error = lang('Invalid CSRF token. Send the form again.'); diff --git a/indexes.inc.php b/indexes.inc.php index b1644d82..68b3c810 100644 --- a/indexes.inc.php +++ b/indexes.inc.php @@ -41,6 +41,7 @@ if ($_POST && !$error && !$_POST["add"]) { page_header(lang('Indexes'), $error, array("table" => $_GET["indexes"]), $_GET["indexes"]); $fields = array_keys(fields($_GET["indexes"])); +$row = array("indexes" => $indexes); if ($_POST) { $row = $_POST; if ($_POST["add"]) { @@ -55,7 +56,6 @@ if ($_POST) { } } } else { - $row = array("indexes" => $indexes); foreach ($row["indexes"] as $key => $index) { $row["indexes"][$key]["columns"][] = ""; } diff --git a/lang.inc.php b/lang.inc.php index c532d7f5..68f8f719 100644 --- a/lang.inc.php +++ b/lang.inc.php @@ -1,5 +1,5 @@ 'English', 'cs' => 'Čeština', // Jakub Vrána - http://php.vrana.cz 'sk' => 'Slovenčina', // Ivan Suchy - http://www.ivansuchy.com @@ -39,6 +39,7 @@ if (isset($_GET["lang"])) { $_SESSION["lang"] = $_GET["lang"]; } +$LANG = "en"; if (isset($langs[$_COOKIE["lang"]])) { setcookie("lang", $_GET["lang"], strtotime("+1 month"), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"])); $LANG = $_COOKIE["lang"]; @@ -51,7 +52,6 @@ if (isset($langs[$_COOKIE["lang"]])) { $accept_language[str_replace("_", "-", $match[1])] = (isset($match[3]) ? $match[3] : 1); } arsort($accept_language); - $LANG = "en"; foreach ($accept_language as $lang => $q) { if (isset($langs[$lang])) { $LANG = $lang; diff --git a/procedure.inc.php b/procedure.inc.php index 352fe6d8..36f42e04 100644 --- a/procedure.inc.php +++ b/procedure.inc.php @@ -32,6 +32,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] page_header((strlen($_GET["procedure"]) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . htmlspecialchars($_GET["procedure"]) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error); $collations = get_vals("SHOW CHARACTER SET"); +$row = array("fields" => array()); if ($_POST) { $row = $_POST; $row["fields"] = (array) $row["fields"]; @@ -39,8 +40,6 @@ if ($_POST) { } elseif (strlen($_GET["procedure"])) { $row = routine($_GET["procedure"], $routine); $row["name"] = $_GET["procedure"]; -} else { - $row = array("fields" => array()); } ?> diff --git a/schema.inc.php b/schema.inc.php index a53c9406..cf8e2e07 100644 --- a/schema.inc.php +++ b/schema.inc.php @@ -30,10 +30,10 @@ while ($row = $result->fetch_assoc()) { if ($row["Engine"] == "InnoDB") { foreach (foreign_keys($row["Name"]) as $val) { if (!$val["db"]) { + $left = $base_left; if ($table_pos[$row["Name"]][1] || $table_pos[$row["Name"]][1]) { $left = min($table_pos[$row["Name"]][1], $table_pos[$val["table"]][1]) - 1; } else { - $left = $base_left; $base_left -= .1; } while ($lefts[(string) $left]) { diff --git a/trigger.inc.php b/trigger.inc.php index 936b7327..d4034087 100644 --- a/trigger.inc.php +++ b/trigger.inc.php @@ -21,6 +21,7 @@ if ($_POST && !$error) { } page_header((strlen($_GET["name"]) ? lang('Alter trigger') . ": " . htmlspecialchars($_GET["name"]) : lang('Create trigger')), $error, array("table" => $_GET["trigger"])); +$row = array("Trigger" => "$_GET[trigger]_bi"); if ($_POST) { $row = $_POST; } elseif (strlen($_GET["name"])) { @@ -31,8 +32,6 @@ if ($_POST) { } } $result->free(); -} else { - $row = array("Trigger" => "$_GET[trigger]_bi"); } ?> diff --git a/user.inc.php b/user.inc.php index 3fc58485..e92b8ea0 100644 --- a/user.inc.php +++ b/user.inc.php @@ -27,8 +27,8 @@ function all_privileges(&$grants, $privileges) { } } +$new_grants = array(); if ($_POST) { - $new_grants = array(); foreach ($_POST["objects"] as $key => $val) { $new_grants[$val] = ((array) $new_grants[$val]) + ((array) $_POST["grants"][$key]); }