2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Handles server databases page.
8 declare(strict_types
=1);
10 use PhpMyAdmin\CheckUserPrivileges
;
11 use PhpMyAdmin\Controllers\Server\DatabasesController
;
12 use PhpMyAdmin\DatabaseInterface
;
13 use PhpMyAdmin\Response
;
15 if (! defined('ROOT_PATH')) {
16 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
19 require_once ROOT_PATH
. 'libraries/common.inc.php';
21 /** @var DatabasesController $controller */
22 $controller = $containerBuilder->get(DatabasesController
::class);
24 /** @var Response $response */
25 $response = $containerBuilder->get(Response
::class);
27 /** @var DatabaseInterface $dbi */
28 $dbi = $containerBuilder->get(DatabaseInterface
::class);
30 $checkUserPrivileges = new CheckUserPrivileges($dbi);
31 $checkUserPrivileges->getPrivileges();
33 if (isset($_POST['drop_selected_dbs'])
34 && $response->isAjax()
35 && ($dbi->isSuperuser() ||
$GLOBALS['cfg']['AllowUserDropDatabase'])
37 $response->addJSON($controller->dropDatabasesAction([
38 'drop_selected_dbs' => $_POST['drop_selected_dbs'],
39 'selected_dbs' => $_POST['selected_dbs'] ??
null,
41 } elseif (isset($_POST['new_db'])
42 && $response->isAjax()
44 $response->addJSON($controller->createDatabaseAction([
45 'new_db' => $_POST['new_db'],
46 'db_collation' => $_POST['db_collation'] ??
null,
49 $header = $response->getHeader();
50 $scripts = $header->getScripts();
51 $scripts->addFile('server/databases.js');
53 $response->addHTML($controller->indexAction([
54 'statistics' => $_REQUEST['statistics'] ??
null,
55 'pos' => $_REQUEST['pos'] ??
null,
56 'sort_by' => $_REQUEST['sort_by'] ??
null,
57 'sort_order' => $_REQUEST['sort_order'] ??
null,