mirror of
https://github.com/vrana/adminer.git
synced 2025-08-13 01:54:00 +02:00
Add empty lines to source code
This commit is contained in:
@@ -28,10 +28,12 @@ if (!$error && $_POST) {
|
||||
} elseif ($_FILES && $_FILES["sql_file"]["error"][0] != 4) { // 4 - UPLOAD_ERR_NO_FILE
|
||||
$query = get_file("sql_file", true);
|
||||
}
|
||||
|
||||
if (is_string($query)) { // get_file() returns error as number, fread() as false
|
||||
if (function_exists('memory_get_usage')) {
|
||||
@ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
|
||||
}
|
||||
|
||||
if ($query != "" && strlen($query) < 1e6) { // don't add big queries
|
||||
$q = $query . (ereg(";[ \t\r\n]*\$", $query) ? "" : ";"); //! doesn't work with DELIMITER |
|
||||
if (!$history || reset(end($history)) != $q) { // no repeated queries
|
||||
@@ -41,6 +43,7 @@ if (!$error && $_POST) {
|
||||
stop_session();
|
||||
}
|
||||
}
|
||||
|
||||
$space = "(?:\\s|/\\*.*\\*/|(?:#|-- )[^\n]*\n|--\n)";
|
||||
$delimiter = ";";
|
||||
$offset = 0;
|
||||
@@ -57,6 +60,7 @@ if (!$error && $_POST) {
|
||||
parse_str($_COOKIE["adminer_export"], $adminer_export);
|
||||
$dump_format = $adminer->dumpFormat();
|
||||
unset($dump_format["sql"]);
|
||||
|
||||
while ($query != "") {
|
||||
if (!$offset && preg_match("~^$space*DELIMITER\\s+(\\S+)~i", $query, $match)) {
|
||||
$delimiter = $match[1];
|
||||
@@ -71,6 +75,7 @@ if (!$error && $_POST) {
|
||||
break;
|
||||
}
|
||||
$offset = $pos + strlen($found);
|
||||
|
||||
if ($found && rtrim($found) != $delimiter) { // find matching quote or comment end
|
||||
while (preg_match('(' . ($found == '/*' ? '\\*/' : ($found == '[' ? ']' : (ereg('^-- |^#', $found) ? "\n" : preg_quote($found) . "|\\\\."))) . '|$)s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES
|
||||
$s = $match[0][0];
|
||||
@@ -83,6 +88,7 @@ if (!$error && $_POST) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else { // end of a query
|
||||
$empty = false;
|
||||
$q = substr($query, 0, $pos);
|
||||
@@ -98,11 +104,14 @@ if (!$error && $_POST) {
|
||||
if ($connection->multi_query($q) && is_object($connection2) && preg_match("~^$space*USE\\b~isU", $q)) {
|
||||
$connection2->query($q);
|
||||
}
|
||||
|
||||
do {
|
||||
$result = $connection->store_result();
|
||||
$end = microtime();
|
||||
$time = " <span class='time'>(" . format_time($start, $end) . ")</span>"
|
||||
. (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : ""); // 1000 - maximum length of encoded URL in IE is 2083 characters
|
||||
. (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
|
||||
;
|
||||
|
||||
if ($connection->error) {
|
||||
echo ($_POST["only_errors"] ? $print : "");
|
||||
echo "<p class='error'>" . lang('Error in query') . ($connection->errno ? " ($connection->errno)" : "") . ": " . error() . "\n";
|
||||
@@ -110,6 +119,7 @@ if (!$error && $_POST) {
|
||||
if ($_POST["error_stops"]) {
|
||||
break 2;
|
||||
}
|
||||
|
||||
} elseif (is_object($result)) {
|
||||
$orgtables = select($result, $connection2);
|
||||
if (!$_POST["only_errors"]) {
|
||||
@@ -133,6 +143,7 @@ if (!$error && $_POST) {
|
||||
}
|
||||
echo "</form>\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
if (preg_match("~^$space*(CREATE|DROP|ALTER)$space+(DATABASE|SCHEMA)\\b~isU", $q)) {
|
||||
restart_session();
|
||||
@@ -143,15 +154,19 @@ if (!$error && $_POST) {
|
||||
echo "<p class='message' title='" . h($connection->info) . "'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n";
|
||||
}
|
||||
}
|
||||
|
||||
$start = $end;
|
||||
} while ($connection->next_result());
|
||||
|
||||
$line += substr_count($q.$found, "\n");
|
||||
$query = substr($query, $offset);
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($empty) {
|
||||
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
|
||||
} elseif ($_POST["only_errors"]) {
|
||||
@@ -161,6 +176,7 @@ if (!$error && $_POST) {
|
||||
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
|
||||
}
|
||||
//! MS SQL - SET SHOWPLAN_ALL OFF
|
||||
|
||||
} else {
|
||||
echo "<p class='error'>" . upload_error($query) . "\n";
|
||||
}
|
||||
@@ -178,6 +194,7 @@ if ($_POST) {
|
||||
$q = $history[$_GET["history"]][0];
|
||||
}
|
||||
textarea("query", $q, 20);
|
||||
|
||||
echo ($_POST ? "" : "<script type='text/javascript'>document.getElementsByTagName('textarea')[0].focus();</script>\n");
|
||||
echo "<p>" . (ini_bool("file_uploads")
|
||||
? lang('File upload') . ': <input type="file" name="sql_file[]" multiple'
|
||||
|
Reference in New Issue
Block a user