2 /* vim: set expandtab sw=4 ts=4 sts=4: */
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
;
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 .= '&goto=db_export.php';
47 ) = Util
::getDbInfo($db, is_null($sub_part) ?
'' : $sub_part);
52 $export_page_title = __('View dump (schema) of database');
54 // exit if no tables in db found
55 if ($num_tables < 1) {
57 Message
::error(__('No tables found in database.'))->getDisplay()
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']);
68 $multi_values .= '<input type="hidden" name="structure_or_data_forced" value="'
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>'
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" />'
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(
104 $_GET['table_select']
106 } elseif (isset($table_select)) {
107 $is_checked = $export->getCheckedClause(
112 $is_checked = ' checked="checked"';
114 if (isset($_GET['table_structure']) && is_array($_GET['table_structure'])) {
115 $structure_checked = $export->getCheckedClause(
117 $_GET['table_structure']
120 $structure_checked = $is_checked;
122 if (isset($_GET['table_data']) && is_array($_GET['table_data'])) {
123 $data_checked = $export->getCheckedClause(
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(' ', ' ', $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>';
145 $multi_values .= "\n";
146 $multi_values .= '</tbody></table></div>';
148 if (! isset($sql_query)) {
151 if (! isset($num_tables)) {
154 if (! isset($unlim_num_rows)) {
157 if (is_null($multi_values)) {
160 $response = Response
::getInstance();
161 $displayExport = new DisplayExport();
163 $displayExport->getDisplay(