Translated using Weblate (Estonian)
[phpmyadmin.git] / index.php
blobb67f5402fa4742c18d34628792c406dfae58c0b2
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Main loader script
6 * @package PhpMyAdmin
7 */
9 use PhpMyAdmin\Charsets;
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\ThemeManager;
19 use PhpMyAdmin\Url;
21 /**
22 * Gets some core libraries and displays a top message if required
24 require_once 'libraries/common.inc.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 = PhpMyAdmin\Util::getScriptNameForOption(
72 $GLOBALS['cfg']['DefaultTabTable'], 'table'
74 } else {
75 $page = PhpMyAdmin\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 GitRevision::print();
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 PhpMyAdmin\Util::getMessage($message);
111 unset($message);
113 if (isset($_SESSION['partial_logout'])) {
114 Message::success(
115 __('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
116 )->display();
117 unset($_SESSION['partial_logout']);
120 $common_url_query = Url::getCommon();
121 $mysql_cur_user_and_host = '';
123 // when $server > 0, a server has been chosen so we can display
124 // all MySQL-related information
125 if ($server > 0) {
126 include 'libraries/server_common.inc.php';
128 // Use the verbose name of the server instead of the hostname
129 // if a value is set
130 $server_info = '';
131 if (! empty($cfg['Server']['verbose'])) {
132 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
133 if ($GLOBALS['cfg']['ShowServerInfo']) {
134 $server_info .= ' (';
137 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
138 $server_info .= $GLOBALS['dbi']->getHostInfo();
140 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
141 $server_info .= ')';
143 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
145 // should we add the port info here?
146 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
147 ? $GLOBALS['cfg']['Server']['verbose']
148 : $GLOBALS['cfg']['Server']['host']);
151 echo '<div id="maincontainer">' , "\n";
152 // Anchor for favorite tables synchronization.
153 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
154 echo '<div id="main_pane_left">';
155 if ($server > 0 || count($cfg['Servers']) > 1
157 if ($cfg['DBG']['demo']) {
158 echo '<div class="group">';
159 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
160 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
161 printf(
163 'You are using the demo server. You can do anything here, but '
164 . 'please do not change root, debian-sys-maint and pma users. '
165 . 'More information is available at %s.'
167 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
169 echo '</p>';
170 echo '</div>';
172 echo '<div class="group">';
173 echo '<h2>' , __('General settings') , '</h2>';
174 echo '<ul>';
177 * Displays the MySQL servers choice form
179 if ($cfg['ServerDefault'] == 0
180 || (! $cfg['NavigationDisplayServers']
181 && (count($cfg['Servers']) > 1
182 || ($server == 0 && count($cfg['Servers']) == 1)))
184 echo '<li id="li_select_server" class="no_bullets" >';
185 include_once 'libraries/select_server.lib.php';
186 echo PhpMyAdmin\Util::getImage('s_host.png') , " "
187 , PMA_selectServer(true, true);
188 echo '</li>';
192 * Displays the mysql server related links
194 if ($server > 0) {
195 include_once 'libraries/check_user_privileges.lib.php';
197 // Logout for advanced authentication
198 if ($cfg['Server']['auth_type'] != 'config') {
199 if ($cfg['ShowChgPassword']) {
200 $conditional_class = 'ajax';
201 PMA_printListItem(
202 PhpMyAdmin\Util::getImage('s_passwd.png') . "&nbsp;" . __(
203 'Change password'
205 'li_change_password',
206 'user_password.php' . $common_url_query,
207 null,
208 null,
209 'change_password_anchor',
210 "no_bullets",
211 $conditional_class
214 } // end if
215 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
216 echo ' <form method="post" action="index.php">' , "\n"
217 . Url::getHiddenInputs(null, null, 4, 'collation_connection')
218 . ' <label for="select_collation_connection">' . "\n"
219 . ' ' . PhpMyAdmin\Util::getImage('s_asci.png')
220 . "&nbsp;" . __('Server connection collation') . "\n"
221 // put the doc link in the form so that it appears on the same line
222 . PhpMyAdmin\Util::showMySQLDocu('Charset-connection')
223 . ': ' . "\n"
224 . ' </label>' . "\n"
226 . Charsets::getCollationDropdownBox(
227 'collation_connection',
228 'select_collation_connection',
229 $collation_connection,
230 true,
231 true
233 . ' </form>' . "\n"
234 . ' </li>' . "\n";
235 } // end of if ($server > 0)
236 echo '</ul>';
237 echo '</div>';
240 echo '<div class="group">';
241 echo '<h2>' , __('Appearance settings') , '</h2>';
242 echo ' <ul>';
244 // Displays language selection combo
245 $language_manager = LanguageManager::getInstance();
246 if (empty($cfg['Lang']) && $language_manager->hasChoice()) {
247 echo '<li id="li_select_lang" class="no_bullets">';
249 echo PhpMyAdmin\Util::getImage('s_lang.png') , " "
250 , $language_manager->getSelectorDisplay();
251 echo '</li>';
254 // ThemeManager if available
256 if ($GLOBALS['cfg']['ThemeManager']) {
257 echo '<li id="li_select_theme" class="no_bullets">';
258 echo PhpMyAdmin\Util::getImage('s_theme.png') , " "
259 , ThemeManager::getInstance()->getHtmlSelectBox();
260 echo '</li>';
262 echo '<li id="li_select_fontsize">';
263 echo PhpMyAdmin\Config::getFontsizeForm();
264 echo '</li>';
266 echo '</ul>';
268 // User preferences
270 if ($server > 0) {
271 echo '<ul>';
272 PMA_printListItem(
273 PhpMyAdmin\Util::getImage('b_tblops.png') . "&nbsp;" . __(
274 'More settings'
276 'li_user_preferences',
277 'prefs_manage.php' . $common_url_query,
278 null,
279 null,
280 null,
281 "no_bullets"
283 echo '</ul>';
286 echo '</div>';
289 echo '</div>';
290 echo '<div id="main_pane_right">';
293 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
295 echo '<div class="group">';
296 echo '<h2>' , __('Database server') , '</h2>';
297 echo '<ul>' , "\n";
298 PMA_printListItem(
299 __('Server:') . ' ' . $server_info,
300 'li_server_info'
302 PMA_printListItem(
303 __('Server type:') . ' ' . PhpMyAdmin\Util::getServerType(),
304 'li_server_type'
306 PMA_printListItem(
307 __('Server connection:') . ' ' . PhpMyAdmin\Util::getServerSSL(),
308 'li_server_type'
310 PMA_printListItem(
311 __('Server version:')
312 . ' '
313 . $GLOBALS['dbi']->getVersionString() . ' - ' . $GLOBALS['dbi']->getVersionComment(),
314 'li_server_version'
316 PMA_printListItem(
317 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
318 'li_mysql_proto'
320 PMA_printListItem(
321 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
322 'li_user_info'
325 echo ' <li id="li_select_mysql_charset">';
326 echo ' ' , __('Server charset:') , ' '
327 . ' <span lang="en" dir="ltr">';
328 $unicode = Charsets::$mysql_charset_map['utf-8'];
329 $charsets = Charsets::getMySQLCharsetsDescriptions();
330 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
331 echo ' </span>'
332 . ' </li>'
333 . ' </ul>'
334 . ' </div>';
337 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
338 echo '<div class="group">';
339 echo '<h2>' , __('Web server') , '</h2>';
340 echo '<ul>';
341 if ($GLOBALS['cfg']['ShowServerInfo']) {
342 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
344 if ($server > 0) {
345 $client_version_str = $GLOBALS['dbi']->getClientInfo();
346 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
347 $client_version_str = 'libmysql - ' . $client_version_str;
349 PMA_printListItem(
350 __('Database client version:') . ' ' . $client_version_str,
351 'li_mysql_client_version'
354 $php_ext_string = __('PHP extension:') . ' ';
356 $extensions = PhpMyAdmin\Util::listPHPExtensions();
358 foreach ($extensions as $extension) {
359 $php_ext_string .= ' ' . $extension
360 . PhpMyAdmin\Util::showPHPDocu('book.' . $extension . '.php');
363 PMA_printListItem(
364 $php_ext_string,
365 'li_used_php_extension'
368 $php_version_string = __('PHP version:') . ' ' . phpversion();
370 PMA_printListItem(
371 $php_version_string,
372 'li_used_php_version'
377 if ($cfg['ShowPhpInfo']) {
378 PMA_printListItem(
379 __('Show PHP information'),
380 'li_phpinfo',
381 'phpinfo.php' . $common_url_query,
382 null,
383 '_blank'
386 echo ' </ul>';
387 echo ' </div>';
390 echo '<div class="group pmagroup">';
391 echo '<h2>phpMyAdmin</h2>';
392 echo '<ul>';
393 $class = null;
394 if ($GLOBALS['cfg']['VersionCheck']) {
395 $class = 'jsversioncheck';
397 PMA_printListItem(
398 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
399 'li_pma_version',
400 null,
401 null,
402 null,
403 null,
404 $class
406 PMA_printListItem(
407 __('Documentation'),
408 'li_pma_docs',
409 PhpMyAdmin\Util::getDocuLink('index'),
410 null,
411 '_blank'
414 // does not work if no target specified, don't know why
415 PMA_printListItem(
416 __('Official Homepage'),
417 'li_pma_homepage',
418 Core::linkURL('https://www.phpmyadmin.net/'),
419 null,
420 '_blank'
422 PMA_printListItem(
423 __('Contribute'),
424 'li_pma_contribute',
425 Core::linkURL('https://www.phpmyadmin.net/contribute/'),
426 null,
427 '_blank'
429 PMA_printListItem(
430 __('Get support'),
431 'li_pma_support',
432 Core::linkURL('https://www.phpmyadmin.net/support/'),
433 null,
434 '_blank'
436 PMA_printListItem(
437 __('List of changes'),
438 'li_pma_changes',
439 'changelog.php' . Url::getCommon(),
440 null,
441 '_blank'
443 PMA_printListItem(
444 __('License'),
445 'li_pma_license',
446 'license.php' . Url::getCommon(),
447 null,
448 '_blank'
450 echo ' </ul>';
451 echo ' </div>';
453 echo '</div>';
455 echo '</div>';
458 * mbstring is used for handling multibytes inside parser, so it is good
459 * to tell user something might be broken without it, see bug #1063149.
461 if (! @extension_loaded('mbstring')) {
462 trigger_error(
464 'The mbstring PHP extension was not found and you seem to be using'
465 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
466 . ' is unable to split strings correctly and it may result in'
467 . ' unexpected results.'
469 E_USER_WARNING
474 * Missing functionality
476 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
477 trigger_error(
479 'The curl extension was not found and allow_url_fopen is '
480 . 'disabled. Due to this some features such as error reporting '
481 . 'or version check are disabled.'
486 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
488 * Check whether session.gc_maxlifetime limits session validity.
490 $gc_time = (int)@ini_get('session.gc_maxlifetime');
491 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
492 trigger_error(
494 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
495 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
496 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
497 'in phpMyAdmin, because of this, your login might expire sooner ' .
498 'than configured in phpMyAdmin.'
500 E_USER_WARNING
506 * Check whether LoginCookieValidity is limited by LoginCookieStore.
508 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
509 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
511 trigger_error(
513 'Login cookie store is lower than cookie validity configured in ' .
514 'phpMyAdmin, because of this, your login will expire sooner than ' .
515 'configured in phpMyAdmin.'
517 E_USER_WARNING
522 * Check if user does not have defined blowfish secret and it is being used.
524 if (! empty($_SESSION['encryption_key'])) {
525 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
526 trigger_error(
528 'The configuration file now needs a secret passphrase (blowfish_secret).'
530 E_USER_WARNING
532 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
533 trigger_error(
535 'The secret passphrase in configuration (blowfish_secret) is too short.'
537 E_USER_WARNING
543 * Check for existence of config directory which should not exist in
544 * production environment.
546 if (@file_exists('config')) {
547 trigger_error(
549 'Directory [code]config[/code], which is used by the setup script, ' .
550 'still exists in your phpMyAdmin directory. It is strongly ' .
551 'recommended to remove it once phpMyAdmin has been configured. ' .
552 'Otherwise the security of your server may be compromised by ' .
553 'unauthorized people downloading your configuration.'
555 E_USER_WARNING
559 if ($server > 0) {
560 $cfgRelation = Relation::getRelationsParam();
561 if (! $cfgRelation['allworks']
562 && $cfg['PmaNoRelation_DisableWarning'] == false
564 $msg_text = __(
565 'The phpMyAdmin configuration storage is not completely '
566 . 'configured, some extended features have been deactivated. '
567 . '%sFind out why%s. '
569 if ($cfg['ZeroConf'] == true) {
570 $msg_text .= '<br>' .
572 'Or alternately go to \'Operations\' tab of any database '
573 . 'to set it up there.'
576 $msg = PhpMyAdmin\Message::notice($msg_text);
577 $msg->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
578 $msg->addParamHtml('</a>');
579 /* Show error if user has configured something, notice elsewhere */
580 if (!empty($cfg['Servers'][$server]['pmadb'])) {
581 $msg->isError(true);
583 $msg->display();
584 } // end if
588 * Warning about Suhosin only if its simulation mode is not enabled
590 if ($cfg['SuhosinDisableWarning'] == false
591 && @ini_get('suhosin.request.max_value_length')
592 && @ini_get('suhosin.simulation') == '0'
594 trigger_error(
595 sprintf(
597 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
598 'for possible issues.'
600 '[doc@faq1-38]',
601 '[/doc]'
603 E_USER_WARNING
607 /* Missing template cache */
608 if (is_null($GLOBALS['PMA_Config']->getTempDir('twig'))) {
609 trigger_error(
610 sprintf(
611 __('The $cfg[\'TempDir\'] (%s) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.'),
612 $GLOBALS['PMA_Config']->get('TempDir')
614 E_USER_WARNING
619 * Warning about incomplete translations.
621 * The data file is created while creating release by ./scripts/remove-incomplete-mo
623 if (@file_exists('libraries/language_stats.inc.php')) {
624 include 'libraries/language_stats.inc.php';
626 * This message is intentionally not translated, because we're
627 * handling incomplete translations here and focus on english
628 * speaking users.
630 if (isset($GLOBALS['language_stats'][$lang])
631 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
633 trigger_error(
634 'You are using an incomplete translation, please help to make it '
635 . 'better by [a@https://www.phpmyadmin.net/translate/'
636 . '@_blank]contributing[/a].',
637 E_USER_NOTICE
643 * prints list item for main page
645 * @param string $name displayed text
646 * @param string $listId id, used for css styles
647 * @param string $url make item as link with $url as target
648 * @param string $mysql_help_page display a link to MySQL's manual
649 * @param string $target special target for $url
650 * @param string $a_id id for the anchor,
651 * used for jQuery to hook in functions
652 * @param string $class class for the li element
653 * @param string $a_class class for the anchor element
655 * @return void
657 function PMA_printListItem($name, $listId = null, $url = null,
658 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
659 $a_class = null
661 echo PhpMyAdmin\Template::get('list/item')
662 ->render(
663 array(
664 'content' => $name,
665 'id' => $listId,
666 'class' => $class,
667 'url' => array(
668 'href' => $url,
669 'target' => $target,
670 'id' => $a_id,
671 'class' => $a_class,
673 'mysql_help_page' => $mysql_help_page,