]> git.joonet.de Git - adminer.git/commitdiff
Treat binary type as hex
authorJakub Vrana <jakub@vrana.cz>
Tue, 28 Sep 2010 08:02:55 +0000 (10:02 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 1 Oct 2010 06:05:05 +0000 (08:05 +0200)
adminer/drivers/mysql.inc.php
adminer/include/adminer.inc.php
adminer/include/functions.inc.php
adminer/select.inc.php
changes.txt

index 059e0c5bc4f302c6b9b785d8d97702c08d127079..b7eb92bf77a16523d15659755a23060be277a87a 100644 (file)
@@ -915,6 +915,7 @@ if (!defined("DRIVER")) {
        $edit_functions = array( ///< @var array of array("$type|$type2" => "$function/$function2") functions used in editing, [0] - edit and insert, [1] - edit only
                array(
                        "char" => "md5/sha1/password/encrypt/uuid", //! JavaScript for disabling maxlength
+                       "binary" => "md5/sha1/hex",
                        "date|time" => "now",
                ), array(
                        "int|float|double|decimal" => "+/-",
index f2144ba750d35899cf8ad9f45c0819f17d22d6e4..6a5897e5f13477453f834f720632221a7fb15ff5 100644 (file)
@@ -150,8 +150,8 @@ document.getElementById('username').focus();
        * @return string
        */
        function selectVal($val, $link, $field) {
-               $return = ($val != "<i>NULL</i>" && $field["type"] == "char" ? "<code>$val</code>" : $val);
-               if (ereg('binary|blob|bytea|raw|file', $field["type"]) && !is_utf8($val)) {
+               $return = ($val != "<i>NULL</i>" && ereg("^char|binary", $field["type"]) ? "<code>$val</code>" : $val);
+               if (ereg('blob|bytea|raw|file', $field["type"]) && !is_utf8($val)) {
                        $return = lang('%d byte(s)', strlen(html_entity_decode($val, ENT_QUOTES)));
                }
                return ($link ? "<a href='$link'>$return</a>" : $return);
@@ -163,7 +163,7 @@ document.getElementById('username').focus();
        * @return string
        */
        function editVal($val, $field) {
-               return $val;
+               return (ereg("binary", $field["type"]) ? reset(unpack("H*", $val)) : $val);
        }
        
        /** Print columns box in select
@@ -449,9 +449,12 @@ document.getElementById('username').focus();
                        $return = idf_escape($name) . " $function " . (preg_match("~^([0-9]+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : $return);
                } elseif (ereg('^(addtime|subtime|concat)$', $function)) {
                        $return = "$function(" . idf_escape($name) . ", $return)";
-               } elseif (ereg('^(md5|sha1|password|encrypt)$', $function)) {
+               } elseif (ereg('^(md5|sha1|password|encrypt|hex)$', $function)) {
                        $return = "$function($return)";
                }
+               if (ereg("binary", $field["type"])) {
+                       $return = "unhex($return)";
+               }
                return $return;
        }
        
index 9bed50724cfd740a99becf635348811af9b69fe3..e994e66f77f5c72613ea4c61b3a07fa49358ed37 100644 (file)
@@ -573,14 +573,14 @@ function input($field, $value, $function) {
                                $checked = (is_int($value) ? ($value >> $i) & 1 : in_array($val, explode(",", $value), true));
                                echo " <label><input type='checkbox' name='fields[$name][$i]' value='" . (1 << $i) . "'" . ($checked ? ' checked' : '') . "$onchange>" . h($val) . '</label>';
                        }
-               } elseif (ereg('binary|blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
+               } elseif (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
                        echo "<input type='file' name='fields-$name'$onchange>";
                } elseif (ereg('text|lob', $field["type"])) {
                        echo "<textarea " . ($jush != "sqlite" || ereg("\n", $value) ? "cols='50' rows='12'" : "cols='30' rows='1' style='height: 1.2em;'") . "$attrs>" . h($value) . '</textarea>'; // 1.2em - line-height
                } else {
                        // int(3) is only a display hint
-                       $maxlength = (!ereg('int', $field["type"]) && preg_match('~^([0-9]+)(,([0-9]+))?$~', $field["length"], $match) ? ($match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
-                       echo "<input value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "") . (ereg('char', $field["type"]) && $field["length"] > 20 ? " size='40'" : "") . "$attrs>";
+                       $maxlength = (!ereg('int', $field["type"]) && preg_match('~^([0-9]+)(,([0-9]+))?$~', $field["length"], $match) ? ((ereg("binary", $field["type"]) ? 2 : 1) * $match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
+                       echo "<input value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "") . (ereg('char|binary', $field["type"]) && $maxlength > 20 ? " size='40'" : "") . "$attrs>";
                }
        }
 }
@@ -615,7 +615,7 @@ function process_input($field) {
        if ($field["type"] == "set") {
                return array_sum((array) $value);
        }
-       if (ereg('binary|blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
+       if (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
                $file = get_file("fields-$idf");
                if (!is_string($file)) {
                        return false; //! report errors
index e2f332be8452aa55aa20b2b9c7788415b5157955..23af29b404c4503b28dfd3eff5563436a48fe566 100644 (file)
@@ -286,7 +286,7 @@ if (!$columns) {
                                                if (!isset($val)) {
                                                        $val = "<i>NULL</i>";
                                                } else {
-                                                       if (ereg('binary|blob|bytea|raw|file', $field["type"]) && $val != "") {
+                                                       if (ereg('blob|bytea|raw|file', $field["type"]) && $val != "") {
                                                                $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf);
                                                        }
                                                        if ($val == "") {
index d537b72bade5975db9e6cd040dac20ef47733eca..834eed715ace916b541c3c8fdf271112876e3b63 100644 (file)
@@ -4,6 +4,7 @@ Allow concurrent logins on the same server
 Allow permanent login without customization
 In-place editation in select
 Foreign key options in Table creation
+Treat binary type as hex
 Show number of tables in server overview
 Operator LIKE %%
 Remember export parameters in cookie
@@ -19,7 +20,7 @@ Ability to jump to any page in select by JavaScript
 Display comment in table overview
 Link last page above data in select
 Link table names in SQL queries
-Japanese translation
+Japanese and Tamil translation
 Defer table information in database overview to JavaScript (performance)
 Big tables optimizations (performance)