diff --git a/adminer/call.inc.php b/adminer/call.inc.php
index 8753e90e..0f7fe0fe 100644
--- a/adminer/call.inc.php
+++ b/adminer/call.inc.php
@@ -55,7 +55,7 @@ if ($in) {
$field = $routine["fields"][$key];
echo "
" . h($field["field"]);
$value = $_POST["fields"][$key];
- if (strlen($value) && ereg("enum|set", $field["type"])) {
+ if ($value != "" && ereg("enum|set", $field["type"])) {
$value = intval($value);
}
input($field, $value, (string) $_POST["function"][$name]); // param name can be empty
diff --git a/adminer/create.inc.php b/adminer/create.inc.php
index 3fcc76f1..fc332e63 100644
--- a/adminer/create.inc.php
+++ b/adminer/create.inc.php
@@ -10,7 +10,7 @@ foreach ($referencable_primary as $table_name => $field) {
$orig_fields = array();
$orig_status = array();
-if (strlen($TABLE)) {
+if ($TABLE != "") {
$orig_fields = fields($TABLE);
$orig_status = table_status($TABLE);
}
@@ -18,7 +18,7 @@ if (strlen($TABLE)) {
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
$auto_increment_index = " PRIMARY KEY";
// don't overwrite primary key by auto_increment
- if (strlen($TABLE) && $_POST["auto_increment_col"]) {
+ if ($TABLE != "" && $_POST["auto_increment_col"]) {
foreach (indexes($TABLE) as $index) {
if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) {
$auto_increment_index = "";
@@ -35,7 +35,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
$after = "FIRST";
foreach ($_POST["fields"] as $key => $field) {
$type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
- if (strlen($field["field"])) {
+ if ($field["field"] != "") {
if ($type_field) {
$default = eregi_replace(" *on update CURRENT_TIMESTAMP", "", $field["default"]);
if ($default != $field["default"]) { // preg_replace $count is available since PHP 5.1.0
@@ -48,47 +48,47 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
$process_field = process_field($field, $type_field);
$auto_increment = ($key == $_POST["auto_increment_col"]);
if ($process_field != process_field($orig_field, $orig_field) || $orig_field["auto_increment"] != $auto_increment) {
- $fields .= "\n" . (strlen($TABLE) ? (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) : "ADD") : " ")
+ $fields .= "\n" . ($TABLE != "" ? ($field["orig"] != "" ? "CHANGE " . idf_escape($field["orig"]) : "ADD") : " ")
. " $process_field"
. ($auto_increment ? " AUTO_INCREMENT$auto_increment_index" : "")
- . (strlen($TABLE) ? " $after" : "") . ","
+ . ($TABLE != "" ? " $after" : "") . ","
;
}
if (!isset($types[$field["type"]])) {
- $fields .= (strlen($TABLE) ? "\nADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . "),";
+ $fields .= ($TABLE != "" ? "\nADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . "),";
}
}
$after = "AFTER " . idf_escape($field["field"]);
//! drop and create foreign keys with renamed columns
- } elseif (strlen($field["orig"])) {
+ } elseif ($field["orig"] != "") {
$fields .= "\nDROP " . idf_escape($field["orig"]) . ",";
}
- if (strlen($field["orig"])) {
+ if ($field["orig"] != "") {
$orig_field = next($orig_fields);
}
}
$status = "COMMENT=" . $connection->quote($_POST["Comment"])
. ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $connection->quote($_POST["Engine"]) : "")
. ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $connection->quote($_POST["Collation"]) : "")
- . (strlen($_POST["auto_increment"]) ? " AUTO_INCREMENT=" . preg_replace('~[^0-9]+~', '', $_POST["auto_increment"]) : "")
+ . ($_POST["auto_increment"] != "" ? " AUTO_INCREMENT=" . preg_replace('~[^0-9]+~', '', $_POST["auto_increment"]) : "")
;
if (in_array($_POST["partition_by"], $partition_by)) {
$partitions = array();
if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
foreach (array_filter($_POST["partition_names"]) as $key => $val) {
$value = $_POST["partition_values"][$key];
- $partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . (strlen($value) ? " ($value)" : " MAXVALUE"); //! SQL injection
+ $partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
}
}
$status .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
? " (" . implode(",", $partitions) . "\n)"
: ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
);
- } elseif ($connection->server_info >= 5.1 && strlen($TABLE)) {
+ } elseif ($connection->server_info >= 5.1 && $TABLE != "") {
$status .= "\nREMOVE PARTITIONING";
}
$location = ME . "table=" . urlencode($_POST["name"]);
- if (strlen($TABLE)) {
+ if ($TABLE != "") {
query_redirect("ALTER TABLE " . idf_escape($TABLE) . "$fields\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
} else {
cookie("adminer_engine", $_POST["Engine"]);
@@ -96,7 +96,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
}
}
-page_header((strlen($TABLE) ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE);
+page_header(($TABLE != "" ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE);
$row = array(
"Engine" => $_COOKIE["adminer_engine"],
@@ -109,7 +109,7 @@ if ($_POST) {
$row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
}
process_fields($row["fields"]);
-} elseif (strlen($TABLE)) {
+} elseif ($TABLE != "") {
$row = $orig_status;
$row["name"] = $TABLE;
$row["fields"] = array();
diff --git a/adminer/database.inc.php b/adminer/database.inc.php
index ee82721d..4bdaca08 100644
--- a/adminer/database.inc.php
+++ b/adminer/database.inc.php
@@ -8,14 +8,14 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
$failed = false;
$last = "";
foreach ($dbs as $db) {
- if (count($dbs) == 1 || strlen($db)) { // ignore empty lines but always try to create single database
+ if (count($dbs) == 1 || $db != "") { // ignore empty lines but always try to create single database
if (!queries("CREATE DATABASE " . idf_escape($db) . ($_POST["collation"] ? " COLLATE " . $connection->quote($_POST["collation"]) : ""))) {
$failed = true;
}
$last = $db;
}
}
- if (query_redirect(queries(), ME . "db=" . urlencode($last), lang('Database has been created.'), !strlen(DB), false, $failed)) {
+ if (query_redirect(queries(), ME . "db=" . urlencode($last), lang('Database has been created.'), DB == "", false, $failed)) {
//! move triggers
$result = $connection->query("SHOW TABLES");
while ($row = $result->fetch_row()) {
@@ -38,7 +38,7 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
}
}
-page_header(strlen(DB) ? lang('Alter database') : lang('Create database'), $error, array(), DB);
+page_header(DB != "" ? lang('Alter database') : lang('Create database'), $error, array(), DB);
$collations = collations();
$name = DB;
@@ -46,7 +46,7 @@ $collate = null;
if ($_POST) {
$name = $_POST["name"];
$collate = $_POST["collation"];
-} elseif (!strlen(DB)) {
+} elseif (DB == "") {
// propose database name with limited privileges
$result = $connection->query("SHOW GRANTS");
while ($row = $result->fetch_row()) {
@@ -70,7 +70,7 @@ if ($_POST) {
\n";
}
?>
diff --git a/adminer/db.inc.php b/adminer/db.inc.php
index 4bd4e794..befc1e67 100644
--- a/adminer/db.inc.php
+++ b/adminer/db.inc.php
@@ -57,7 +57,7 @@ if (!$table_status) {
echo " | $row[Engine] | $row[Collation]";
foreach (array("Data_length" => "create", "Index_length" => "indexes", "Data_free" => "edit", "Auto_increment" => "create", "Rows" => "select") as $key => $link) {
$val = number_format($row[$key], 0, '.', lang(','));
- echo ' | ' . (strlen($row[$key]) ? '' . str_replace(" ", " ", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '' : ' ');
+ echo ' | ' . ($row[$key] != "" ? '' . str_replace(" ", " ", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '' : ' ');
}
echo " | " . nbsp($row["Comment"]);
} else {
diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php
index d478cdc9..50c6b118 100644
--- a/adminer/dump.inc.php
+++ b/adminer/dump.inc.php
@@ -2,7 +2,7 @@
$TABLE = $_GET["dump"];
if ($_POST) {
- $ext = dump_headers((strlen($TABLE) ? $TABLE : DB), (!strlen(DB) || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
+ $ext = dump_headers(($TABLE != "" ? $TABLE : DB), (DB == "" || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
if ($_POST["format"] == "sql") {
echo "-- Adminer $VERSION dump
SET NAMES utf8;
@@ -14,7 +14,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
}
$style = $_POST["db_style"];
- foreach ((strlen(DB) ? array(DB) : (array) $_POST["databases"]) as $db) {
+ foreach ((DB != "" ? array(DB) : (array) $_POST["databases"]) as $db) {
if ($connection->select_db($db)) {
if ($_POST["format"] == "sql" && ereg('CREATE', $style) && ($result = $connection->query("SHOW CREATE DATABASE " . idf_escape($db)))) {
if ($style == "DROP+CREATE") {
@@ -57,8 +57,8 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
if ($_POST["table_style"] || $_POST["data_style"]) {
$views = array();
foreach (table_status() as $row) {
- $table = (!strlen(DB) || in_array($row["Name"], (array) $_POST["tables"]));
- $data = (!strlen(DB) || in_array($row["Name"], (array) $_POST["data"]));
+ $table = (DB == "" || in_array($row["Name"], (array) $_POST["tables"]));
+ $data = (DB == "" || in_array($row["Name"], (array) $_POST["data"]));
if ($table || $data) {
if (isset($row["Engine"])) {
if ($ext == "tar") {
@@ -72,7 +72,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
dump_triggers($row["Name"], $_POST["table_style"]);
}
if ($ext == "tar") {
- echo tar_file((strlen(DB) ? "" : "$db/") . "$row[Name].csv", ob_get_clean());
+ echo tar_file((DB != "" ? "" : "$db/") . "$row[Name].csv", ob_get_clean());
} elseif ($_POST["format"] == "sql") {
echo "\n";
}
@@ -134,7 +134,7 @@ DROP PROCEDURE adminer_alter;
exit;
}
-page_header(lang('Export'), "", (strlen($_GET["export"]) ? array("table" => $_GET["export"]) : array()), DB);
+page_header(lang('Export'), "", ($_GET["export"] != "" ? array("table" => $_GET["export"]) : array()), DB);
?>
|
---|