aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/libraries/classes/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Controllers')
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/AbstractController.php51
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/AjaxController.php97
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/BrowseForeignersController.php82
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/AbstractController.php42
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/CentralColumnsController.php195
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/DataDictionaryController.php156
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/EventsController.php43
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/MultiTableQueryController.php61
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/RoutinesController.php44
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/SqlController.php49
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/StructureController.php1088
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Database/TriggersController.php43
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/HomeController.php517
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/BinlogController.php149
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/CollationsController.php100
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/DatabasesController.php424
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/EnginesController.php69
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/PluginsController.php77
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/ReplicationController.php72
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/SqlController.php34
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AbstractController.php42
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AdvisorController.php60
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/MonitorController.php146
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/ProcessesController.php240
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/QueriesController.php75
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/StatusController.php260
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/VariablesController.php639
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Server/VariablesController.php238
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Setup/AbstractController.php70
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Setup/ConfigController.php55
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Setup/FormController.php50
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Setup/HomeController.php228
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Setup/ServersController.php66
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/AbstractController.php54
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/ChartController.php261
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/GisVisualizationController.php227
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/IndexesController.php179
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/RelationController.php398
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/SearchController.php1244
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/SqlController.php53
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/Table/StructureController.php1648
-rw-r--r--srcs/phpmyadmin/libraries/classes/Controllers/TransformationOverviewController.php80
42 files changed, 9706 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/AbstractController.php b/srcs/phpmyadmin/libraries/classes/Controllers/AbstractController.php
new file mode 100644
index 0000000..601e79f
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Controllers/AbstractController.php
@@ -0,0 +1,51 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Holds the PhpMyAdmin\Controllers\AbstractController
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Controllers;
+
+use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Response;
+use PhpMyAdmin\Template;
+
+/**
+ * Base class for all of controller
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+abstract class AbstractController
+{
+ /**
+ * @var Response
+ */
+ protected $response;
+
+ /**
+ * @var DatabaseInterface
+ */
+ protected $dbi;
+
+ /**
+ * @var Template
+ */
+ protected $template;
+
+ /**
+ * AbstractController constructor.
+ *
+ * @param Response $response Response object
+ * @param DatabaseInterface $dbi DatabaseInterface object
+ * @param Template $template Template that should be used (if provided, default one otherwise)
+ */
+ public function __construct($response, $dbi, Template $template)
+ {
+ $this->response = $response;
+ $this->dbi = $dbi;
+ $this->template = $template;
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/AjaxController.php b/srcs/phpmyadmin/libraries/classes/Controllers/AjaxController.php
new file mode 100644
index 0000000..0662277
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Controllers/AjaxController.php
@@ -0,0 +1,97 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Holds the PhpMyAdmin\Controllers\AjaxController
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Controllers;
+
+use PhpMyAdmin\Config;
+use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Message;
+use PhpMyAdmin\Response;
+use PhpMyAdmin\Template;
+
+/**
+ * Class AjaxController
+ * @package PhpMyAdmin\Controllers
+ */
+class AjaxController extends AbstractController
+{
+ /**
+ * @var Config
+ */
+ private $config;
+
+ /**
+ * AjaxController constructor.
+ *
+ * @param Response $response Response instance
+ * @param DatabaseInterface $dbi DatabaseInterface instance
+ * @param Template $template Template object
+ * @param Config $config Config instance
+ */
+ public function __construct($response, $dbi, Template $template, $config)
+ {
+ parent::__construct($response, $dbi, $template);
+ $this->config = $config;
+ }
+
+ /**
+ * @return array JSON
+ */
+ public function databases(): array
+ {
+ global $dblist;
+
+ return ['databases' => $dblist->databases];
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return array JSON
+ */
+ public function tables(array $params): array
+ {
+ return ['tables' => $this->dbi->getTables($params['db'])];
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return array JSON
+ */
+ public function columns(array $params): array
+ {
+ return [
+ 'columns' => $this->dbi->getColumnNames(
+ $params['db'],
+ $params['table']
+ ),
+ ];
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return array JSON
+ */
+ public function getConfig(array $params): array
+ {
+ return ['value' => $this->config->get($params['key'])];
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return true|Message
+ */
+ public function setConfig(array $params)
+ {
+ return $this->config->setUserValue(
+ null,
+ $params['key'],
+ json_decode($params['value'])
+ );
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/BrowseForeignersController.php b/srcs/phpmyadmin/libraries/classes/Controllers/BrowseForeignersController.php
new file mode 100644
index 0000000..24441cd
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Controllers/BrowseForeignersController.php
@@ -0,0 +1,82 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Holds the PhpMyAdmin\Controllers\BrowseForeignersController
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Controllers;
+
+use PhpMyAdmin\BrowseForeigners;
+use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Relation;
+use PhpMyAdmin\Response;
+use PhpMyAdmin\Template;
+
+/**
+ * Display selection for relational field values
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+class BrowseForeignersController extends AbstractController
+{
+ /**
+ * @var BrowseForeigners
+ */
+ private $browseForeigners;
+
+ /**
+ * @var Relation
+ */
+ private $relation;
+
+ /**
+ * BrowseForeignersController constructor.
+ *
+ * @param Response $response Response instance
+ * @param DatabaseInterface $dbi DatabaseInterface instance
+ * @param Template $template Template object
+ * @param BrowseForeigners $browseForeigners BrowseForeigners instance
+ * @param Relation $relation Relation instance
+ */
+ public function __construct($response, $dbi, Template $template, $browseForeigners, $relation)
+ {
+ parent::__construct($response, $dbi, $template);
+ $this->browseForeigners = $browseForeigners;
+ $this->relation = $relation;
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return string HTML
+ */
+ public function index(array $params): string
+ {
+ $foreigners = $this->relation->getForeigners(
+ $params['db'],
+ $params['table']
+ );
+ $foreignLimit = $this->browseForeigners->getForeignLimit(
+ $params['foreign_showAll']
+ );
+ $foreignData = $this->relation->getForeignData(
+ $foreigners,
+ $params['field'],
+ true,
+ $params['foreign_filter'] ?? '',
+ $foreignLimit ?? null,
+ true
+ );
+
+ return $this->browseForeigners->getHtmlForRelationalFieldSelection(
+ $params['db'],
+ $params['table'],
+ $params['field'],
+ $foreignData,
+ $params['fieldkey'] ?? '',
+ $params['data'] ?? ''
+ );
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Database/AbstractController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Database/AbstractController.php
new file mode 100644
index 0000000..31b752b
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Controllers/Database/AbstractController.php
@@ -0,0 +1,42 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Holds the PhpMyAdmin\Controllers\Database\AbstractController
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Controllers\Database;
+
+use PhpMyAdmin\Controllers\AbstractController as Controller;
+use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Response;
+use PhpMyAdmin\Template;
+
+/**
+ * Handles database related logic
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+abstract class AbstractController extends Controller
+{
+ /**
+ * @var string
+ */
+ protected $db;
+
+ /**
+ * AbstractController constructor.
+ *
+ * @param Response $response Response object
+ * @param DatabaseInterface $dbi DatabaseInterface object
+ * @param Template $template Template object
+ * @param string $db Database name
+ */
+ public function __construct($response, $dbi, Template $template, $db)
+ {
+ parent::__construct($response, $dbi, $template);
+ $this->db = $db;
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Database/CentralColumnsController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Database/CentralColumnsController.php
new file mode 100644
index 0000000..97798ea
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Controllers/Database/CentralColumnsController.php
@@ -0,0 +1,195 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Central Columns view/edit
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Controllers\Database;
+
+use PhpMyAdmin\CentralColumns;
+use PhpMyAdmin\Core;
+use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Message;
+use PhpMyAdmin\Response;
+use PhpMyAdmin\Template;
+
+/**
+ * Class CentralColumnsController
+ * @package PhpMyAdmin\Controllers\Database
+ */
+class CentralColumnsController extends AbstractController
+{
+ /**
+ * @var CentralColumns
+ */
+ private $centralColumns;
+
+ /**
+ * CentralColumnsController constructor.
+ *
+ * @param Response $response Response instance
+ * @param DatabaseInterface $dbi DatabaseInterface instance
+ * @param Template $template Template object
+ * @param string $db Database name
+ * @param CentralColumns $centralColumns CentralColumns instance
+ */
+ public function __construct($response, $dbi, Template $template, $db, $centralColumns)
+ {
+ parent::__construct($response, $dbi, $template, $db);
+ $this->centralColumns = $centralColumns;
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return string HTML
+ */
+ public function index(array $params): string
+ {
+ global $pmaThemeImage, $text_dir;
+
+ if (! empty($params['total_rows'])
+ && Core::isValid($params['total_rows'], 'integer')
+ ) {
+ $totalRows = (int) $params['total_rows'];
+ } else {
+ $totalRows = $this->centralColumns->getCount($this->db);
+ }
+
+ $pos = 0;
+ if (Core::isValid($params['pos'], 'integer')) {
+ $pos = (int) $params['pos'];
+ }
+
+ return $this->centralColumns->getHtmlForMain(
+ $this->db,
+ $totalRows,
+ $pos,
+ $pmaThemeImage,
+ $text_dir
+ );
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return array JSON
+ */
+ public function getColumnList(array $params): array
+ {
+ return $this->centralColumns->getListRaw(
+ $this->db,
+ $params['cur_table'] ?? ''
+ );
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return string HTML
+ */
+ public function populateColumns(array $params): string
+ {
+ return $this->centralColumns->getHtmlForColumnDropdown(
+ $this->db,
+ $params['selectedTable']
+ );
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return true|Message
+ */
+ public function editSave(array $params)
+ {
+ $columnDefault = $params['col_default'];
+ if ($columnDefault === 'NONE' && $params['col_default_sel'] !== 'USER_DEFINED') {
+ $columnDefault = '';
+ }
+ return $this->centralColumns->updateOneColumn(
+ $this->db,
+ $params['orig_col_name'],
+ $params['col_name'],
+ $params['col_type'],
+ $params['col_attribute'],
+ $params['col_length'],
+ isset($params['col_isNull']) ? 1 : 0,
+ $params['collation'],
+ $params['col_extra'] ?? '',
+ $columnDefault
+ );
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return true|Message
+ */
+ public function addNewColumn(array $params)
+ {
+ $columnDefault = $params['col_default'];
+ if ($columnDefault === 'NONE' && $params['col_default_sel'] !== 'USER_DEFINED') {
+ $columnDefault = '';
+ }
+ return $this->centralColumns->updateOneColumn(
+ $this->db,
+ '',
+ $params['col_name'],
+ $params['col_type'],
+ $params['col_attribute'],
+ $params['col_length'],
+ isset($params['col_isNull']) ? 1 : 0,
+ $params['collation'],
+ $params['col_extra'] ?? '',
+ $columnDefault
+ );
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return true|Message
+ */
+ public function addColumn(array $params)
+ {
+ return $this->centralColumns->syncUniqueColumns(
+ [$params['column-select']],
+ false,
+ $params['table-select']
+ );
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return string HTML
+ */
+ public function editPage(array $params): string
+ {
+ return $this->centralColumns->getHtmlForEditingPage(
+ $params['selected_fld'],
+ $params['db']
+ );
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return true|Message
+ */
+ public function updateMultipleColumn(array $params)
+ {
+ return $this->centralColumns->updateMultipleColumn($params);
+ }
+
+ /**
+ * @param array $params Request parameters
+ * @return true|Message
+ */
+ public function deleteSave(array $params)
+ {
+ $name = [];
+ parse_str($params['col_name'], $name);
+ return $this->centralColumns->deleteColumnsFromList(
+ $params['db'],
+ $name['selected_fld'],
+ false
+ );
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Database/DataDictionaryController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Database/DataDictionaryController.php
new file mode 100644
index 0000000..ba424b6
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Controllers/Database/DataDictionaryController.php
@@ -0,0 +1,156 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Holds the PhpMyAdmin\Controllers\Database\DataDictionaryController
+ *
+ * @package PhpMyAdmin\Controllers
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Controllers\Database;
+
+use PhpMyAdmin\DatabaseInterface;
+use PhpMyAdmin\Index;
+use PhpMyAdmin\Relation;
+use PhpMyAdmin\Response;
+use PhpMyAdmin\Template;
+use PhpMyAdmin\Transformations;
+use PhpMyAdmin\Util;
+
+/**
+ * Class DataDictionaryController
+ * @package PhpMyAdmin\Controllers\Database
+ */
+class DataDictionaryController extends AbstractController
+{
+ /**
+ * @var Relation
+ */
+ private $relation;
+
+ /**
+ * @var Transformations
+ */
+ private $transformations;
+
+ /**
+ * DataDictionaryController constructor.
+ *
+ * @param Response $response Response instance
+ * @param DatabaseInterface $dbi DatabaseInterface instance
+ * @param Template $template Template object
+ * @param string $db Database name
+ * @param Relation $relation Relation instance
+ * @param Transformations $transformations Transformations instance
+ */
+ public function __construct($response, $dbi, Template $template, $db, $relation, $transformations)
+ {
+ parent::__construct($response, $dbi, $template, $db);
+ $this->relation = $relation;
+ $this->transformations = $transformations;
+ }
+
+ /**
+ * @return string HTML
+ */
+ public function index(): string
+ {
+ $cfgRelation = $this->relation->getRelationsParam();
+
+ $comment = $this->relation->getDbComment($this->db);
+
+ $this->dbi->selectDb($this->db);
+ $tablesNames = $this->dbi->getTables($this->db);
+
+ $tables = [];
+ foreach ($tablesNames as $tableName) {
+ $showComment = (string) $this->dbi->getTable(
+ $this->db,
+ $tableName
+ )->getStatusInfo('TABLE_COMMENT');
+
+ list(, $primaryKeys, , ) = Util::processIndexData(
+ $this->dbi->getTableIndexes($this->db, $tableName)
+ );
+
+ list($foreigners, $hasRelation) = $this->relation->getRelationsAndStatus(
+ ! empty($cfgRelation['relation']),
+ $this->db,
+ $tableName
+ );
+
+ $columnsComments = $this->relation->getComments($this->db, $tableName);
+
+ $columns = $this->dbi->getColumns($this->db, $tableName);
+ $rows = [];
+ foreach ($columns as $row) {
+ $extractedColumnSpec = Util::extractColumnSpec($row['Type']);
+
+ $relation = '';
+ if ($hasRelation) {
+ $foreigner = $this->relation->searchColumnInForeigners(
+ $foreigners,
+ $row['Field']
+ );
+ if ($foreigner !== false && $foreigner !== []) {
+ $relation = $foreigner['foreign_table'];
+ $relation .= ' -> ';
+ $relation .= $foreigner['foreign_field'];
+ }
+ }
+
+ $mime = '';
+ if ($cfgRelation['mimework']) {
+ $mimeMap = $this->transformations->getMime(
+ $this->db,
+ $tableName,
+ true
+ );
+ if (isset($mimeMap[$row['Field']])) {
+ $mime = str_replace(
+ '_',
+ '/',
+ $mimeMap[$row['Field']]['mimetype']
+ );
+ }
+ }
+
+ $rows[$row['Field']] = [
+ 'name' => $row['Field'],
+ 'has_primary_key' => isset($primaryKeys[$row['Field']]),
+ 'type' => $extractedColumnSpec['type'],
+ 'print_type' => $extractedColumnSpec['print_type'],
+ 'is_nullable' => $row['Null'] !== '' && $row['Null'] !== 'NO',
+ 'default' => $row['Default'] ?? null,
+ 'comment' => $columnsComments[$row['Field']] ?? '',
+ 'mime' => $mime,
+ 'relation' => $relation,
+ ];
+ }
+
+ $indexesTable = '';
+ if (count(Index::getFromTable($tableName, $this->db)) > 0) {
+ $indexesTable = Index::getHtmlForIndexes(
+ $tableName,
+ $this->db,
+ true
+ );
+ }
+
+ $tables[$tableName] = [
+ 'name' => $tableName,
+ 'comment' => $showComment,
+ 'has_relation' => $hasRelation,
+ 'has_mime' => $cfgRelation['mimework'],
+ 'columns' => $rows,
+ 'indexes_table' => $indexesTable,
+ ];
+ }
+
+ return $this->template->render('database/data_dictionary/index', [
+ 'database' => $this->db,
+ 'comment' => $comment,
+ 'tables' => $tables,
+ ]);
+ }
+}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Database/EventsController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Database/EventsController.php
new file mode 100644
index 0000000..e2b0121
--- /dev/null
+++ b/srcs/phpmyadmin/libraries/classes/Controllers/Database/EventsController.php
@@ -0,0 +1,43 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Holds the PhpMyAdmin\Controllers\Database\EventsController
+ *
+ * @package PhpMyAdmin\Controllers\Database
+ */
+declare(strict_types=1);
+
+namespace PhpMyAdmin