diff --git a/export.php b/export.php index beaa05fe19..1f70a1b4e0 100644 --- a/export.php +++ b/export.php @@ -294,7 +294,7 @@ $tables = []; if ($export_type == 'server') { $err_url = 'server_export.php' . Url::getCommon(); } elseif ($export_type == 'database' && strlen($db) > 0) { - $err_url = 'db_export.php' . Url::getCommon(['db' => $db]); + $err_url = Url::getFromRoute('/database/export', ['db' => $db]); // Check if we have something to export if (isset($table_select)) { $tables = $table_select; @@ -415,8 +415,8 @@ if ($save_on_server) { $message = PhpMyAdmin\Message::error( __('No tables found in database.') ); - $active_page = 'db_export.php'; - include ROOT_PATH . 'db_export.php'; + $active_page = Url::getFromRoute('/database/export'); + include ROOT_PATH . 'libraries/entry_points/database/export.php'; exit; } } diff --git a/index.php b/index.php index 413bf490be..b233ab193e 100644 --- a/index.php +++ b/index.php @@ -47,6 +47,9 @@ if (isset($_GET['route']) || isset($_POST['route'])) { $routes->addRoute(['GET', 'POST'], '/events', function () { require_once ROOT_PATH . 'libraries/entry_points/database/events.php'; }); + $routes->addRoute(['GET', 'POST'], '/export', function () { + require_once ROOT_PATH . 'libraries/entry_points/database/export.php'; + }); $routes->addRoute(['GET', 'POST'], '/multi_table_query', function () { require_once ROOT_PATH . 'libraries/entry_points/database/multi_table_query.php'; }); diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php index 18556b0633..45940e0772 100644 --- a/libraries/classes/Core.php +++ b/libraries/classes/Core.php @@ -26,7 +26,6 @@ class Core * @static array $goto_whitelist */ public static $goto_whitelist = [ - 'db_export.php', 'db_importdocsql.php', 'db_import.php', 'export.php', diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php index 1a5c495a3f..ffb240a4f3 100644 --- a/libraries/classes/Export.php +++ b/libraries/classes/Export.php @@ -501,7 +501,7 @@ class Export if ($export_type == 'server') { $back_button .= 'server_export.php" data-post="' . Url::getCommon([], ''); } elseif ($export_type == 'database') { - $back_button .= 'db_export.php" data-post="' . Url::getCommon(['db' => $db], ''); + $back_button .= Url::getFromRoute('/database/export') . '" data-post="' . Url::getCommon(['db' => $db], ''); } else { $back_button .= 'tbl_export.php" data-post="' . Url::getCommon( [ @@ -1054,8 +1054,8 @@ class Export $active_page = 'server_export.php'; include_once ROOT_PATH . 'server_export.php'; } elseif ($export_type == 'database') { - $active_page = 'db_export.php'; - include_once ROOT_PATH . 'db_export.php'; + $active_page = Url::getFromRoute('/database/export'); + include_once ROOT_PATH . 'libraries/entry_points/database/export.php'; } else { $active_page = 'tbl_export.php'; include_once ROOT_PATH . 'tbl_export.php'; diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php index a789aa02b9..0d02417f46 100644 --- a/libraries/classes/Menu.php +++ b/libraries/classes/Menu.php @@ -488,7 +488,8 @@ class Menu $tabs['export']['text'] = __('Export'); $tabs['export']['icon'] = 'b_export'; - $tabs['export']['link'] = 'db_export.php'; + $tabs['export']['link'] = Url::getFromRoute('/database/export'); + $tabs['export']['active'] = isset($_REQUEST['route']) && $_REQUEST['route'] === '/database/export'; if ($num_tables == 0) { $tabs['export']['warning'] = __('Database seems to be empty!'); } diff --git a/db_export.php b/libraries/entry_points/database/export.php similarity index 93% rename from db_export.php rename to libraries/entry_points/database/export.php index d585392739..d74afb236f 100644 --- a/db_export.php +++ b/libraries/entry_points/database/export.php @@ -13,15 +13,14 @@ use PhpMyAdmin\Display\Export as DisplayExport; use PhpMyAdmin\Export; use PhpMyAdmin\Message; use PhpMyAdmin\Response; +use PhpMyAdmin\Url; use PhpMyAdmin\Util; -if (! defined('ROOT_PATH')) { - define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR); +if (! defined('PHPMYADMIN')) { + exit; } -global $containerBuilder, $db, $table, $url_query; - -require_once ROOT_PATH . 'libraries/common.inc.php'; +global $containerBuilder, $db, $table, $url_query, $url_params; /** @var Response $response */ $response = $containerBuilder->get(Response::class); @@ -39,10 +38,15 @@ $scripts->addFile('export.js'); $export = $containerBuilder->get('export'); // $sub_part is used in Util::getDbInfo() to see if we are coming from -// db_export.php, in which case we don't obey $cfg['MaxTableList'] +// /database/export, in which case we don't obey $cfg['MaxTableList'] $sub_part = '_export'; + require_once ROOT_PATH . 'libraries/db_common.inc.php'; -$url_query .= '&goto=db_export.php'; + +$url_params = [ + 'goto' => Url::getFromRoute('/database/export'), +]; +$url_query .= Url::getCommon($url_params, '&'); list( $tables, diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php index 7a538fab1d..08c5d74d11 100644 --- a/libraries/mult_submits.inc.php +++ b/libraries/mult_submits.inc.php @@ -94,7 +94,7 @@ if (! empty($submit_mult) break; case 'export': unset($submit_mult); - include ROOT_PATH . 'db_export.php'; + include ROOT_PATH . 'libraries/entry_points/database/export.php'; exit; case 'copy_tbl': $views = $GLOBALS['dbi']->getVirtualTables($db); diff --git a/test/classes/CoreTest.php b/test/classes/CoreTest.php index ba0a82a9b1..011a23211a 100644 --- a/test/classes/CoreTest.php +++ b/test/classes/CoreTest.php @@ -23,7 +23,6 @@ use stdClass; class CoreTest extends PmaTestCase { protected $goto_whitelist = [ - 'db_export.php', 'export.php', 'import.php', 'index.php',