Translated using Weblate (German)
[phpmyadmin.git] / db_export.php
blobb65b17863836476dcc259bf2d421f2ce8a0debe5
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * dumps a database
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Config\PageSettings;
11 use PhpMyAdmin\DatabaseInterface;
12 use PhpMyAdmin\Di\Container;
13 use PhpMyAdmin\Display\Export as DisplayExport;
14 use PhpMyAdmin\Export;
15 use PhpMyAdmin\Message;
16 use PhpMyAdmin\Response;
17 use PhpMyAdmin\Util;
19 if (! defined('ROOT_PATH')) {
20 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
23 require_once ROOT_PATH . 'libraries/common.inc.php';
25 $container = Container::getDefaultContainer();
26 $container->set(Response::class, Response::getInstance());
28 /** @var Response $response */
29 $response = $container->get(Response::class);
31 /** @var DatabaseInterface $dbi */
32 $dbi = $container->get(DatabaseInterface::class);
34 PageSettings::showGroup('Export');
36 $header = $response->getHeader();
37 $scripts = $header->getScripts();
38 $scripts->addFile('export.js');
40 $export = new Export($dbi);
42 // $sub_part is used in Util::getDbInfo() to see if we are coming from
43 // db_export.php, in which case we don't obey $cfg['MaxTableList']
44 $sub_part = '_export';
45 require_once ROOT_PATH . 'libraries/db_common.inc.php';
46 $url_query .= '&amp;goto=db_export.php';
48 list(
49 $tables,
50 $num_tables,
51 $total_num_tables,
52 $sub_part,
53 $is_show_stats,
54 $db_is_system_schema,
55 $tooltip_truename,
56 $tooltip_aliasname,
57 $pos
58 ) = Util::getDbInfo($db, is_null($sub_part) ? '' : $sub_part);
60 /**
61 * Displays the form
63 $export_page_title = __('View dump (schema) of database');
65 // exit if no tables in db found
66 if ($num_tables < 1) {
67 $response->addHTML(
68 Message::error(__('No tables found in database.'))->getDisplay()
70 exit;
71 } // end if
73 $multi_values = '<div class="export_table_list_container">';
74 if (isset($_POST['structure_or_data_forced'])) {
75 $force_val = htmlspecialchars($_POST['structure_or_data_forced']);
76 } else {
77 $force_val = 0;
79 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
80 . $force_val . '">';
81 $multi_values .= '<table class="export_table_select">'
82 . '<thead><tr><th></th>'
83 . '<th>' . __('Tables') . '</th>'
84 . '<th class="export_structure">' . __('Structure') . '</th>'
85 . '<th class="export_data">' . __('Data') . '</th>'
86 . '</tr><tr>'
87 . '<td></td>'
88 . '<td class="export_table_name all">' . __('Select all') . '</td>'
89 . '<td class="export_structure all">'
90 . '<input type="checkbox" id="table_structure_all"></td>'
91 . '<td class="export_data all"><input type="checkbox" id="table_data_all">'
92 . '</td>'
93 . '</tr></thead>'
94 . '<tbody>';
95 $multi_values .= "\n";
97 // when called by libraries/mult_submits.inc.php
98 if (! empty($_POST['selected_tbl']) && empty($table_select)) {
99 $table_select = $_POST['selected_tbl'];
102 foreach ($tables as $each_table) {
103 if (isset($_POST['table_select']) && is_array($_POST['table_select'])) {
104 $is_checked = $export->getCheckedClause(
105 $each_table['Name'],
106 $_POST['table_select']
108 } elseif (isset($table_select)) {
109 $is_checked = $export->getCheckedClause(
110 $each_table['Name'],
111 $table_select
113 } else {
114 $is_checked = ' checked="checked"';
116 if (isset($_POST['table_structure']) && is_array($_POST['table_structure'])) {
117 $structure_checked = $export->getCheckedClause(
118 $each_table['Name'],
119 $_POST['table_structure']
121 } else {
122 $structure_checked = $is_checked;
124 if (isset($_POST['table_data']) && is_array($_POST['table_data'])) {
125 $data_checked = $export->getCheckedClause(
126 $each_table['Name'],
127 $_POST['table_data']
129 } else {
130 $data_checked = $is_checked;
132 $table_html = htmlspecialchars($each_table['Name']);
133 $multi_values .= '<tr class="marked">';
134 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
135 . ' value="' . $table_html . '"' . $is_checked . ' class="checkall"></td>';
136 $multi_values .= '<td class="export_table_name">'
137 . str_replace(' ', '&nbsp;', $table_html) . '</td>';
138 $multi_values .= '<td class="export_structure">'
139 . '<input type="checkbox" name="table_structure[]"'
140 . ' value="' . $table_html . '"' . $structure_checked . '></td>';
141 $multi_values .= '<td class="export_data">'
142 . '<input type="checkbox" name="table_data[]"'
143 . ' value="' . $table_html . '"' . $data_checked . '></td>';
144 $multi_values .= '</tr>';
145 } // end for
147 $multi_values .= "\n";
148 $multi_values .= '</tbody></table></div>';
150 if (! isset($sql_query)) {
151 $sql_query = '';
153 if (! isset($num_tables)) {
154 $num_tables = 0;
156 if (! isset($unlim_num_rows)) {
157 $unlim_num_rows = 0;
159 if (is_null($multi_values)) {
160 $multi_values = '';
162 $response = Response::getInstance();
163 $displayExport = new DisplayExport();
164 $response->addHTML(
165 $displayExport->getDisplay(
166 'database',
167 $db,
168 $table,
169 $sql_query,
170 $num_tables,
171 $unlim_num_rows,
172 $multi_values