Change simple preg_match to ereg
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@812 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
ccd85eb0c7
commit
5abd943c29
|
@ -3,7 +3,7 @@ $where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_
|
||||||
$update = ($where && !$_POST["clone"]);
|
$update = ($where && !$_POST["clone"]);
|
||||||
$fields = fields($_GET["edit"]);
|
$fields = fields($_GET["edit"]);
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
if (isset($_GET["default"]) ? $field["auto_increment"] || preg_match('~text|blob~', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) {
|
if (isset($_GET["default"]) ? $field["auto_increment"] || ereg('text|blob', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) {
|
||||||
unset($fields[$name]);
|
unset($fields[$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ echo ($unsigned ? " <select name=\"$key" . '[unsigned]"' . (!$field["type"] || e
|
||||||
function process_type($field, $collate = "COLLATE") {
|
function process_type($field, $collate = "COLLATE") {
|
||||||
global $dbh, $enum_length, $unsigned;
|
global $dbh, $enum_length, $unsigned;
|
||||||
return " $field[type]"
|
return " $field[type]"
|
||||||
. ($field["length"] && !preg_match('~^date|time$~', $field["type"]) ? "(" . process_length($field["length"]) . ")" : "")
|
. ($field["length"] && !ereg('^date|time$', $field["type"]) ? "(" . process_length($field["length"]) . ")" : "")
|
||||||
. (preg_match('~int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
. (ereg('int|float|double|decimal', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
||||||
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . $dbh->quote($field["collation"]) : "")
|
. (ereg('char|text|enum|set', $field["type"]) && $field["collation"] ? " $collate " . $dbh->quote($field["collation"]) : "")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,19 +280,19 @@ function input($name, $field, $value) {
|
||||||
$onchange = ($first ? ' onchange="var f = this.form[\'function[' . addcslashes($name, "\r\n'\\") . ']\']; if (' . $first . ' > f.selectedIndex) f.selectedIndex = ' . $first . ';"' : '');
|
$onchange = ($first ? ' onchange="var f = this.form[\'function[' . addcslashes($name, "\r\n'\\") . ']\']; if (' . $first . ' > f.selectedIndex) f.selectedIndex = ' . $first . ';"' : '');
|
||||||
$options = array("");
|
$options = array("");
|
||||||
if (!isset($_GET["default"])) {
|
if (!isset($_GET["default"])) {
|
||||||
if (preg_match('~char|date|time~', $field["type"])) {
|
if (ereg('char|date|time', $field["type"])) {
|
||||||
$options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now")); //! JavaScript for disabling maxlength
|
$options = (ereg('char', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now")); //! JavaScript for disabling maxlength
|
||||||
}
|
}
|
||||||
if (!isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET))) {
|
if (!isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET))) {
|
||||||
// relative functions
|
// relative functions
|
||||||
if (preg_match('~int|float|double|decimal~', $field["type"])) {
|
if (ereg('int|float|double|decimal', $field["type"])) {
|
||||||
$options = array("", "+", "-");
|
$options = array("", "+", "-");
|
||||||
}
|
}
|
||||||
if (preg_match('~date~', $field["type"])) {
|
if (ereg('date', $field["type"])) {
|
||||||
$options[] = "+ interval";
|
$options[] = "+ interval";
|
||||||
$options[] = "- interval";
|
$options[] = "- interval";
|
||||||
}
|
}
|
||||||
if (preg_match('~time~', $field["type"])) {
|
if (ereg('time', $field["type"])) {
|
||||||
$options[] = "addtime";
|
$options[] = "addtime";
|
||||||
$options[] = "subtime";
|
$options[] = "subtime";
|
||||||
}
|
}
|
||||||
|
@ -311,7 +311,7 @@ function input($name, $field, $value) {
|
||||||
}
|
}
|
||||||
} elseif (strpos($field["type"], "text") !== false) {
|
} elseif (strpos($field["type"], "text") !== false) {
|
||||||
echo '<textarea name="fields[' . $name . ']" cols="50" rows="12"' . $onchange . '>' . htmlspecialchars($value) . '</textarea>';
|
echo '<textarea name="fields[' . $name . ']" cols="50" rows="12"' . $onchange . '>' . htmlspecialchars($value) . '</textarea>';
|
||||||
} elseif (preg_match('~binary|blob~', $field["type"])) {
|
} elseif (ereg('binary|blob', $field["type"])) {
|
||||||
echo (ini_get("file_uploads") ? '<input type="file" name="' . $name . '"' . $onchange . '>' : lang('File uploads are disabled.') . ' ');
|
echo (ini_get("file_uploads") ? '<input type="file" name="' . $name . '"' . $onchange . '>' : lang('File uploads are disabled.') . ' ');
|
||||||
} else {
|
} else {
|
||||||
// int(3) is only a display hint
|
// int(3) is only a display hint
|
||||||
|
@ -334,7 +334,7 @@ function process_input($name, $field) {
|
||||||
return (isset($_GET["default"]) ? $dbh->quote($value) : intval($value));
|
return (isset($_GET["default"]) ? $dbh->quote($value) : intval($value));
|
||||||
} elseif ($field["type"] == "set") {
|
} elseif ($field["type"] == "set") {
|
||||||
return (isset($_GET["default"]) ? "'" . implode(",", array_map('escape_string', (array) $value)) . "'" : array_sum((array) $value));
|
return (isset($_GET["default"]) ? "'" . implode(",", array_map('escape_string', (array) $value)) . "'" : array_sum((array) $value));
|
||||||
} elseif (preg_match('~binary|blob~', $field["type"])) {
|
} elseif (ereg('binary|blob', $field["type"])) {
|
||||||
$file = get_file($idf);
|
$file = get_file($idf);
|
||||||
if (!is_string($file)) {
|
if (!is_string($file)) {
|
||||||
return false; //! report errors
|
return false; //! report errors
|
||||||
|
|
|
@ -64,13 +64,13 @@ foreach ($schema as $name => $table) {
|
||||||
foreach ($table["fields"] as $field) {
|
foreach ($table["fields"] as $field) {
|
||||||
$val = htmlspecialchars($field["field"]);
|
$val = htmlspecialchars($field["field"]);
|
||||||
$title = ' title="' . htmlspecialchars($field["full_type"] . ($field["null"] ? " " . lang('NULL') : '')) . '"';
|
$title = ' title="' . htmlspecialchars($field["full_type"] . ($field["null"] ? " " . lang('NULL') : '')) . '"';
|
||||||
if (preg_match('~char|text~', $field["type"])) {
|
if (ereg('char|text', $field["type"])) {
|
||||||
$val = "<span class='char'$title>$val</span>";
|
$val = "<span class='char'$title>$val</span>";
|
||||||
} elseif (preg_match('~date|time|year~', $field["type"])) {
|
} elseif (ereg('date|time|year', $field["type"])) {
|
||||||
$val = "<span class='date'$title>$val</span>";
|
$val = "<span class='date'$title>$val</span>";
|
||||||
} elseif (preg_match('~binary|blob~', $field["type"])) {
|
} elseif (ereg('binary|blob', $field["type"])) {
|
||||||
$val = "<span class='binary'$title>$val</span>";
|
$val = "<span class='binary'$title>$val</span>";
|
||||||
} elseif (preg_match('~enum|set~', $field["type"])) {
|
} elseif (ereg('enum|set', $field["type"])) {
|
||||||
$val = "<span class='enum'$title>$val</span>";
|
$val = "<span class='enum'$title>$val</span>";
|
||||||
} else {
|
} else {
|
||||||
$val = "<span$title>$val</span>";
|
$val = "<span$title>$val</span>";
|
||||||
|
|
|
@ -14,7 +14,7 @@ unset($text_length);
|
||||||
foreach ($fields as $key => $field) {
|
foreach ($fields as $key => $field) {
|
||||||
if (isset($field["privileges"]["select"])) {
|
if (isset($field["privileges"]["select"])) {
|
||||||
$columns[$key] = strip_tags(adminer_field_name($fields, $key)); //! numeric $key is problematic in optionlist()
|
$columns[$key] = strip_tags(adminer_field_name($fields, $key)); //! numeric $key is problematic in optionlist()
|
||||||
if (preg_match('~text|blob~', $field["type"])) {
|
if (ereg('text|blob', $field["type"])) {
|
||||||
$text_length = (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
|
$text_length = (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,12 +273,12 @@ if (!$columns) {
|
||||||
}
|
}
|
||||||
if (!isset($val)) {
|
if (!isset($val)) {
|
||||||
$val = "<i>NULL</i>";
|
$val = "<i>NULL</i>";
|
||||||
} elseif (preg_match('~blob|binary~', $fields[$key]["type"]) && !is_utf8($val)) { //! download link may be printed even with is_utf8
|
} elseif (ereg('blob|binary', $fields[$key]["type"]) && !is_utf8($val)) { //! download link may be printed even with is_utf8
|
||||||
$val = '<a href="' . htmlspecialchars($SELF) . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&' . $unique_idf . '">' . lang('%d byte(s)', strlen($val)) . '</a>';
|
$val = '<a href="' . htmlspecialchars($SELF) . 'download=' . urlencode($_GET["select"]) . '&field=' . urlencode($key) . '&' . $unique_idf . '">' . lang('%d byte(s)', strlen($val)) . '</a>';
|
||||||
} else {
|
} else {
|
||||||
if (!strlen(trim($val, " \t"))) {
|
if (!strlen(trim($val, " \t"))) {
|
||||||
$val = " ";
|
$val = " ";
|
||||||
} elseif (intval($text_length) > 0 && preg_match('~blob|text~', $fields[$key]["type"])) {
|
} elseif (intval($text_length) > 0 && ereg('blob|text', $fields[$key]["type"])) {
|
||||||
$val = nl2br(shorten_utf8($val, intval($text_length))); // usage of LEFT() would reduce traffic but complicates query
|
$val = nl2br(shorten_utf8($val, intval($text_length))); // usage of LEFT() would reduce traffic but complicates query
|
||||||
} else {
|
} else {
|
||||||
$val = nl2br(htmlspecialchars($val));
|
$val = nl2br(htmlspecialchars($val));
|
||||||
|
|
|
@ -40,7 +40,7 @@ if (isset($_GET["host"]) && ($result = $dbh->query("SHOW GRANTS FOR " . $dbh->qu
|
||||||
if (preg_match('~GRANT (.*) ON (.*) TO ~', $row[0], $match) && preg_match_all('~ *([^(,]*[^ ,(])( *\\([^)]+\\))?~', $match[1], $matches, PREG_SET_ORDER)) { //! escape the part between ON and TO
|
if (preg_match('~GRANT (.*) ON (.*) TO ~', $row[0], $match) && preg_match_all('~ *([^(,]*[^ ,(])( *\\([^)]+\\))?~', $match[1], $matches, PREG_SET_ORDER)) { //! escape the part between ON and TO
|
||||||
foreach ($matches as $val) {
|
foreach ($matches as $val) {
|
||||||
$grants["$match[2]$val[2]"][$val[1]] = true;
|
$grants["$match[2]$val[2]"][$val[1]] = true;
|
||||||
if (preg_match('~ WITH GRANT OPTION~', $row[0])) { //! don't check inside strings and identifiers
|
if (ereg(' WITH GRANT OPTION', $row[0])) { //! don't check inside strings and identifiers
|
||||||
$grants["$match[2]$val[2]"]["GRANT OPTION"] = true;
|
$grants["$match[2]$val[2]"]["GRANT OPTION"] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue