Translated using Weblate (Interlingua)
[phpmyadmin.git] / index.php
blob9bf8d6c666209ea4ce2e4b3e90d3e0041c368773
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Main loader script
6 * @package PhpMyAdmin
7 */
8 use PMA\libraries\RecentFavoriteTable;
9 use PMA\libraries\URL;
10 use PMA\libraries\Sanitize;
11 use PMA\libraries\Charsets;
12 use PMA\libraries\ThemeManager;
14 /**
15 * Gets some core libraries and displays a top message if required
17 require_once 'libraries/common.inc.php';
19 /**
20 * display Git revision if requested
22 require_once 'libraries/display_git_revision.lib.php';
24 /**
25 * pass variables to child pages
27 $drops = array(
28 'lang',
29 'server',
30 'collation_connection',
31 'db',
32 'table'
34 foreach ($drops as $each_drop) {
35 if (array_key_exists($each_drop, $_GET)) {
36 unset($_GET[$each_drop]);
39 unset($drops, $each_drop);
42 * Black list of all scripts to which front-end must submit data.
43 * Such scripts must not be loaded on home page.
46 $target_blacklist = array (
47 'import.php', 'export.php'
50 // If we have a valid target, let's load that script instead
51 if (! empty($_REQUEST['target'])
52 && is_string($_REQUEST['target'])
53 && ! preg_match('/^index/', $_REQUEST['target'])
54 && ! in_array($_REQUEST['target'], $target_blacklist)
55 && in_array($_REQUEST['target'], $goto_whitelist)
56 ) {
57 include $_REQUEST['target'];
58 exit;
61 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
62 exit;
65 // See FAQ 1.34
66 if (! empty($_REQUEST['db'])) {
67 $page = null;
68 if (! empty($_REQUEST['table'])) {
69 $page = PMA\libraries\Util::getScriptNameForOption(
70 $GLOBALS['cfg']['DefaultTabTable'], 'table'
72 } else {
73 $page = PMA\libraries\Util::getScriptNameForOption(
74 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
77 include $page;
78 exit;
81 /**
82 * Check if it is an ajax request to reload the recent tables list.
84 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
85 $response = PMA\libraries\Response::getInstance();
86 $response->addJSON(
87 'list',
88 RecentFavoriteTable::getInstance('recent')->getHtmlList()
90 exit;
93 if ($GLOBALS['PMA_Config']->isGitRevision()) {
94 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
95 PMA_printGitRevision();
96 exit;
98 echo '<div id="is_git_revision"></div>';
101 // Handles some variables that may have been sent by the calling script
102 $GLOBALS['db'] = '';
103 $GLOBALS['table'] = '';
104 $show_query = '1';
106 // Any message to display?
107 if (! empty($message)) {
108 echo PMA\libraries\Util::getMessage($message);
109 unset($message);
112 $common_url_query = URL::getCommon();
113 $mysql_cur_user_and_host = '';
115 // when $server > 0, a server has been chosen so we can display
116 // all MySQL-related information
117 if ($server > 0) {
118 include 'libraries/server_common.inc.php';
120 // Use the verbose name of the server instead of the hostname
121 // if a value is set
122 $server_info = '';
123 if (! empty($cfg['Server']['verbose'])) {
124 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
125 if ($GLOBALS['cfg']['ShowServerInfo']) {
126 $server_info .= ' (';
129 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
130 $server_info .= $GLOBALS['dbi']->getHostInfo();
132 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
133 $server_info .= ')';
135 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
137 // should we add the port info here?
138 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
139 ? $GLOBALS['cfg']['Server']['verbose']
140 : $GLOBALS['cfg']['Server']['host']);
143 echo '<div id="maincontainer">' , "\n";
144 // Anchor for favorite tables synchronization.
145 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
146 echo '<div id="main_pane_left">';
147 if ($server > 0 || count($cfg['Servers']) > 1
149 if ($cfg['DBG']['demo']) {
150 echo '<div class="group">';
151 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
152 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
153 printf(
155 'You are using the demo server. You can do anything here, but '
156 . 'please do not change root, debian-sys-maint and pma users. '
157 . 'More information is available at %s.'
159 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
161 echo '</p>';
162 echo '</div>';
164 echo '<div class="group">';
165 echo '<h2>' , __('General settings') , '</h2>';
166 echo '<ul>';
169 * Displays the MySQL servers choice form
171 if ($cfg['ServerDefault'] == 0
172 || (! $cfg['NavigationDisplayServers']
173 && (count($cfg['Servers']) > 1
174 || ($server == 0 && count($cfg['Servers']) == 1)))
176 echo '<li id="li_select_server" class="no_bullets" >';
177 include_once 'libraries/select_server.lib.php';
178 echo PMA\libraries\Util::getImage('s_host.png') , " "
179 , PMA_selectServer(true, true);
180 echo '</li>';
184 * Displays the mysql server related links
186 if ($server > 0) {
187 include_once 'libraries/check_user_privileges.lib.php';
189 // Logout for advanced authentication
190 if ($cfg['Server']['auth_type'] != 'config') {
191 if ($cfg['ShowChgPassword']) {
192 $conditional_class = 'ajax';
193 PMA_printListItem(
194 PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __(
195 'Change password'
197 'li_change_password',
198 'user_password.php' . $common_url_query,
199 null,
200 null,
201 'change_password_anchor',
202 "no_bullets",
203 $conditional_class
206 } // end if
207 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
208 echo ' <form method="post" action="index.php">' , "\n"
209 . URL::getHiddenInputs(null, null, 4, 'collation_connection')
210 . ' <label for="select_collation_connection">' . "\n"
211 . ' ' . PMA\libraries\Util::getImage('s_asci.png')
212 . "&nbsp;" . __('Server connection collation') . "\n"
213 // put the doc link in the form so that it appears on the same line
214 . PMA\libraries\Util::showMySQLDocu('Charset-connection')
215 . ': ' . "\n"
216 . ' </label>' . "\n"
218 . Charsets::getCollationDropdownBox(
219 'collation_connection',
220 'select_collation_connection',
221 $collation_connection,
222 true,
223 true
225 . ' </form>' . "\n"
226 . ' </li>' . "\n";
227 } // end of if ($server > 0)
228 echo '</ul>';
229 echo '</div>';
232 echo '<div class="group">';
233 echo '<h2>' , __('Appearance settings') , '</h2>';
234 echo ' <ul>';
236 // Displays language selection combo
237 if (empty($cfg['Lang'])) {
238 echo '<li id="li_select_lang" class="no_bullets">';
239 include_once 'libraries/display_select_lang.lib.php';
240 echo PMA\libraries\Util::getImage('s_lang.png') , " "
241 , PMA_getLanguageSelectorHtml();
242 echo '</li>';
245 // ThemeManager if available
247 if ($GLOBALS['cfg']['ThemeManager']) {
248 echo '<li id="li_select_theme" class="no_bullets">';
249 echo PMA\libraries\Util::getImage('s_theme.png') , " "
250 , ThemeManager::getInstance()->getHtmlSelectBox();
251 echo '</li>';
253 echo '<li id="li_select_fontsize">';
254 echo PMA\libraries\Config::getFontsizeForm();
255 echo '</li>';
257 echo '</ul>';
259 // User preferences
261 if ($server > 0) {
262 echo '<ul>';
263 PMA_printListItem(
264 PMA\libraries\Util::getImage('b_tblops.png') . "&nbsp;" . __(
265 'More settings'
267 'li_user_preferences',
268 'prefs_manage.php' . $common_url_query,
269 null,
270 null,
271 null,
272 "no_bullets"
274 echo '</ul>';
277 echo '</div>';
280 echo '</div>';
281 echo '<div id="main_pane_right">';
284 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
286 echo '<div class="group">';
287 echo '<h2>' , __('Database server') , '</h2>';
288 echo '<ul>' , "\n";
289 PMA_printListItem(
290 __('Server:') . ' ' . $server_info,
291 'li_server_info'
293 PMA_printListItem(
294 __('Server type:') . ' ' . PMA\libraries\Util::getServerType(),
295 'li_server_type'
297 PMA_printListItem(
298 __('Server version:')
299 . ' '
300 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
301 'li_server_version'
303 PMA_printListItem(
304 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
305 'li_mysql_proto'
307 PMA_printListItem(
308 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
309 'li_user_info'
312 echo ' <li id="li_select_mysql_charset">';
313 echo ' ' , __('Server charset:') , ' '
314 . ' <span lang="en" dir="ltr">';
315 $unicode = Charsets::$mysql_charset_map['utf-8'];
316 $charsets = Charsets::getMySQLCharsetsDescriptions();
317 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
318 echo ' </span>'
319 . ' </li>'
320 . ' </ul>'
321 . ' </div>';
324 if ($GLOBALS['cfg']['ShowServerInfo']) {
325 echo '<div class="group">';
326 echo '<h2>' , __('Web server') , '</h2>';
327 echo '<ul>';
328 if ($GLOBALS['cfg']['ShowServerInfo']) {
329 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
331 if ($server > 0) {
332 $client_version_str = $GLOBALS['dbi']->getClientInfo();
333 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
334 $client_version_str = 'libmysql - ' . $client_version_str;
336 PMA_printListItem(
337 __('Database client version:') . ' ' . $client_version_str,
338 'li_mysql_client_version'
341 $php_ext_string = __('PHP extension:') . ' ';
343 $extensions = PMA\libraries\Util::listPHPExtensions();
345 foreach ($extensions as $extension) {
346 $php_ext_string .= ' ' . $extension
347 . PMA\libraries\Util::showPHPDocu('book.' . $extension . '.php');
350 PMA_printListItem(
351 $php_ext_string,
352 'li_used_php_extension'
355 $php_version_string = __('PHP version:') . ' ' . phpversion();
357 PMA_printListItem(
358 $php_version_string,
359 'li_used_php_version'
364 echo ' </ul>';
365 echo ' </div>';
368 echo '<div class="group pmagroup">';
369 echo '<h2>phpMyAdmin</h2>';
370 echo '<ul>';
371 $class = null;
372 if ($GLOBALS['cfg']['VersionCheck']) {
373 $class = 'jsversioncheck';
375 PMA_printListItem(
376 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
377 'li_pma_version',
378 null,
379 null,
380 null,
381 null,
382 $class
384 PMA_printListItem(
385 __('Documentation'),
386 'li_pma_docs',
387 PMA\libraries\Util::getDocuLink('index'),
388 null,
389 '_blank'
392 // does not work if no target specified, don't know why
393 PMA_printListItem(
394 __('Official Homepage'),
395 'li_pma_homepage',
396 PMA_linkURL('https://www.phpMyAdmin.net/'),
397 null,
398 '_blank'
400 PMA_printListItem(
401 __('Contribute'),
402 'li_pma_contribute',
403 PMA_linkURL('https://www.phpmyadmin.net/contribute/'),
404 null,
405 '_blank'
407 PMA_printListItem(
408 __('Get support'),
409 'li_pma_support',
410 PMA_linkURL('https://www.phpmyadmin.net/support/'),
411 null,
412 '_blank'
414 PMA_printListItem(
415 __('List of changes'),
416 'li_pma_changes',
417 'changelog.php' . URL::getCommon(),
418 null,
419 '_blank'
421 PMA_printListItem(
422 __('License'),
423 'li_pma_license',
424 'license.php' . URL::getCommon(),
425 null,
426 '_blank'
428 echo ' </ul>';
429 echo ' </div>';
431 echo '</div>';
433 echo '</div>';
436 * mbstring is used for handling multibytes inside parser, so it is good
437 * to tell user something might be broken without it, see bug #1063149.
439 if (! @extension_loaded('mbstring')) {
440 trigger_error(
442 'The mbstring PHP extension was not found and you seem to be using'
443 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
444 . ' is unable to split strings correctly and it may result in'
445 . ' unexpected results.'
447 E_USER_WARNING
452 * Missing functionality
454 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
455 trigger_error(
457 'The curl extension was not found and allow_url_fopen is '
458 . 'disabled. Due to this some features such as error reporting '
459 . 'or version check are disabled.'
464 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
466 * Check whether session.gc_maxlifetime limits session validity.
468 $gc_time = (int)@ini_get('session.gc_maxlifetime');
469 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
470 trigger_error(
472 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
473 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
474 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
475 'in phpMyAdmin, because of this, your login might expire sooner ' .
476 'than configured in phpMyAdmin.'
478 E_USER_WARNING
484 * Check whether LoginCookieValidity is limited by LoginCookieStore.
486 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
487 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
489 trigger_error(
491 'Login cookie store is lower than cookie validity configured in ' .
492 'phpMyAdmin, because of this, your login will expire sooner than ' .
493 'configured in phpMyAdmin.'
495 E_USER_WARNING
500 * Check if user does not have defined blowfish secret and it is being used.
502 if (! empty($_SESSION['encryption_key'])) {
503 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
504 trigger_error(
506 'The configuration file now needs a secret passphrase (blowfish_secret).'
508 E_USER_WARNING
510 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
511 trigger_error(
513 'The secret passphrase in configuration (blowfish_secret) is too short.'
515 E_USER_WARNING
521 * Check for existence of config directory which should not exist in
522 * production environment.
524 if (@file_exists('config')) {
525 trigger_error(
527 'Directory [code]config[/code], which is used by the setup script, ' .
528 'still exists in your phpMyAdmin directory. It is strongly ' .
529 'recommended to remove it once phpMyAdmin has been configured. ' .
530 'Otherwise the security of your server may be compromised by ' .
531 'unauthorized people downloading your configuration.'
533 E_USER_WARNING
537 if ($server > 0) {
538 $cfgRelation = PMA_getRelationsParam();
539 if (! $cfgRelation['allworks']
540 && $cfg['PmaNoRelation_DisableWarning'] == false
542 $msg_text = __(
543 'The phpMyAdmin configuration storage is not completely '
544 . 'configured, some extended features have been deactivated. '
545 . '%sFind out why%s. '
547 if ($cfg['ZeroConf'] == true) {
548 $msg_text .= '<br>' .
550 'Or alternately go to \'Operations\' tab of any database '
551 . 'to set it up there.'
554 $msg = PMA\libraries\Message::notice($msg_text);
555 $msg->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
556 $msg->addParamHtml('</a>');
557 /* Show error if user has configured something, notice elsewhere */
558 if (!empty($cfg['Servers'][$server]['pmadb'])) {
559 $msg->isError(true);
561 $msg->display();
562 } // end if
566 * Warning about different MySQL library and server version
567 * (a difference on the third digit does not count).
568 * If someday there is a constant that we can check about mysqlnd,
569 * we can use it instead of strpos().
570 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
571 * We also do not warn if MariaDB is detected, as it has its own version
572 * numbering.
574 if (isset($GLOBALS['dbi'])
575 && $cfg['ServerLibraryDifference_DisableWarning'] == false
577 $_client_info = $GLOBALS['dbi']->getClientInfo();
578 if ($server > 0
579 && mb_strpos($_client_info, 'mysqlnd') === false
580 && mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') === false
581 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(
582 PMA_MYSQL_INT_VERSION, 0, 3
585 trigger_error(
586 Sanitize::sanitize(
587 sprintf(
589 'Your PHP MySQL library version %s differs from your ' .
590 'MySQL server version %s. This may cause unpredictable ' .
591 'behavior.'
593 $_client_info,
594 substr(
595 PMA_MYSQL_STR_VERSION,
597 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
601 E_USER_NOTICE
604 unset($_client_info);
608 * Warning about Suhosin only if its simulation mode is not enabled
610 if ($cfg['SuhosinDisableWarning'] == false
611 && @ini_get('suhosin.request.max_value_length')
612 && @ini_get('suhosin.simulation') == '0'
614 trigger_error(
615 sprintf(
617 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
618 'for possible issues.'
620 '[doc@faq1-38]',
621 '[/doc]'
623 E_USER_WARNING
628 * Warning about incomplete translations.
630 * The data file is created while creating release by ./scripts/remove-incomplete-mo
632 if (@file_exists('libraries/language_stats.inc.php')) {
633 include 'libraries/language_stats.inc.php';
635 * This message is intentionally not translated, because we're
636 * handling incomplete translations here and focus on english
637 * speaking users.
639 if (isset($GLOBALS['language_stats'][$lang])
640 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
642 trigger_error(
643 'You are using an incomplete translation, please help to make it '
644 . 'better by [a@https://www.phpmyadmin.net/translate/'
645 . '@_blank]contributing[/a].',
646 E_USER_NOTICE
652 * prints list item for main page
654 * @param string $name displayed text
655 * @param string $listId id, used for css styles
656 * @param string $url make item as link with $url as target
657 * @param string $mysql_help_page display a link to MySQL's manual
658 * @param string $target special target for $url
659 * @param string $a_id id for the anchor,
660 * used for jQuery to hook in functions
661 * @param string $class class for the li element
662 * @param string $a_class class for the anchor element
664 * @return void
666 function PMA_printListItem($name, $listId = null, $url = null,
667 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
668 $a_class = null
670 echo PMA\libraries\Template::get('list/item')
671 ->render(
672 array(
673 'content' => $name,
674 'id' => $listId,
675 'class' => $class,
676 'url' => array(
677 'href' => $url,
678 'target' => $target,
679 'id' => $a_id,
680 'class' => $a_class,
682 'mysql_help_page' => $mysql_help_page,