2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 declare(strict_types
=1);
10 use PhpMyAdmin\Charsets
;
11 use PhpMyAdmin\CheckUserPrivileges
;
12 use PhpMyAdmin\Config
;
14 use PhpMyAdmin\Display\GitRevision
;
15 use PhpMyAdmin\LanguageManager
;
16 use PhpMyAdmin\Message
;
17 use PhpMyAdmin\RecentFavoriteTable
;
18 use PhpMyAdmin\Relation
;
19 use PhpMyAdmin\Response
;
20 use PhpMyAdmin\Sanitize
;
21 use PhpMyAdmin\Server\Select
;
22 use PhpMyAdmin\ThemeManager
;
25 use PhpMyAdmin\UserPreferences
;
27 if (! defined('ROOT_PATH')) {
28 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
32 * Gets some core libraries and displays a top message if required
34 require_once ROOT_PATH
. 'libraries/common.inc.php';
37 * pass variables to child pages
42 'collation_connection',
46 foreach ($drops as $each_drop) {
47 if (array_key_exists($each_drop, $_GET)) {
48 unset($_GET[$each_drop]);
51 unset($drops, $each_drop);
54 * Black list of all scripts to which front-end must submit data.
55 * Such scripts must not be loaded on home page.
63 // If we have a valid target, let's load that script instead
64 if (! empty($_REQUEST['target'])
65 && is_string($_REQUEST['target'])
66 && 0 !== strpos($_REQUEST['target'], "index")
67 && ! in_array($_REQUEST['target'], $target_blacklist)
68 && Core
::checkPageValidity($_REQUEST['target'], [], true)
70 include ROOT_PATH
. $_REQUEST['target'];
74 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
78 // if user selected a theme
79 if (isset($_POST['set_theme'])) {
80 $tmanager = ThemeManager
::getInstance();
81 $tmanager->setActiveTheme($_POST['set_theme']);
82 $tmanager->setThemeCookie();
84 $userPreferences = new UserPreferences();
85 $prefs = $userPreferences->load();
86 $prefs["config_data"]["ThemeDefault"] = $_POST['set_theme'];
87 $userPreferences->save($prefs["config_data"]);
89 header('Location: index.php' . Url
::getCommonRaw());
92 // Change collation connection
93 if (isset($_POST['collation_connection'])) {
94 $GLOBALS['PMA_Config']->setUserValue(
96 'DefaultConnectionCollation',
97 $_POST['collation_connection'],
100 header('Location: index.php' . Url
::getCommonRaw());
106 if (! empty($_REQUEST['db'])) {
108 if (! empty($_REQUEST['table'])) {
109 $page = Util
::getScriptNameForOption(
110 $GLOBALS['cfg']['DefaultTabTable'],
114 $page = Util
::getScriptNameForOption(
115 $GLOBALS['cfg']['DefaultTabDatabase'],
119 include ROOT_PATH
. $page;
123 $response = Response
::getInstance();
125 * Check if it is an ajax request to reload the recent tables list.
127 if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
130 RecentFavoriteTable
::getInstance('recent')->getHtmlList()
135 if ($GLOBALS['PMA_Config']->isGitRevision()) {
136 // If ajax request to get revision
137 if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
138 GitRevision
::display();
141 // Else show empty html
142 echo '<div id="is_git_revision"></div>';
145 // Handles some variables that may have been sent by the calling script
147 $GLOBALS['table'] = '';
150 // Any message to display?
151 if (! empty($message)) {
152 echo Util
::getMessage($message);
155 if (isset($_SESSION['partial_logout'])) {
157 __('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
159 unset($_SESSION['partial_logout']);
162 $common_url_query = Url
::getCommon();
163 $mysql_cur_user_and_host = '';
165 // when $server > 0, a server has been chosen so we can display
166 // all MySQL-related information
168 include ROOT_PATH
. 'libraries/server_common.inc.php';
170 // Use the verbose name of the server instead of the hostname
173 if (! empty($cfg['Server']['verbose'])) {
174 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
175 if ($GLOBALS['cfg']['ShowServerInfo']) {
176 $server_info .= ' (';
179 if ($GLOBALS['cfg']['ShowServerInfo'] ||
empty($cfg['Server']['verbose'])) {
180 $server_info .= $GLOBALS['dbi']->getHostInfo();
182 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
185 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
187 // should we add the port info here?
188 $short_server_info = (! empty($GLOBALS['cfg']['Server']['verbose'])
189 ?
$GLOBALS['cfg']['Server']['verbose']
190 : $GLOBALS['cfg']['Server']['host']);
193 echo '<div id="maincontainer">' , "\n";
194 // Anchor for favorite tables synchronization.
195 echo RecentFavoriteTable
::getInstance('favorite')->getHtmlSyncFavoriteTables();
196 echo '<div id="main_pane_left">';
197 if ($server > 0 ||
count($cfg['Servers']) > 1
199 if ($cfg['DBG']['demo']) {
200 echo '<div class="group">';
201 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
202 echo '<p class="cfg_dbg_demo">';
205 'You are using the demo server. You can do anything here, but '
206 . 'please do not change root, debian-sys-maint and pma users. '
207 . 'More information is available at %s.'
209 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
214 echo '<div class="group">';
215 echo '<h2>' , __('General settings') , '</h2>';
219 * Displays the MySQL servers choice form
221 if ($cfg['ServerDefault'] == 0
222 ||
(! $cfg['NavigationDisplayServers']
223 && (count($cfg['Servers']) > 1
224 ||
($server == 0 && count($cfg['Servers']) == 1)))
226 echo '<li id="li_select_server" class="no_bullets" >';
227 echo Util
::getImage('s_host') , " "
228 , Select
::render(true, true);
233 * Displays the mysql server related links
236 $checkUserPrivileges = new CheckUserPrivileges($GLOBALS['dbi']);
237 $checkUserPrivileges->getPrivileges();
239 // Logout for advanced authentication
240 if (($cfg['Server']['auth_type'] != 'config') && $cfg['ShowChgPassword']) {
241 $conditional_class = 'ajax';
243 Util
::getImage('s_passwd') . " " . __(
246 'li_change_password',
247 'user_password.php' . $common_url_query,
250 'change_password_anchor',
255 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
256 echo ' <form class="disableAjax" method="post" action="index.php">' , "\n"
257 . Url
::getHiddenInputs(null, null, 4, 'collation_connection')
258 . ' <label for="select_collation_connection">' . "\n"
259 . ' ' . Util
::getImage('s_asci')
260 . " " . __('Server connection collation') . "\n"
261 // put the doc link in the form so that it appears on the same line
262 . Util
::showMySQLDocu('Charset-connection')
266 . Charsets
::getCollationDropdownBox(
268 $GLOBALS['cfg']['Server']['DisableIS'],
269 'collation_connection',
270 'select_collation_connection',
271 $collation_connection,
277 } // end of if ($server > 0)
282 echo '<div class="group">';
283 echo '<h2>' , __('Appearance settings') , '</h2>';
286 // Displays language selection combo
287 $language_manager = LanguageManager
::getInstance();
288 if (empty($cfg['Lang']) && $language_manager->hasChoice()) {
289 echo '<li id="li_select_lang" class="no_bullets">';
291 echo Util
::getImage('s_lang') , " "
292 , $language_manager->getSelectorDisplay();
296 // ThemeManager if available
298 if ($GLOBALS['cfg']['ThemeManager']) {
299 echo '<li id="li_select_theme" class="no_bullets">';
300 echo Util
::getImage('s_theme') , " "
301 , ThemeManager
::getInstance()->getHtmlSelectBox();
312 Util
::getImage('b_tblops') . " " . __(
315 'li_user_preferences',
316 'prefs_manage.php' . $common_url_query,
329 echo '<div id="main_pane_right">';
332 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
333 echo '<div class="group">';
334 echo '<h2>' , __('Database server') , '</h2>';
337 __('Server:') . ' ' . $server_info,
341 __('Server type:') . ' ' . Util
::getServerType(),
345 __('Server connection:') . ' ' . Util
::getServerSSL(),
349 __('Server version:')
351 . $GLOBALS['dbi']->getVersionString() . ' - ' . $GLOBALS['dbi']->getVersionComment(),
355 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
359 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
363 echo ' <li id="li_select_mysql_charset">';
364 echo ' ' , __('Server charset:') , ' '
365 . ' <span lang="en" dir="ltr">';
366 $unicode = Charsets
::$mysql_charset_map['utf-8'];
367 $charsets = Charsets
::getMySQLCharsetsDescriptions(
369 $GLOBALS['cfg']['Server']['DisableIS']
371 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
378 if ($GLOBALS['cfg']['ShowServerInfo'] ||
$GLOBALS['cfg']['ShowPhpInfo']) {
379 echo '<div class="group">';
380 echo '<h2>' , __('Web server') , '</h2>';
382 if ($GLOBALS['cfg']['ShowServerInfo']) {
383 Core
::printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
386 $client_version_str = $GLOBALS['dbi']->getClientInfo();
387 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
388 $client_version_str = 'libmysql - ' . $client_version_str;
391 __('Database client version:') . ' ' . $client_version_str,
392 'li_mysql_client_version'
395 $php_ext_string = __('PHP extension:') . ' ';
397 $extensions = Util
::listPHPExtensions();
399 foreach ($extensions as $extension) {
400 $php_ext_string .= ' ' . $extension
401 . Util
::showPHPDocu('book.' . $extension . '.php');
406 'li_used_php_extension'
409 $php_version_string = __('PHP version:') . ' ' . phpversion();
413 'li_used_php_version'
418 if ($cfg['ShowPhpInfo']) {
420 __('Show PHP information'),
422 'phpinfo.php' . $common_url_query,
431 echo '<div class="group pmagroup">';
432 echo '<h2>phpMyAdmin</h2>';
435 if ($GLOBALS['cfg']['VersionCheck']) {
436 $class = 'jsversioncheck';
439 __('Version information:') . ' <span class="version">' . PMA_VERSION
. '</span>',
450 Util
::getDocuLink('index'),
455 // does not work if no target specified, don't know why
457 __('Official Homepage'),
459 Core
::linkURL('https://www.phpmyadmin.net/'),
466 Core
::linkURL('https://www.phpmyadmin.net/contribute/'),
473 Core
::linkURL('https://www.phpmyadmin.net/support/'),
478 __('List of changes'),
480 'changelog.php' . Url
::getCommon(),
487 'license.php' . Url
::getCommon(),
499 * mbstring is used for handling multibytes inside parser, so it is good
500 * to tell user something might be broken without it, see bug #1063149.
502 if (! extension_loaded('mbstring')) {
505 'The mbstring PHP extension was not found and you seem to be using'
506 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
507 . ' is unable to split strings correctly and it may result in'
508 . ' unexpected results.'
515 * Missing functionality
517 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
520 'The curl extension was not found and allow_url_fopen is '
521 . 'disabled. Due to this some features such as error reporting '
522 . 'or version check are disabled.'
527 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
529 * Check whether session.gc_maxlifetime limits session validity.
531 $gc_time = (int) ini_get('session.gc_maxlifetime');
532 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity']) {
535 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
536 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
537 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
538 'in phpMyAdmin, because of this, your login might expire sooner ' .
539 'than configured in phpMyAdmin.'
547 * Check whether LoginCookieValidity is limited by LoginCookieStore.
549 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
550 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
554 'Login cookie store is lower than cookie validity configured in ' .
555 'phpMyAdmin, because of this, your login will expire sooner than ' .
556 'configured in phpMyAdmin.'
563 * Warning if using the default MySQL controluser account
566 && isset($GLOBALS['cfg']['Server']['controluser']) && $GLOBALS['cfg']['Server']['controluser'] == 'pma'
567 && isset($GLOBALS['cfg']['Server']['controlpass']) && $GLOBALS['cfg']['Server']['controlpass'] == 'pmapass'
570 __('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\'.'),
577 * Check if user does not have defined blowfish secret and it is being used.
579 if (! empty($_SESSION['encryption_key'])) {
580 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
583 'The configuration file now needs a secret passphrase (blowfish_secret).'
587 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
590 'The secret passphrase in configuration (blowfish_secret) is too short.'
598 * Check for existence of config directory which should not exist in
599 * production environment.
601 if (@file_exists
(ROOT_PATH
. 'config')) {
604 'Directory [code]config[/code], which is used by the setup script, ' .
605 'still exists in your phpMyAdmin directory. It is strongly ' .
606 'recommended to remove it once phpMyAdmin has been configured. ' .
607 'Otherwise the security of your server may be compromised by ' .
608 'unauthorized people downloading your configuration.'
614 $relation = new Relation($GLOBALS['dbi']);
617 $cfgRelation = $relation->getRelationsParam();
618 if (! $cfgRelation['allworks']
619 && $cfg['PmaNoRelation_DisableWarning'] == false
622 'The phpMyAdmin configuration storage is not completely '
623 . 'configured, some extended features have been deactivated. '
624 . '%sFind out why%s. '
626 if ($cfg['ZeroConf'] == true) {
627 $msg_text .= '<br>' .
629 'Or alternately go to \'Operations\' tab of any database '
630 . 'to set it up there.'
633 $msg = Message
::notice($msg_text);
634 $msg->addParamHtml('<a href="./chk_rel.php" data-post="' . $common_url_query . '">');
635 $msg->addParamHtml('</a>');
636 /* Show error if user has configured something, notice elsewhere */
637 if (! empty($cfg['Servers'][$server]['pmadb'])) {
645 * Warning about Suhosin only if its simulation mode is not enabled
647 if ($cfg['SuhosinDisableWarning'] == false
648 && ini_get('suhosin.request.max_value_length')
649 && ini_get('suhosin.simulation') == '0'
654 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
655 'for possible issues.'
664 /* Missing template cache */
665 if (is_null($GLOBALS['PMA_Config']->getTempDir('twig'))) {
668 __('The $cfg[\'TempDir\'] (%s) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.'),
669 $GLOBALS['PMA_Config']->get('TempDir')
676 * Warning about incomplete translations.
678 * The data file is created while creating release by ./scripts/remove-incomplete-mo
680 if (@file_exists
(ROOT_PATH
. 'libraries/language_stats.inc.php')) {
681 include ROOT_PATH
. 'libraries/language_stats.inc.php';
683 * This message is intentionally not translated, because we're
684 * handling incomplete translations here and focus on english
687 if (isset($GLOBALS['language_stats'][$lang])
688 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
691 'You are using an incomplete translation, please help to make it '
692 . 'better by [a@https://www.phpmyadmin.net/translate/'
693 . '@_blank]contributing[/a].',