aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status
diff options
context:
space:
mode:
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Controllers/Server/Status')
-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
7 files changed, 0 insertions, 1462 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AbstractController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AbstractController.php
deleted file mode 100644
index 8d4b51d..0000000
--- a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AbstractController.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Holds the PhpMyAdmin\Controllers\Server\Status\AbstractController
- *
- * @package PhpMyAdmin\Controllers
- */
-declare(strict_types=1);
-
-namespace PhpMyAdmin\Controllers\Server\Status;
-
-use PhpMyAdmin\Controllers\AbstractController as Controller;
-use PhpMyAdmin\DatabaseInterface;
-use PhpMyAdmin\Response;
-use PhpMyAdmin\Server\Status\Data;
-use PhpMyAdmin\Template;
-
-/**
- * Abstract class Controller
- * @package PhpMyAdmin\Controllers\Server\Status
- */
-abstract class AbstractController extends Controller
-{
- /**
- * @var Data
- */
- protected $data;
-
- /**
- * AbstractController constructor.
- *
- * @param Response $response Response object
- * @param DatabaseInterface $dbi DatabaseInterface object
- * @param Template $template Template object
- * @param Data $data Data object
- */
- public function __construct($response, $dbi, Template $template, $data)
- {
- parent::__construct($response, $dbi, $template);
- $this->data = $data;
- }
-}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AdvisorController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AdvisorController.php
deleted file mode 100644
index 5b93b0e..0000000
--- a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/AdvisorController.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Holds the PhpMyAdmin\Controllers\Server\Status\AdvisorController
- *
- * @package PhpMyAdmin\Controllers
- */
-declare(strict_types=1);
-
-namespace PhpMyAdmin\Controllers\Server\Status;
-
-use PhpMyAdmin\Advisor;
-use PhpMyAdmin\DatabaseInterface;
-use PhpMyAdmin\Response;
-use PhpMyAdmin\Server\Status\Data;
-use PhpMyAdmin\Template;
-use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
-
-/**
- * Displays the advisor feature
- *
- * @package PhpMyAdmin\Controllers
- */
-class AdvisorController extends AbstractController
-{
- /**
- * @var Advisor
- */
- private $advisor;
-
- /**
- * AdvisorController constructor.
- *
- * @param Response $response Response object
- * @param DatabaseInterface $dbi DatabaseInterface object
- * @param Template $template Template object
- * @param Data $data Data object
- * @param Advisor $advisor Advisor instance
- */
- public function __construct($response, $dbi, Template $template, $data, Advisor $advisor)
- {
- parent::__construct($response, $dbi, $template, $data);
- $this->advisor = $advisor;
- }
-
- /**
- * @return string
- */
- public function index(): string
- {
- $data = '';
- if ($this->data->dataLoaded) {
- $data = json_encode($this->advisor->run());
- }
-
- return $this->template->render('server/status/advisor/index', [
- 'data' => $data,
- ]);
- }
-}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/MonitorController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/MonitorController.php
deleted file mode 100644
index 1d2cadc..0000000
--- a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/MonitorController.php
+++ /dev/null
@@ -1,146 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Holds the PhpMyAdmin\Controllers\Server\Status\MonitorController
- *
- * @package PhpMyAdmin\Controllers
- */
-declare(strict_types=1);
-
-namespace PhpMyAdmin\Controllers\Server\Status;
-
-use PhpMyAdmin\DatabaseInterface;
-use PhpMyAdmin\Response;
-use PhpMyAdmin\Server\Status\Data;
-use PhpMyAdmin\Server\Status\Monitor;
-use PhpMyAdmin\SysInfo;
-use PhpMyAdmin\Template;
-
-/**
- * Class MonitorController
- * @package PhpMyAdmin\Controllers\Server\Status
- */
-class MonitorController extends AbstractController
-{
- /**
- * @var Monitor
- */
- private $monitor;
-
- /**
- * MonitorController constructor.
- *
- * @param Response $response Response object
- * @param DatabaseInterface $dbi DatabaseInterface object
- * @param Template $template Template object
- * @param Data $data Data object
- * @param Monitor $monitor Monitor object
- */
- public function __construct($response, $dbi, Template $template, $data, $monitor)
- {
- parent::__construct($response, $dbi, $template, $data);
- $this->monitor = $monitor;
- }
-
- /**
- * @return string HTML
- */
- public function index(): string
- {
- $form = [
- 'server_time' => microtime(true) * 1000,
- 'server_os' => SysInfo::getOs(),
- 'is_superuser' => $this->dbi->isSuperuser(),
- 'server_db_isLocal' => $this->data->db_isLocal,
- ];
-
- $javascriptVariableNames = [];
- foreach ($this->data->status as $name => $value) {
- if (is_numeric($value)) {
- $javascriptVariableNames[] = $name;
- }
- }
-
- return $this->template->render('server/status/monitor/index', [
- 'image_path' => $GLOBALS['pmaThemeImage'],
- 'javascript_variable_names' => $javascriptVariableNames,
- 'form' => $form,
- ]);
- }
-
- /**
- * @param array $params Request parameters
- * @return array JSON
- */
- public function chartingData(array $params): array
- {
- $json = [];
- $json['message'] = $this->monitor->getJsonForChartingData(
- $params['requiredData'] ?? ''
- );
-
- return $json;
- }
-
- /**
- * @param array $params Request parameters
- * @return array JSON
- */
- public function logDataTypeSlow(array $params): array
- {
- $json = [];
- $json['message'] = $this->monitor->getJsonForLogDataTypeSlow(
- (int) $params['time_start'],
- (int) $params['time_end']
- );
-
- return $json;
- }
-
- /**
- * @param array $params Request parameters
- * @return array JSON
- */
- public function logDataTypeGeneral(array $params): array
- {
- $json = [];
- $json['message'] = $this->monitor->getJsonForLogDataTypeGeneral(
- (int) $params['time_start'],
- (int) $params['time_end'],
- (bool) $params['limitTypes'],
- (bool) $params['removeVariables']
- );
-
- return $json;
- }
-
- /**
- * @param array $params Request parameters
- * @return array JSON
- */
- public function loggingVars(array $params): array
- {
- $json = [];
- $json['message'] = $this->monitor->getJsonForLoggingVars(
- $params['varName'],
- $params['varValue']
- );
-
- return $json;
- }
-
- /**
- * @param array $params Request parameters
- * @return array JSON
- */
- public function queryAnalyzer(array $params): array
- {
- $json = [];
- $json['message'] = $this->monitor->getJsonForQueryAnalyzer(
- $params['database'] ?? '',
- $params['query'] ?? ''
- );
-
- return $json;
- }
-}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/ProcessesController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/ProcessesController.php
deleted file mode 100644
index 9817e1b..0000000
--- a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/ProcessesController.php
+++ /dev/null
@@ -1,240 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Holds the PhpMyAdmin\Controllers\Server\Status\ProcessesController
- *
- * @package PhpMyAdmin\Controllers
- */
-declare(strict_types=1);
-
-namespace PhpMyAdmin\Controllers\Server\Status;
-
-use PhpMyAdmin\Message;
-use PhpMyAdmin\Util;
-
-/**
- * Class ProcessesController
- * @package PhpMyAdmin\Controllers\Server\Status
- */
-class ProcessesController extends AbstractController
-{
- /**
- * @param array $params Request parameters
- * @return string
- */
- public function index(array $params): string
- {
- $isChecked = false;
- if (! empty($params['showExecuting'])) {
- $isChecked = true;
- }
-
- $urlParams = [
- 'ajax_request' => true,
- 'full' => $params['full'] ?? '',
- 'column_name' => $params['column_name'] ?? '',
- 'order_by_field' => $params['order_by_field'] ?? '',
- 'sort_order' => $params['sort_order'] ?? '',
- ];
-
- $serverProcessList = $this->getList($params);
-
- return $this->template->render('server/status/processes/index', [
- 'url_params' => $urlParams,
- 'is_checked' => $isChecked,
- 'server_process_list' => $serverProcessList,
- ]);
- }
-
- /**
- * Only sends the process list table
- *
- * @param array $params Request parameters
- * @return string
- */
- public function refresh(array $params): string
- {
- return $this->getList($params);
- }
-
- /**
- * @param array $params Request parameters
- * @return array
- */
- public function kill(array $params): array
- {
- $kill = (int) $params['kill'];
- $query = $this->dbi->getKillQuery($kill);
-
- if ($this->dbi->tryQuery($query)) {
- $message = Message::success(
- __('Thread %s was successfully killed.')
- );
- $this->response->setRequestStatus(true);
- } else {
- $message = Message::error(
- __(
- 'phpMyAdmin was unable to kill thread %s.'
- . ' It probably has already been closed.'
- )
- );
- $this->response->setRequestStatus(false);
- }
- $message->addParam($kill);
-
- $json = [];
- $json['message'] = $message;
-
- return $json;
- }
-
- /**
- * @param array $params Request parameters
- * @return string
- */
- private function getList(array $params): string
- {
- $urlParams = [];
-
- $showFullSql = ! empty($params['full']);
- if ($showFullSql) {
- $urlParams['full'] = '';
- } else {
- $urlParams['full'] = 1;
- }
-
- // This array contains display name and real column name of each
- // sortable column in the table
- $sortableColumns = [
- [
- 'column_name' => __('ID'),
- 'order_by_field' => 'Id',
- ],
- [
- 'column_name' => __('User'),
- 'order_by_field' => 'User',
- ],
- [
- 'column_name' => __('Host'),
- 'order_by_field' => 'Host',
- ],
- [
- 'column_name' => __('Database'),
- 'order_by_field' => 'db',
- ],
- [
- 'column_name' => __('Command'),
- 'order_by_field' => 'Command',
- ],
- [
- 'column_name' => __('Time'),
- 'order_by_field' => 'Time',
- ],
- [
- 'column_name' => __('Status'),
- 'order_by_field' => 'State',
- ],
- [
- 'column_name' => __('Progress'),
- 'order_by_field' => 'Progress',
- ],
- [
- 'column_name' => __('SQL query'),
- 'order_by_field' => 'Info',
- ],
- ];
- $sortableColCount = count($sortableColumns);
-
- $sqlQuery = $showFullSql
- ? 'SHOW FULL PROCESSLIST'
- : 'SHOW PROCESSLIST';
- if ((! empty($params['order_by_field'])
- && ! empty($params['sort_order']))
- || ! empty($params['showExecuting'])
- ) {
- $urlParams['order_by_field'] = $params['order_by_field'];
- $urlParams['sort_order'] = $params['sort_order'];
- $urlParams['showExecuting'] = $params['showExecuting'];
- $sqlQuery = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ';
- }
- if (! empty($params['showExecuting'])) {
- $sqlQuery .= ' WHERE state != "" ';
- }
- if (! empty($params['order_by_field']) && ! empty($params['sort_order'])) {
- $sqlQuery .= ' ORDER BY '
- . Util::backquote($params['order_by_field'])
- . ' ' . $params['sort_order'];
- }
-
- $result = $this->dbi->query($sqlQuery);
-
- $columns = [];
- foreach ($sortableColumns as $columnKey => $column) {
- $is_sorted = ! empty($params['order_by_field'])
- && ! empty($params['sort_order'])
- && ($params['order_by_field'] == $column['order_by_field']);
-
- $column['sort_order'] = 'ASC';
- if ($is_sorted && $params['sort_order'] === 'ASC') {
- $column['sort_order'] = 'DESC';
- }
- if (isset($params['showExecuting'])) {
- $column['showExecuting'] = 'on';
- }
-
- $columns[$columnKey] = [
- 'name' => $column['column_name'],
- 'params' => $column,
- 'is_sorted' => $is_sorted,
- 'sort_order' => $column['sort_order'],
- 'has_full_query' => false,
- 'is_full' => false,
- ];
-
- if (0 === --$sortableColCount) {
- $columns[$columnKey]['has_full_query'] = true;
- if ($showFullSql) {
- $columns[$columnKey]['is_full'] = true;
- }
- }
- }
-
- $rows = [];
- while ($process = $this->dbi->fetchAssoc($result)) {
- // Array keys need to modify due to the way it has used
- // to display column values
- if ((! empty($params['order_by_field']) && ! empty($params['sort_order']))
- || ! empty($params['showExecuting'])
- ) {
- foreach (array_keys($process) as $key) {
- $newKey = ucfirst(mb_strtolower($key));
- if ($newKey !== $key) {
- $process[$newKey] = $process[$key];
- unset($process[$key]);
- }
- }
- }
-
- $rows[] = [
- 'id' => $process['Id'],
- 'user' => $process['User'],
- 'host' => $process['Host'],
- 'db' => ! isset($process['db']) || strlen($process['db']) === 0 ? '' : $process['db'],
- 'command' => $process['Command'],
- 'time' => $process['Time'],
- 'state' => ! empty($process['State']) ? $process['State'] : '---',
- 'progress' => ! empty($process['Progress']) ? $process['Progress'] : '---',
- 'info' => ! empty($process['Info']) ? Util::formatSql(
- $process['Info'],
- ! $showFullSql
- ) : '---',
- ];
- }
-
- return $this->template->render('server/status/processes/list', [
- 'columns' => $columns,
- 'rows' => $rows,
- 'refresh_params' => $urlParams,
- ]);
- }
-}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/QueriesController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/QueriesController.php
deleted file mode 100644
index 76430d4..0000000
--- a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/QueriesController.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Displays query statistics for the server
- *
- * @package PhpMyAdmin\Controllers
- */
-declare(strict_types=1);
-
-namespace PhpMyAdmin\Controllers\Server\Status;
-
-/**
- * Class QueriesController
- * @package PhpMyAdmin\Controllers\Server\Status
- */
-class QueriesController extends AbstractController
-{
- /**
- * @return string HTML
- */
- public function index(): string
- {
- if ($this->data->dataLoaded) {
- $hourFactor = 3600 / $this->data->status['Uptime'];
- $usedQueries = $this->data->used_queries;
- $totalQueries = array_sum($usedQueries);
-
- $stats = [
- 'total' => $totalQueries,
- 'per_hour' => $totalQueries * $hourFactor,
- 'per_minute' => $totalQueries * 60 / $this->data->status['Uptime'],
- 'per_second' => $totalQueries / $this->data->status['Uptime'],
- ];
-
- // reverse sort by value to show most used statements first
- arsort($usedQueries);
-
- $chart = [];
- $querySum = array_sum($usedQueries);
- $otherSum = 0;
- $queries = [];
- foreach ($usedQueries as $key => $value) {
- // For the percentage column, use Questions - Connections, because
- // the number of connections is not an item of the Query types
- // but is included in Questions. Then the total of the percentages is 100.
- $name = str_replace(['Com_', '_'], ['', ' '], $key);
- // Group together values that make out less than 2% into "Other", but only
- // if we have more than 6 fractions already
- if ($value < $querySum * 0.02 && count($chart) > 6) {
- $otherSum += $value;
- } else {
- $chart[$name] = $value;
- }
-
- $queries[$key] = [
- 'name' => $name,
- 'value' => $value,
- 'per_hour' => $value * $hourFactor,
- 'percentage' => $value * 100 / $totalQueries,
- ];
- }
-
- if ($otherSum > 0) {
- $chart[__('Other')] = $otherSum;
- }
- }
-
- return $this->template->render('server/status/queries/index', [
- 'is_data_loaded' => $this->data->dataLoaded,
- 'stats' => $stats ?? null,
- 'queries' => $queries ?? [],
- 'chart' => $chart ?? [],
- ]);
- }
-}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/StatusController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/StatusController.php
deleted file mode 100644
index 53d78a3..0000000
--- a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/StatusController.php
+++ /dev/null
@@ -1,260 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Holds the PhpMyAdmin\Controllers\Server\Status\StatusController
- *
- * @package PhpMyAdmin\Controllers
- */
-declare(strict_types=1);
-
-namespace PhpMyAdmin\Controllers\Server\Status;
-
-use PhpMyAdmin\ReplicationGui;
-use PhpMyAdmin\Util;
-use Throwable;
-use Twig_Error_Loader;
-use Twig_Error_Runtime;
-use Twig_Error_Syntax;
-
-/**
- * Class StatusController
- * @package PhpMyAdmin\Controllers\Server\Status
- */
-class StatusController extends AbstractController
-{
- /**
- * @param ReplicationGui $replicationGui ReplicationGui instance
- *
- * @return string
- * @throws Throwable
- * @throws Twig_Error_Loader
- * @throws Twig_Error_Runtime
- * @throws Twig_Error_Syntax
- */
- public function index(ReplicationGui $replicationGui): string
- {
- global $replication_info;
-
- $traffic = [];
- $connections = [];
- $replication = '';
- if ($this->data->dataLoaded) {
- $networkTraffic = implode(
- ' ',
- Util::formatByteDown(
- $this->data->status['Bytes_received'] + $this->data->status['Bytes_sent'],
- 3,
- 1
- )
- );
- $uptime = Util::timespanFormat($this->data->status['Uptime']);
- $startTime = Util::localisedDate($this->getStartTime());
-
- $traffic = $this->getTrafficInfo();
-
- $connections = $this->getConnectionsInfo();
-
- // display replication information
- if ($replication_info['master']['status']
- || $replication_info['slave']['status']
- ) {
- $replication = $this->getReplicationInfo($replicationGui);
- }
- }
-
- return $this->template->render('server/status/status/index', [
- 'is_data_loaded' => $this->data->dataLoaded,
- 'network_traffic' => $networkTraffic ?? null,
- 'uptime' => $uptime ?? null,
- 'start_time' => $startTime ?? null,
- 'traffic' => $traffic,
- 'connections' => $connections,
- 'is_master' => $replication_info['master']['status'],
- 'is_slave' => $replication_info['slave']['status'],
- 'replication' => $replication,
- ]);
- }
-
- /**
- * @return int
- */
- private function getStartTime(): int
- {
- return (int) $this->dbi->fetchValue(
- 'SELECT UNIX_TIMESTAMP() - ' . $this->data->status['Uptime']
- );
- }
-
- /**
- * @return array
- */
- private function getTrafficInfo(): array
- {
- $hourFactor = 3600 / $this->data->status['Uptime'];
-
- return [
- [
- 'name' => __('Received'),
- 'number' => implode(
- ' ',
- Util::formatByteDown(
- $this->data->status['Bytes_received'],
- 3,
- 1
- )
- ),
- 'per_hour' => implode(
- ' ',
- Util::formatByteDown(
- $this->data->status['Bytes_received'] * $hourFactor,
- 3,
- 1
- )
- ),
- ],
- [
- 'name' => __('Sent'),
- 'number' => implode(
- ' ',
- Util::formatByteDown(
- $this->data->status['Bytes_sent'],
- 3,
- 1
- )
- ),
- 'per_hour' => implode(
- ' ',
- Util::formatByteDown(
- $this->data->status['Bytes_sent'] * $hourFactor,
- 3,
- 1
- )
- ),
- ],
- [
- 'name' => __('Total'),
- 'number' => implode(
- ' ',
- Util::formatByteDown(
- $this->data->status['Bytes_received'] + $this->data->status['Bytes_sent'],
- 3,
- 1
- )
- ),
- 'per_hour' => implode(
- ' ',
- Util::formatByteDown(
- ($this->data->status['Bytes_received'] + $this->data->status['Bytes_sent']) * $hourFactor,
- 3,
- 1
- )
- ),
- ],
- ];
- }
-
- /**
- * @return array
- */
- private function getConnectionsInfo(): array
- {
- $hourFactor = 3600 / $this->data->status['Uptime'];
-
- $failedAttemptsPercentage = '---';
- $abortedPercentage = '---';
- if ($this->data->status['Connections'] > 0) {
- $failedAttemptsPercentage = Util::formatNumber(
- $this->data->status['Aborted_connects'] * 100 / $this->data->status['Connections'],
- 0,
- 2,
- true
- ) . '%';
-
- $abortedPercentage = Util::formatNumber(
- $this->data->status['Aborted_clients'] * 100 / $this->data->status['Connections'],
- 0,
- 2,
- true
- ) . '%';
- }
-
- return [
- [
- 'name' => __('Max. concurrent connections'),
- 'number' => Util::formatNumber(
- $this->data->status['Max_used_connections'],
- 0
- ),
- 'per_hour' => '---',
- 'percentage' => '---',
- ],
- [
- 'name' => __('Failed attempts'),
- 'number' => Util::formatNumber(
- $this->data->status['Aborted_connects'],
- 4,
- 1,
- true
- ),
- 'per_hour' => Util::formatNumber(
- $this->data->status['Aborted_connects'] * $hourFactor,
- 4,
- 2,
- true
- ),
- 'percentage' => $failedAttemptsPercentage,
- ],
- [
- 'name' => __('Aborted'),
- 'number' => Util::formatNumber(
- $this->data->status['Aborted_clients'],
- 4,
- 1,
- true
- ),
- 'per_hour' => Util::formatNumber(
- $this->data->status['Aborted_clients'] * $hourFactor,
- 4,
- 2,
- true
- ),
- 'percentage' => $abortedPercentage,
- ],
- [
- 'name' => __('Total'),
- 'number' => Util::formatNumber(
- $this->data->status['Connections'],
- 4,
- 0
- ),
- 'per_hour' => Util::formatNumber(
- $this->data->status['Connections'] * $hourFactor,
- 4,
- 2
- ),
- 'percentage' => Util::formatNumber(100, 0, 2) . '%',
- ],
- ];
- }
-
- /**
- * @param ReplicationGui $replicationGui ReplicationGui instance
- *
- * @return string
- */
- private function getReplicationInfo(ReplicationGui $replicationGui): string
- {
- global $replication_info, $replication_types;
-
- $output = '';
- foreach ($replication_types as $type) {
- if (isset($replication_info[$type]['status'])
- && $replication_info[$type]['status']
- ) {
- $output .= $replicationGui->getHtmlForReplicationStatusTable($type);
- }
- }
-
- return $output;
- }
-}
diff --git a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/VariablesController.php b/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/VariablesController.php
deleted file mode 100644
index a17f15f..0000000
--- a/srcs/phpmyadmin/libraries/classes/Controllers/Server/Status/VariablesController.php
+++ /dev/null
@@ -1,639 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Displays a list of server status variables
- *
- * @package PhpMyAdmin\Controllers
- */
-declare(strict_types=1);
-
-namespace PhpMyAdmin\Controllers\Server\Status;
-
-use PhpMyAdmin\Util;
-
-/**
- * Class VariablesController
- * @package PhpMyAdmin\Controllers\Server\Status
- */
-class VariablesController extends AbstractController
-{
- /**
- * @param array $params Request parameters
- * @return string HTML
- */
- public function index(array $params): string
- {
- if (isset($params['flush'])) {
- $this->flush($params['flush']);
- }
-
- if ($this->data->dataLoaded) {
- $categories = [];
- foreach ($this->data->sections as $sectionId => $sectionName) {
- if (isset($this->data->sectionUsed[$sectionId])) {
- $categories[$sectionId] = [
- 'id' => $sectionId,
- 'name' => $sectionName,
- 'is_selected' => false,
- ];
- if (! empty($params['filterCategory'])
- && $params['filterCategory'] === $sectionId
- ) {
- $categories[$sectionId]['is_selected'] = true;
- }
- }
- }
-
- $links = [];
- foreach ($this->data->links as $sectionName => $sectionLinks) {
- $links[$sectionName] = [
- 'name' => 'status_' . $sectionName,
- 'links' => $sectionLinks,
- ];
- }
-
- $descriptions = $this->getDescriptions();
- $alerts = $this->getAlerts();
-
- $variables = [];
- foreach ($this->data->status as $name => $value) {
- $variables[$name] = [
- 'name' => $name,
- 'value' => $value,
- 'is_numeric' => is_numeric($value),
- 'class' => $this->data->allocationMap[$name] ?? null,
- 'doc' => '',
- 'has_alert' => false,
- 'is_alert' => false,
- 'description' => $descriptions[$name] ?? '',
- 'description_doc' => [],
- ];
-
- // Fields containing % are calculated,
- // they can not be described in MySQL documentation
- if (mb_strpos($name, '%') === false) {
- $variables[$name]['doc'] = Util::linkToVarDocumentation(
- $name,
- $this->dbi->isMariaDB()
- );
- }
-
- if (isset($alerts[$name])) {
- $variables[$name]['has_alert'] = true;
- if ($value > $alerts[$name]) {
- $variables[$name]['is_alert'] = true;
- }
- }
-
- if (isset($this->data->links[$name])) {
- foreach ($this->data->links[$name] as $linkName => $linkUrl) {
- $variables[$name]['description_doc'][] = [
- 'name' => $linkName,
- 'url' => $linkUrl,
- ];
- }
- }
- }
- }
-
- return $this->template->render('server/status/variables/index', [
- 'is_data_loaded' => $this->data->dataLoaded,
- 'filter_text' => ! empty($params['filterText']) ? $params['filterText'] : '',
- 'is_only_alerts' => ! empty($params['filterAlert']),
- 'is_not_formatted' => ! empty($params['dontFormat']),
- 'categories' => $categories ?? [],
- 'links' => $links ?? [],
- 'variables' => $variables ?? [],
- ]);
- }
-
- /**
- * Flush status variables if requested
- *
- * @param string $flush Variable name
- * @return void
- */
- private function flush(string $flush): void
- {
- $flushCommands = [
- 'STATUS',
- 'TABLES',
- 'QUERY CACHE',
- ];
-
- if (in_array($flush, $flushCommands)) {
- $this->dbi->query('FLUSH ' . $flush . ';');
- }
- }
-
- /**
- * @return array
- */
- private function getAlerts(): array
- {
- // name => max value before alert
- return [
- // lower is better
- // variable => max value
- 'Aborted_clients' => 0,
- 'Aborted_connects' => 0,
-
- 'Binlog_cache_disk_use' => 0,
-
- 'Created_tmp_disk_tables' => 0,
-
- 'Handler_read_rnd' => 0,
- 'Handler_read_rnd_next' => 0,
-
- 'Innodb_buffer_pool_pages_dirty' => 0,
- 'Innodb_buffer_pool_reads' => 0,
- 'Innodb_buffer_pool_wait_free' => 0,
- 'Innodb_log_waits' => 0,
- 'Innodb_row_lock_time_avg' => 10, // ms
- 'Innodb_row_lock_time_max' => 50, // ms
- 'Innodb_row_lock_waits' => 0,
-
- 'Slow_queries' => 0,
- 'Delayed_errors' => 0,
- 'Select_full_join' => 0,
- 'Select_range_check' => 0,
- 'Sort_merge_passes' => 0,
- 'Opened_tables' => 0,
- 'Table_locks_waited' => 0,
- 'Qcache_lowmem_prunes' => 0,
-