Translated using Weblate (Estonian)
[phpmyadmin.git] / index.php
blob2d9bb25e385e9023e9444bcabcffd8107c4ee138
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\Response;
9 use PMA\libraries\RecentFavoriteTable;
10 use PMA\libraries\URL;
11 use PMA\libraries\Sanitize;
12 use PMA\libraries\Charsets;
13 use PMA\libraries\ThemeManager;
14 use PMA\libraries\LanguageManager;
16 /**
17 * Gets some core libraries and displays a top message if required
19 require_once 'libraries/common.inc.php';
21 /**
22 * display Git revision if requested
24 require_once 'libraries/display_git_revision.lib.php';
26 /**
27 * pass variables to child pages
29 $drops = array(
30 'lang',
31 'server',
32 'collation_connection',
33 'db',
34 'table'
36 foreach ($drops as $each_drop) {
37 if (array_key_exists($each_drop, $_GET)) {
38 unset($_GET[$each_drop]);
41 unset($drops, $each_drop);
44 * Black list of all scripts to which front-end must submit data.
45 * Such scripts must not be loaded on home page.
48 $target_blacklist = array (
49 'import.php', 'export.php'
52 // If we have a valid target, let's load that script instead
53 if (! empty($_REQUEST['target'])
54 && is_string($_REQUEST['target'])
55 && ! preg_match('/^index/', $_REQUEST['target'])
56 && ! in_array($_REQUEST['target'], $target_blacklist)
57 && in_array($_REQUEST['target'], $goto_whitelist)
58 ) {
59 include $_REQUEST['target'];
60 exit;
63 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
64 exit;
67 // See FAQ 1.34
68 if (! empty($_REQUEST['db'])) {
69 $page = null;
70 if (! empty($_REQUEST['table'])) {
71 $page = PMA\libraries\Util::getScriptNameForOption(
72 $GLOBALS['cfg']['DefaultTabTable'], 'table'
74 } else {
75 $page = PMA\libraries\Util::getScriptNameForOption(
76 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
79 include $page;
80 exit;
83 $response = Response::getInstance();
84 /**
85 * Check if it is an ajax request to reload the recent tables list.
87 if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
88 $response->addJSON(
89 'list',
90 RecentFavoriteTable::getInstance('recent')->getHtmlList()
92 exit;
95 if ($GLOBALS['PMA_Config']->isGitRevision()) {
96 if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
97 PMA_printGitRevision();
98 exit;
100 echo '<div id="is_git_revision"></div>';
103 // Handles some variables that may have been sent by the calling script
104 $GLOBALS['db'] = '';
105 $GLOBALS['table'] = '';
106 $show_query = '1';
108 // Any message to display?
109 if (! empty($message)) {
110 echo PMA\libraries\Util::getMessage($message);
111 unset($message);
114 $common_url_query = URL::getCommon();
115 $mysql_cur_user_and_host = '';
117 // when $server > 0, a server has been chosen so we can display
118 // all MySQL-related information
119 if ($server > 0) {
120 include 'libraries/server_common.inc.php';
122 // Use the verbose name of the server instead of the hostname
123 // if a value is set
124 $server_info = '';
125 if (! empty($cfg['Server']['verbose'])) {
126 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
127 if ($GLOBALS['cfg']['ShowServerInfo']) {
128 $server_info .= ' (';
131 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
132 $server_info .= $GLOBALS['dbi']->getHostInfo();
134 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
135 $server_info .= ')';
137 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
139 // should we add the port info here?
140 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
141 ? $GLOBALS['cfg']['Server']['verbose']
142 : $GLOBALS['cfg']['Server']['host']);
145 echo '<div id="maincontainer">' , "\n";
146 // Anchor for favorite tables synchronization.
147 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
148 echo '<div id="main_pane_left">';
149 if ($server > 0 || count($cfg['Servers']) > 1
151 if ($cfg['DBG']['demo']) {
152 echo '<div class="group">';
153 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
154 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
155 printf(
157 'You are using the demo server. You can do anything here, but '
158 . 'please do not change root, debian-sys-maint and pma users. '
159 . 'More information is available at %s.'
161 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
163 echo '</p>';
164 echo '</div>';
166 echo '<div class="group">';
167 echo '<h2>' , __('General settings') , '</h2>';
168 echo '<ul>';
171 * Displays the MySQL servers choice form
173 if ($cfg['ServerDefault'] == 0
174 || (! $cfg['NavigationDisplayServers']
175 && (count($cfg['Servers']) > 1
176 || ($server == 0 && count($cfg['Servers']) == 1)))
178 echo '<li id="li_select_server" class="no_bullets" >';
179 include_once 'libraries/select_server.lib.php';
180 echo PMA\libraries\Util::getImage('s_host.png') , " "
181 , PMA_selectServer(true, true);
182 echo '</li>';
186 * Displays the mysql server related links
188 if ($server > 0) {
189 include_once 'libraries/check_user_privileges.lib.php';
191 // Logout for advanced authentication
192 if ($cfg['Server']['auth_type'] != 'config') {
193 if ($cfg['ShowChgPassword']) {
194 $conditional_class = 'ajax';
195 PMA_printListItem(
196 PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __(
197 'Change password'
199 'li_change_password',
200 'user_password.php' . $common_url_query,
201 null,
202 null,
203 'change_password_anchor',
204 "no_bullets",
205 $conditional_class
208 } // end if
209 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
210 echo ' <form method="post" action="index.php">' , "\n"
211 . URL::getHiddenInputs(null, null, 4, 'collation_connection')
212 . ' <label for="select_collation_connection">' . "\n"
213 . ' ' . PMA\libraries\Util::getImage('s_asci.png')
214 . "&nbsp;" . __('Server connection collation') . "\n"
215 // put the doc link in the form so that it appears on the same line
216 . PMA\libraries\Util::showMySQLDocu('Charset-connection')
217 . ': ' . "\n"
218 . ' </label>' . "\n"
220 . Charsets::getCollationDropdownBox(
221 'collation_connection',
222 'select_collation_connection',
223 $collation_connection,
224 true,
225 true
227 . ' </form>' . "\n"
228 . ' </li>' . "\n";
229 } // end of if ($server > 0)
230 echo '</ul>';
231 echo '</div>';
234 echo '<div class="group">';
235 echo '<h2>' , __('Appearance settings') , '</h2>';
236 echo ' <ul>';
238 // Displays language selection combo
239 if (empty($cfg['Lang'])) {
240 echo '<li id="li_select_lang" class="no_bullets">';
242 echo PMA\libraries\Util::getImage('s_lang.png') , " "
243 , LanguageManager::getInstance()->getSelectorDisplay();
244 echo '</li>';
247 // ThemeManager if available
249 if ($GLOBALS['cfg']['ThemeManager']) {
250 echo '<li id="li_select_theme" class="no_bullets">';
251 echo PMA\libraries\Util::getImage('s_theme.png') , " "
252 , ThemeManager::getInstance()->getHtmlSelectBox();
253 echo '</li>';
255 echo '<li id="li_select_fontsize">';
256 echo PMA\libraries\Config::getFontsizeForm();
257 echo '</li>';
259 echo '</ul>';
261 // User preferences
263 if ($server > 0) {
264 echo '<ul>';
265 PMA_printListItem(
266 PMA\libraries\Util::getImage('b_tblops.png') . "&nbsp;" . __(
267 'More settings'
269 'li_user_preferences',
270 'prefs_manage.php' . $common_url_query,
271 null,
272 null,
273 null,
274 "no_bullets"
276 echo '</ul>';
279 echo '</div>';
282 echo '</div>';
283 echo '<div id="main_pane_right">';
286 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
288 echo '<div class="group">';
289 echo '<h2>' , __('Database server') , '</h2>';
290 echo '<ul>' , "\n";
291 PMA_printListItem(
292 __('Server:') . ' ' . $server_info,
293 'li_server_info'
295 PMA_printListItem(
296 __('Server type:') . ' ' . PMA\libraries\Util::getServerType(),
297 'li_server_type'
299 PMA_printListItem(
300 __('Server version:')
301 . ' '
302 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
303 'li_server_version'
305 PMA_printListItem(
306 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
307 'li_mysql_proto'
309 PMA_printListItem(
310 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
311 'li_user_info'
314 echo ' <li id="li_select_mysql_charset">';
315 echo ' ' , __('Server charset:') , ' '
316 . ' <span lang="en" dir="ltr">';
317 $unicode = Charsets::$mysql_charset_map['utf-8'];
318 $charsets = Charsets::getMySQLCharsetsDescriptions();
319 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
320 echo ' </span>'
321 . ' </li>'
322 . ' </ul>'
323 . ' </div>';
326 if ($GLOBALS['cfg']['ShowServerInfo']) {
327 echo '<div class="group">';
328 echo '<h2>' , __('Web server') , '</h2>';
329 echo '<ul>';
330 if ($GLOBALS['cfg']['ShowServerInfo']) {
331 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
333 if ($server > 0) {
334 $client_version_str = $GLOBALS['dbi']->getClientInfo();
335 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
336 $client_version_str = 'libmysql - ' . $client_version_str;
338 PMA_printListItem(
339 __('Database client version:') . ' ' . $client_version_str,
340 'li_mysql_client_version'
343 $php_ext_string = __('PHP extension:') . ' ';
345 $extensions = PMA\libraries\Util::listPHPExtensions();
347 foreach ($extensions as $extension) {
348 $php_ext_string .= ' ' . $extension
349 . PMA\libraries\Util::showPHPDocu('book.' . $extension . '.php');
352 PMA_printListItem(
353 $php_ext_string,
354 'li_used_php_extension'
357 $php_version_string = __('PHP version:') . ' ' . phpversion();
359 PMA_printListItem(
360 $php_version_string,
361 'li_used_php_version'
366 echo ' </ul>';
367 echo ' </div>';
370 echo '<div class="group pmagroup">';
371 echo '<h2>phpMyAdmin</h2>';
372 echo '<ul>';
373 $class = null;
374 if ($GLOBALS['cfg']['VersionCheck']) {
375 $class = 'jsversioncheck';
377 PMA_printListItem(
378 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
379 'li_pma_version',
380 null,
381 null,
382 null,
383 null,
384 $class
386 PMA_printListItem(
387 __('Documentation'),
388 'li_pma_docs',
389 PMA\libraries\Util::getDocuLink('index'),
390 null,
391 '_blank'
394 // does not work if no target specified, don't know why
395 PMA_printListItem(
396 __('Official Homepage'),
397 'li_pma_homepage',
398 PMA_linkURL('https://www.phpmyadmin.net/'),
399 null,
400 '_blank'
402 PMA_printListItem(
403 __('Contribute'),
404 'li_pma_contribute',
405 PMA_linkURL('https://www.phpmyadmin.net/contribute/'),
406 null,
407 '_blank'
409 PMA_printListItem(
410 __('Get support'),
411 'li_pma_support',
412 PMA_linkURL('https://www.phpmyadmin.net/support/'),
413 null,
414 '_blank'
416 PMA_printListItem(
417 __('List of changes'),
418 'li_pma_changes',
419 'changelog.php' . URL::getCommon(),
420 null,
421 '_blank'
423 PMA_printListItem(
424 __('License'),
425 'li_pma_license',
426 'license.php' . URL::getCommon(),
427 null,
428 '_blank'
430 echo ' </ul>';
431 echo ' </div>';
433 echo '</div>';
435 echo '</div>';
438 * mbstring is used for handling multibytes inside parser, so it is good
439 * to tell user something might be broken without it, see bug #1063149.
441 if (! @extension_loaded('mbstring')) {
442 trigger_error(
444 'The mbstring PHP extension was not found and you seem to be using'
445 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
446 . ' is unable to split strings correctly and it may result in'
447 . ' unexpected results.'
449 E_USER_WARNING
454 * Missing functionality
456 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
457 trigger_error(
459 'The curl extension was not found and allow_url_fopen is '
460 . 'disabled. Due to this some features such as error reporting '
461 . 'or version check are disabled.'
466 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
468 * Check whether session.gc_maxlifetime limits session validity.
470 $gc_time = (int)@ini_get('session.gc_maxlifetime');
471 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
472 trigger_error(
474 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
475 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
476 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
477 'in phpMyAdmin, because of this, your login might expire sooner ' .
478 'than configured in phpMyAdmin.'
480 E_USER_WARNING
486 * Check whether LoginCookieValidity is limited by LoginCookieStore.
488 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
489 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
491 trigger_error(
493 'Login cookie store is lower than cookie validity configured in ' .
494 'phpMyAdmin, because of this, your login will expire sooner than ' .
495 'configured in phpMyAdmin.'
497 E_USER_WARNING
502 * Check if user does not have defined blowfish secret and it is being used.
504 if (! empty($_SESSION['encryption_key'])) {
505 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
506 trigger_error(
508 'The configuration file now needs a secret passphrase (blowfish_secret).'
510 E_USER_WARNING
512 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
513 trigger_error(
515 'The secret passphrase in configuration (blowfish_secret) is too short.'
517 E_USER_WARNING
523 * Check for existence of config directory which should not exist in
524 * production environment.
526 if (@file_exists('config')) {
527 trigger_error(
529 'Directory [code]config[/code], which is used by the setup script, ' .
530 'still exists in your phpMyAdmin directory. It is strongly ' .
531 'recommended to remove it once phpMyAdmin has been configured. ' .
532 'Otherwise the security of your server may be compromised by ' .
533 'unauthorized people downloading your configuration.'
535 E_USER_WARNING
539 if ($server > 0) {
540 $cfgRelation = PMA_getRelationsParam();
541 if (! $cfgRelation['allworks']
542 && $cfg['PmaNoRelation_DisableWarning'] == false
544 $msg_text = __(
545 'The phpMyAdmin configuration storage is not completely '
546 . 'configured, some extended features have been deactivated. '
547 . '%sFind out why%s. '
549 if ($cfg['ZeroConf'] == true) {
550 $msg_text .= '<br>' .
552 'Or alternately go to \'Operations\' tab of any database '
553 . 'to set it up there.'
556 $msg = PMA\libraries\Message::notice($msg_text);
557 $msg->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
558 $msg->addParamHtml('</a>');
559 /* Show error if user has configured something, notice elsewhere */
560 if (!empty($cfg['Servers'][$server]['pmadb'])) {
561 $msg->isError(true);
563 $msg->display();
564 } // end if
568 * Warning about different MySQL library and server version
569 * (a difference on the third digit does not count).
570 * If someday there is a constant that we can check about mysqlnd,
571 * we can use it instead of strpos().
572 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
573 * We also do not warn if MariaDB is detected, as it has its own version
574 * numbering.
576 if (isset($GLOBALS['dbi'])
577 && $cfg['ServerLibraryDifference_DisableWarning'] == false
579 $_client_info = $GLOBALS['dbi']->getClientInfo();
580 if ($server > 0
581 && mb_strpos($_client_info, 'mysqlnd') === false
582 && mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') === false
583 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(
584 PMA_MYSQL_INT_VERSION, 0, 3
587 trigger_error(
588 Sanitize::sanitize(
589 sprintf(
591 'Your PHP MySQL library version %s differs from your ' .
592 'MySQL server version %s. This may cause unpredictable ' .
593 'behavior.'
595 $_client_info,
596 substr(
597 PMA_MYSQL_STR_VERSION,
599 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
603 E_USER_NOTICE
606 unset($_client_info);
610 * Warning about Suhosin only if its simulation mode is not enabled
612 if ($cfg['SuhosinDisableWarning'] == false
613 && @ini_get('suhosin.request.max_value_length')
614 && @ini_get('suhosin.simulation') == '0'
616 trigger_error(
617 sprintf(
619 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
620 'for possible issues.'
622 '[doc@faq1-38]',
623 '[/doc]'
625 E_USER_WARNING
630 * Warning about incomplete translations.
632 * The data file is created while creating release by ./scripts/remove-incomplete-mo
634 if (@file_exists('libraries/language_stats.inc.php')) {
635 include 'libraries/language_stats.inc.php';
637 * This message is intentionally not translated, because we're
638 * handling incomplete translations here and focus on english
639 * speaking users.
641 if (isset($GLOBALS['language_stats'][$lang])
642 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
644 trigger_error(
645 'You are using an incomplete translation, please help to make it '
646 . 'better by [a@https://www.phpmyadmin.net/translate/'
647 . '@_blank]contributing[/a].',
648 E_USER_NOTICE
654 * prints list item for main page
656 * @param string $name displayed text
657 * @param string $listId id, used for css styles
658 * @param string $url make item as link with $url as target
659 * @param string $mysql_help_page display a link to MySQL's manual
660 * @param string $target special target for $url
661 * @param string $a_id id for the anchor,
662 * used for jQuery to hook in functions
663 * @param string $class class for the li element
664 * @param string $a_class class for the anchor element
666 * @return void
668 function PMA_printListItem($name, $listId = null, $url = null,
669 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
670 $a_class = null
672 echo PMA\libraries\Template::get('list/item')
673 ->render(
674 array(
675 'content' => $name,
676 'id' => $listId,
677 'class' => $class,
678 'url' => array(
679 'href' => $url,
680 'target' => $target,
681 'id' => $a_id,
682 'class' => $a_class,
684 'mysql_help_page' => $mysql_help_page,