2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Generic AJAX endpoint for getting information about database
9 use PhpMyAdmin\Response
;
13 $_GET['ajax_request'] = 'true';
15 require_once 'libraries/common.inc.php';
17 $response = Response
::getInstance();
18 $response->setAJAX(true);
20 if (empty($_POST['type'])) {
21 Core
::fatalError(__('Bad type!'));
24 switch ($_POST['type']) {
25 case 'list-databases':
26 $response->addJSON('databases', $GLOBALS['dblist']->databases
);
29 Util
::checkParameters(array('db'), true);
30 $response->addJSON('tables', $GLOBALS['dbi']->getTables($_POST['db']));
33 Util
::checkParameters(array('db', 'table'), true);
34 $response->addJSON('columns', $GLOBALS['dbi']->getColumnNames($_POST['db'], $_POST['table']));
37 Util
::checkParameters(array('key'), true);
38 $response->addJSON('value', $GLOBALS['PMA_Config']->get($_POST['key']));
41 Util
::checkParameters(array('key', 'value'), true);
42 $result = $GLOBALS['PMA_Config']->setUserValue(null, $_POST['key'], json_decode($_POST['value']));
43 if ($result !== true) {
44 $response = Response
::getInstance();
45 $response->setRequestStatus(false);
46 $response->addJSON('message', $result);
50 Core
::fatalError(__('Bad type!'));