Translated using Weblate (Norwegian Bokmål)
[phpmyadmin.git] / ajax.php
blob5f4fc8c22fa63314182584c8fde65205d62851a5
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($_REQUEST['db']));
31 break;
32 case 'list-columns':
33 Util::checkParameters(array('db', 'table'), true);
34 $response->addJSON('columns', $GLOBALS['dbi']->getColumnNames($_REQUEST['db'], $_REQUEST['table']));
35 break;
36 case 'config-get':
37 Util::checkParameters(array('key'), true);
38 $response->addJSON('value', $GLOBALS['PMA_Config']->get($_REQUEST['key']));
39 break;
40 case 'config-set':
41 Util::checkParameters(array('key', 'value'), true);
42 $result = $GLOBALS['PMA_Config']->setUserValue(null, $_REQUEST['key'], json_decode($_REQUEST['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!'));