Refactor index.php
Extracts actions to controller Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
f3c94b7c92
commit
4b61201899
315
index.php
315
index.php
@ -9,15 +9,9 @@ declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Controllers\HomeController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Display\GitRevision;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\RecentFavoriteTable;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\ThemeManager;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
@ -42,10 +36,9 @@ foreach ($drops as $each_drop) {
|
||||
}
|
||||
unset($drops, $each_drop);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Black list of all scripts to which front-end must submit data.
|
||||
* Such scripts must not be loaded on home page.
|
||||
*
|
||||
*/
|
||||
$target_blacklist = [
|
||||
'import.php',
|
||||
@ -63,39 +56,32 @@ if (! empty($_REQUEST['target'])
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
|
||||
$controller = new HomeController(
|
||||
$response,
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['PMA_Config']
|
||||
);
|
||||
|
||||
if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// if user selected a theme
|
||||
if (isset($_POST['set_theme'])) {
|
||||
$tmanager = ThemeManager::getInstance();
|
||||
$tmanager->setActiveTheme($_POST['set_theme']);
|
||||
$tmanager->setThemeCookie();
|
||||
|
||||
$userPreferences = new UserPreferences();
|
||||
$prefs = $userPreferences->load();
|
||||
$prefs["config_data"]["ThemeDefault"] = $_POST['set_theme'];
|
||||
$userPreferences->save($prefs["config_data"]);
|
||||
$controller->setTheme([
|
||||
'set_theme' => $_POST['set_theme'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
exit();
|
||||
}
|
||||
// Change collation connection
|
||||
if (isset($_POST['collation_connection'])) {
|
||||
$GLOBALS['PMA_Config']->setUserValue(
|
||||
null,
|
||||
'DefaultConnectionCollation',
|
||||
$_POST['collation_connection'],
|
||||
'utf8mb4_unicode_ci'
|
||||
);
|
||||
} elseif (isset($_POST['collation_connection'])) {
|
||||
$controller->setCollationConnection([
|
||||
'collation_connection' => $_POST['collation_connection'],
|
||||
]);
|
||||
|
||||
header('Location: index.php' . Url::getCommonRaw());
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// See FAQ 1.34
|
||||
if (! empty($_REQUEST['db'])) {
|
||||
} elseif (! empty($_REQUEST['db'])) {
|
||||
// See FAQ 1.34
|
||||
$page = null;
|
||||
if (! empty($_REQUEST['table'])) {
|
||||
$page = Util::getScriptNameForOption(
|
||||
@ -109,257 +95,22 @@ if (! empty($_REQUEST['db'])) {
|
||||
);
|
||||
}
|
||||
include ROOT_PATH . $page;
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
|
||||
$controller = new HomeController(
|
||||
$response,
|
||||
$GLOBALS['dbi']
|
||||
);
|
||||
|
||||
/**
|
||||
* Check if it is an ajax request to reload the recent tables list.
|
||||
*/
|
||||
if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
|
||||
$response->addJSON(
|
||||
'list',
|
||||
RecentFavoriteTable::getInstance('recent')->getHtmlList()
|
||||
);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($GLOBALS['PMA_Config']->isGitRevision()) {
|
||||
// If ajax request to get revision
|
||||
if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
|
||||
GitRevision::display();
|
||||
exit;
|
||||
}
|
||||
// Else show empty html
|
||||
echo '<div id="is_git_revision"></div>';
|
||||
}
|
||||
|
||||
// Handles some variables that may have been sent by the calling script
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
$show_query = '1';
|
||||
|
||||
// Any message to display?
|
||||
if (! empty($message)) {
|
||||
echo Util::getMessage($message);
|
||||
unset($message);
|
||||
}
|
||||
if (isset($_SESSION['partial_logout'])) {
|
||||
Message::success(
|
||||
__('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
|
||||
)->display();
|
||||
unset($_SESSION['partial_logout']);
|
||||
}
|
||||
|
||||
if ($server > 0) {
|
||||
include ROOT_PATH . 'libraries/server_common.inc.php';
|
||||
}
|
||||
|
||||
echo $controller->index();
|
||||
|
||||
/**
|
||||
* mbstring is used for handling multibytes inside parser, so it is good
|
||||
* to tell user something might be broken without it, see bug #1063149.
|
||||
*/
|
||||
if (! extension_loaded('mbstring')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The mbstring PHP extension was not found and you seem to be using'
|
||||
. ' a multibyte charset. Without the mbstring extension phpMyAdmin'
|
||||
. ' is unable to split strings correctly and it may result in'
|
||||
. ' unexpected results.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Missing functionality
|
||||
*/
|
||||
if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The curl extension was not found and allow_url_fopen is '
|
||||
. 'disabled. Due to this some features such as error reporting '
|
||||
. 'or version check are disabled.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($cfg['LoginCookieValidityDisableWarning'] == false) {
|
||||
/**
|
||||
* Check whether session.gc_maxlifetime limits session validity.
|
||||
*/
|
||||
$gc_time = (int) ini_get('session.gc_maxlifetime');
|
||||
if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity']) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
|
||||
'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
|
||||
'gc_maxlifetime[/a] is lower than cookie validity configured ' .
|
||||
'in phpMyAdmin, because of this, your login might expire sooner ' .
|
||||
'than configured in phpMyAdmin.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether LoginCookieValidity is limited by LoginCookieStore.
|
||||
*/
|
||||
if ($GLOBALS['cfg']['LoginCookieStore'] != 0
|
||||
&& $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
|
||||
} elseif ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
|
||||
$response->addJSON($controller->reloadRecentTablesList());
|
||||
} elseif ($GLOBALS['PMA_Config']->isGitRevision()
|
||||
&& isset($_REQUEST['git_revision'])
|
||||
&& $response->isAjax()
|
||||
) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Login cookie store is lower than cookie validity configured in ' .
|
||||
'phpMyAdmin, because of this, your login will expire sooner than ' .
|
||||
'configured in phpMyAdmin.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
$response->addHTML($controller->gitRevision());
|
||||
} else {
|
||||
// Handles some variables that may have been sent by the calling script
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
$show_query = '1';
|
||||
|
||||
/**
|
||||
* Warning if using the default MySQL controluser account
|
||||
*/
|
||||
if ($server != 0
|
||||
&& isset($GLOBALS['cfg']['Server']['controluser']) && $GLOBALS['cfg']['Server']['controluser'] == 'pma'
|
||||
&& isset($GLOBALS['cfg']['Server']['controlpass']) && $GLOBALS['cfg']['Server']['controlpass'] == 'pmapass'
|
||||
) {
|
||||
trigger_error(
|
||||
__('Your server is running with default values for the controluser and password (controlpass) and is open to intrusion; you really should fix this security weakness by changing the password for controluser \'pma\'.'),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if user does not have defined blowfish secret and it is being used.
|
||||
*/
|
||||
if (! empty($_SESSION['encryption_key'])) {
|
||||
if (empty($GLOBALS['cfg']['blowfish_secret'])) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The configuration file now needs a secret passphrase (blowfish_secret).'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
} elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The secret passphrase in configuration (blowfish_secret) is too short.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
if ($server > 0) {
|
||||
include ROOT_PATH . 'libraries/server_common.inc.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for existence of config directory which should not exist in
|
||||
* production environment.
|
||||
*/
|
||||
if (@file_exists(ROOT_PATH . 'config')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Directory [code]config[/code], which is used by the setup script, ' .
|
||||
'still exists in your phpMyAdmin directory. It is strongly ' .
|
||||
'recommended to remove it once phpMyAdmin has been configured. ' .
|
||||
'Otherwise the security of your server may be compromised by ' .
|
||||
'unauthorized people downloading your configuration.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
$relation = new Relation($GLOBALS['dbi']);
|
||||
|
||||
if ($server > 0) {
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if (! $cfgRelation['allworks']
|
||||
&& $cfg['PmaNoRelation_DisableWarning'] == false
|
||||
) {
|
||||
$msg_text = __(
|
||||
'The phpMyAdmin configuration storage is not completely '
|
||||
. 'configured, some extended features have been deactivated. '
|
||||
. '%sFind out why%s. '
|
||||
);
|
||||
if ($cfg['ZeroConf'] == true) {
|
||||
$msg_text .= '<br>' .
|
||||
__(
|
||||
'Or alternately go to \'Operations\' tab of any database '
|
||||
. 'to set it up there.'
|
||||
);
|
||||
}
|
||||
$msg = Message::notice($msg_text);
|
||||
$msg->addParamHtml('<a href="./chk_rel.php" data-post="' . Url::getCommon() . '">');
|
||||
$msg->addParamHtml('</a>');
|
||||
/* Show error if user has configured something, notice elsewhere */
|
||||
if (! empty($cfg['Servers'][$server]['pmadb'])) {
|
||||
$msg->isError(true);
|
||||
}
|
||||
$msg->display();
|
||||
} // end if
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning about Suhosin only if its simulation mode is not enabled
|
||||
*/
|
||||
if ($cfg['SuhosinDisableWarning'] == false
|
||||
&& ini_get('suhosin.request.max_value_length')
|
||||
&& ini_get('suhosin.simulation') == '0'
|
||||
) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__(
|
||||
'Server running with Suhosin. Please refer to %sdocumentation%s ' .
|
||||
'for possible issues.'
|
||||
),
|
||||
'[doc@faq1-38]',
|
||||
'[/doc]'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/* Missing template cache */
|
||||
if (is_null($GLOBALS['PMA_Config']->getTempDir('twig'))) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__('The $cfg[\'TempDir\'] (%s) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.'),
|
||||
$GLOBALS['PMA_Config']->get('TempDir')
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning about incomplete translations.
|
||||
*
|
||||
* The data file is created while creating release by ./scripts/remove-incomplete-mo
|
||||
*/
|
||||
if (@file_exists(ROOT_PATH . 'libraries/language_stats.inc.php')) {
|
||||
include ROOT_PATH . 'libraries/language_stats.inc.php';
|
||||
/*
|
||||
* This message is intentionally not translated, because we're
|
||||
* handling incomplete translations here and focus on english
|
||||
* speaking users.
|
||||
*/
|
||||
if (isset($GLOBALS['language_stats'][$lang])
|
||||
&& $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
|
||||
) {
|
||||
trigger_error(
|
||||
'You are using an incomplete translation, please help to make it '
|
||||
. 'better by [a@https://www.phpmyadmin.net/translate/'
|
||||
. '@_blank]contributing[/a].',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
$response->addHTML($controller->index());
|
||||
}
|
||||
|
||||
@ -11,11 +11,16 @@ namespace PhpMyAdmin\Controllers;
|
||||
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\CheckUserPrivileges;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Display\GitRevision;
|
||||
use PhpMyAdmin\LanguageManager;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\RecentFavoriteTable;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Server\Select;
|
||||
use PhpMyAdmin\ThemeManager;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
@ -24,16 +29,54 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class HomeController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var ThemeManager
|
||||
*/
|
||||
private $themeManager;
|
||||
|
||||
/**
|
||||
* HomeController constructor.
|
||||
*
|
||||
* @param \PhpMyAdmin\Response $response Response instance
|
||||
* @param \PhpMyAdmin\DatabaseInterface $dbi DatabaseInterface instance
|
||||
* @param Config $config Config instance
|
||||
*/
|
||||
public function __construct($response, $dbi, $config)
|
||||
{
|
||||
parent::__construct($response, $dbi);
|
||||
$this->config = $config;
|
||||
$this->themeManager = ThemeManager::getInstance();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string HTML
|
||||
*/
|
||||
public function index(): string
|
||||
{
|
||||
global $cfg, $server, $collation_connection;
|
||||
global $cfg, $server, $collation_connection, $message;
|
||||
|
||||
$languageManager = LanguageManager::getInstance();
|
||||
|
||||
$syncFavoriteTables = RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
|
||||
if (! empty($message)) {
|
||||
$displayMessage = Util::getMessage($message);
|
||||
unset($message);
|
||||
}
|
||||
if (isset($_SESSION['partial_logout'])) {
|
||||
$partialLogout = Message::success(__(
|
||||
'You were logged out from one server, to logout completely '
|
||||
. 'from phpMyAdmin, you need to logout from all servers.'
|
||||
))->getDisplay();
|
||||
unset($_SESSION['partial_logout']);
|
||||
}
|
||||
|
||||
$syncFavoriteTables = RecentFavoriteTable::getInstance('favorite')
|
||||
->getHtmlSyncFavoriteTables();
|
||||
|
||||
$hasServer = $server > 0 || count($cfg['Servers']) > 1;
|
||||
if ($hasServer) {
|
||||
@ -100,7 +143,7 @@ class HomeController extends AbstractController
|
||||
|
||||
$themeSelection = '';
|
||||
if ($cfg['ThemeManager']) {
|
||||
$themeSelection = ThemeManager::getInstance()->getHtmlSelectBox();
|
||||
$themeSelection = $this->themeManager->getHtmlSelectBox();
|
||||
}
|
||||
|
||||
$databaseServer = [];
|
||||
@ -141,12 +184,12 @@ class HomeController extends AbstractController
|
||||
$webServer['software'] = $_SERVER['SERVER_SOFTWARE'];
|
||||
|
||||
if ($server > 0) {
|
||||
$client_version_str = $this->dbi->getClientInfo();
|
||||
if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
|
||||
$client_version_str = 'libmysql - ' . $client_version_str;
|
||||
$clientVersion = $this->dbi->getClientInfo();
|
||||
if (preg_match('#\d+\.\d+\.\d+#', $clientVersion)) {
|
||||
$clientVersion = 'libmysql - ' . $clientVersion;
|
||||
}
|
||||
|
||||
$webServer['database'] = $client_version_str;
|
||||
$webServer['database'] = $clientVersion;
|
||||
$webServer['php_extensions'] = Util::listPHPExtensions();
|
||||
$webServer['php_version'] = phpversion();
|
||||
}
|
||||
@ -166,7 +209,41 @@ class HomeController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
$relation = new Relation($this->dbi);
|
||||
if ($server > 0) {
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if (! $cfgRelation['allworks']
|
||||
&& $cfg['PmaNoRelation_DisableWarning'] == false
|
||||
) {
|
||||
$messageText = __(
|
||||
'The phpMyAdmin configuration storage is not completely '
|
||||
. 'configured, some extended features have been deactivated. '
|
||||
. '%sFind out why%s. '
|
||||
);
|
||||
if ($cfg['ZeroConf'] == true) {
|
||||
$messageText .= '<br>' .
|
||||
__(
|
||||
'Or alternately go to \'Operations\' tab of any database '
|
||||
. 'to set it up there.'
|
||||
);
|
||||
}
|
||||
$messageInstance = Message::notice($messageText);
|
||||
$messageInstance->addParamHtml('<a href="./chk_rel.php" data-post="' . Url::getCommon() . '">');
|
||||
$messageInstance->addParamHtml('</a>');
|
||||
/* Show error if user has configured something, notice elsewhere */
|
||||
if (! empty($cfg['Servers'][$server]['pmadb'])) {
|
||||
$messageInstance->isError(true);
|
||||
}
|
||||
$configStorageMessage = $messageInstance->getDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkRequirements();
|
||||
|
||||
return $this->template->render('home/index', [
|
||||
'message' => $displayMessage ?? '',
|
||||
'partial_logout' => $partialLogout ?? '',
|
||||
'is_git_revision' => $this->config->isGitRevision(),
|
||||
'server' => $server,
|
||||
'sync_favorite_tables' => $syncFavoriteTables,
|
||||
'has_server' => $hasServer,
|
||||
@ -183,6 +260,245 @@ class HomeController extends AbstractController
|
||||
'php_info' => $phpInfo ?? '',
|
||||
'is_version_checked' => $cfg['VersionCheck'],
|
||||
'phpmyadmin_version' => PMA_VERSION,
|
||||
'config_storage_message' => $configStorageMessage ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params Request parameters
|
||||
* @return void
|
||||
*/
|
||||
public function setTheme(array $params): void
|
||||
{
|
||||
$this->themeManager->setActiveTheme($params['set_theme']);
|
||||
$this->themeManager->setThemeCookie();
|
||||
|
||||
$userPreferences = new UserPreferences();
|
||||
$preferences = $userPreferences->load();
|
||||
$preferences['config_data']['ThemeDefault'] = $params['set_theme'];
|
||||
$userPreferences->save($preferences['config_data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params Request parameters
|
||||
* @return void
|
||||
*/
|
||||
public function setCollationConnection(array $params): void
|
||||
{
|
||||
$this->config->setUserValue(
|
||||
null,
|
||||
'DefaultConnectionCollation',
|
||||
$params['collation_connection'],
|
||||
'utf8mb4_unicode_ci'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array JSON
|
||||
*/
|
||||
public function reloadRecentTablesList(): array
|
||||
{
|
||||
return [
|
||||
'list' => RecentFavoriteTable::getInstance('recent')->getHtmlList(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string HTML
|
||||
*/
|
||||
public function gitRevision(): string
|
||||
{
|
||||
return (new GitRevision(
|
||||
$this->response,
|
||||
$this->config,
|
||||
$this->template
|
||||
))->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function checkRequirements(): void
|
||||
{
|
||||
global $cfg, $server, $lang;
|
||||
|
||||
/**
|
||||
* mbstring is used for handling multibytes inside parser, so it is good
|
||||
* to tell user something might be broken without it, see bug #1063149.
|
||||
*/
|
||||
if (! extension_loaded('mbstring')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The mbstring PHP extension was not found and you seem to be using'
|
||||
. ' a multibyte charset. Without the mbstring extension phpMyAdmin'
|
||||
. ' is unable to split strings correctly and it may result in'
|
||||
. ' unexpected results.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Missing functionality
|
||||
*/
|
||||
if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The curl extension was not found and allow_url_fopen is '
|
||||
. 'disabled. Due to this some features such as error reporting '
|
||||
. 'or version check are disabled.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($cfg['LoginCookieValidityDisableWarning'] == false) {
|
||||
/**
|
||||
* Check whether session.gc_maxlifetime limits session validity.
|
||||
*/
|
||||
$gc_time = (int) ini_get('session.gc_maxlifetime');
|
||||
if ($gc_time < $cfg['LoginCookieValidity']) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
|
||||
'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
|
||||
'gc_maxlifetime[/a] is lower than cookie validity configured ' .
|
||||
'in phpMyAdmin, because of this, your login might expire sooner ' .
|
||||
'than configured in phpMyAdmin.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether LoginCookieValidity is limited by LoginCookieStore.
|
||||
*/
|
||||
if ($cfg['LoginCookieStore'] != 0
|
||||
&& $cfg['LoginCookieStore'] < $cfg['LoginCookieValidity']
|
||||
) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Login cookie store is lower than cookie validity configured in ' .
|
||||
'phpMyAdmin, because of this, your login will expire sooner than ' .
|
||||
'configured in phpMyAdmin.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning if using the default MySQL controluser account
|
||||
*/
|
||||
if ($server != 0
|
||||
&& isset($cfg['Server']['controluser']) && $cfg['Server']['controluser'] == 'pma'
|
||||
&& isset($cfg['Server']['controlpass']) && $cfg['Server']['controlpass'] == 'pmapass'
|
||||
) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Your server is running with default values for the ' .
|
||||
'controluser and password (controlpass) and is open to ' .
|
||||
'intrusion; you really should fix this security weakness' .
|
||||
' by changing the password for controluser \'pma\'.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user does not have defined blowfish secret and it is being used.
|
||||
*/
|
||||
if (! empty($_SESSION['encryption_key'])) {
|
||||
if (empty($cfg['blowfish_secret'])) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The configuration file now needs a secret passphrase (blowfish_secret).'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
} elseif (strlen($cfg['blowfish_secret']) < 32) {
|
||||
trigger_error(
|
||||
__(
|
||||
'The secret passphrase in configuration (blowfish_secret) is too short.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for existence of config directory which should not exist in
|
||||
* production environment.
|
||||
*/
|
||||
if (@file_exists(ROOT_PATH . 'config')) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Directory [code]config[/code], which is used by the setup script, ' .
|
||||
'still exists in your phpMyAdmin directory. It is strongly ' .
|
||||
'recommended to remove it once phpMyAdmin has been configured. ' .
|
||||
'Otherwise the security of your server may be compromised by ' .
|
||||
'unauthorized people downloading your configuration.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning about Suhosin only if its simulation mode is not enabled
|
||||
*/
|
||||
if ($cfg['SuhosinDisableWarning'] == false
|
||||
&& ini_get('suhosin.request.max_value_length')
|
||||
&& ini_get('suhosin.simulation') == '0'
|
||||
) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__(
|
||||
'Server running with Suhosin. Please refer ' .
|
||||
'to %sdocumentation%s for possible issues.'
|
||||
),
|
||||
'[doc@faq1-38]',
|
||||
'[/doc]'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/* Missing template cache */
|
||||
if (is_null($this->config->getTempDir('twig'))) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
__(
|
||||
'The $cfg[\'TempDir\'] (%s) is not accessible. ' .
|
||||
'phpMyAdmin is not able to cache templates and will ' .
|
||||
'be slow because of this.'
|
||||
),
|
||||
$this->config->get('TempDir')
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning about incomplete translations.
|
||||
*
|
||||
* The data file is created while creating release by ./scripts/remove-incomplete-mo
|
||||
*/
|
||||
if (@file_exists(ROOT_PATH . 'libraries/language_stats.inc.php')) {
|
||||
include ROOT_PATH . 'libraries/language_stats.inc.php';
|
||||
/*
|
||||
* This message is intentionally not translated, because we're
|
||||
* handling incomplete translations here and focus on english
|
||||
* speaking users.
|
||||
*/
|
||||
if (isset($GLOBALS['language_stats'][$lang])
|
||||
&& $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
|
||||
) {
|
||||
trigger_error(
|
||||
'You are using an incomplete translation, please help to make it '
|
||||
. 'better by [a@https://www.phpmyadmin.net/translate/'
|
||||
. '@_blank]contributing[/a].',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1252,46 +1252,6 @@ class Core
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* prints list item for main page
|
||||
*
|
||||
* @param string $name displayed text
|
||||
* @param string $listId id, used for css styles
|
||||
* @param string $url make item as link with $url as target
|
||||
* @param string $mysql_help_page display a link to MySQL's manual
|
||||
* @param string $target special target for $url
|
||||
* @param string $a_id id for the anchor,
|
||||
* used for jQuery to hook in functions
|
||||
* @param string $class class for the li element
|
||||
* @param string $a_class class for the anchor element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function printListItem(
|
||||
string $name,
|
||||
?string $listId = null,
|
||||
?string $url = null,
|
||||
?string $mysql_help_page = null,
|
||||
?string $target = null,
|
||||
?string $a_id = null,
|
||||
?string $class = null,
|
||||
?string $a_class = null
|
||||
): void {
|
||||
$template = new Template();
|
||||
echo $template->render('list/item', [
|
||||
'content' => $name,
|
||||
'id' => $listId,
|
||||
'class' => $class,
|
||||
'url' => [
|
||||
'href' => $url,
|
||||
'target' => $target,
|
||||
'id' => $a_id,
|
||||
'class' => $a_class,
|
||||
],
|
||||
'mysql_help_page' => $mysql_help_page,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks request and fails with fatal error if something problematic is found
|
||||
*
|
||||
|
||||
@ -9,8 +9,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Display;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
@ -21,59 +23,85 @@ use PhpMyAdmin\Util;
|
||||
class GitRevision
|
||||
{
|
||||
/**
|
||||
* Prints details about the current Git commit revision
|
||||
*
|
||||
* @return void
|
||||
* @var Response
|
||||
*/
|
||||
public static function display()
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var Template
|
||||
*/
|
||||
private $template;
|
||||
|
||||
/**
|
||||
* GitRevision constructor.
|
||||
* @param Response $response Response instance
|
||||
* @param Config $config Config instance
|
||||
* @param Template $template Template instance
|
||||
*/
|
||||
public function __construct($response, $config, $template)
|
||||
{
|
||||
$this->response = $response;
|
||||
$this->config = $config;
|
||||
$this->template = $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns details about the current Git commit revision
|
||||
*
|
||||
* @return string HTML
|
||||
*/
|
||||
public function display(): string
|
||||
{
|
||||
// load revision data from repo
|
||||
$GLOBALS['PMA_Config']->checkGitRevision();
|
||||
$this->config->checkGitRevision();
|
||||
|
||||
if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
|
||||
$response = Response::getInstance();
|
||||
$response->setRequestStatus(false);
|
||||
return;
|
||||
if (! $this->config->get('PMA_VERSION_GIT')) {
|
||||
$this->response->setRequestStatus(false);
|
||||
return '';
|
||||
}
|
||||
|
||||
// if using a remote commit fast-forwarded, link to GitHub
|
||||
$commit_hash = substr(
|
||||
$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'),
|
||||
$commitHash = substr(
|
||||
$this->config->get('PMA_VERSION_GIT_COMMITHASH'),
|
||||
0,
|
||||
7
|
||||
);
|
||||
$commit_hash = '<strong title="'
|
||||
. htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE'))
|
||||
. '">' . $commit_hash . '</strong>';
|
||||
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
|
||||
$commit_hash = '<a href="'
|
||||
$commitHash = '<strong title="'
|
||||
. htmlspecialchars($this->config->get('PMA_VERSION_GIT_MESSAGE'))
|
||||
. '">' . $commitHash . '</strong>';
|
||||
if ($this->config->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
|
||||
$commitHash = '<a href="'
|
||||
. Core::linkURL(
|
||||
'https://github.com/phpmyadmin/phpmyadmin/commit/'
|
||||
. $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')
|
||||
. $this->config->get('PMA_VERSION_GIT_COMMITHASH')
|
||||
)
|
||||
. '" rel="noopener noreferrer" target="_blank">' . $commit_hash . '</a>';
|
||||
. '" rel="noopener noreferrer" target="_blank">' . $commitHash . '</a>';
|
||||
}
|
||||
|
||||
$branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
|
||||
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
|
||||
$branch = $this->config->get('PMA_VERSION_GIT_BRANCH');
|
||||
if ($this->config->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
|
||||
$branch = '<a href="'
|
||||
. Core::linkURL(
|
||||
'https://github.com/phpmyadmin/phpmyadmin/tree/'
|
||||
. $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')
|
||||
. $this->config->get('PMA_VERSION_GIT_BRANCH')
|
||||
)
|
||||
. '" rel="noopener noreferrer" target="_blank">' . $branch . '</a>';
|
||||
}
|
||||
if ($branch !== false) {
|
||||
$branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
|
||||
$branch = sprintf(__('%1$s from %2$s branch'), $commitHash, $branch);
|
||||
} else {
|
||||
$branch = $commit_hash . ' (' . __('no branch') . ')';
|
||||
$branch = $commitHash . ' (' . __('no branch') . ')';
|
||||
}
|
||||
|
||||
$committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
|
||||
$author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
|
||||
Core::printListItem(
|
||||
__('Git revision:') . ' '
|
||||
$committer = $this->config->get('PMA_VERSION_GIT_COMMITTER');
|
||||
$author = $this->config->get('PMA_VERSION_GIT_AUTHOR');
|
||||
|
||||
$name = __('Git revision:') . ' '
|
||||
. $branch . ',<br> '
|
||||
. sprintf(
|
||||
__('committed on %1$s by %2$s'),
|
||||
@ -93,11 +121,19 @@ class GitRevision
|
||||
) . '">'
|
||||
. htmlspecialchars($author['name']) . '</a>'
|
||||
)
|
||||
: ''),
|
||||
'li_pma_version_git',
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
: '');
|
||||
|
||||
return $this->template->render('list/item', [
|
||||
'content' => $name,
|
||||
'id' => 'li_pma_version_git',
|
||||
'class' => null,
|
||||
'url' => [
|
||||
'href' => null,
|
||||
'target' => null,
|
||||
'id' => null,
|
||||
'class' => null,
|
||||
],
|
||||
'mysql_help_page' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,11 @@
|
||||
{% if is_git_revision %}
|
||||
<div id="is_git_revision"></div>
|
||||
{% endif %}
|
||||
|
||||
{{ message|raw }}
|
||||
|
||||
{{ partial_logout|raw }}
|
||||
|
||||
<div id="maincontainer">
|
||||
{{ sync_favorite_tables|raw }}
|
||||
|
||||
@ -182,3 +190,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ config_storage_message|raw }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user