1)); if ($_POST["format"] != "csv") { $max_packet = 16777216; echo "SET NAMES utf8;\n"; echo "SET foreign_key_checks = 0;\n"; echo "SET time_zone = '" . $mysql->escape_string($mysql->result($mysql->query("SELECT @@time_zone"))) . "';\n"; echo "SET max_allowed_packet = $max_packet, GLOBAL max_allowed_packet = $max_packet;\n"; echo "\n"; } foreach ($_POST["databases"] as $db => $style) { $db = bracket_escape($db, "back"); if ($mysql->select_db($db)) { if ($_POST["format"] != "csv" && in_array($style, array("DROP, CREATE", "CREATE", "CREATE, ALTER")) && ($result = $mysql->query("SHOW CREATE DATABASE " . idf_escape($db)))) { if ($style == "DROP, CREATE") { echo "DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n"; } $create = $mysql->result($result, 1); echo ($style == "CREATE, ALTER" ? preg_replace('~^CREATE DATABASE ~', '\\0IF NOT EXISTS ', $create) : $create) . ";\n"; $result->free(); } if ($style && $_POST["format"] != "csv") { echo "USE " . idf_escape($db) . ";\n"; if ($mysql->server_info >= 5) { $out = ""; foreach (array("FUNCTION", "PROCEDURE") as $routine) { $result = $mysql->query("SHOW $routine STATUS WHERE Db = '" . $mysql->escape_string($db) . "'"); while ($row = $result->fetch_assoc()) { if (!$out) { echo "DELIMITER ;;\n\n"; $out = "DELIMITER ;\n\n"; } echo $mysql->result($mysql->query("SHOW CREATE $routine " . idf_escape($row["Name"])), 2) . ";;\n\n"; } $result->free(); } echo $out; } } if (($style || strlen($_GET["db"])) && (array_filter($_POST["tables"]) || array_filter($_POST["data"]))) { $views = array(); $result = $mysql->query("SHOW TABLE STATUS"); while ($row = $result->fetch_assoc()) { $key = (strlen($_GET["db"]) ? bracket_escape($row["Name"]) : 0); if ($_POST["tables"][$key] || $_POST["data"][$key]) { if (isset($row["Engine"])) { if ($ext == "tar") { ob_start(); } dump_table($row["Name"], $_POST["tables"][$key]); dump_data($row["Name"], $_POST["data"][$key]); if ($ext == "tar") { echo tar_file((strlen($_GET["db"]) ? "" : "$db/") . "$row[Name].csv", ob_get_clean()); } } elseif ($_POST["format"] != "csv") { $views[$row["Name"]] = $_POST["tables"][$key]; } } } $result->free(); foreach ($views as $view => $style) { dump_table($view, $style); } } } } exit; } page_header(lang('Export'), "", (strlen($_GET["export"]) ? array("table" => $_GET["export"]) : array()), $_GET["db"]); ?>