mirror of
https://github.com/vrana/adminer.git
synced 2025-08-18 12:21:24 +02:00
Use single \ in ' strings
This commit is contained in:
@@ -575,7 +575,7 @@ class Adminer {
|
||||
$return = array();
|
||||
foreach ((array) $_GET["order"] as $key => $val) {
|
||||
if ($val != "") {
|
||||
$return[] = (preg_match('~^((COUNT\\(DISTINCT |[A-Z0-9_]+\\()(`(?:[^`]|``)+`|"(?:[^"]|"")+")\\)|COUNT\\(\\*\\))$~', $val) ? $val : idf_escape($val)) //! MS SQL uses []
|
||||
$return[] = (preg_match('~^((COUNT\(DISTINCT |[A-Z0-9_]+\()(`(?:[^`]|``)+`|"(?:[^"]|"")+")\)|COUNT\(\*\))$~', $val) ? $val : idf_escape($val)) //! MS SQL uses []
|
||||
. (isset($_GET["desc"][$key]) ? " DESC" : "")
|
||||
;
|
||||
}
|
||||
@@ -718,7 +718,7 @@ class Adminer {
|
||||
$return = "$function()";
|
||||
} elseif (preg_match('~^current_(date|timestamp)$~', $function)) {
|
||||
$return = $function;
|
||||
} elseif (preg_match('~^([+-]|\\|\\|)$~', $function)) {
|
||||
} elseif (preg_match('~^([+-]|\|\|)$~', $function)) {
|
||||
$return = idf_escape($name) . " $function $return";
|
||||
} elseif (preg_match('~^[+-] interval$~', $function)) {
|
||||
$return = idf_escape($name) . " $function " . (preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+\$~i", $value) ? $value : $return);
|
||||
@@ -962,7 +962,7 @@ class Adminer {
|
||||
}
|
||||
$server_info = $connection->server_info;
|
||||
?>
|
||||
bodyLoad('<?php echo (is_object($connection) ? preg_replace('~^(\\d\\.?\\d).*~s', '\\1', $server_info) : ""); ?>'<?php echo (preg_match('~MariaDB~', $server_info) ? ", true" : ""); ?>);
|
||||
bodyLoad('<?php echo (is_object($connection) ? preg_replace('~^(\d\.?\d).*~s', '\1', $server_info) : ""); ?>'<?php echo (preg_match('~MariaDB~', $server_info) ? ", true" : ""); ?>);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ $HTTPS = $_SERVER["HTTPS"] && strcasecmp($_SERVER["HTTPS"], "off");
|
||||
if (!defined("SID")) {
|
||||
session_cache_limiter(""); // to allow restarting session
|
||||
session_name("adminer_sid"); // use specific session name to get own namespace
|
||||
$params = array(0, preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]), "", $HTTPS);
|
||||
$params = array(0, preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"]), "", $HTTPS);
|
||||
if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
|
||||
$params[] = true; // HttpOnly
|
||||
}
|
||||
@@ -83,7 +83,7 @@ include "../adminer/drivers/mysql.inc.php"; // must be included as last driver
|
||||
|
||||
define("SERVER", $_GET[DRIVER]); // read from pgsql=localhost
|
||||
define("DB", $_GET["db"]); // for the sake of speed and size
|
||||
define("ME", preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . '?'
|
||||
define("ME", preg_replace('~^[^?]*/([^?]*).*~', '\1', $_SERVER["REQUEST_URI"]) . '?'
|
||||
. (sid() ? SID . '&' : '')
|
||||
. (SERVER !== null ? DRIVER . "=" . urlencode(SERVER) . '&' : '')
|
||||
. (isset($_GET["username"]) ? "username=" . urlencode($_GET["username"]) . '&' : '')
|
||||
|
@@ -358,7 +358,7 @@ function grant($grant, $privileges, $columns, $on) {
|
||||
: queries("$grant ALL PRIVILEGES$on") && queries("$grant GRANT OPTION$on")
|
||||
);
|
||||
}
|
||||
return queries("$grant " . preg_replace('~(GRANT OPTION)\\([^)]*\\)~', '\\1', implode("$columns, ", $privileges) . $columns) . $on);
|
||||
return queries("$grant " . preg_replace('~(GRANT OPTION)\([^)]*\)~', '\1', implode("$columns, ", $privileges) . $columns) . $on);
|
||||
}
|
||||
|
||||
/** Drop old object and create a new one
|
||||
@@ -441,7 +441,7 @@ function create_routine($routine, $row) {
|
||||
* @return string
|
||||
*/
|
||||
function remove_definer($query) {
|
||||
return preg_replace('~^([A-Z =]+) DEFINER=`' . preg_replace('~@(.*)~', '`@`(%|\\1)', logged_user()) . '`~', '\\1', $query); //! proper escaping of user
|
||||
return preg_replace('~^([A-Z =]+) DEFINER=`' . preg_replace('~@(.*)~', '`@`(%|\1)', logged_user()) . '`~', '\1', $query); //! proper escaping of user
|
||||
}
|
||||
|
||||
/** Format foreign key to use in SQL query
|
||||
@@ -497,7 +497,7 @@ function ini_bytes($ini) {
|
||||
function doc_link($paths, $text = "<sup>?</sup>") {
|
||||
global $jush, $connection;
|
||||
$server_info = $connection->server_info;
|
||||
$version = preg_replace('~^(\\d\\.?\\d).*~s', '\\1', $server_info); // two most significant digits
|
||||
$version = preg_replace('~^(\d\.?\d).*~s', '\1', $server_info); // two most significant digits
|
||||
$urls = array(
|
||||
'sql' => "https://dev.mysql.com/doc/refman/$version/en/",
|
||||
'sqlite' => "https://www.sqlite.org/",
|
||||
|
@@ -482,7 +482,7 @@ function where($where, $fields = array()) {
|
||||
$key = bracket_escape($key, 1); // 1 - back
|
||||
$column = escape_key($key);
|
||||
$return[] = $column
|
||||
. ($jush == "sql" && preg_match('~^[0-9]*\\.[0-9]*$~', $val) ? " LIKE " . q(addcslashes($val, "%_\\"))
|
||||
. ($jush == "sql" && preg_match('~^[0-9]*\.[0-9]*$~', $val) ? " LIKE " . q(addcslashes($val, "%_\\"))
|
||||
: ($jush == "mssql" ? " LIKE " . q(preg_replace('~[_%[]~', '[\0]', $val))
|
||||
: " = " . unconvert_field($fields[$key], q($val))
|
||||
)) // LIKE because of floats but slow with ints, in MS SQL because of text
|
||||
@@ -549,7 +549,7 @@ function cookie($name, $value, $lifetime = 2592000) { // 2592000 - 30 days
|
||||
global $HTTPS;
|
||||
return header("Set-Cookie: $name=" . urlencode($value)
|
||||
. ($lifetime ? "; expires=" . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT" : "")
|
||||
. "; path=" . preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"])
|
||||
. "; path=" . preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"])
|
||||
. ($HTTPS ? "; secure" : "")
|
||||
. "; HttpOnly; SameSite=lax",
|
||||
false);
|
||||
@@ -599,7 +599,7 @@ function set_session($key, $val) {
|
||||
*/
|
||||
function auth_url($vendor, $server, $username, $db = null) {
|
||||
global $drivers;
|
||||
preg_match('~([^?]*)\\??(.*)~', remove_from_uri(implode("|", array_keys($drivers)) . "|username|" . ($db !== null ? "db|" : "") . session_name()), $match);
|
||||
preg_match('~([^?]*)\??(.*)~', remove_from_uri(implode("|", array_keys($drivers)) . "|username|" . ($db !== null ? "db|" : "") . session_name()), $match);
|
||||
return "$match[1]?"
|
||||
. (sid() ? SID . "&" : "")
|
||||
. ($vendor != "server" || $server != "" ? urlencode($vendor) . "=" . urlencode($server) . "&" : "")
|
||||
@@ -759,7 +759,7 @@ function get_file($key, $decompress = false) {
|
||||
}
|
||||
$name = $file["name"][$key];
|
||||
$tmp_name = $file["tmp_name"][$key];
|
||||
$content = file_get_contents($decompress && preg_match('~\\.gz$~', $name)
|
||||
$content = file_get_contents($decompress && preg_match('~\.gz$~', $name)
|
||||
? "compress.zlib://$tmp_name"
|
||||
: $tmp_name
|
||||
); //! may not be reachable because of open_basedir
|
||||
@@ -804,7 +804,7 @@ function repeat_pattern($pattern, $length) {
|
||||
*/
|
||||
function is_utf8($val) {
|
||||
// don't print control chars except \t\r\n
|
||||
return (preg_match('~~u', $val) && !preg_match('~[\\0-\\x8\\xB\\xC\\xE-\\x1F]~', $val));
|
||||
return (preg_match('~~u', $val) && !preg_match('~[\0-\x8\xB\xC\xE-\x1F]~', $val));
|
||||
}
|
||||
|
||||
/** Shorten UTF-8 string
|
||||
@@ -974,7 +974,7 @@ function input($field, $value, $function) {
|
||||
echo "<textarea$attrs cols='50' rows='12' class='jush-js'>" . h($value) . '</textarea>';
|
||||
} else {
|
||||
// int(3) is only a display hint
|
||||
$maxlength = (!preg_match('~int~', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? ((preg_match("~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 = (!preg_match('~int~', $field["type"]) && preg_match('~^(\d+)(,(\d+))?$~', $field["length"], $match) ? ((preg_match("~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));
|
||||
if ($jush == 'sql' && min_version(5.6) && preg_match('~time~', $field["type"])) {
|
||||
$maxlength += 7; // microtime
|
||||
}
|
||||
|
Reference in New Issue
Block a user