Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initialize variables outside blocks

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@427 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
commit d8df52061e8e851f338ec4c8ff91ab51a0d021c9 1 parent de8a3c5
jakubvrana authored
View
6 auth.inc.php
@@ -9,11 +9,7 @@
$_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;
}
View
3  createv.inc.php
@@ -15,13 +15,12 @@
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();
}
?>
View
4 database.inc.php
@@ -31,12 +31,12 @@
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()) {
View
2  dump.inc.php
@@ -1,6 +1,6 @@
<?php
function dump_table($table, $style) {
- global $mysql, $max_packet;
+ global $mysql, $max_packet, $types;
$result = $mysql->query("SHOW CREATE TABLE " . idf_escape($table));
if ($result) {
echo $mysql->result($result, 1) . ";\n\n";
View
5 edit.inc.php
@@ -7,12 +7,12 @@
}
}
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 @@
}
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 @@
} else {
$row = array();
}
-} else {
- unset($row);
}
?>
View
10 functions.inc.php
@@ -215,14 +215,14 @@ function select($result) {
echo "<p class='message'>" . lang('No rows.') . "</p>\n";
} else {
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
+ $links = array();
+ $indexes = array();
+ $columns = array();
+ $blobs = array();
+ $types = array();
for ($i=0; $row = $result->fetch_row(); $i++) {
if (!$i) {
echo "<thead><tr>";
- $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)) {
View
2  index.php
@@ -42,6 +42,7 @@
$enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"';
$inout = array("IN", "OUT", "INOUT");
+ $error = "";
if (isset($_GET["table"])) {
include "./table.inc.php";
} elseif (isset($_GET["view"])) {
@@ -53,7 +54,6 @@
} 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.');
View
2  indexes.inc.php
@@ -41,6 +41,7 @@
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 @@
}
}
} else {
- $row = array("indexes" => $indexes);
foreach ($row["indexes"] as $key => $index) {
$row["indexes"][$key]["columns"][] = "";
}
View
4 lang.inc.php
@@ -1,5 +1,5 @@
<?php
-static $langs = array(
+$langs = array(
'en' => 'English',
'cs' => 'Čeština', // Jakub Vrána - http://php.vrana.cz
'sk' => 'Slovenčina', // Ivan Suchy - http://www.ivansuchy.com
@@ -39,6 +39,7 @@ function switch_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 @@ function switch_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;
View
3  procedure.inc.php
@@ -32,6 +32,7 @@
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 @@
} elseif (strlen($_GET["procedure"])) {
$row = routine($_GET["procedure"], $routine);
$row["name"] = $_GET["procedure"];
-} else {
- $row = array("fields" => array());
}
?>
View
2  schema.inc.php
@@ -30,10 +30,10 @@
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]) {
View
3  trigger.inc.php
@@ -21,6 +21,7 @@
}
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 @@
}
}
$result->free();
-} else {
- $row = array("Trigger" => "$_GET[trigger]_bi");
}
?>
View
2  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]);
}
Please sign in to comment.
Something went wrong with that request. Please try again.