Translated using Weblate (Ukrainian)
[phpmyadmin.git] / ajax.php
blobf0c8f74877b395ed6d5b2b6cf89892f6f721b6a4
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 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Response;
11 use PhpMyAdmin\Util;
12 use PhpMyAdmin\Core;
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);
28 break;
29 case 'list-tables':
30 Util::checkParameters(['db'], true);
31 $response->addJSON('tables', $GLOBALS['dbi']->getTables($_REQUEST['db']));
32 break;
33 case 'list-columns':
34 Util::checkParameters(['db', 'table'], true);
35 $response->addJSON('columns', $GLOBALS['dbi']->getColumnNames($_REQUEST['db'], $_REQUEST['table']));
36 break;
37 case 'config-get':
38 Util::checkParameters(['key'], true);
39 $response->addJSON('value', $GLOBALS['PMA_Config']->get($_REQUEST['key']));
40 break;
41 case 'config-set':
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);
49 break;
50 default:
51 Core::fatalError(__('Bad type!'));