select_db(DB); } $queries = 0; $errors = ""; while ($query != "") { if (!$offset && preg_match('~^\\s*DELIMITER\\s+(.+)~i', $query, $match)) { $delimiter = $match[1]; $query = substr($query, strlen($match[0])); } else { preg_match('(' . preg_quote($delimiter) . '|[\'`"]|/\\*|-- |#|$)', $query, $match, PREG_OFFSET_CAPTURE, $offset); // should always match $found = $match[0][0]; $offset = $match[0][1] + strlen($found); if (!$found && $fp && !feof($fp)) { $query .= fread($fp, 1e5); } else { if (!$found && rtrim($query) == "") { break; } if (!$found || $found == $delimiter) { // end of a query $empty = false; $q = substr($query, 0, $match[0][1]); $queries++; echo "
" . shorten_utf8(trim($q), 1000) . "
\n"; ob_flush(); flush(); // can take a long time - show the running query $start = explode(" ", microtime()); // microtime(true) is available since PHP 5 //! don't allow changing of character_set_results, convert encoding of displayed query if (!$connection->multi_query($q)) { echo "

" . lang('Error in query') . ": " . error() . "\n"; $errors .= " $queries"; if ($_POST["error_stops"]) { break; } } else { if (is_object($connection2) && preg_match("~^$space*(USE)\\b~isU", $q)) { $connection2->query($q); } do { $result = $connection->store_result(); $end = explode(" ", microtime()); $time = " (" . lang('%.3f s', max(0, $end[0] - $start[0] + $end[1] - $start[1])) . ")"; if (is_object($result)) { select($result, $connection2); echo "

" . ($result->num_rows ? lang('%d row(s)', $result->num_rows) : "") . $time; if ($connection2 && preg_match("~^($space|\\()*SELECT\\b~isU", $q)) { $id = "explain-$queries"; echo ", EXPLAIN\n"; echo "

\n"; } } else { if (preg_match("~^$space*(CREATE|DROP|ALTER)$space+(DATABASE|SCHEMA)\\b~isU", $q)) { restart_session(); set_session("databases", null); // clear cache session_write_close(); } echo "

" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n"; } $start = $end; } while ($connection->next_result()); } $query = substr($query, $offset); $offset = 0; } else { // find matching quote or comment end while (preg_match('~' . ($found == '/*' ? '\\*/' : (ereg('-- |#', $found) ? "\n" : "$found|\\\\.")) . '|$~s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES $s = $match[0][0]; $offset = $match[0][1] + strlen($s); if (!$s && $fp && !feof($fp)) { $query .= fread($fp, 1e6); } elseif ($s[0] != "\\") { break; } } } } } } if ($errors && $queries > 1) { echo "

" . lang('Error in query') . ": $errors\n"; } if ($empty) { echo "

" . lang('No commands to execute.') . "\n"; } //! MS SQL - SET SHOWPLAN_ALL OFF } else { echo "

" . upload_error($query) . "\n"; } } ?>

document.getElementsByTagName('textarea')[0].focus();\n"); echo "

" . (ini_bool("file_uploads") ? lang('File upload') . ': ' : lang('File uploads are disabled.')); ?>

"zlib", "bz2" => "bz2") as $key => $val) { if (extension_loaded($val)) { $compress[] = ".$key"; } } echo lang('Webserver file %s', "adminer.sql" . ($compress ? "[" . implode("|", $compress) . "]" : "") . ""); echo ' '; echo "\n"; if ($history) { print_fieldset("history", lang('History'), $_GET["history"] != ""); foreach ($history as $key => $val) { //! save and display timestamp echo '' . lang('Edit') . " " . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $val)))), 80, "") . "
\n"; } echo "\n"; echo "\n"; } ?>