Translated using Weblate (Interlingua)
[phpmyadmin.git] / index.php
blob93a3785322d6a50257e34e27fc00c43f1897d1cd
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Main loader script
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Charsets;
9 use PhpMyAdmin\Config;
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\Display\GitRevision;
12 use PhpMyAdmin\LanguageManager;
13 use PhpMyAdmin\Message;
14 use PhpMyAdmin\RecentFavoriteTable;
15 use PhpMyAdmin\Relation;
16 use PhpMyAdmin\Response;
17 use PhpMyAdmin\Sanitize;
18 use PhpMyAdmin\Server\Select;
19 use PhpMyAdmin\ThemeManager;
20 use PhpMyAdmin\Url;
21 use PhpMyAdmin\Util;
23 /**
24 * Gets some core libraries and displays a top message if required
26 require_once 'libraries/common.inc.php';
28 /**
29 * pass variables to child pages
31 $drops = array(
32 'lang',
33 'server',
34 'collation_connection',
35 'db',
36 'table'
38 foreach ($drops as $each_drop) {
39 if (array_key_exists($each_drop, $_GET)) {
40 unset($_GET[$each_drop]);
43 unset($drops, $each_drop);
46 * Black list of all scripts to which front-end must submit data.
47 * Such scripts must not be loaded on home page.
50 $target_blacklist = array (
51 'import.php', 'export.php'
54 // If we have a valid target, let's load that script instead
55 if (! empty($_REQUEST['target'])
56 && is_string($_REQUEST['target'])
57 && ! preg_match('/^index/', $_REQUEST['target'])
58 && ! in_array($_REQUEST['target'], $target_blacklist)
59 && Core::checkPageValidity($_REQUEST['target'])
60 ) {
61 include $_REQUEST['target'];
62 exit;
65 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
66 exit;
69 // user selected font size
70 if (isset($_POST['set_fontsize']) && preg_match('/^[0-9.]+(px|em|pt|\%)$/', $_POST['set_fontsize'])) {
71 $GLOBALS['PMA_Config']->setUserValue(
72 null,
73 'FontSize',
74 $_POST['set_fontsize'],
75 '82%'
77 header('Location: index.php' . Url::getCommonRaw());
78 exit();
80 // if user selected a theme
81 if (isset($_POST['set_theme'])) {
82 $tmanager = ThemeManager::getInstance();
83 $tmanager->setActiveTheme($_POST['set_theme']);
84 $tmanager->setThemeCookie();
85 header('Location: index.php' . Url::getCommonRaw());
86 exit();
90 // See FAQ 1.34
91 if (! empty($_REQUEST['db'])) {
92 $page = null;
93 if (! empty($_REQUEST['table'])) {
94 $page = Util::getScriptNameForOption(
95 $GLOBALS['cfg']['DefaultTabTable'], 'table'
97 } else {
98 $page = Util::getScriptNameForOption(
99 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
102 include $page;
103 exit;
106 $response = Response::getInstance();
108 * Check if it is an ajax request to reload the recent tables list.
110 if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
111 $response->addJSON(
112 'list',
113 RecentFavoriteTable::getInstance('recent')->getHtmlList()
115 exit;
118 if ($GLOBALS['PMA_Config']->isGitRevision()) {
119 if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
120 GitRevision::display();
121 exit;
123 echo '<div id="is_git_revision"></div>';
126 // Handles some variables that may have been sent by the calling script
127 $GLOBALS['db'] = '';
128 $GLOBALS['table'] = '';
129 $show_query = '1';
131 // Any message to display?
132 if (! empty($message)) {
133 echo Util::getMessage($message);
134 unset($message);
136 if (isset($_SESSION['partial_logout'])) {
137 Message::success(
138 __('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
139 )->display();
140 unset($_SESSION['partial_logout']);
143 $common_url_query = Url::getCommon();
144 $mysql_cur_user_and_host = '';
146 // when $server > 0, a server has been chosen so we can display
147 // all MySQL-related information
148 if ($server > 0) {
149 include 'libraries/server_common.inc.php';
151 // Use the verbose name of the server instead of the hostname
152 // if a value is set
153 $server_info = '';
154 if (! empty($cfg['Server']['verbose'])) {
155 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
156 if ($GLOBALS['cfg']['ShowServerInfo']) {
157 $server_info .= ' (';
160 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
161 $server_info .= $GLOBALS['dbi']->getHostInfo();
163 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
164 $server_info .= ')';
166 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
168 // should we add the port info here?
169 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
170 ? $GLOBALS['cfg']['Server']['verbose']
171 : $GLOBALS['cfg']['Server']['host']);
174 echo '<div id="maincontainer">' , "\n";
175 // Anchor for favorite tables synchronization.
176 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
177 echo '<div id="main_pane_left">';
178 if ($server > 0 || count($cfg['Servers']) > 1
180 if ($cfg['DBG']['demo']) {
181 echo '<div class="group">';
182 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
183 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
184 printf(
186 'You are using the demo server. You can do anything here, but '
187 . 'please do not change root, debian-sys-maint and pma users. '
188 . 'More information is available at %s.'
190 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
192 echo '</p>';
193 echo '</div>';
195 echo '<div class="group">';
196 echo '<h2>' , __('General settings') , '</h2>';
197 echo '<ul>';
200 * Displays the MySQL servers choice form
202 if ($cfg['ServerDefault'] == 0
203 || (! $cfg['NavigationDisplayServers']
204 && (count($cfg['Servers']) > 1
205 || ($server == 0 && count($cfg['Servers']) == 1)))
207 echo '<li id="li_select_server" class="no_bullets" >';
208 echo Util::getImage('s_host') , " "
209 , Select::render(true, true);
210 echo '</li>';
214 * Displays the mysql server related links
216 if ($server > 0) {
217 include_once 'libraries/check_user_privileges.inc.php';
219 // Logout for advanced authentication
220 if ($cfg['Server']['auth_type'] != 'config') {
221 if ($cfg['ShowChgPassword']) {
222 $conditional_class = 'ajax';
223 Core::printListItem(
224 Util::getImage('s_passwd') . "&nbsp;" . __(
225 'Change password'
227 'li_change_password',
228 'user_password.php' . $common_url_query,
229 null,
230 null,
231 'change_password_anchor',
232 "no_bullets",
233 $conditional_class
236 } // end if
237 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
238 echo ' <form method="post" action="index.php">' , "\n"
239 . Url::getHiddenInputs(null, null, 4, 'collation_connection')
240 . ' <label for="select_collation_connection">' . "\n"
241 . ' ' . Util::getImage('s_asci')
242 . "&nbsp;" . __('Server connection collation') . "\n"
243 // put the doc link in the form so that it appears on the same line
244 . Util::showMySQLDocu('Charset-connection')
245 . ': ' . "\n"
246 . ' </label>' . "\n"
248 . Charsets::getCollationDropdownBox(
249 $GLOBALS['dbi'],
250 $GLOBALS['cfg']['Server']['DisableIS'],
251 'collation_connection',
252 'select_collation_connection',
253 $collation_connection,
254 true,
255 true
257 . ' </form>' . "\n"
258 . ' </li>' . "\n";
259 } // end of if ($server > 0)
260 echo '</ul>';
261 echo '</div>';
264 echo '<div class="group">';
265 echo '<h2>' , __('Appearance settings') , '</h2>';
266 echo ' <ul>';
268 // Displays language selection combo
269 $language_manager = LanguageManager::getInstance();
270 if (empty($cfg['Lang']) && $language_manager->hasChoice()) {
271 echo '<li id="li_select_lang" class="no_bullets">';
273 echo Util::getImage('s_lang') , " "
274 , $language_manager->getSelectorDisplay();
275 echo '</li>';
278 // ThemeManager if available
280 if ($GLOBALS['cfg']['ThemeManager']) {
281 echo '<li id="li_select_theme" class="no_bullets">';
282 echo Util::getImage('s_theme') , " "
283 , ThemeManager::getInstance()->getHtmlSelectBox();
284 echo '</li>';
286 echo '<li id="li_select_fontsize">';
287 echo Config::getFontsizeForm();
288 echo '</li>';
290 echo '</ul>';
292 // User preferences
294 if ($server > 0) {
295 echo '<ul>';
296 Core::printListItem(
297 Util::getImage('b_tblops') . "&nbsp;" . __(
298 'More settings'
300 'li_user_preferences',
301 'prefs_manage.php' . $common_url_query,
302 null,
303 null,
304 null,
305 "no_bullets"
307 echo '</ul>';
310 echo '</div>';
313 echo '</div>';
314 echo '<div id="main_pane_right">';
317 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
319 echo '<div class="group">';
320 echo '<h2>' , __('Database server') , '</h2>';
321 echo '<ul>' , "\n";
322 Core::printListItem(
323 __('Server:') . ' ' . $server_info,
324 'li_server_info'
326 Core::printListItem(
327 __('Server type:') . ' ' . Util::getServerType(),
328 'li_server_type'
330 Core::printListItem(
331 __('Server connection:') . ' ' . Util::getServerSSL(),
332 'li_server_type'
334 Core::printListItem(
335 __('Server version:')
336 . ' '
337 . $GLOBALS['dbi']->getVersionString() . ' - ' . $GLOBALS['dbi']->getVersionComment(),
338 'li_server_version'
340 Core::printListItem(
341 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
342 'li_mysql_proto'
344 Core::printListItem(
345 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
346 'li_user_info'
349 echo ' <li id="li_select_mysql_charset">';
350 echo ' ' , __('Server charset:') , ' '
351 . ' <span lang="en" dir="ltr">';
352 $unicode = Charsets::$mysql_charset_map['utf-8'];
353 $charsets = Charsets::getMySQLCharsetsDescriptions(
354 $GLOBALS['dbi'],
355 $GLOBALS['cfg']['Server']['DisableIS']
357 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
358 echo ' </span>'
359 . ' </li>'
360 . ' </ul>'
361 . ' </div>';
364 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
365 echo '<div class="group">';
366 echo '<h2>' , __('Web server') , '</h2>';
367 echo '<ul>';
368 if ($GLOBALS['cfg']['ShowServerInfo']) {
369 Core::printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
371 if ($server > 0) {
372 $client_version_str = $GLOBALS['dbi']->getClientInfo();
373 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
374 $client_version_str = 'libmysql - ' . $client_version_str;
376 Core::printListItem(
377 __('Database client version:') . ' ' . $client_version_str,
378 'li_mysql_client_version'
381 $php_ext_string = __('PHP extension:') . ' ';
383 $extensions = Util::listPHPExtensions();
385 foreach ($extensions as $extension) {
386 $php_ext_string .= ' ' . $extension
387 . Util::showPHPDocu('book.' . $extension . '.php');
390 Core::printListItem(
391 $php_ext_string,
392 'li_used_php_extension'
395 $php_version_string = __('PHP version:') . ' ' . phpversion();
397 Core::printListItem(
398 $php_version_string,
399 'li_used_php_version'
404 if ($cfg['ShowPhpInfo']) {
405 Core::printListItem(
406 __('Show PHP information'),
407 'li_phpinfo',
408 'phpinfo.php' . $common_url_query,
409 null,
410 '_blank'
413 echo ' </ul>';
414 echo ' </div>';
417 echo '<div class="group pmagroup">';
418 echo '<h2>phpMyAdmin</h2>';
419 echo '<ul>';
420 $class = null;
421 if ($GLOBALS['cfg']['VersionCheck']) {
422 $class = 'jsversioncheck';
424 Core::printListItem(
425 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
426 'li_pma_version',
427 null,
428 null,
429 null,
430 null,
431 $class
433 Core::printListItem(
434 __('Documentation'),
435 'li_pma_docs',
436 Util::getDocuLink('index'),
437 null,
438 '_blank'
441 // does not work if no target specified, don't know why
442 Core::printListItem(
443 __('Official Homepage'),
444 'li_pma_homepage',
445 Core::linkURL('https://www.phpmyadmin.net/'),
446 null,
447 '_blank'
449 Core::printListItem(
450 __('Contribute'),
451 'li_pma_contribute',
452 Core::linkURL('https://www.phpmyadmin.net/contribute/'),
453 null,
454 '_blank'
456 Core::printListItem(
457 __('Get support'),
458 'li_pma_support',
459 Core::linkURL('https://www.phpmyadmin.net/support/'),
460 null,
461 '_blank'
463 Core::printListItem(
464 __('List of changes'),
465 'li_pma_changes',
466 'changelog.php' . Url::getCommon(),
467 null,
468 '_blank'
470 Core::printListItem(
471 __('License'),
472 'li_pma_license',
473 'license.php' . Url::getCommon(),
474 null,
475 '_blank'
477 echo ' </ul>';
478 echo ' </div>';
480 echo '</div>';
482 echo '</div>';
485 * mbstring is used for handling multibytes inside parser, so it is good
486 * to tell user something might be broken without it, see bug #1063149.
488 if (! @extension_loaded('mbstring')) {
489 trigger_error(
491 'The mbstring PHP extension was not found and you seem to be using'
492 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
493 . ' is unable to split strings correctly and it may result in'
494 . ' unexpected results.'
496 E_USER_WARNING
501 * Missing functionality
503 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
504 trigger_error(
506 'The curl extension was not found and allow_url_fopen is '
507 . 'disabled. Due to this some features such as error reporting '
508 . 'or version check are disabled.'
513 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
515 * Check whether session.gc_maxlifetime limits session validity.
517 $gc_time = (int)@ini_get('session.gc_maxlifetime');
518 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
519 trigger_error(
521 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
522 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
523 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
524 'in phpMyAdmin, because of this, your login might expire sooner ' .
525 'than configured in phpMyAdmin.'
527 E_USER_WARNING
533 * Check whether LoginCookieValidity is limited by LoginCookieStore.
535 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
536 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
538 trigger_error(
540 'Login cookie store is lower than cookie validity configured in ' .
541 'phpMyAdmin, because of this, your login will expire sooner than ' .
542 'configured in phpMyAdmin.'
544 E_USER_WARNING
549 * Check if user does not have defined blowfish secret and it is being used.
551 if (! empty($_SESSION['encryption_key'])) {
552 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
553 trigger_error(
555 'The configuration file now needs a secret passphrase (blowfish_secret).'
557 E_USER_WARNING
559 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
560 trigger_error(
562 'The secret passphrase in configuration (blowfish_secret) is too short.'
564 E_USER_WARNING
570 * Check for existence of config directory which should not exist in
571 * production environment.
573 if (@file_exists('config')) {
574 trigger_error(
576 'Directory [code]config[/code], which is used by the setup script, ' .
577 'still exists in your phpMyAdmin directory. It is strongly ' .
578 'recommended to remove it once phpMyAdmin has been configured. ' .
579 'Otherwise the security of your server may be compromised by ' .
580 'unauthorized people downloading your configuration.'
582 E_USER_WARNING
586 if ($server > 0) {
587 $cfgRelation = Relation::getRelationsParam();
588 if (! $cfgRelation['allworks']
589 && $cfg['PmaNoRelation_DisableWarning'] == false
591 $msg_text = __(
592 'The phpMyAdmin configuration storage is not completely '
593 . 'configured, some extended features have been deactivated. '
594 . '%sFind out why%s. '
596 if ($cfg['ZeroConf'] == true) {
597 $msg_text .= '<br>' .
599 'Or alternately go to \'Operations\' tab of any database '
600 . 'to set it up there.'
603 $msg = Message::notice($msg_text);
604 $msg->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
605 $msg->addParamHtml('</a>');
606 /* Show error if user has configured something, notice elsewhere */
607 if (!empty($cfg['Servers'][$server]['pmadb'])) {
608 $msg->isError(true);
610 $msg->display();
611 } // end if
615 * Warning about Suhosin only if its simulation mode is not enabled
617 if ($cfg['SuhosinDisableWarning'] == false
618 && @ini_get('suhosin.request.max_value_length')
619 && @ini_get('suhosin.simulation') == '0'
621 trigger_error(
622 sprintf(
624 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
625 'for possible issues.'
627 '[doc@faq1-38]',
628 '[/doc]'
630 E_USER_WARNING
634 /* Missing template cache */
635 if (is_null($GLOBALS['PMA_Config']->getTempDir('twig'))) {
636 trigger_error(
637 sprintf(
638 __('The $cfg[\'TempDir\'] (%s) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.'),
639 $GLOBALS['PMA_Config']->get('TempDir')
641 E_USER_WARNING
646 * Warning about incomplete translations.
648 * The data file is created while creating release by ./scripts/remove-incomplete-mo
650 if (@file_exists('libraries/language_stats.inc.php')) {
651 include 'libraries/language_stats.inc.php';
653 * This message is intentionally not translated, because we're
654 * handling incomplete translations here and focus on english
655 * speaking users.
657 if (isset($GLOBALS['language_stats'][$lang])
658 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
660 trigger_error(
661 'You are using an incomplete translation, please help to make it '
662 . 'better by [a@https://www.phpmyadmin.net/translate/'
663 . '@_blank]contributing[/a].',
664 E_USER_NOTICE