Translated using Weblate (German)
[phpmyadmin.git] / db_export.php
blob234a7d0ccb9c2ca3089800d2a2c967b35f503bd2
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\Display\Export as DisplayExport;
12 use PhpMyAdmin\Export;
13 use PhpMyAdmin\Message;
14 use PhpMyAdmin\Response;
15 use PhpMyAdmin\Util;
17 /**
18 * Gets some core libraries
20 require_once 'libraries/common.inc.php';
22 PageSettings::showGroup('Export');
24 $response = Response::getInstance();
25 $header = $response->getHeader();
26 $scripts = $header->getScripts();
27 $scripts->addFile('export.js');
29 $export = new Export();
31 // $sub_part is used in Util::getDbInfo() to see if we are coming from
32 // db_export.php, in which case we don't obey $cfg['MaxTableList']
33 $sub_part = '_export';
34 require_once 'libraries/db_common.inc.php';
35 $url_query .= '&amp;goto=db_export.php';
37 list(
38 $tables,
39 $num_tables,
40 $total_num_tables,
41 $sub_part,
42 $is_show_stats,
43 $db_is_system_schema,
44 $tooltip_truename,
45 $tooltip_aliasname,
46 $pos
47 ) = Util::getDbInfo($db, is_null($sub_part) ? '' : $sub_part);
49 /**
50 * Displays the form
52 $export_page_title = __('View dump (schema) of database');
54 // exit if no tables in db found
55 if ($num_tables < 1) {
56 $response->addHTML(
57 Message::error(__('No tables found in database.'))->getDisplay()
59 exit;
60 } // end if
62 $multi_values = '<div class="export_table_list_container">';
63 if (isset($_GET['structure_or_data_forced'])) {
64 $force_val = htmlspecialchars($_GET['structure_or_data_forced']);
65 } else {
66 $force_val = 0;
68 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
69 . $force_val . '">';
70 $multi_values .= '<table class="export_table_select">'
71 . '<thead><tr><th></th>'
72 . '<th>' . __('Tables') . '</th>'
73 . '<th class="export_structure">' . __('Structure') . '</th>'
74 . '<th class="export_data">' . __('Data') . '</th>'
75 . '</tr><tr>'
76 . '<td></td>'
77 . '<td class="export_table_name all">' . __('Select all') . '</td>'
78 . '<td class="export_structure all">'
79 . '<input type="checkbox" id="table_structure_all" /></td>'
80 . '<td class="export_data all"><input type="checkbox" id="table_data_all" />'
81 . '</td>'
82 . '</tr></thead>'
83 . '<tbody>';
84 $multi_values .= "\n";
86 // when called by libraries/mult_submits.inc.php
87 if (!empty($_POST['selected_tbl']) && empty($table_select)) {
88 $table_select = $_POST['selected_tbl'];
91 // Check if the selected tables are defined in $_GET
92 // (from clicking Back button on export.php)
93 foreach (['table_select', 'table_structure', 'table_data'] as $one_key) {
94 if (isset($_GET[$one_key])) {
95 $_GET[$one_key] = urldecode($_GET[$one_key]);
96 $_GET[$one_key] = explode(",", $_GET[$one_key]);
100 foreach ($tables as $each_table) {
101 if (isset($_GET['table_select']) && is_array($_GET['table_select'])) {
102 $is_checked = $export->getCheckedClause(
103 $each_table['Name'],
104 $_GET['table_select']
106 } elseif (isset($table_select)) {
107 $is_checked = $export->getCheckedClause(
108 $each_table['Name'],
109 $table_select
111 } else {
112 $is_checked = ' checked="checked"';
114 if (isset($_GET['table_structure']) && is_array($_GET['table_structure'])) {
115 $structure_checked = $export->getCheckedClause(
116 $each_table['Name'],
117 $_GET['table_structure']
119 } else {
120 $structure_checked = $is_checked;
122 if (isset($_GET['table_data']) && is_array($_GET['table_data'])) {
123 $data_checked = $export->getCheckedClause(
124 $each_table['Name'],
125 $_GET['table_data']
127 } else {
128 $data_checked = $is_checked;
130 $table_html = htmlspecialchars($each_table['Name']);
131 $multi_values .= '<tr class="marked">';
132 $multi_values .= '<td><input type="checkbox" name="table_select[]"'
133 . ' value="' . $table_html . '"' . $is_checked . ' class="checkall"/></td>';
134 $multi_values .= '<td class="export_table_name">'
135 . str_replace(' ', '&nbsp;', $table_html) . '</td>';
136 $multi_values .= '<td class="export_structure">'
137 . '<input type="checkbox" name="table_structure[]"'
138 . ' value="' . $table_html . '"' . $structure_checked . ' /></td>';
139 $multi_values .= '<td class="export_data">'
140 . '<input type="checkbox" name="table_data[]"'
141 . ' value="' . $table_html . '"' . $data_checked . ' /></td>';
142 $multi_values .= '</tr>';
143 } // end for
145 $multi_values .= "\n";
146 $multi_values .= '</tbody></table></div>';
148 if (! isset($sql_query)) {
149 $sql_query = '';
151 if (! isset($num_tables)) {
152 $num_tables = 0;
154 if (! isset($unlim_num_rows)) {
155 $unlim_num_rows = 0;
157 if (is_null($multi_values)) {
158 $multi_values = '';
160 $response = Response::getInstance();
161 $displayExport = new DisplayExport();
162 $response->addHTML(
163 $displayExport->getDisplay(
164 'database',
165 $db,
166 $table,
167 $sql_query,
168 $num_tables,
169 $unlim_num_rows,
170 $multi_values