2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Generic AJAX endpoint for getting information about database
8 declare(strict_types
=1);
10 use PhpMyAdmin\Controllers\AjaxController
;
12 use PhpMyAdmin\DatabaseInterface
;
13 use PhpMyAdmin\Response
;
16 if (! defined('ROOT_PATH')) {
17 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
20 $_GET['ajax_request'] = 'true';
22 require_once ROOT_PATH
. 'libraries/common.inc.php';
24 /** @var Response $response */
25 $response = $containerBuilder->get(Response
::class);
26 $response->setAjax(true);
28 /** @var DatabaseInterface $dbi */
29 $dbi = $containerBuilder->get(DatabaseInterface
::class);
31 /** @var AjaxController $controller */
32 $controller = $containerBuilder->get(AjaxController
::class);
34 if (empty($_POST['type'])) {
35 Core
::fatalError(__('Bad type!'));
38 switch ($_POST['type']) {
39 case 'list-databases':
40 $response->addJSON($controller->databases());
43 Util
::checkParameters(['db'], true);
44 $response->addJSON($controller->tables([
49 Util
::checkParameters(['db', 'table'], true);
50 $response->addJSON($controller->columns([
52 'table' => $_POST['table'],
56 Util
::checkParameters(['key'], true);
57 $response->addJSON($controller->getConfig([
58 'key' => $_POST['key'],
62 Util
::checkParameters(['key', 'value'], true);
63 $result = $controller->setConfig([
64 'key' => $_POST['key'],
65 'value' => $_POST['value'],
67 if ($result !== true) {
68 $response->setRequestStatus(false);
69 $response->addJSON('message', $result);
73 Core
::fatalError(__('Bad type!'));