Greedy expressions
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@105 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
b7e446b1cb
commit
a9907f186c
|
@ -49,7 +49,7 @@ if ($_SESSION["lang"]) {
|
||||||
}
|
}
|
||||||
$file = preg_replace_callback('~(<\\?php)?\\s*(include|require)(_once)? "([^"]*)";(\\s*\\?>)?~', 'put_file', $file);
|
$file = preg_replace_callback('~(<\\?php)?\\s*(include|require)(_once)? "([^"]*)";(\\s*\\?>)?~', 'put_file', $file);
|
||||||
if ($_SESSION["lang"]) {
|
if ($_SESSION["lang"]) {
|
||||||
$file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']*|\\\\.)+)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
|
$file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
|
||||||
$file = str_replace("<?php switch_lang(); ?>\n", "", $file);
|
$file = str_replace("<?php switch_lang(); ?>\n", "", $file);
|
||||||
$file = str_replace("<?php echo get_lang(); ?>", $_SESSION["lang"], $file);
|
$file = str_replace("<?php echo get_lang(); ?>", $_SESSION["lang"], $file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ if ($_SERVER["argc"] > 1) {
|
||||||
$messages_all = array();
|
$messages_all = array();
|
||||||
foreach (glob("*.php") as $filename) {
|
foreach (glob("*.php") as $filename) {
|
||||||
$file = file_get_contents($filename);
|
$file = file_get_contents($filename);
|
||||||
if (preg_match_all("~lang\\(('(?:[^\\\\']*|\\\\.)+')([),])~", $file, $matches)) {
|
if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) {
|
||||||
$messages_all += array_combine($matches[1], $matches[2]);
|
$messages_all += array_combine($matches[1], $matches[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ $file = file_get_contents("lang.inc.php");
|
||||||
preg_match_all("~\n\t\t'(.*)' => array\\(\n(.*\n)\t\t\\)~sU", $file, $translations, PREG_OFFSET_CAPTURE);
|
preg_match_all("~\n\t\t'(.*)' => array\\(\n(.*\n)\t\t\\)~sU", $file, $translations, PREG_OFFSET_CAPTURE);
|
||||||
foreach (array_reverse($translations[2], true) as $key => $translation) {
|
foreach (array_reverse($translations[2], true) as $key => $translation) {
|
||||||
$messages = $messages_all;
|
$messages = $messages_all;
|
||||||
preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']*|\\\\.)+') => .*[^,\n]),?~m", $translation[0], $matches, PREG_SET_ORDER);
|
preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", $translation[0], $matches, PREG_SET_ORDER);
|
||||||
$s = "";
|
$s = "";
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
if (isset($messages[$match[3]])) {
|
if (isset($messages[$match[3]])) {
|
||||||
|
|
|
@ -5,8 +5,7 @@ function normalize_enum($match) {
|
||||||
return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0]{0} . $match[0]{0}, $match[0]{0}, substr($match[0], 1, -1))), '\\')) . "'";
|
return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0]{0} . $match[0]{0}, $match[0]{0}, substr($match[0], 1, -1))), '\\')) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$length = '\'(?:\'\'|[^\'\\\\]*|\\\\.)+\'|"(?:""|[^"\\\\]*|\\\\.)+"';
|
$pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]+|``)*)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
|
||||||
$pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]*|``)+)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$length)+)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
|
|
||||||
$create = $mysql->result($mysql->query("SHOW CREATE " . (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE") . " " . idf_escape($_GET["call"])), 0, 2);
|
$create = $mysql->result($mysql->query("SHOW CREATE " . (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE") . " " . idf_escape($_GET["call"])), 0, 2);
|
||||||
preg_match("~\\($pattern(?:\\s*,$pattern)*~is", $create, $match);
|
preg_match("~\\($pattern(?:\\s*,$pattern)*~is", $create, $match);
|
||||||
$in = array();
|
$in = array();
|
||||||
|
@ -17,7 +16,7 @@ foreach ($matches as $i => $match) {
|
||||||
$field = array(
|
$field = array(
|
||||||
"field" => str_replace("``", "`", $match[2]) . $match[3],
|
"field" => str_replace("``", "`", $match[2]) . $match[3],
|
||||||
"type" => $match[4], //! type aliases
|
"type" => $match[4], //! type aliases
|
||||||
"length" => preg_replace_callback("~$length~s", 'normalize_enum', $match[5]),
|
"length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $match[5]),
|
||||||
"unsigned" => ($match[6] ? "unsigned" : ""), // zerofill ignored
|
"unsigned" => ($match[6] ? "unsigned" : ""), // zerofill ignored
|
||||||
"null" => true,
|
"null" => true,
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,12 +23,11 @@ if ($_POST && !$error && !$_POST["add"]) {
|
||||||
$fields = array();
|
$fields = array();
|
||||||
ksort($_POST["fields"]);
|
ksort($_POST["fields"]);
|
||||||
$after = "FIRST";
|
$after = "FIRST";
|
||||||
$length = '\'(?:\'\'|[^\'\\\\]*|\\\\.)+\'|"(?:""|[^"\\\\]*|\\\\.)+"';
|
|
||||||
foreach ($_POST["fields"] as $key => $field) {
|
foreach ($_POST["fields"] as $key => $field) {
|
||||||
if (strlen($field["field"]) && isset($types[$field["type"]])) {
|
if (strlen($field["field"]) && isset($types[$field["type"]])) {
|
||||||
$fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD "))
|
$fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD "))
|
||||||
. idf_escape($field["field"]) . " $field[type]"
|
. idf_escape($field["field"]) . " $field[type]"
|
||||||
. ($field["length"] ? "(" . (preg_match("~^\\s*(?:$length)(?:\\s*,\\s*(?:$length))*\\s*\$~", $field["length"]) && preg_match_all("~$length~", $field["length"], $matches) ? implode(",", $matches[0]) : intval($field["length"])) . ")" : "")
|
. ($field["length"] ? "(" . (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $field["length"]) && preg_match_all("~$enum_length~", $field["length"], $matches) ? implode(",", $matches[0]) : intval($field["length"])) . ")" : "")
|
||||||
. (preg_match('~int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
. (preg_match('~int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
||||||
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " COLLATE '" . $mysql->escape_string($field["collation"]) . "'" : "")
|
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " COLLATE '" . $mysql->escape_string($field["collation"]) . "'" : "")
|
||||||
. ($field["null"] ? "" : " NOT NULL")
|
. ($field["null"] ? "" : " NOT NULL")
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
if ($_POST && !$error) {
|
if ($_POST && !$error) {
|
||||||
if ($_POST["drop"]) {
|
if ($_POST["drop"]) {
|
||||||
if ($mysql->query("DROP DATABASE " . idf_escape($_GET["db"]))) {
|
if ($mysql->query("DROP DATABASE " . idf_escape($_GET["db"]))) {
|
||||||
redirect(substr(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF), 0, -1), lang('Database has been dropped.'));
|
redirect(substr(preg_replace('~db=[^&]*&~', '', $SELF), 0, -1), lang('Database has been dropped.'));
|
||||||
}
|
}
|
||||||
} elseif ($_GET["db"] !== $_POST["name"]) {
|
} elseif ($_GET["db"] !== $_POST["name"]) {
|
||||||
if ($mysql->query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . $mysql->escape_string($_POST["collation"]) . "'" : ""))) {
|
if ($mysql->query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . $mysql->escape_string($_POST["collation"]) . "'" : ""))) {
|
||||||
if (!strlen($_GET["db"])) {
|
if (!strlen($_GET["db"])) {
|
||||||
redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
|
redirect(preg_replace('~db=[^&]*&~', '', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
|
||||||
}
|
}
|
||||||
$result = $mysql->query("SHOW TABLES");
|
$result = $mysql->query("SHOW TABLES");
|
||||||
while ($row = $result->fetch_row()) {
|
while ($row = $result->fetch_row()) {
|
||||||
|
@ -18,7 +18,7 @@ if ($_POST && !$error) {
|
||||||
$result->free();
|
$result->free();
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
$mysql->query("DROP DATABASE " . idf_escape($_GET["db"]));
|
$mysql->query("DROP DATABASE " . idf_escape($_GET["db"]));
|
||||||
redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'));
|
redirect(preg_replace('~db=[^&]*&~', '', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (!$_POST["collation"] || $mysql->query("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE '" . $mysql->escape_string($_POST["collation"]) . "'")) {
|
} elseif (!$_POST["collation"] || $mysql->query("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE '" . $mysql->escape_string($_POST["collation"]) . "'")) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ function indexes($table) {
|
||||||
|
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
global $mysql;
|
global $mysql;
|
||||||
static $pattern = '~`((?:[^`]*|``)+)`~';
|
static $pattern = '~`((?:[^`]+|``)*)`~';
|
||||||
$return = array();
|
$return = array();
|
||||||
$result = $mysql->query("SHOW CREATE TABLE " . idf_escape($table));
|
$result = $mysql->query("SHOW CREATE TABLE " . idf_escape($table));
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
@ -255,7 +255,7 @@ function input($name, $field, $value) {
|
||||||
if (!isset($_GET["default"])) {
|
if (!isset($_GET["default"])) {
|
||||||
echo '<input type="radio" name="fields[' . $name . ']" value="0"' . ($value === 0 ? ' checked="checked"' : '') . ' />';
|
echo '<input type="radio" name="fields[' . $name . ']" value="0"' . ($value === 0 ? ' checked="checked"' : '') . ' />';
|
||||||
}
|
}
|
||||||
preg_match_all("~'((?:[^']*|'')+)'~", $field["length"], $matches);
|
preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
|
||||||
foreach ($matches[1] as $i => $val) {
|
foreach ($matches[1] as $i => $val) {
|
||||||
$val = stripcslashes(str_replace("''", "'", $val));
|
$val = stripcslashes(str_replace("''", "'", $val));
|
||||||
$id = "field-$name-" . ($i+1);
|
$id = "field-$name-" . ($i+1);
|
||||||
|
@ -267,7 +267,7 @@ function input($name, $field, $value) {
|
||||||
echo ' <label for="' . $id . '"><input type="radio" name="fields[' . $name . ']" id="' . $id . '" value=""' . (strlen($value) ? '' : ' checked="checked"') . ' />' . lang('NULL') . '</label>';
|
echo ' <label for="' . $id . '"><input type="radio" name="fields[' . $name . ']" id="' . $id . '" value=""' . (strlen($value) ? '' : ' checked="checked"') . ' />' . lang('NULL') . '</label>';
|
||||||
}
|
}
|
||||||
} elseif ($field["type"] == "set") { //! 64 bits
|
} elseif ($field["type"] == "set") { //! 64 bits
|
||||||
preg_match_all("~'((?:[^']*|'')+)'~", $field["length"], $matches);
|
preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
|
||||||
foreach ($matches[1] as $i => $val) {
|
foreach ($matches[1] as $i => $val) {
|
||||||
$val = stripcslashes(str_replace("''", "'", $val));
|
$val = stripcslashes(str_replace("''", "'", $val));
|
||||||
$id = "field-$name-" . ($i+1);
|
$id = "field-$name-" . ($i+1);
|
||||||
|
|
|
@ -28,6 +28,7 @@ if (isset($_GET["dump"])) {
|
||||||
$error = (in_array($_POST["token"], (array) $TOKENS) ? "" : lang('Invalid CSRF token. Send the form again.'));
|
$error = (in_array($_POST["token"], (array) $TOKENS) ? "" : lang('Invalid CSRF token. Send the form again.'));
|
||||||
}
|
}
|
||||||
$token = ($_POST && !$error ? $_POST["token"] : token());
|
$token = ($_POST && !$error ? $_POST["token"] : token());
|
||||||
|
$enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"';
|
||||||
if (isset($_GET["default"])) {
|
if (isset($_GET["default"])) {
|
||||||
$_GET["edit"] = $_GET["default"];
|
$_GET["edit"] = $_GET["default"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ if ($_POST && $error) {
|
||||||
$query = substr($query, strlen($match[0]));
|
$query = substr($query, strlen($match[0]));
|
||||||
} elseif (preg_match("~$delimiter|['`\"]|\$~", $query, $match, PREG_OFFSET_CAPTURE, $offset)) {
|
} elseif (preg_match("~$delimiter|['`\"]|\$~", $query, $match, PREG_OFFSET_CAPTURE, $offset)) {
|
||||||
if ($match[0][0] && $match[0][0] != $delimiter) {
|
if ($match[0][0] && $match[0][0] != $delimiter) {
|
||||||
preg_match('~\\G([^\\\\' . $match[0][0] . ']*|\\\\.)+(' . $match[0][0] . '|$)~s', $query, $match, PREG_OFFSET_CAPTURE, $match[0][1] + 1);
|
preg_match('~\\G([^\\\\' . $match[0][0] . ']+|\\\\.)*(' . $match[0][0] . '|$)~s', $query, $match, PREG_OFFSET_CAPTURE, $match[0][1] + 1);
|
||||||
$offset = $match[0][1] + strlen($match[0][0]);
|
$offset = $match[0][1] + strlen($match[0][0]);
|
||||||
} else {
|
} else {
|
||||||
$empty = false;
|
$empty = false;
|
||||||
|
|
Loading…
Reference in a new issue