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); ?>
@@ -149,9 +149,9 @@ if ($connection->server_info >= 5) { } echo "" . lang('Output') . "" . $adminer->dumpOutput(0) . "\n"; // token is not needed but checked in bootstrap for all POST data echo "" . lang('Format') . "" . $adminer->dumpFormat(0) . "\n"; -echo "" . lang('Database') . "" . html_select('db_style', $db_style, (strlen(DB) ? '' : 'CREATE')); +echo "" . lang('Database') . "" . html_select('db_style', $db_style, (DB != "" ? '' : 'CREATE')); if ($connection->server_info >= 5) { - $checked = !strlen($_GET["dump"]); + $checked = $_GET["dump"] == ""; echo checkbox("routines", 1, $checked, lang('Routines')); if ($connection->server_info >= 5.1) { echo checkbox("events", 1, $checked, lang('Events')); @@ -165,15 +165,15 @@ echo "" . lang('Data') . "" . html_select('data_style', $data_style, "; echo ""; for ($j=0; $j < count($row); $j++) { $field = $result->fetch_field(); - if (strlen($field->orgtable)) { + if ($field->orgtable != "") { if (!isset($indexes[$field->orgtable])) { // find primary key in each table $indexes[$field->orgtable] = array(); @@ -53,7 +53,7 @@ function select($result, $connection2 = null) { } else { if ($blobs[$key] && !is_utf8($val)) { $val = "" . lang('%d byte(s)', strlen($val)) . ""; //! link to download - } elseif (!strlen($val)) { + } elseif ($val == "") { $val = " "; // some content to print a border } else { $val = h($val); @@ -132,7 +132,7 @@ function process_length($length) { function process_type($field, $collate = "COLLATE") { global $connection, $unsigned; return " $field[type]" - . (strlen($field["length"]) && !ereg('^date|time$', $field["type"]) ? "(" . process_length($field["length"]) . ")" : "") + . ($field["length"] != "" && !ereg('^date|time$', $field["type"]) ? "(" . process_length($field["length"]) . ")" : "") . (ereg('int|float|double|decimal', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "") . (ereg('char|text|enum|set', $field["type"]) && $field["collation"] ? " $collate " . $connection->quote($field["collation"]) : "") ; @@ -182,7 +182,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $forei global $inout; $column_comments = false; foreach ($fields as $field) { - if (strlen($field["comment"])) { + if ($field["comment"] != "") { $column_comments = true; break; } @@ -213,7 +213,7 @@ if ($type == "PROCEDURE") { echo "
"; echo ""; echo "\n"; $views = ""; foreach (table_status() as $row) { - $checked = !strlen($TABLE) || $row["Name"] == $TABLE; + $checked = $TABLE == "" || $row["Name"] == $TABLE; $print = "
" . checkbox("tables[]", $row["Name"], $checked, $row["Name"], "formUncheck('check-tables');"); if (!$row["Engine"]) { $views .= "$print\n"; diff --git a/adminer/edit.inc.php b/adminer/edit.inc.php index 8b67ebc2..b3c22320 100644 --- a/adminer/edit.inc.php +++ b/adminer/edit.inc.php @@ -4,7 +4,7 @@ $where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_ $update = (isset($_GET["select"]) ? $_POST["edit"] : $where); $fields = fields($TABLE); foreach ($fields as $name => $field) { - if (!isset($field["privileges"][$update ? "update" : "insert"]) || !strlen($adminer->fieldName($field))) { + if (!isset($field["privileges"][$update ? "update" : "insert"]) || $adminer->fieldName($field) == "") { unset($fields[$name]); } } @@ -77,7 +77,7 @@ if ($fields) { echo "
" . $adminer->fieldName($field); $default = $_GET["set"][bracket_escape($name)]; $value = (isset($row) - ? (strlen($row[$name]) && ereg("enum|set", $field["type"]) ? intval($row[$name]) : $row[$name]) + ? ($row[$name] != "" && ereg("enum|set", $field["type"]) ? intval($row[$name]) : $row[$name]) : ($_POST["clone"] && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : (isset($default) ? $default : $field["default"]))) ); if (!$_POST["save"] && is_string($value)) { diff --git a/adminer/event.inc.php b/adminer/event.inc.php index 52d15f17..3556b4c4 100644 --- a/adminer/event.inc.php +++ b/adminer/event.inc.php @@ -14,22 +14,22 @@ if ($_POST && !$error) { : "AT " . $connection->quote($_POST["STARTS"]) ) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE" ; - query_redirect((strlen($EVENT) + query_redirect(($EVENT != "" ? "ALTER EVENT " . idf_escape($EVENT) . $schedule . ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "") : "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $connection->quote($_POST["EVENT_COMMENT"]) . " DO\n$_POST[EVENT_DEFINITION]" - , substr(ME, 0, -1), (strlen($EVENT) ? lang('Event has been altered.') : lang('Event has been created.'))); + , substr(ME, 0, -1), ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.'))); } } -page_header((strlen($EVENT) ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error); +page_header(($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error); $row = array(); if ($_POST) { $row = $_POST; -} elseif (strlen($EVENT)) { +} elseif ($EVENT != "") { $result = $connection->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $connection->quote(DB) . " AND EVENT_NAME = " . $connection->quote($EVENT)); $row = $result->fetch_assoc(); } @@ -49,5 +49,5 @@ if ($_POST) {

-> +> diff --git a/adminer/foreign.inc.php b/adminer/foreign.inc.php index ab503a82..33c45e64 100644 --- a/adminer/foreign.inc.php +++ b/adminer/foreign.inc.php @@ -11,11 +11,11 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change- $target[$key] = $_POST["target"][$key]; } query_redirect("ALTER TABLE " . idf_escape($TABLE) - . (strlen($_GET["name"]) ? "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]) . "," : "") + . ($_GET["name"] != "" ? "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]) . "," : "") . "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . idf_escape($_POST["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" . (in_array($_POST["on_delete"], $on_actions) ? " ON DELETE $_POST[on_delete]" : "") . (in_array($_POST["on_update"], $on_actions) ? " ON UPDATE $_POST[on_update]" : "") - , ME . "table=" . urlencode($TABLE), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.'))); + , ME . "table=" . urlencode($TABLE), ($_GET["name"] != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.'))); $error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.') . "
$error"; //! no partitioning } } @@ -31,7 +31,7 @@ if ($_POST) { } elseif ($_POST["change"] || $_POST["change-js"]) { $row["target"] = array(); } -} elseif (strlen($_GET["name"])) { +} elseif ($_GET["name"] != "") { $foreign_keys = foreign_keys($TABLE); $row = $foreign_keys[$_GET["name"]]; $row["source"][] = ""; @@ -43,7 +43,7 @@ $target = ($TABLE === $row["table"] ? $source : array_keys(fields($row["table"])

- + : @@ -68,6 +68,6 @@ foreach ($row["source"] as $key => $val) {

-> +>

diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index e0dc28bd..d382e839 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -207,7 +207,7 @@ class Adminer { } $i = 0; foreach ((array) $_GET["where"] as $val) { - if (strlen("$val[col]$val[val]") && in_array($val["op"], $this->operators)) { + if ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators)) { echo "
"; echo html_select("where[$i][op]", $this->operators, $val["op"]); echo "
\n"; @@ -308,15 +308,15 @@ class Adminer { global $connection; $return = array(); foreach ($indexes as $i => $index) { - if ($index["type"] == "FULLTEXT" && strlen($_GET["fulltext"][$i])) { + if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") { $return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . $connection->quote($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")"; } } foreach ((array) $_GET["where"] as $val) { - if (strlen("$val[col]$val[val]") && in_array($val["op"], $this->operators)) { + if ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators)) { $in = process_length($val["val"]); - $cond = " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : (ereg('IN$', $val["op"]) ? " (" . (strlen($in) ? $in : "NULL") . ")" : " " . $this->processInput($fields[$val["col"]], $val["val"]))); - if (strlen($val["col"])) { + $cond = " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : (ereg('IN$', $val["op"]) ? " (" . ($in != "" ? $in : "NULL") . ")" : " " . $this->processInput($fields[$val["col"]], $val["val"]))); + if ($val["col"] != "") { $return[] = idf_escape($val["col"]) . $cond; } else { // find anywhere @@ -505,7 +505,7 @@ class Adminer {

-"> +"> "(" . lang('database') . ")") + $databases, DB, "this.form.submit();") : ''); ?> @@ -514,7 +514,7 @@ class Adminer {

select_db(DB)) { + if ($missing != "db" && DB != "" && $connection->select_db(DB)) { $tables = tables_list(); if (!$tables) { echo "

" . lang('No tables.') . "\n"; diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 0e8b923c..3e4284f9 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -11,7 +11,7 @@ if (isset($_POST["server"])) { ); } if (count($_POST) == 3 + ($_POST["permanent"] ? 1 : 0)) { // 3 - server, username, password - $location = ((string) $_GET["server"] === $_POST["server"] ? remove_from_uri(session_name()) : preg_replace('~^([^?]*).*~', '\\1', ME) . (strlen($_POST["server"]) ? '?server=' . urlencode($_POST["server"]) : '')); + $location = ((string) $_GET["server"] === $_POST["server"] ? remove_from_uri(session_name()) : preg_replace('~^([^?]*).*~', '\\1', ME) . ($_POST["server"] != "" ? '?server=' . urlencode($_POST["server"]) : '')); if (SID) { $pos = strpos($location, '?'); $location = ($pos ? substr_replace($location, SID . "&", $pos + 1, 0) : "$location?" . SID); @@ -37,7 +37,7 @@ if (isset($_POST["server"])) { } } elseif ($_COOKIE["adminer_permanent"] && !isset($_SESSION["usernames"][$_GET["server"]])) { list($server, $username, $cipher) = array_map('base64_decode', explode(":", $_COOKIE["adminer_permanent"])); - if (!strlen($_GET["server"]) || $server == $_GET["server"]) { + if ($_GET["server"] == "" || $server == $_GET["server"]) { session_regenerate_id(); // defense against session fixation $_SESSION["usernames"][$server] = $username; $_SESSION["passwords"][$server] = decrypt_string($cipher, $adminer->permanentLogin()); diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 61c109ae..997ff60e 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -40,7 +40,7 @@ if (isset($_GET["file"])) { } if (!isset($_SERVER["REQUEST_URI"])) { - $_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"] . (strlen($_SERVER["QUERY_STRING"]) ? "?$_SERVER[QUERY_STRING]" : ""); + $_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"] . ($_SERVER["QUERY_STRING"] != "" ? "?$_SERVER[QUERY_STRING]" : ""); } session_write_close(); // disable session.auto_start @@ -75,7 +75,7 @@ if (function_exists("set_magic_quotes_runtime")) { @set_time_limit(0); // @ - can be disabled define("DB", $_GET["db"]); // for the sake of speed and size -define("ME", preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . '?' . (SID ? SID . '&' : '') . (strlen($_GET["server"]) ? 'server=' . urlencode($_GET["server"]) . '&' : '') . (strlen(DB) ? 'db=' . urlencode(DB) . '&' : '')); +define("ME", preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . '?' . (SID ? SID . '&' : '') . ($_GET["server"] != "" ? 'server=' . urlencode($_GET["server"]) . '&' : '') . (DB != "" ? 'db=' . urlencode(DB) . '&' : '')); include "../adminer/include/version.inc.php"; include "../adminer/include/functions.inc.php"; diff --git a/adminer/include/connect.inc.php b/adminer/include/connect.inc.php index 592506c8..dc82806f 100644 --- a/adminer/include/connect.inc.php +++ b/adminer/include/connect.inc.php @@ -1,7 +1,7 @@ select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]))) { - if (strlen(DB)) { +if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]))) { + if (DB != "") { unset($_SESSION["databases"][$_GET["server"]]); } connect_error(); // separate function to catch SQLite error diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 1ff03b65..2374c8da 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -3,14 +3,14 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { global $LANG, $VERSION, $adminer, $connection; header("Content-Type: text/html; charset=utf-8"); header("X-Frame-Options: deny"); // ClickJacking protection in IE8, Safari 4, Chrome 2, NoScript plugin - $title_all = $title . (strlen($title2) ? ": " . h($title2) : ""); + $title_all = $title . ($title2 != "" ? ": " . h($title2) : ""); ?> -<?php echo $title_all . (strlen($_GET["server"]) && $_GET["server"] != "localhost" ? h("- $_GET[server]") : "") . " - " . $adminer->name(); ?> +<?php echo $title_all . ($_GET["server"] != "" && $_GET["server"] != "localhost" ? h("- $_GET[server]") : "") . " - " . $adminer->name(); ?> @@ -25,14 +25,14 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { ' . (isset($_GET["server"]) ? h($_GET["server"]) : lang('Server')) . ' » '; + echo '

" . html_select("fields[$i][inout]", $inout, $field["inout"]); } ?> -" onchange=" 1 ? "" : "editingAddRow(this, $allowed); "); ?>editingNameChange(this);" maxlength="64">"> +" onchange=" 1 ? "" : "editingAddRow(this, $allowed); "); ?>editingNameChange(this);" maxlength="64">"> @@ -348,9 +348,9 @@ function drop_create($drop, $create, $location, $message_drop, $message_alter, $ if ($_POST["drop"]) { return query_redirect($drop, $location, $message_drop, true, !$_POST["dropped"]); } - $dropped = strlen($name) && ($_POST["dropped"] || queries($drop)); + $dropped = $name != "" && ($_POST["dropped"] || queries($drop)); $created = queries($create); - if (!queries_redirect($location, (strlen($name) ? $message_alter : $message_create), $created) && $dropped) { + if (!queries_redirect($location, ($name != "" ? $message_alter : $message_create), $created) && $dropped) { restart_session(); $_SESSION["messages"][] = $message_drop; } diff --git a/adminer/include/export.inc.php b/adminer/include/export.inc.php index d7b7f945..e258cd71 100644 --- a/adminer/include/export.inc.php +++ b/adminer/include/export.inc.php @@ -167,7 +167,7 @@ function dump_data($table, $style, $select = "") { } function dump_headers($identifier, $multi_table = false) { - $filename = (strlen($identifier) ? friendly_url($identifier) : "dump"); + $filename = ($identifier != "" ? friendly_url($identifier) : "dump"); $output = $_POST["output"]; $ext = ($_POST["format"] == "sql" ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR header("Content-Type: " . diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 4425d484..fcc5b2c9 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -57,7 +57,7 @@ function h($string) { * @return string */ function nbsp($string) { - return (strlen(trim($string)) ? h($string) : " "); + return (trim($string) != "" ? h($string) : " "); } /** Generate HTML checkbox @@ -72,7 +72,7 @@ function checkbox($name, $value, $checked, $label = "", $onclick = "") { static $id = 0; $id++; $return = ""; - return (strlen($label) ? "" : $return); + return ($label != "" ? "" : $return); } /** Generate list of HTML options @@ -227,7 +227,7 @@ function redirect($location, $message = null) { restart_session(); $_SESSION["messages"][] = $message; } - header("Location: " . (strlen($location) ? $location : ".")); + header("Location: " . ($location != "" ? $location : ".")); exit; } @@ -430,7 +430,7 @@ function input($field, $value, $function) { $attrs = " name='fields[$name]'$onchange"; echo (count($functions) > 1 ? html_select("function[$name]", $functions, !isset($function) || in_array($function, $functions) ? $function : "") : nbsp(reset($functions))) . ''; $input = $adminer->editInput($_GET["edit"], $field, $attrs, $value); // usage in call is without a table - if (strlen($input)) { + if ($input != "") { echo $input; } elseif ($field["type"] == "set") { //! 64 bits preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches); @@ -462,7 +462,7 @@ function process_input($field) { $value = $_POST["fields"][$idf]; if ($field["type"] == "enum" ? $value == -1 : $function == "orig") { return false; - } elseif ($field["type"] == "enum" || $field["auto_increment"] ? !strlen($value) : $function == "NULL") { + } elseif ($field["type"] == "enum" || $field["auto_increment"] ? $value == "" : $function == "NULL") { return "NULL"; } elseif ($field["type"] == "enum") { return intval($value); @@ -485,7 +485,7 @@ function process_input($field) { */ function dump_csv($row) { foreach ($row as $key => $val) { - if (preg_match("~[\"\n,]~", $val) || (isset($val) && !strlen($val))) { + if (preg_match("~[\"\n,]~", $val) || $val === "") { $row[$key] = '"' . str_replace('"', '""', $val) . '"'; } } diff --git a/adminer/include/mysql.inc.php b/adminer/include/mysql.inc.php index 11e495f1..d3a6d129 100644 --- a/adminer/include/mysql.inc.php +++ b/adminer/include/mysql.inc.php @@ -11,9 +11,9 @@ if (extension_loaded("mysqli")) { function connect($server, $username, $password) { list($host, $port) = explode(":", $server, 2); // part after : is used for port or socket return @$this->real_connect( - (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")), + ($server != "" ? $host : ini_get("mysqli.default_host")), + ("$server$username" != "" ? $username : ini_get("mysqli.default_user")), + ("$server$username$password" != "" ? $password : ini_get("mysqli.default_pw")), null, (is_numeric($port) ? $port : ini_get("mysqli.default_port")), (!is_numeric($port) ? $port : null) @@ -39,9 +39,9 @@ if (extension_loaded("mysqli")) { function connect($server, $username, $password) { $this->_link = @mysql_connect( - (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")), + ($server != "" ? $server : ini_get("mysql.default_host")), + ("$server$username" != "" ? $username : ini_get("mysql.default_user")), + ("$server$username$password" != "" ? $password : ini_get("mysql.default_password")), true, 131072 // CLIENT_MULTI_RESULTS for CALL ); @@ -229,13 +229,13 @@ function tables_list() { function table_status($name = "") { global $connection; $return = array(); - $result = $connection->query("SHOW TABLE STATUS" . (strlen($name) ? " LIKE " . $connection->quote(addcslashes($name, "%_")) : "")); + $result = $connection->query("SHOW TABLE STATUS" . ($name != "" ? " LIKE " . $connection->quote(addcslashes($name, "%_")) : "")); while ($row = $result->fetch_assoc()) { if ($row["Engine"] == "InnoDB") { // ignore internal comment, unnecessary since MySQL 5.1.21 $row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["Comment"]); } - if (strlen($name)) { + if ($name != "") { return $row; } $return[$row["Name"]] = $row; @@ -273,7 +273,7 @@ function fields($table) { "type" => $match[1], "length" => $match[2], "unsigned" => ltrim($match[3] . $match[4]), - "default" => (strlen($row["Default"]) || ereg("char", $match[1]) ? $row["Default"] : null), + "default" => ($row["Default"] != "" || ereg("char", $match[1]) ? $row["Default"] : null), "null" => ($row["Null"] == "YES"), "auto_increment" => ($row["Extra"] == "auto_increment"), "on_update" => (eregi('^on update (.+)', $row["Extra"], $match) ? $match[1] : ""), //! available since MySQL 5.1.23 @@ -325,8 +325,8 @@ function foreign_keys($table) { preg_match_all("~`($pattern)`~", $match[2], $source); preg_match_all("~`($pattern)`~", $match[5], $target); $return[$match[1]] = array( - "db" => idf_unescape(strlen($match[4]) ? $match[3] : $match[4]), - "table" => idf_unescape(strlen($match[4]) ? $match[4] : $match[3]), + "db" => idf_unescape($match[4] != "" ? $match[3] : $match[4]), + "table" => idf_unescape($match[4] != "" ? $match[4] : $match[3]), "source" => array_map('idf_unescape', $source[1]), "target" => array_map('idf_unescape', $target[1]), "on_delete" => $match[6], diff --git a/adminer/indexes.inc.php b/adminer/indexes.inc.php index c3275e44..239379d6 100644 --- a/adminer/indexes.inc.php +++ b/adminer/indexes.inc.php @@ -11,7 +11,7 @@ if ($_POST && !$error && !$_POST["add"]) { $set = array(); ksort($index["columns"]); foreach ($index["columns"] as $key => $column) { - if (strlen($column)) { + if ($column != "") { $length = $index["lengths"][$key]; $set[] = idf_escape($column) . ($length ? "(" . intval($length) . ")" : ""); $columns[count($columns) + 1] = $column; @@ -50,7 +50,7 @@ if ($_POST) { $row = $_POST; if ($_POST["add"]) { foreach ($row["indexes"] as $key => $index) { - if (strlen($index["columns"][count($index["columns"])])) { + if ($index["columns"][count($index["columns"])] != "") { $row["indexes"][$key]["columns"][] = ""; } } diff --git a/adminer/privileges.inc.php b/adminer/privileges.inc.php index 9642c812..0540040a 100644 --- a/adminer/privileges.inc.php +++ b/adminer/privileges.inc.php @@ -6,7 +6,7 @@ if (!$result) { ?>

-"> +"> : : diff --git a/adminer/procedure.inc.php b/adminer/procedure.inc.php index 5638aee5..a631b8cf 100644 --- a/adminer/procedure.inc.php +++ b/adminer/procedure.inc.php @@ -8,7 +8,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] $fields = (array) $_POST["fields"]; ksort($fields); // enforce fields order foreach ($fields as $field) { - if (strlen($field["field"])) { + if ($field["field"] != "") { $set[] = (in_array($field["inout"], $inout) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET"); } } @@ -23,7 +23,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] ); } -page_header((strlen($PROCEDURE) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error); +page_header(($PROCEDURE != "" ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error); $collations = get_vals("SHOW CHARACTER SET"); sort($collations); @@ -32,7 +32,7 @@ if ($_POST) { $row = $_POST; $row["fields"] = (array) $row["fields"]; process_fields($row["fields"]); -} elseif (strlen($PROCEDURE)) { +} elseif ($PROCEDURE != "") { $row = routine($PROCEDURE, $routine); $row["name"] = $PROCEDURE; } @@ -49,5 +49,5 @@ if ($_POST) { : " maxlength="64"> -> +>

diff --git a/adminer/select.inc.php b/adminer/select.inc.php index b7d4917f..a166a16a 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -10,7 +10,7 @@ $columns = array(); // selectable columns unset($text_length); foreach ($fields as $key => $field) { $name = $adminer->fieldName($field); - if (isset($field["privileges"]["select"]) && strlen($name)) { + if (isset($field["privileges"]["select"]) && $name != "") { $columns[$key] = html_entity_decode(strip_tags($name)); if (ereg('text|blob', $field["type"])) { $text_length = $adminer->selectLengthProcess(); @@ -110,7 +110,7 @@ if ($_POST && !$error) { } else { $set = ""; foreach ($matches2[1] as $i => $col) { - $set .= ", " . idf_escape($cols[$i]) . " = " . (!strlen($col) && $fields[$cols[$i]]["null"] ? "NULL" : $connection->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col)))); + $set .= ", " . idf_escape($cols[$i]) . " = " . ($col == "" && $fields[$cols[$i]]["null"] ? "NULL" : $connection->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col)))); } $set = substr($set, 1); $result = queries("INSERT INTO " . idf_escape($_GET["select"]) . " SET$set ON DUPLICATE KEY UPDATE$set"); @@ -148,8 +148,8 @@ if (!$columns) { } else { echo "
\n"; echo "
"; - echo (strlen($_GET["server"]) ? '' : ""); - echo (strlen(DB) ? '' : ""); // not used in Editor + echo ($_GET["server"] != "" ? '' : ""); + echo (DB != "" ? '' : ""); // not used in Editor echo ''; echo "
\n"; $adminer->selectColumnsPrint($select, $columns); @@ -160,7 +160,7 @@ if (!$columns) { $adminer->selectActionPrint($text_length); echo "
\n"; - $query = "SELECT " . (intval($limit) && $group && count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . (strlen($limit) ? " LIMIT " . intval($limit) . ($_GET["page"] ? " OFFSET " . ($limit * $_GET["page"]) : "") : ""); + $query = "SELECT " . (intval($limit) && $group && count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . ($limit != "" ? " LIMIT " . intval($limit) . ($_GET["page"] ? " OFFSET " . ($limit * $_GET["page"]) : "") : ""); echo $adminer->selectQuery($query); $result = $connection->query($query); @@ -193,7 +193,7 @@ if (!$columns) { $val = $_GET["columns"][key($select)]; $field = $fields[$select ? $val["col"] : $key]; $name = ($field ? $adminer->fieldName($field, $order) : "*"); - if (strlen($name)) { + if ($name != "") { $order++; $names[$key] = $name; echo '
' . apply_sql_function($val["fun"], $name) . ""; //! columns looking like functions @@ -207,7 +207,7 @@ if (!$columns) { foreach ($row as $key => $val) { if (isset($names[$key])) { $field = $fields[$key]; - if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) { + if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) { $email_fields[$key] = (is_email($val) ? $names[$key] : ""); //! filled e-mails may be contained on other pages } $link = ""; @@ -215,12 +215,12 @@ if (!$columns) { if (!isset($val)) { $val = "NULL"; } else { - if (ereg('blob|binary', $field["type"]) && strlen($val)) { + if (ereg('blob|binary', $field["type"]) && $val != "") { $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . "&$unique_idf"); } - if (!strlen($val)) { + if ($val == "") { $val = " "; - } elseif (strlen($text_length) && ereg('text|blob', $field["type"]) && is_utf8($val)) { + } elseif ($text_length != "" && ereg('text|blob', $field["type"]) && is_utf8($val)) { $val = shorten_utf8($val, max(0, intval($text_length))); // usage of LEFT() would reduce traffic but complicate query } else { $val = h($val); @@ -232,7 +232,7 @@ if (!$columns) { foreach ($foreign_key["source"] as $i => $source) { $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]); } - $link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link); // InnoDB supports non-UNIQUE keys + $link = h(($foreign_key["db"] != "" ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link); // InnoDB supports non-UNIQUE keys break; } } diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index e87aad14..f1f794e1 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -22,7 +22,7 @@ if (!$error && $_POST) { } if (is_string($query)) { // get_file() returns error as number, fread() as false @ini_set("memory_limit", 2 * strlen($query) + memory_get_usage() + 8e6); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables - if (strlen($query) && strlen($query) < 1e6 && (!$history || end($history) != $query)) { // don't add repeated and big queries + if ($query != "" && strlen($query) < 1e6 && (!$history || end($history) != $query)) { // don't add repeated and big queries $history[] = $query; } $space = "(\\s|/\\*.*\\*/|(#|-- )[^\n]*\n|--\n)"; @@ -35,12 +35,12 @@ if (!$error && $_POST) { $delimiter = ";"; $offset = 0; $empty = true; - $connection2 = (strlen(DB) ? connect() : null); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error + $connection2 = (DB != "" ? connect() : null); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error if (is_object($connection2)) { $connection2->select_db(DB); } $explain = 1; - while (strlen($query)) { + while ($query != "") { if (!$offset && preg_match('~^\\s*DELIMITER\\s+(.+)~i', $query, $match)) { $delimiter = $match[1]; $query = substr($query, strlen($match[0])); @@ -51,7 +51,7 @@ if (!$error && $_POST) { if (!$found && $fp && !feof($fp)) { $query .= fread($fp, 1e5); } else { - if (!$found && !strlen(rtrim($query))) { + if (!$found && rtrim($query) == "") { break; } if (!$found || $found == $delimiter) { // end of a query @@ -122,7 +122,7 @@ if (!$error && $_POST) { $q = $_GET["sql"]; // overwrite $q from if ($_POST) to save memory if ($_POST) { $q = $_POST["query"]; -} elseif (strlen($_GET["history"])) { +} elseif ($_GET["history"] != "") { $q = $history[$_GET["history"]]; } echo h($q); diff --git a/adminer/table.inc.php b/adminer/table.inc.php index 544f5424..5b576118 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -43,10 +43,10 @@ if ($fields) { if ($foreign_keys) { echo "\n"; foreach ($foreign_keys as $name => $foreign_key) { - $link = (strlen($foreign_key["db"]) ? "" . h($foreign_key["db"]) . "." : "") . h($foreign_key["table"]); + $link = ($foreign_key["db"] != "" ? "" . h($foreign_key["db"]) . "." : "") . h($foreign_key["table"]); echo ""; echo "
" . implode(", ", array_map('h', $foreign_key["source"])) . ""; - echo "$link"; + echo "$link"; echo "(" . implode(", ", array_map('h', $foreign_key["target"])) . ")"; echo '' . lang('Alter') . ''; } diff --git a/adminer/trigger.inc.php b/adminer/trigger.inc.php index 9f82a504..784eb756 100644 --- a/adminer/trigger.inc.php +++ b/adminer/trigger.inc.php @@ -16,12 +16,12 @@ if ($_POST && !$error && in_array($_POST["Timing"], $trigger_time) && in_array($ ); } -page_header((strlen($_GET["name"]) ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $TABLE)); +page_header(($_GET["name"] != "" ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $TABLE)); $row = array("Trigger" => $TABLE . "_bi"); if ($_POST) { $row = $_POST; -} elseif (strlen($_GET["name"])) { +} elseif ($_GET["name"] != "") { $result = $connection->query("SHOW TRIGGERS WHERE `Trigger` = " . $connection->quote($_GET["name"])); $row = $result->fetch_assoc(); } @@ -38,5 +38,5 @@ if ($_POST) { -> +> diff --git a/adminer/user.inc.php b/adminer/user.inc.php index 8ab986f7..6cad287b 100644 --- a/adminer/user.inc.php +++ b/adminer/user.inc.php @@ -107,7 +107,7 @@ if ($_POST) { } else { $row = $_GET + array("host" => $connection->result($connection->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"))); // create user on the same domain by default $row["pass"] = $old_pass; - if (strlen($old_pass)) { + if ($old_pass != "") { $row["hashed"] = true; } $grants[""] = true; diff --git a/adminer/view.inc.php b/adminer/view.inc.php index de39ebb6..b78448d5 100644 --- a/adminer/view.inc.php +++ b/adminer/view.inc.php @@ -13,12 +13,12 @@ if ($_POST && !$error) { ); } -page_header((strlen($TABLE) ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE); +page_header(($TABLE != "" ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE); $row = array(); if ($_POST) { $row = $_POST; -} elseif (strlen($TABLE)) { +} elseif ($TABLE != "") { $row = view($TABLE); $row["name"] = $TABLE; } diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 85c9e728..e65b799a 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -42,11 +42,11 @@ class Adminer { } function tableName($tableStatus) { - return h(strlen($tableStatus["Comment"]) ? $tableStatus["Comment"] : $tableStatus["Name"]); + return h($tableStatus["Comment"] != "" ? $tableStatus["Comment"] : $tableStatus["Name"]); } function fieldName($field, $order = 0) { - return h(strlen($field["comment"]) ? $field["comment"] : $field["field"]); + return h($field["comment"] != "" ? $field["comment"] : $field["field"]); } function selectLinks($tableStatus, $set = "") { @@ -71,7 +71,7 @@ ORDER BY ORDINAL_POSITION"); } foreach ($return as $key => $val) { $name = $this->tableName(table_status($key)); - if (strlen($name)) { + if ($name != "") { $search = preg_quote($tableName); $separator = "(:|\\s*-)?\\s+"; $return[$key]["name"] = (preg_match("(^$search$separator(.+)|^(.+?)$separator$search\$)", $name, $match) ? $match[2] . $match[3] : $name); @@ -126,7 +126,7 @@ ORDER BY ORDINAL_POSITION"); if (count($foreignKey["source"]) == 1) { $id = idf_escape($foreignKey["target"][0]); $name = $this->rowDescription($foreignKey["table"]); - if (strlen($name)) { + if ($name != "") { // find all used ids $ids = array(); foreach ($rows as $row) { @@ -206,7 +206,7 @@ ORDER BY ORDINAL_POSITION"); } $i = 0; foreach ((array) $_GET["where"] as $val) { - if (strlen("$val[col]$val[val]")) { + if ("$val[col]$val[val]" != "") { echo "
"; echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]); echo "
\n"; @@ -275,10 +275,10 @@ ORDER BY ORDINAL_POSITION"); $return = array(); foreach ((array) $_GET["where"] as $key => $val) { $col = $val["col"]; - if (strlen(($key < 0 ? "" : $col) . $val["val"])) { + if (($key < 0 ? "" : $col) . $val["val"] != "") { $conds = array(); - foreach ((strlen($col) ? array($col => $fields[$col]) : $fields) as $name => $field) { - if (strlen($col) || is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) { + foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) { + if ($col != "" || is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) { $text_type = ereg('char|text|enum|set', $field["type"]); $value = $this->processInput($field, ($text_type && ereg('^[^%]+$', $val["val"]) ? "%$val[val]%" : $val["val"])); $conds[] = idf_escape($name) . ($value == "NULL" ? " IS" . ($val["op"] == ">=" ? " NOT" : "") : (in_array($val["op"], $this->operators) ? " $val[op]" : ($val["op"] != "=" && $text_type ? " LIKE" : " ="))) . " $value"; @@ -295,8 +295,8 @@ ORDER BY ORDINAL_POSITION"); return array(idf_escape($_GET["order"][0]) . (isset($_GET["desc"][0]) ? " DESC" : "")); } $index_order = $_GET["index_order"]; - foreach ((strlen($index_order) ? array($indexes[$index_order]) : $indexes) as $index) { - if (strlen($index_order) || $index["type"] == "INDEX") { + foreach (($index_order != "" ? array($indexes[$index_order]) : $indexes) as $index) { + if ($index_order != "" || $index["type"] == "INDEX") { $desc = false; foreach ($index["columns"] as $val) { if (ereg('date|timestamp', $fields[$val]["type"])) { @@ -424,10 +424,10 @@ ORDER BY ORDINAL_POSITION"); } $return = $value; if (ereg('date|timestamp', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P[0-9]*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P[0-9]{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)) { - $return = (strlen($match["p1"]) ? $match["p1"] : (strlen($match["p2"]) ? ($match["p2"] < 70 ? 20 : 19) . $match["p2"] : gmdate("Y"))) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match); + $return = ($match["p1"] != "" ? $match["p1"] : ($match["p2"] != "" ? ($match["p2"] < 70 ? 20 : 19) . $match["p2"] : gmdate("Y"))) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match); } $return = $connection->quote($return); - if (!ereg('varchar|text', $field["type"]) && $field["full_type"] != "tinyint(1)" && !strlen($value)) { + if (!ereg('varchar|text', $field["type"]) && $field["full_type"] != "tinyint(1)" && $value == "") { $return = "NULL"; } return $return; @@ -474,7 +474,7 @@ ORDER BY ORDINAL_POSITION"); echo "

\n"; foreach ($tables as $row) { $name = $this->tableName($row); - if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name + if (isset($row["Engine"]) && $name != "") { // ignore views and tables without name echo "" . bold($name, $_GET["select"] == $row["Name"]) . "
\n"; } } @@ -487,7 +487,7 @@ ORDER BY ORDINAL_POSITION"); if (count($foreignKey["source"]) == 1) { $id = idf_escape($foreignKey["target"][0]); $name = $this->rowDescription($foreignKey["table"]); - if (strlen($name)) { + if ($name != "") { $return = &$this->values[$foreignKey["table"]]; if (!isset($return)) { $return = array("" => "") + get_key_vals("SELECT $id, $name FROM " . idf_escape($foreignKey["table"]) . " ORDER BY 2 LIMIT 1001"); diff --git a/editor/include/export.inc.php b/editor/include/export.inc.php index a9d45551..dd48f7bc 100644 --- a/editor/include/export.inc.php +++ b/editor/include/export.inc.php @@ -14,7 +14,7 @@ function dump_data($table, $style, $select = "") { } function dump_headers($identifier) { - $filename = (strlen($identifier) ? friendly_url($identifier) : "dump"); + $filename = ($identifier != "" ? friendly_url($identifier) : "dump"); $ext = "csv"; header("Content-Type: text/csv; charset=utf-8"); header("Content-Disposition: attachment; filename=$filename.$ext");