From 5002b89bd5724072078efbdbb3bfd9ac9402b79e Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sat, 23 Oct 2010 00:02:24 +0200 Subject: [PATCH] Big numbers without E --- adminer/create.inc.php | 2 +- adminer/drivers/mssql.inc.php | 2 +- adminer/drivers/mysql.inc.php | 4 ++-- adminer/include/adminer.inc.php | 2 +- adminer/include/bootstrap.inc.php | 3 ++- adminer/include/functions.inc.php | 4 ++-- adminer/processlist.inc.php | 2 +- adminer/static/editing.js | 12 ++++++------ adminer/static/functions.js | 4 ++-- editor/include/adminer.inc.php | 4 ++-- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/adminer/create.inc.php b/adminer/create.inc.php index 92091dd5..e1128e6f 100644 --- a/adminer/create.inc.php +++ b/adminer/create.inc.php @@ -83,7 +83,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] $_POST["Comment"], ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? $_POST["Engine"] : ""), ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? $_POST["Collation"] : ""), - ($_POST["Auto_increment"] != "" ? preg_replace('~\\D+~', '', $_POST["Auto_increment"]) : ""), + ($_POST["Auto_increment"] != "" ? +$_POST["Auto_increment"] : ""), $partitioning )); } diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index de3114bd..11f15b54 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -399,7 +399,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table) } function auto_increment() { - return " IDENTITY" . ($_POST["Auto_increment"] != "" ? "(" . preg_replace('~\\D+~', '', $_POST["Auto_increment"]) . ",1)" : ""); + return " IDENTITY" . ($_POST["Auto_increment"] != "" ? "(" . (+$_POST["Auto_increment"]) . ",1)" : ""); } function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) { diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 406dc4a5..cc0fd66e 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -212,7 +212,7 @@ if (!defined("DRIVER")) { var $extension = "PDO_MySQL"; function connect($server, $username, $password) { - $this->dsn("mysql:host=" . str_replace(":", ";unix_socket=", preg_replace('~:([0-9])~', ';port=\\1', $server)), $username, $password); + $this->dsn("mysql:host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\\d)~', ';port=\\1', $server)), $username, $password); $this->query("SET NAMES utf8"); // charset in DSN is ignored return true; } @@ -820,7 +820,7 @@ if (!defined("DRIVER")) { global $connection; $return = $connection->result("SHOW CREATE TABLE " . table($table), 1); if (!$auto_increment) { - $return = preg_replace('~ AUTO_INCREMENT=[0-9]+~', '', $return); //! skip comments + $return = preg_replace('~ AUTO_INCREMENT=\\d+~', '', $return); //! skip comments } return $return; } diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 2b15cfd3..7068088c 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -453,7 +453,7 @@ document.getElementById('username').focus(); } elseif (ereg('^([+-]|\\|\\|)$', $function)) { $return = idf_escape($name) . " $function $return"; } elseif (ereg('^[+-] interval$', $function)) { - $return = idf_escape($name) . " $function " . (preg_match("~^([0-9]+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : $return); + $return = idf_escape($name) . " $function " . (preg_match("~^(\\d+|'[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|hex)$', $function)) { diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index fc3ae784..003c9164 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -39,11 +39,12 @@ if (!defined("SID")) { // disable magic quotes to be able to use database escaping function remove_slashes(array(&$_GET, &$_POST, &$_COOKIE)); -if (function_exists("set_magic_quotes_runtime")) { +if (function_exists("set_magic_quotes_runtime")) { // removed in PHP 6 set_magic_quotes_runtime(false); } @set_time_limit(0); // @ - can be disabled @ini_set("zend.ze1_compatibility_mode", false); // @ - deprecated +@ini_set("precision", 20); // @ - can be disabled include "../adminer/include/lang.inc.php"; include "../adminer/lang/$LANG.inc.php"; diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 1331e5f3..7fe46c44 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -618,7 +618,7 @@ function input($field, $value, $function) { echo "'; // 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) ? ((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)); + $maxlength = (!ereg('int', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $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 " 20 ? " size='40'" : "") . "$attrs>"; } } @@ -760,7 +760,7 @@ function is_mail($email) { */ function is_url($string) { $domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // one domain component //! IDN - return (preg_match("~^(https?)://($domain?\\.)+$domain(:[0-9]+)?(/.*)?(\\?.*)?(#.*)?\$~i", $string, $match) ? strtolower($match[1]) : ""); //! restrict path, query and fragment characters + return (preg_match("~^(https?)://($domain?\\.)+$domain(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i", $string, $match) ? strtolower($match[1]) : ""); //! restrict path, query and fragment characters } /** Print header for hidden fieldset (close by ) diff --git a/adminer/processlist.inc.php b/adminer/processlist.inc.php index 7f773d34..c37d105b 100644 --- a/adminer/processlist.inc.php +++ b/adminer/processlist.inc.php @@ -2,7 +2,7 @@ if ($_POST && !$error) { $killed = 0; foreach ((array) $_POST["kill"] as $val) { - if (queries("KILL " . ereg_replace("[^0-9]+", "", $val))) { + if (queries("KILL " . (+$val))) { $killed++; } } diff --git a/adminer/static/editing.js b/adminer/static/editing.js index a3464248..c2244277 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -139,7 +139,7 @@ function editingAddRow(button, allowed, focus) { if (allowed && rowCount >= allowed) { return false; } - var match = /([0-9]+)(\.[0-9]+)?/.exec(button.name); + var match = /(\d+)(\.\d+)?/.exec(button.name); var x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1'; var row = button.parentNode.parentNode; var row2 = row.cloneNode(true); @@ -309,11 +309,11 @@ function indexesAddRow(field) { } var selects = row.getElementsByTagName('select'); for (var i=0; i < selects.length; i++) { - selects[i].name = selects[i].name.replace(/indexes\[[0-9]+/, '$&1'); + selects[i].name = selects[i].name.replace(/indexes\[\d+/, '$&1'); selects[i].selectedIndex = 0; } var input = row.getElementsByTagName('input')[0]; - input.name = input.name.replace(/indexes\[[0-9]+/, '$&1'); + input.name = input.name.replace(/indexes\[\d+/, '$&1'); input.value = ''; field.parentNode.parentNode.parentNode.appendChild(row); } @@ -325,10 +325,10 @@ function indexesAddColumn(field) { field.onchange = function () { }; var column = field.parentNode.cloneNode(true); var select = column.getElementsByTagName('select')[0]; - select.name = select.name.replace(/\]\[[0-9]+/, '$&1'); + select.name = select.name.replace(/\]\[\d+/, '$&1'); select.selectedIndex = 0; var input = column.getElementsByTagName('input')[0]; - input.name = input.name.replace(/\]\[[0-9]+/, '$&1'); + input.name = input.name.replace(/\]\[\d+/, '$&1'); input.value = ''; field.parentNode.parentNode.appendChild(column); } @@ -374,7 +374,7 @@ function schemaMousemove(ev) { isTop = (div2.offsetTop + ref[0] * em > divs[i].offsetTop + top * em); } if (!lineSet[id]) { - var line = document.getElementById(divs[i].id.replace(/^....(.+)-[0-9]+$/, 'refl$1')); + var line = document.getElementById(divs[i].id.replace(/^....(.+)-\d+$/, 'refl$1')); var shift = ev.clientY - y - that.offsetTop; line.style.left = (left + left1) + 'em'; if (isTop) { diff --git a/adminer/static/functions.js b/adminer/static/functions.js index f8478a00..fa0c7b4f 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -109,12 +109,12 @@ function selectAddRow(field) { var row = field.parentNode.cloneNode(true); var selects = row.getElementsByTagName('select'); for (var i=0; i < selects.length; i++) { - selects[i].name = selects[i].name.replace(/[a-z]\[[0-9]+/, '$&1'); + selects[i].name = selects[i].name.replace(/[a-z]\[\d+/, '$&1'); selects[i].selectedIndex = 0; } var inputs = row.getElementsByTagName('input'); if (inputs.length) { - inputs[0].name = inputs[0].name.replace(/[a-z]\[[0-9]+/, '$&1'); + inputs[0].name = inputs[0].name.replace(/[a-z]\[\d+/, '$&1'); inputs[0].value = ''; inputs[0].className = ''; } diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 501fb935..099d74ed 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -179,7 +179,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 function editVal($val, $field) { if (ereg('date|timestamp', $field["type"]) && isset($val)) { - return preg_replace('~^([0-9]{2}([0-9]+))-(0?([0-9]+))-(0?([0-9]+))~', lang('$1-$3-$5'), $val); + return preg_replace('~^(\\d{2}(\\d+))-(0?(\\d+))-(0?(\\d+))~', lang('$1-$3-$5'), $val); } return (ereg("binary", $field["type"]) ? reset(unpack("H*", $val)) : $val); } @@ -412,7 +412,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 return "$function()"; } $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)) { + if (ereg('date|timestamp', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P\\d*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P\\d{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $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 = q($return);