<?php $TABLE = $_GET["dump"]; if ($_POST && !$error) { $cookie = ""; foreach (array("output", "format", "db_style", "routines", "events", "table_style", "auto_increment", "triggers", "data_style") as $key) { $cookie .= "&{$key}=" . urlencode($_POST[$key]); } cookie("adminer_export", substr($cookie, 1)); $tables = array_flip((array) $_POST["tables"]) + array_flip((array) $_POST["data"]); $ext = dump_headers(count($tables) == 1 ? key($tables) : DB, DB == "" || count($tables) > 1); $is_sql = preg_match('~sql~', $_POST["format"]); if ($is_sql) { echo "-- Adminer {$VERSION} " . $drivers[DRIVER] . " dump\n\n"; if ($jush == "sql") { echo "SET NAMES utf8;\nSET time_zone = '+00:00';\n" . ($_POST["data_style"] ? "SET foreign_key_checks = 0;\nSET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';\n" : "") . "\n"; $connection->query("SET time_zone = '+00:00';"); } } $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))) {
$primary = $unselected = null; foreach ($indexes as $index) { if ($index["type"] == "PRIMARY") { $primary = array_flip($index["columns"]); $unselected = $select ? $primary : array(); break; } } foreach ((array) $unselected as $key => $val) { if (in_array(idf_escape($key), $select)) { unset($unselected[$key]); } } if ($_POST["export"]) { cookie("adminer_import", "output=" . urlencode($_POST["output"]) . "&format=" . urlencode($_POST["format"])); dump_headers($TABLE); $adminer->dumpTable($TABLE, ""); if (!is_array($_POST["check"]) || $unselected === array()) { $where2 = $where; if (is_array($_POST["check"])) { $where2[] = "({$where_check})"; } $query = "SELECT {$from}" . ($where2 ? "\nWHERE " . implode(" AND ", $where2) : "") . $group_by; } else { $union = array(); foreach ($_POST["check"] as $val) { // where is not unique so OR can't be used $union[] = "(SELECT" . limit($from, "\nWHERE " . ($where ? implode(" AND ", $where) . " AND " : "") . where_check($val) . $group_by, 1) . ")"; } $query = implode(" UNION ALL ", $union); }
<?php if (!$error && $_POST["export"]) { dump_headers(!empty($_POST['filename']) ? $_POST['filename'] : 'sql'); $adminer->dumpTable("", ""); $adminer->dumpData("", "table", $_POST["query"]); exit; } restart_session(); $history_all =& get_session("queries"); $history =& $history_all[DB]; if (!$error && $_POST["clear"]) { $history = array(); redirect(remove_from_uri("history")); } page_header(isset($_GET["import"]) ? lang('Import') : lang('SQL command'), $error); if (!$error && $_POST) { $fp = false; if (!isset($_GET["import"])) { $query = $_POST["query"]; } elseif ($_POST["webfile"]) { $fp = @fopen(file_exists("adminer.sql") ? "adminer.sql" : "compress.zlib://adminer.sql.gz", "rb"); $query = $fp ? fread($fp, 1000000.0) : false; } else { $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() + 8000000.0)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
<?php if (!$error && $_POST["export"]) { dump_headers("sql"); $adminer->dumpTable("", ""); $adminer->dumpData("", "table", $_POST["query"]); exit; } restart_session(); $history_all =& get_session("queries"); $history =& $history_all[DB]; if (!$error && $_POST["clear"]) { $history = array(); adminer_redirect(remove_from_uri("history")); } page_header(isset($_GET["import"]) ? lang('Import') : lang('SQL command'), $error); if (!$error && $_POST) { $fp = false; if (!isset($_GET["import"])) { $query = $_POST["query"]; } elseif ($_POST["webfile"]) { $fp = @fopen(file_exists("adminer.sql") ? "adminer.sql" : "compress.zlib://adminer.sql.gz", "rb"); $query = $fp ? fread($fp, 1000000.0) : false; } else { $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() + 8000000.0)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
<?php $TABLE = $_GET["dump"]; if ($_POST) { $cookie = ""; foreach (array("output", "format", "db_style", "routines", "events", "table_style", "auto_increment", "triggers", "data_style") as $key) { $cookie .= "&{$key}=" . urlencode($_POST[$key]); } cookie("adminer_export", substr($cookie, 1)); $ext = dump_headers($TABLE != "" ? $TABLE : DB, DB == "" || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1); $is_sql = $_POST["format"] == "sql"; if ($is_sql) { echo "-- Adminer {$VERSION} " . $drivers[DRIVER] . " dump\n\n" . ($jush != "sql" ? "" : "SET NAMES utf8;\nSET foreign_key_checks = 0;\nSET time_zone = " . q($connection->result("SELECT @@time_zone")) . ";\nSET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';\n\n"); } $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) { if ($connection->select_db($db)) { if ($is_sql && ereg('CREATE', $style) && ($create = $connection->result("SHOW CREATE DATABASE " . idf_escape($db), 1))) { if ($style == "DROP+CREATE") { echo "DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n"; } echo ($style == "CREATE+ALTER" ? preg_replace('~^CREATE DATABASE ~', '\\0IF NOT EXISTS ', $create) : $create) . ";\n"; } if ($is_sql) {