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 if (! defined('ROOT_PATH')) {
15 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
18 $_GET['ajax_request'] = 'true';
20 require_once ROOT_PATH
. 'libraries/common.inc.php';
22 $response = Response
::getInstance();
23 $response->setAjax(true);
25 if (empty($_POST['type'])) {
26 Core
::fatalError(__('Bad type!'));
29 switch ($_POST['type']) {
30 case 'list-databases':
31 $response->addJSON('databases', $GLOBALS['dblist']->databases
);
34 Util
::checkParameters(['db'], true);
35 $response->addJSON('tables', $GLOBALS['dbi']->getTables($_POST['db']));
38 Util
::checkParameters(['db', 'table'], true);
39 $response->addJSON('columns', $GLOBALS['dbi']->getColumnNames($_POST['db'], $_POST['table']));
42 Util
::checkParameters(['key'], true);
43 $response->addJSON('value', $GLOBALS['PMA_Config']->get($_POST['key']));
46 Util
::checkParameters(['key', 'value'], true);
47 $result = $GLOBALS['PMA_Config']->setUserValue(null, $_POST['key'], json_decode($_POST['value']));
48 if ($result !== true) {
49 $response = Response
::getInstance();
50 $response->setRequestStatus(false);
51 $response->addJSON('message', $result);
55 Core
::fatalError(__('Bad type!'));