1)); $is_sql = preg_match('~sql~', $_POST["format"]); if ($is_sql) { echo "-- Adminer $VERSION " . $drivers[DRIVER] . " " . str_replace("\n", " ", $connection->server_info) . " dump\n\n"; if ($jush == "sql") { echo "SET NAMES utf8; SET time_zone = '+00:00'; SET foreign_key_checks = 0; " . ($_POST["data_style"] ? "SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; " : "") . " "; $connection->query("SET time_zone = '+00:00'"); $connection->query("SET sql_mode = ''"); } } $style = $_POST["db_style"]; $databases = array(DB); if (DB == "") { $databases = $_POST["databases"]; if (is_string($databases)) { $databases = explode("\n", rtrim(str_replace("\r", "", $databases), "\n")); } } foreach ((array) $databases as $db) { $adminer->dumpDatabase($db); if ($connection->select_db($db)) { if ($is_sql && preg_match('~CREATE~', $style) && ($create = $connection->result("SHOW CREATE DATABASE " . idf_escape($db), 1))) { set_utf8mb4($create); if ($style == "DROP+CREATE") { echo "DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n"; } echo "$create;\n"; } if ($is_sql) { if ($style) { echo use_sql($db) . ";\n\n"; } $out = ""; if ($_POST["routines"]) { foreach (array("FUNCTION", "PROCEDURE") as $routine) { foreach (get_rows("SHOW $routine STATUS WHERE Db = " . q($db), null, "-- ") as $row) { $create = remove_definer($connection->result("SHOW CREATE $routine " . idf_escape($row["Name"]), 2)); set_utf8mb4($create); $out .= ($style != 'DROP+CREATE' ? "DROP $routine IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "") . "$create;;\n\n"; } } } if ($_POST["events"]) { foreach (get_rows("SHOW EVENTS", null, "-- ") as $row) { $create = remove_definer($connection->result("SHOW CREATE EVENT " . idf_escape($row["Name"]), 3)); set_utf8mb4($create); $out .= ($style != 'DROP+CREATE' ? "DROP EVENT IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "") . "$create;;\n\n"; } } if ($out) { echo "DELIMITER ;;\n\n$out" . "DELIMITER ;\n\n"; } } if ($_POST["table_style"] || $_POST["data_style"]) { $views = array(); foreach (table_status('', true) as $name => $table_status) { $table = (DB == "" || in_array($name, (array) $_POST["tables"])); $data = (DB == "" || in_array($name, (array) $_POST["data"])); if ($table || $data) { if ($ext == "tar") { $tmp_file = new TmpFile; ob_start(array($tmp_file, 'write'), 1e5); } $adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""), (is_view($table_status) ? 2 : 0)); if (is_view($table_status)) { $views[] = $name; } elseif ($data) { $fields = fields($name); $adminer->dumpData($name, $_POST["data_style"], "SELECT *" . convert_fields($fields, $fields) . " FROM " . table($name)); } if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name))) { echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n"; } if ($ext == "tar") { ob_end_flush(); tar_file((DB != "" ? "" : "$db/") . "$name.csv", $tmp_file); } elseif ($is_sql) { echo "\n"; } } } // add FKs after creating tables (except in MySQL which uses SET FOREIGN_KEY_CHECKS=0) if (function_exists('foreign_keys_sql')) { foreach (table_status('', true) as $name => $table_status) { $table = (DB == "" || in_array($name, (array) $_POST["tables"])); if ($table && !is_view($table_status)) { echo foreign_keys_sql($name); } } } foreach ($views as $view) { $adminer->dumpTable($view, $_POST["table_style"], 1); } if ($ext == "tar") { echo pack("x512"); } } } } if ($is_sql) { echo "-- " . $connection->result("SELECT NOW()") . "\n"; } exit; } page_header(lang('Export'), $error, ($_GET["export"] != "" ? array("table" => $_GET["export"]) : array()), h(DB)); ?>
"text", "format" => "sql", "db_style" => (DB != "" ? "" : "CREATE"), "table_style" => "DROP+CREATE", "data_style" => "INSERT"); } if (!isset($row["events"])) { // backwards compatibility $row["routines"] = $row["events"] = ($_GET["dump"] == ""); $row["triggers"] = $row["table_style"]; } echo "
" . lang('Output') . "" . html_select("output", $adminer->dumpOutput(), $row["output"], 0) . "\n"; // 0 - radio echo "
" . lang('Format') . "" . html_select("format", $adminer->dumpFormat(), $row["format"], 0) . "\n"; // 0 - radio echo ($jush == "sqlite" ? "" : "
" . lang('Database') . "" . html_select('db_style', $db_style, $row["db_style"]) . (support("routine") ? checkbox("routines", 1, $row["routines"], lang('Routines')) : "") . (support("event") ? checkbox("events", 1, $row["events"], lang('Events')) : "") ); echo "
" . lang('Tables') . "" . html_select('table_style', $table_style, $row["table_style"]) . checkbox("auto_increment", 1, $row["auto_increment"], lang('Auto Increment')) . (support("trigger") ? checkbox("triggers", 1, $row["triggers"], lang('Triggers')) : "") ; echo "
" . lang('Data') . "" . html_select('data_style', $data_style, $row["data_style"]); ?>

"; echo "\n"; $databases = $adminer->databases(); if ($databases) { foreach ($databases as $db) { if (!information_schema($db)) { $prefix = preg_replace('~_.*~', '', $db); echo "
" . script("qs('#check-tables').onclick = partial(formCheck, /^tables\\[/);", ""); echo "" . script("qs('#check-data').onclick = partial(formCheck, /^data\\[/);", ""); echo "\n"; $views = ""; $tables_list = tables_list(); foreach ($tables_list as $name => $type) { $prefix = preg_replace('~_.*~', '', $name); $checked = ($TABLE == "" || $TABLE == (substr($TABLE, -1) == "%" ? "$prefix%" : $name)); //! % may be part of table name $print = "
" . checkbox("tables[]", $name, $checked, $name, "", "block"); if ($type !== null && !preg_match('~table~i', $type)) { $views .= "$print\n"; } else { echo "$print\n"; } $prefixes[$prefix]++; } echo $views; if ($tables_list) { echo script("ajaxSetHtml('" . js_escape(ME) . "script=db');"); } } else { echo "
"; echo ""; echo script("qs('#check-databases').onclick = partial(formCheck, /^databases\\[/);", ""); echo "
" . checkbox("databases[]", $db, $TABLE == "" || $TABLE == "$prefix%", $db, "", "block") . "\n"; $prefixes[$prefix]++; } } } else { echo "
"; } } ?>

$val) { if ($key != "" && $val > 1) { echo ($first ? "

" : " ") . "" . h($key) . ""; $first = false; } }