]> git.joonet.de Git - adminer.git/commitdiff
Replace strlen() by != ""
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sat, 9 Jan 2010 23:33:41 +0000 (23:33 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Sat, 9 Jan 2010 23:33:41 +0000 (23:33 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1288 7c3ca157-0c34-0410-bff1-cbf682f78f5c

28 files changed:
adminer/call.inc.php
adminer/create.inc.php
adminer/database.inc.php
adminer/db.inc.php
adminer/dump.inc.php
adminer/edit.inc.php
adminer/event.inc.php
adminer/foreign.inc.php
adminer/include/adminer.inc.php
adminer/include/auth.inc.php
adminer/include/bootstrap.inc.php
adminer/include/connect.inc.php
adminer/include/design.inc.php
adminer/include/editing.inc.php
adminer/include/export.inc.php
adminer/include/functions.inc.php
adminer/include/mysql.inc.php
adminer/indexes.inc.php
adminer/privileges.inc.php
adminer/procedure.inc.php
adminer/select.inc.php
adminer/sql.inc.php
adminer/table.inc.php
adminer/trigger.inc.php
adminer/user.inc.php
adminer/view.inc.php
editor/include/adminer.inc.php
editor/include/export.inc.php

index 8753e90e9a12cb30a69580a9bd99d9b9169d5d36..0f7fe0fe2a85bae43bc1db1b1648724bd01ea6ce 100644 (file)
@@ -55,7 +55,7 @@ if ($in) {
                $field = $routine["fields"][$key];
                echo "<tr><th>" . 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
index 3fcc76f13ec82bebabc776dcb930708a5b1ee63b..fc332e639063f3f81a4b597b45fe0497f3822d14 100644 (file)
@@ -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();
index ee82721d065c8bb878654c7729c6c13b83868369..4bdaca08caff07218beea3368d5ebffbf9306411 100644 (file)
@@ -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) {
 <input type="hidden" name="token" value="<?php echo $token; ?>">
  <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
-if (!$_POST["add_x"] && !strlen($_GET["db"])) {
+if (!$_POST["add_x"] && $_GET["db"] == "") {
        echo "<input type='image' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
 }
 ?>
index 4bd4e794583d75e7fb115e1975e9a58921ff90ef..befc1e67eb2fd78051ade5f159fe74d48a96d447 100644 (file)
@@ -57,7 +57,7 @@ if (!$table_status) {
                        echo "<td>$row[Engine]<td>$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 '<td align="right">' . (strlen($row[$key]) ? '<a href="' . h(ME . "$link=") . urlencode($name) . '">' . str_replace(" ", "&nbsp;", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '</a>' : '&nbsp;');
+                               echo '<td align="right">' . ($row[$key] != "" ? '<a href="' . h(ME . "$link=") . urlencode($name) . '">' . str_replace(" ", "&nbsp;", ($key == "Rows" && $row["Engine"] == "InnoDB" && $val ? lang('~ %s', $val) : $val)) . '</a>' : '&nbsp;');
                        }
                        echo "<td>" . nbsp($row["Comment"]);
                } else {
index d478cdc9c541de2d4f098c0d7f9fd8ebfe4eb12e..50c6b118fd3da7d2622842a12f7760a3c47341e0 100644 (file)
@@ -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);
 ?>
 
 <form action="" method="post">
@@ -149,9 +149,9 @@ if ($connection->server_info >= 5) {
 }
 echo "<tr><th>" . lang('Output') . "<td><input type='hidden' name='token' value='$token'>" . $adminer->dumpOutput(0) . "\n"; // token is not needed but checked in bootstrap for all POST data
 echo "<tr><th>" . lang('Format') . "<td>" . $adminer->dumpFormat(0) . "\n";
-echo "<tr><th>" . lang('Database') . "<td>" . html_select('db_style', $db_style, (strlen(DB) ? '' : 'CREATE'));
+echo "<tr><th>" . lang('Database') . "<td>" . 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 "<tr><th>" . lang('Data') . "<td>" . html_select('data_style', $data_style,
 
 <table cellspacing="0">
 <?php
-if (strlen(DB)) {
-       $checked = (strlen($TABLE) ? "" : " checked");
+if (DB != "") {
+       $checked = ($TABLE != "" ? "" : " checked");
        echo "<thead><tr>";
        echo "<th style='text-align: left;'><label><input type='checkbox' id='check-tables'$checked onclick='formCheck(this, /^tables\\[/);'>" . lang('Tables') . "</label>";
        echo "<th style='text-align: right;'><label>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='formCheck(this, /^data\\[/);'></label>";
        echo "</thead>\n";
        $views = "";
        foreach (table_status() as $row) {
-               $checked = !strlen($TABLE) || $row["Name"] == $TABLE;
+               $checked = $TABLE == "" || $row["Name"] == $TABLE;
                $print = "<tr><td>" . checkbox("tables[]", $row["Name"], $checked, $row["Name"], "formUncheck('check-tables');");
                if (!$row["Engine"]) {
                        $views .= "$print\n";
index 8b67ebc2417e5d505015a321b5d6b9e158e7851b..b3c223208630edcc5355046a5c06bc6a0a6eb1d6 100644 (file)
@@ -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 "<tr><th>" . $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)) {
index 52d15f1737fd6535ed458596586ad6963ce55bee..3556b4c4d8f1b29e5f8c182d3af82765818ce89b 100644 (file)
@@ -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) {
 <p>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if (strlen($EVENT)) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
+<?php if ($EVENT != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
 </form>
index ab503a8226e7b9b253124e0d6eec9d7324b77d9c..33c45e64a786ab0aca2bc0625ae45824aba1de02 100644 (file)
@@ -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.') . "<br>$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"])
 
 <form action="" method="post">
 <p>
-<?php if (!strlen($row["db"])) { ?>
+<?php if ($row["db"] == "") { ?>
 <?php echo lang('Target table'); ?>:
 <?php echo html_select("table", array_keys(table_status_referencable()), $row["table"], "this.form['change-js'].value = '1'; this.form.submit();"); ?>
 <input type="hidden" name="change-js" value="">
@@ -68,6 +68,6 @@ foreach ($row["source"] as $key => $val) {
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <noscript><p><input type="submit" name="add" value="<?php echo lang('Add column'); ?>"></noscript>
 <?php } ?>
-<?php if (strlen($_GET["name"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
+<?php if ($_GET["name"] != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
index e0dc28bd7f433b85b11e85b06b2e6aca2e98f1cb..d382e83987ec5f0627004783616e2c2cb0c34490 100644 (file)
@@ -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 "<div><select name='where[$i][col]'><option value=''>" . lang('(anywhere)') . optionlist($columns, $val["col"], true) . "</select>";
                                echo html_select("where[$i][op]", $this->operators, $val["op"]);
                                echo "<input name='where[$i][val]' value='" . h($val["val"]) . "'></div>\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 {
 <form action="">
 <p>
 <?php if (SID) { ?><input type="hidden" name="<?php echo session_name(); ?>" value="<?php echo h(session_id()); ?>"><?php } ?>
-<?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo h($_GET["server"]); ?>"><?php } ?>
+<?php if ($_GET["server"] != "") { ?><input type="hidden" name="server" value="<?php echo h($_GET["server"]); ?>"><?php } ?>
 <?php echo ($databases ? html_select("db", array("" => "(" . lang('database') . ")") + $databases, DB, "this.form.submit();") : '<input name="db" value="' . h(DB) . '">'); ?>
 <?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value=""><?php } ?>
 <?php if (isset($_GET["schema"])) { ?><input type="hidden" name="schema" value=""><?php } ?>
@@ -514,7 +514,7 @@ class Adminer {
 </p>
 </form>
 <?php
-                       if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
+                       if ($missing != "db" && DB != "" && $connection->select_db(DB)) {
                                $tables = tables_list();
                                if (!$tables) {
                                        echo "<p class='message'>" . lang('No tables.') . "\n";
index 0e8b923c50d3266448c9d63b2be6cf1077e08b9f..3e4284f9f970b2c230a9b156e6279473c74faeb1 100644 (file)
@@ -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());
index 61c109aee6d58e70f8e3e7c9e4eab7e68d08de23..997ff60e1a3a88389759df552044946b76a8d214 100644 (file)
@@ -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";
index 592506c88110c5b359a5c6c5177e402d81bbc88a..dc82806ff8de68140704876021cbab0c2f40b7cb 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 function connect_error() {
        global $connection, $VERSION, $token, $error;
-       if (strlen(DB)) {
+       if (DB != "") {
                page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), false);
        } else {
                if ($_POST["db"] && !$error) {
@@ -51,8 +51,8 @@ function connect_error() {
 if (isset($_GET["status"])) {
        $_GET["variables"] = $_GET["status"];
 }
-if (!(strlen(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 (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
index 1ff03b654df65f8361822395e5e81c60c497774d..2374c8da7ce60c11c703d06dd7c12a523b5251ce 100644 (file)
@@ -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) : "");
        ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
 <html lang="<?php echo $LANG; ?>">
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <meta http-equiv="Content-Script-Type" content="text/javascript">
 <meta name="robots" content="noindex">
-<title><?php echo $title_all . (strlen($_GET["server"]) && $_GET["server"] != "localhost" ? h("- $_GET[server]") : "") . " - " . $adminer->name(); ?></title>
+<title><?php echo $title_all . ($_GET["server"] != "" && $_GET["server"] != "localhost" ? h("- $_GET[server]") : "") . " - " . $adminer->name(); ?></title>
 <link rel="shortcut icon" type="image/x-icon" href="../adminer/static/favicon.ico">
 <link rel="stylesheet" type="text/css" href="../adminer/static/default.css<?php // Ondrej Valka, http://valka.info ?>">
 <?php if (file_exists("adminer.css")) { ?>
@@ -25,14 +25,14 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
 <?php
        if (isset($breadcrumb)) {
                $link = substr(preg_replace('~db=[^&]*&~', '', ME), 0, -1);
-               echo '<p id="breadcrumb"><a href="' . (strlen($link) ? h($link) : ".") . '">' . (isset($_GET["server"]) ? h($_GET["server"]) : lang('Server')) . '</a> &raquo; ';
+               echo '<p id="breadcrumb"><a href="' . ($link != "" ? h($link) : ".") . '">' . (isset($_GET["server"]) ? h($_GET["server"]) : lang('Server')) . '</a> &raquo; ';
                if (is_array($breadcrumb)) {
-                       if (strlen(DB)) {
+                       if (DB != "") {
                                echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h(DB) . '</a> &raquo; ';
                        }
                        foreach ($breadcrumb as $key => $val) {
                                $desc = (is_array($val) ? $val[1] : $val);
-                               if (strlen($desc)) {
+                               if ($desc != "") {
                                        echo '<a href="' . h(ME . "$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> &raquo; ';
                                }
                        }
@@ -49,7 +49,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
                $_SESSION["passwords"] = array();
        }
        $databases = &$_SESSION["databases"][$_GET["server"]];
-       if (strlen(DB) && $databases && !in_array(DB, $databases, true)) {
+       if (DB != "" && $databases && !in_array(DB, $databases, true)) {
                $databases = null;
        }
        if ($error) {
index c623a4499896a8fa97a875c9a79ec7a6c7afebab..a5fda4c7fed553e29c518de4edd548a548e265a2 100644 (file)
@@ -20,7 +20,7 @@ function select($result, $connection2 = null) {
                                echo "<thead><tr>";
                                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 = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
-                                       } elseif (!strlen($val)) {
+                                       } elseif ($val == "") {
                                                $val = "&nbsp;"; // 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 "<td>" . html_select("fields[$i][inout]", $inout, $field["inout"]);
 }
 ?>
-<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="<?php echo (strlen($field["field"]) || count($fields) > 1 ? "" : "editingAddRow(this, $allowed); "); ?>editingNameChange(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($field[($_POST ? "orig" : "field")]); ?>">
+<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="<?php echo ($field["field"] != "" || count($fields) > 1 ? "" : "editingAddRow(this, $allowed); "); ?>editingNameChange(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($field[($_POST ? "orig" : "field")]); ?>">
 <?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
 <?php if ($type == "TABLE") { ?>
 <td><?php echo checkbox("fields[$i][null]", 1, $field["null"]); ?>
@@ -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;
        }
index d7b7f9457fdeddcc66bdc7a7794b95aec93f59d4..e258cd7195c36bc17c040a7bb54c0b0490764fad 100644 (file)
@@ -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: " .
index 4425d484c49c8a876593da238dbf353478f024b3..fcc5b2c91188b61240de77dc8f2da56a8e1faf30 100644 (file)
@@ -57,7 +57,7 @@ function h($string) {
 * @return string
 */
 function nbsp($string) {
-       return (strlen(trim($string)) ? h($string) : "&nbsp;");
+       return (trim($string) != "" ? h($string) : "&nbsp;");
 }
 
 /** Generate HTML checkbox
@@ -72,7 +72,7 @@ function checkbox($name, $value, $checked, $label = "", $onclick = "") {
        static $id = 0;
        $id++;
        $return = "<input type='checkbox' name='$name' value='" . h($value) . "'" . ($checked ? " checked" : "") . ($onclick ? " onclick=\"$onclick\"" : "") . " id='checkbox-$id'>";
-       return (strlen($label) ? "<label for='checkbox-$id'>$return" . h($label) . "</label>" : $return);
+       return ($label != "" ? "<label for='checkbox-$id'>$return" . h($label) . "</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))) . '<td>';
                $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) . '"';
                }
        }
index 11e495f1783375599bf0c6699f177acd931dbe14..d3a6d129f889a8a4cbba33315fc395e08564a529 100644 (file)
@@ -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],
index c3275e4462c01401fdfbe21e1be528d900d666d3..239379d6f3cf8a35595b3b8d3ceb8a8cb72f2bc2 100644 (file)
@@ -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"][] = "";
                        }
                }
index 9642c812fd8fae9e6998b8b0985f9ad962a1f9b9..0540040adb74973e7ac775c82740580f65bd010c 100644 (file)
@@ -6,7 +6,7 @@ if (!$result) {
        ?>
 <form action=""><p>
 <?php if (SID) { ?><input type="hidden" name="<?php echo session_name(); ?>" value="<?php echo h(session_id()); ?>"><?php } ?>
-<?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo h($_GET["server"]); ?>"><?php } ?>
+<?php if ($_GET["server"] != "") { ?><input type="hidden" name="server" value="<?php echo h($_GET["server"]); ?>"><?php } ?>
 <?php echo lang('Username'); ?>: <input name="user">
 <?php echo lang('Server'); ?>: <input name="host" value="localhost">
 <input type="hidden" name="grant" value="">
index 5638aee53ecb749dd22537f300af32eda32994f7..a631b8cf59751d600ccf4e78ed788ca8590aa312 100644 (file)
@@ -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) {
 <?php if ($dropped) { ?><input type="hidden" name="dropped" value="1"><?php } ?>
 <?php echo lang('Name'); ?>: <input name="name" value="<?php echo h($row["name"]); ?>" maxlength="64">
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if (strlen($PROCEDURE)) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
+<?php if ($PROCEDURE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
 </form>
index b7d4917fba7eeb7b49ce9718d3cb382d291f361b..a166a16aea82eb8c055b20a5b17c9b72c6b3a124 100644 (file)
@@ -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 "<form action='' id='form'>\n";
        echo "<div style='display: none;'>";
-       echo (strlen($_GET["server"]) ? '<input type="hidden" name="server" value="' . h($_GET["server"]) . '">' : "");
-       echo (strlen(DB) ? '<input type="hidden" name="db" value="' . h(DB) . '">' : ""); // not used in Editor
+       echo ($_GET["server"] != "" ? '<input type="hidden" name="server" value="' . h($_GET["server"]) . '">' : "");
+       echo (DB != "" ? '<input type="hidden" name="db" value="' . h(DB) . '">' : ""); // not used in Editor
        echo '<input type="hidden" name="select" value="' . h($TABLE) . '">';
        echo "</div>\n";
        $adminer->selectColumnsPrint($select, $columns);
@@ -160,7 +160,7 @@ if (!$columns) {
        $adminer->selectActionPrint($text_length);
        echo "</form>\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 '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"][0] == $key && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; //! 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 = "<i>NULL</i>";
                                                } 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 = "&nbsp;";
-                                                       } 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;
                                                                        }
                                                                }
index e87aad14a062068edda895ff44ac35f96fc0a702..f1f794e14782585a473647a203c05eff805f4df4 100644 (file)
@@ -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);
index 544f5424199ec7c5cd0a8b0d10f703cc866b7971..5b576118178de85e5794d3b3a731e40573c1f02e 100644 (file)
@@ -43,10 +43,10 @@ if ($fields) {
                        if ($foreign_keys) {
                                echo "<table cellspacing='0'>\n";
                                foreach ($foreign_keys as $name => $foreign_key) {
-                                       $link = (strlen($foreign_key["db"]) ? "<strong>" . h($foreign_key["db"]) . "</strong>." : "") . h($foreign_key["table"]);
+                                       $link = ($foreign_key["db"] != "" ? "<strong>" . h($foreign_key["db"]) . "</strong>." : "") . h($foreign_key["table"]);
                                        echo "<tr>";
                                        echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>";
-                                       echo "<td><a href='" . h(strlen($foreign_key["db"]) ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ME) . "table=" . urlencode($foreign_key["table"]) . "'>$link</a>";
+                                       echo "<td><a href='" . h($foreign_key["db"] != "" ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ME) . "table=" . urlencode($foreign_key["table"]) . "'>$link</a>";
                                        echo "(<em>" . implode("</em>, <em>", array_map('h', $foreign_key["target"])) . "</em>)";
                                        echo '<td><a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>';
                                }
index 9f82a504869fd4425148f36797c91b4fb5d95f1c..784eb7564988360b32e1b369ca7e414926a21370 100644 (file)
@@ -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) {
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 <?php if ($dropped) { ?><input type="hidden" name="dropped" value="1"><?php } ?>
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if (strlen($_GET["name"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
+<?php if ($_GET["name"] != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
 </form>
index 8ab986f70786bc5dda38312c4858c1df1f20053e..6cad287bedfcdcd29f3eb90ea3a59e5f2b45e356 100644 (file)
@@ -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;
index de39ebb6c069b5fbb026983b1edbf4bf1fb43f14..b78448d5852a345758d150b6161f0b1424840a46 100644 (file)
@@ -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;
 }
index 85c9e7288cce9b55919102e36831de07c0a2458a..e65b799a3c3b184f3e65128b5055907f919bf294 100644 (file)
@@ -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 "<div><select name='where[$i][col]'><option value=''>" . lang('(anywhere)') . optionlist($columns, $val["col"], true) . "</select>";
                                echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]);
                                echo "<input name='where[$i][val]' value='" . h($val["val"]) . "'></div>\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<p1>[0-9]*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P<p\\2>[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 "<p id='tables'>\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 "<a href='" . h(ME) . 'select=' . urlencode($row["Name"]) . "'>" . bold($name, $_GET["select"] == $row["Name"]) . "</a><br>\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");
index a9d4555145b1e1322816d28cc7f09a5b7c47f62f..dd48f7bc876320c3c7a7fe2583ab1a44634f5175 100644 (file)
@@ -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");