Translated using Weblate (Czech)
[phpmyadmin.git] / ajax.php
blob7f615a018cc436f22ac1aa764f6a0b8e98871ea1
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Generic AJAX endpoint for getting information about database
6 * @package PhpMyAdmin
7 */
9 use PhpMyAdmin\Response;
10 use PhpMyAdmin\Util;
11 use PhpMyAdmin\Core;
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);
27 break;
28 case 'list-tables':
29 Util::checkParameters(array('db'), true);
30 $response->addJSON('tables', $GLOBALS['dbi']->getTables($_POST['db']));
31 break;
32 case 'list-columns':
33 Util::checkParameters(array('db', 'table'), true);
34 $response->addJSON('columns', $GLOBALS['dbi']->getColumnNames($_POST['db'], $_POST['table']));
35 break;
36 case 'config-get':
37 Util::checkParameters(array('key'), true);
38 $response->addJSON('value', $GLOBALS['PMA_Config']->get($_POST['key']));
39 break;
40 case 'config-set':
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);
48 break;
49 default:
50 Core::fatalError(__('Bad type!'));