mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 09:34:10 +02:00
Use single \ in ' strings
This commit is contained in:
@@ -239,7 +239,7 @@ if (isset($_GET["mssql"])) {
|
||||
var $extension = "PDO_DBLIB";
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
$this->dsn("dblib:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\\d)~', ';port=\\1', $server)), $username, $password);
|
||||
$this->dsn("dblib:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\d)~', ';port=\1', $server)), $username, $password);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||
|
||||
function view($name) {
|
||||
global $connection;
|
||||
return array("select" => preg_replace('~^(?:[^[]|\\[[^]]*])*\\s+AS\\s+~isU', '', $connection->result("SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = SCHEMA_NAME() AND TABLE_NAME = " . q($name))));
|
||||
return array("select" => preg_replace('~^(?:[^[]|\[[^]]*])*\s+AS\s+~isU', '', $connection->result("SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = SCHEMA_NAME() AND TABLE_NAME = " . q($name))));
|
||||
}
|
||||
|
||||
function collations() {
|
||||
@@ -423,7 +423,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||
|
||||
function error() {
|
||||
global $connection;
|
||||
return nl_br(h(preg_replace('~^(\\[[^]]*])+~m', '', $connection->error)));
|
||||
return nl_br(h(preg_replace('~^(\[[^]]*])+~m', '', $connection->error)));
|
||||
}
|
||||
|
||||
function create_database($db, $collation) {
|
||||
@@ -454,7 +454,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||
if (!$val) {
|
||||
$alter["DROP"][] = " COLUMN $column";
|
||||
} else {
|
||||
$val[1] = preg_replace("~( COLLATE )'(\\w+)'~", "\\1\\2", $val[1]);
|
||||
$val[1] = preg_replace("~( COLLATE )'(\\w+)'~", '\1\2', $val[1]);
|
||||
if ($field[0] == "") {
|
||||
$alter["ADD"][] = "\n " . implode("", $val) . ($table == "" ? substr($foreign[$val[0]], 16 + strlen($val[0])) : ""); // 16 - strlen(" FOREIGN KEY ()")
|
||||
} else {
|
||||
@@ -561,7 +561,7 @@ WHERE s.xtype = 'TR' AND s.name = " . q($name)
|
||||
); // triggers are not schema-scoped
|
||||
$return = reset($rows);
|
||||
if ($return) {
|
||||
$return["Statement"] = preg_replace('~^.+\\s+AS\\s+~isU', '', $return["text"]); //! identifiers, comments
|
||||
$return["Statement"] = preg_replace('~^.+\s+AS\s+~isU', '', $return["text"]); //! identifiers, comments
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
@@ -240,7 +240,7 @@ if (!defined("DRIVER")) {
|
||||
);
|
||||
}
|
||||
$this->dsn(
|
||||
"mysql:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\\d)~', ';port=\\1', $server)),
|
||||
"mysql:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\d)~', ';port=\1', $server)),
|
||||
$username,
|
||||
$password,
|
||||
$options
|
||||
@@ -484,7 +484,7 @@ if (!defined("DRIVER")) {
|
||||
) as $row) {
|
||||
if ($row["Engine"] == "InnoDB") {
|
||||
// ignore internal comment, unnecessary since MySQL 5.1.21
|
||||
$row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["Comment"]);
|
||||
$row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\1', $row["Comment"]);
|
||||
}
|
||||
if (!isset($row["Engine"])) {
|
||||
$row["Comment"] = "";
|
||||
@@ -521,7 +521,7 @@ if (!defined("DRIVER")) {
|
||||
function fields($table) {
|
||||
$return = array();
|
||||
foreach (get_rows("SHOW FULL COLUMNS FROM " . table($table)) as $row) {
|
||||
preg_match('~^([^( ]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
|
||||
preg_match('~^([^( ]+)(?:\((.+)\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
|
||||
$return[$row["Field"]] = array(
|
||||
"field" => $row["Field"],
|
||||
"full_type" => $row["Type"],
|
||||
@@ -591,7 +591,7 @@ if (!defined("DRIVER")) {
|
||||
*/
|
||||
function view($name) {
|
||||
global $connection;
|
||||
return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU', '', $connection->result("SHOW CREATE VIEW " . table($name), 1)));
|
||||
return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\s+AS\s+~isU', '', $connection->result("SHOW CREATE VIEW " . table($name), 1)));
|
||||
}
|
||||
|
||||
/** Get sorted grouped list of collations
|
||||
@@ -870,7 +870,7 @@ if (!defined("DRIVER")) {
|
||||
"field" => $name,
|
||||
"type" => strtolower($param[5]),
|
||||
"length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $param[6]),
|
||||
"unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$param[8] $param[7]"))),
|
||||
"unsigned" => strtolower(preg_replace('~\s+~', ' ', trim("$param[8] $param[7]"))),
|
||||
"null" => 1,
|
||||
"full_type" => $param[4],
|
||||
"inout" => strtoupper($param[1]),
|
||||
@@ -976,7 +976,7 @@ if (!defined("DRIVER")) {
|
||||
global $connection;
|
||||
$return = $connection->result("SHOW CREATE TABLE " . table($table), 1);
|
||||
if (!$auto_increment) {
|
||||
$return = preg_replace('~ AUTO_INCREMENT=\\d+~', '', $return); //! skip comments
|
||||
$return = preg_replace('~ AUTO_INCREMENT=\d+~', '', $return); //! skip comments
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
@@ -358,7 +358,7 @@ ORDER BY a.attnum"
|
||||
$row["full_type"] = $row["type"] . $length . $addon . $array;
|
||||
}
|
||||
$row["null"] = !$row["attnotnull"];
|
||||
$row["auto_increment"] = preg_match('~^nextval\\(~i', $row["default"]);
|
||||
$row["auto_increment"] = preg_match('~^nextval\(~i', $row["default"]);
|
||||
$row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1);
|
||||
if (preg_match('~(.+)::[^)]+(.*)~', $row["default"], $match)) {
|
||||
$row["default"] = ($match[1] == "NULL" ? null : (($match[1][0] == "'" ? idf_unescape($match[1]) : $match[1]) . $match[2]));
|
||||
@@ -434,8 +434,8 @@ WHERE table_schema = current_schema() AND table_name = " . q($name))));
|
||||
function error() {
|
||||
global $connection;
|
||||
$return = h($connection->error);
|
||||
if (preg_match('~^(.*\\n)?([^\\n]*)\\n( *)\\^(\\n.*)?$~s', $return, $match)) {
|
||||
$return = $match[1] . preg_replace('~((?:[^&]|&[^;]*;){' . strlen($match[3]) . '})(.*)~', '\\1<b>\\2</b>', $match[2]) . $match[4];
|
||||
if (preg_match('~^(.*\n)?([^\n]*)\n( *)\^(\n.*)?$~s', $return, $match)) {
|
||||
$return = $match[1] . preg_replace('~((?:[^&]|&[^;]*;){' . strlen($match[3]) . '})(.*)~', '\1<b>\2</b>', $match[2]) . $match[4];
|
||||
}
|
||||
return nl_br($return);
|
||||
}
|
||||
|
@@ -152,7 +152,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
|
||||
function fetch_field() {
|
||||
$name = $this->_result->fieldName($this->_offset++);
|
||||
$pattern = '(\\[.*]|"(?:[^"]|"")*"|(.+))';
|
||||
$pattern = '(\[.*]|"(?:[^"]|"")*"|(.+))';
|
||||
if (preg_match("~^($pattern\\.)?$pattern\$~", $name, $match)) {
|
||||
$table = ($match[3] != "" ? $match[3] : idf_unescape($match[2]));
|
||||
$name = ($match[5] != "" ? $match[5] : idf_unescape($match[4]));
|
||||
@@ -402,7 +402,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
|
||||
function view($name) {
|
||||
global $connection;
|
||||
return array("select" => preg_replace('~^(?:[^`"[]+|`[^`]*`|"[^"]*")* AS\\s+~iU', '', $connection->result("SELECT sql FROM sqlite_master WHERE name = " . q($name)))); //! identifiers may be inside []
|
||||
return array("select" => preg_replace('~^(?:[^`"[]+|`[^`]*`|"[^"]*")* AS\s+~iU', '', $connection->result("SELECT sql FROM sqlite_master WHERE name = " . q($name)))); //! identifiers may be inside []
|
||||
}
|
||||
|
||||
function collations() {
|
||||
@@ -649,7 +649,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
if ($name == "") {
|
||||
return array("Statement" => "BEGIN\n\t;\nEND");
|
||||
}
|
||||
$idf = '(?:[^`"\\s]+|`[^`]*`|"[^"]*")+';
|
||||
$idf = '(?:[^`"\s]+|`[^`]*`|"[^"]*")+';
|
||||
$trigger_options = trigger_options();
|
||||
preg_match(
|
||||
"~^CREATE\\s+TRIGGER\\s*$idf\\s*(" . implode("|", $trigger_options["Timing"]) . ")\\s+([a-z]+)(?:\\s+OF\\s+($idf))?\\s+ON\\s*$idf\\s*(?:FOR\\s+EACH\\s+ROW\\s)?(.*)~is",
|
||||
@@ -670,7 +670,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
$return = array();
|
||||
$trigger_options = trigger_options();
|
||||
foreach (get_rows("SELECT * FROM sqlite_master WHERE type = 'trigger' AND tbl_name = " . q($table)) as $row) {
|
||||
preg_match('~^CREATE\\s+TRIGGER\\s*(?:[^`"\\s]+|`[^`]*`|"[^"]*")+\\s*(' . implode("|", $trigger_options["Timing"]) . ')\\s*(.*)\\s+ON\\b~iU', $row["sql"], $match);
|
||||
preg_match('~^CREATE\s+TRIGGER\s*(?:[^`"\s]+|`[^`]*`|"[^"]*")+\s*(' . implode("|", $trigger_options["Timing"]) . ')\s*(.*)\s+ON\b~iU', $row["sql"], $match);
|
||||
$return[$row["name"]] = array($match[1], $match[2]);
|
||||
}
|
||||
return $return;
|
||||
|
Reference in New Issue
Block a user