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\Response
;
14 $_GET['ajax_request'] = 'true';
16 require_once 'libraries/common.inc.php';
18 $response = Response
::getInstance();
19 $response->setAJAX(true);
21 if (empty($_POST['type'])) {
22 Core
::fatalError(__('Bad type!'));
25 switch ($_POST['type']) {
26 case 'list-databases':
27 $response->addJSON('databases', $GLOBALS['dblist']->databases
);
30 Util
::checkParameters(['db'], true);
31 $response->addJSON('tables', $GLOBALS['dbi']->getTables($_REQUEST['db']));
34 Util
::checkParameters(['db', 'table'], true);
35 $response->addJSON('columns', $GLOBALS['dbi']->getColumnNames($_REQUEST['db'], $_REQUEST['table']));
38 Util
::checkParameters(['key'], true);
39 $response->addJSON('value', $GLOBALS['PMA_Config']->get($_REQUEST['key']));
42 Util
::checkParameters(['key', 'value'], true);
43 $result = $GLOBALS['PMA_Config']->setUserValue(null, $_REQUEST['key'], json_decode($_REQUEST['value']));
44 if ($result !== true) {
45 $response = Response
::getInstance();
46 $response->setRequestStatus(false);
47 $response->addJSON('message', $result);
51 Core
::fatalError(__('Bad type!'));