Translated using Weblate (Norwegian Bokmål)
[phpmyadmin.git] / index.php
blob25a0699904210ef4afc644c4e6ec6a8945b8f565
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\Message;
9 use PMA\libraries\Response;
10 use PMA\libraries\RecentFavoriteTable;
11 use PMA\libraries\URL;
12 use PMA\libraries\Sanitize;
13 use PMA\libraries\Charsets;
14 use PMA\libraries\ThemeManager;
15 use PMA\libraries\LanguageManager;
17 /**
18 * Gets some core libraries and displays a top message if required
20 require_once 'libraries/common.inc.php';
22 /**
23 * display Git revision if requested
25 require_once 'libraries/display_git_revision.lib.php';
27 /**
28 * pass variables to child pages
30 $drops = array(
31 'lang',
32 'server',
33 'collation_connection',
34 'db',
35 'table'
37 foreach ($drops as $each_drop) {
38 if (array_key_exists($each_drop, $_GET)) {
39 unset($_GET[$each_drop]);
42 unset($drops, $each_drop);
45 * Black list of all scripts to which front-end must submit data.
46 * Such scripts must not be loaded on home page.
49 $target_blacklist = array (
50 'import.php', 'export.php'
53 // If we have a valid target, let's load that script instead
54 if (! empty($_REQUEST['target'])
55 && is_string($_REQUEST['target'])
56 && ! preg_match('/^index/', $_REQUEST['target'])
57 && ! in_array($_REQUEST['target'], $target_blacklist)
58 && in_array($_REQUEST['target'], $goto_whitelist)
59 ) {
60 include $_REQUEST['target'];
61 exit;
64 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
65 exit;
68 // See FAQ 1.34
69 if (! empty($_REQUEST['db'])) {
70 $page = null;
71 if (! empty($_REQUEST['table'])) {
72 $page = PMA\libraries\Util::getScriptNameForOption(
73 $GLOBALS['cfg']['DefaultTabTable'], 'table'
75 } else {
76 $page = PMA\libraries\Util::getScriptNameForOption(
77 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
80 include $page;
81 exit;
84 $response = Response::getInstance();
85 /**
86 * Check if it is an ajax request to reload the recent tables list.
88 if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
89 $response->addJSON(
90 'list',
91 RecentFavoriteTable::getInstance('recent')->getHtmlList()
93 exit;
96 if ($GLOBALS['PMA_Config']->isGitRevision()) {
97 if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
98 PMA_printGitRevision();
99 exit;
101 echo '<div id="is_git_revision"></div>';
104 // Handles some variables that may have been sent by the calling script
105 $GLOBALS['db'] = '';
106 $GLOBALS['table'] = '';
107 $show_query = '1';
109 // Any message to display?
110 if (! empty($message)) {
111 echo PMA\libraries\Util::getMessage($message);
112 unset($message);
114 if (isset($_SESSION['partial_logout'])) {
115 Message::success(
116 __('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
117 )->display();
118 unset($_SESSION['partial_logout']);
121 $common_url_query = URL::getCommon();
122 $mysql_cur_user_and_host = '';
124 // when $server > 0, a server has been chosen so we can display
125 // all MySQL-related information
126 if ($server > 0) {
127 include 'libraries/server_common.inc.php';
129 // Use the verbose name of the server instead of the hostname
130 // if a value is set
131 $server_info = '';
132 if (! empty($cfg['Server']['verbose'])) {
133 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
134 if ($GLOBALS['cfg']['ShowServerInfo']) {
135 $server_info .= ' (';
138 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
139 $server_info .= $GLOBALS['dbi']->getHostInfo();
141 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
142 $server_info .= ')';
144 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
146 // should we add the port info here?
147 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
148 ? $GLOBALS['cfg']['Server']['verbose']
149 : $GLOBALS['cfg']['Server']['host']);
152 echo '<div id="maincontainer">' , "\n";
153 // Anchor for favorite tables synchronization.
154 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
155 echo '<div id="main_pane_left">';
156 if ($server > 0 || count($cfg['Servers']) > 1
158 if ($cfg['DBG']['demo']) {
159 echo '<div class="group">';
160 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
161 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
162 printf(
164 'You are using the demo server. You can do anything here, but '
165 . 'please do not change root, debian-sys-maint and pma users. '
166 . 'More information is available at %s.'
168 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
170 echo '</p>';
171 echo '</div>';
173 echo '<div class="group">';
174 echo '<h2>' , __('General settings') , '</h2>';
175 echo '<ul>';
178 * Displays the MySQL servers choice form
180 if ($cfg['ServerDefault'] == 0
181 || (! $cfg['NavigationDisplayServers']
182 && (count($cfg['Servers']) > 1
183 || ($server == 0 && count($cfg['Servers']) == 1)))
185 echo '<li id="li_select_server" class="no_bullets" >';
186 include_once 'libraries/select_server.lib.php';
187 echo PMA\libraries\Util::getImage('s_host.png') , " "
188 , PMA_selectServer(true, true);
189 echo '</li>';
193 * Displays the mysql server related links
195 if ($server > 0) {
196 include_once 'libraries/check_user_privileges.lib.php';
198 // Logout for advanced authentication
199 if ($cfg['Server']['auth_type'] != 'config') {
200 if ($cfg['ShowChgPassword']) {
201 $conditional_class = 'ajax';
202 PMA_printListItem(
203 PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __(
204 'Change password'
206 'li_change_password',
207 'user_password.php' . $common_url_query,
208 null,
209 null,
210 'change_password_anchor',
211 "no_bullets",
212 $conditional_class
215 } // end if
216 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
217 echo ' <form method="post" action="index.php">' , "\n"
218 . URL::getHiddenInputs(null, null, 4, 'collation_connection')
219 . ' <label for="select_collation_connection">' . "\n"
220 . ' ' . PMA\libraries\Util::getImage('s_asci.png')
221 . "&nbsp;" . __('Server connection collation') . "\n"
222 // put the doc link in the form so that it appears on the same line
223 . PMA\libraries\Util::showMySQLDocu('Charset-connection')
224 . ': ' . "\n"
225 . ' </label>' . "\n"
227 . Charsets::getCollationDropdownBox(
228 'collation_connection',
229 'select_collation_connection',
230 $collation_connection,
231 true,
232 true
234 . ' </form>' . "\n"
235 . ' </li>' . "\n";
236 } // end of if ($server > 0)
237 echo '</ul>';
238 echo '</div>';
241 echo '<div class="group">';
242 echo '<h2>' , __('Appearance settings') , '</h2>';
243 echo ' <ul>';
245 // Displays language selection combo
246 $language_manager = LanguageManager::getInstance();
247 if (empty($cfg['Lang']) && $language_manager->hasChoice()) {
248 echo '<li id="li_select_lang" class="no_bullets">';
250 echo PMA\libraries\Util::getImage('s_lang.png') , " "
251 , $language_manager->getSelectorDisplay();
252 echo '</li>';
255 // ThemeManager if available
257 if ($GLOBALS['cfg']['ThemeManager']) {
258 echo '<li id="li_select_theme" class="no_bullets">';
259 echo PMA\libraries\Util::getImage('s_theme.png') , " "
260 , ThemeManager::getInstance()->getHtmlSelectBox();
261 echo '</li>';
263 echo '<li id="li_select_fontsize">';
264 echo PMA\libraries\Config::getFontsizeForm();
265 echo '</li>';
267 echo '</ul>';
269 // User preferences
271 if ($server > 0) {
272 echo '<ul>';
273 PMA_printListItem(
274 PMA\libraries\Util::getImage('b_tblops.png') . "&nbsp;" . __(
275 'More settings'
277 'li_user_preferences',
278 'prefs_manage.php' . $common_url_query,
279 null,
280 null,
281 null,
282 "no_bullets"
284 echo '</ul>';
287 echo '</div>';
290 echo '</div>';
291 echo '<div id="main_pane_right">';
294 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
296 echo '<div class="group">';
297 echo '<h2>' , __('Database server') , '</h2>';
298 echo '<ul>' , "\n";
299 PMA_printListItem(
300 __('Server:') . ' ' . $server_info,
301 'li_server_info'
303 PMA_printListItem(
304 __('Server type:') . ' ' . PMA\libraries\Util::getServerType(),
305 'li_server_type'
307 PMA_printListItem(
308 __('Server version:')
309 . ' '
310 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
311 'li_server_version'
313 PMA_printListItem(
314 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
315 'li_mysql_proto'
317 PMA_printListItem(
318 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
319 'li_user_info'
322 echo ' <li id="li_select_mysql_charset">';
323 echo ' ' , __('Server charset:') , ' '
324 . ' <span lang="en" dir="ltr">';
325 $unicode = Charsets::$mysql_charset_map['utf-8'];
326 $charsets = Charsets::getMySQLCharsetsDescriptions();
327 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
328 echo ' </span>'
329 . ' </li>'
330 . ' </ul>'
331 . ' </div>';
334 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
335 echo '<div class="group">';
336 echo '<h2>' , __('Web server') , '</h2>';
337 echo '<ul>';
338 if ($GLOBALS['cfg']['ShowServerInfo']) {
339 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
341 if ($server > 0) {
342 $client_version_str = $GLOBALS['dbi']->getClientInfo();
343 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
344 $client_version_str = 'libmysql - ' . $client_version_str;
346 PMA_printListItem(
347 __('Database client version:') . ' ' . $client_version_str,
348 'li_mysql_client_version'
351 $php_ext_string = __('PHP extension:') . ' ';
353 $extensions = PMA\libraries\Util::listPHPExtensions();
355 foreach ($extensions as $extension) {
356 $php_ext_string .= ' ' . $extension
357 . PMA\libraries\Util::showPHPDocu('book.' . $extension . '.php');
360 PMA_printListItem(
361 $php_ext_string,
362 'li_used_php_extension'
365 $php_version_string = __('PHP version:') . ' ' . phpversion();
367 PMA_printListItem(
368 $php_version_string,
369 'li_used_php_version'
374 if ($cfg['ShowPhpInfo']) {
375 PMA_printListItem(
376 __('Show PHP information'),
377 'li_phpinfo',
378 'phpinfo.php' . $common_url_query,
379 null,
380 '_blank'
383 echo ' </ul>';
384 echo ' </div>';
387 echo '<div class="group pmagroup">';
388 echo '<h2>phpMyAdmin</h2>';
389 echo '<ul>';
390 $class = null;
391 if ($GLOBALS['cfg']['VersionCheck']) {
392 $class = 'jsversioncheck';
394 PMA_printListItem(
395 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
396 'li_pma_version',
397 null,
398 null,
399 null,
400 null,
401 $class
403 PMA_printListItem(
404 __('Documentation'),
405 'li_pma_docs',
406 PMA\libraries\Util::getDocuLink('index'),
407 null,
408 '_blank'
411 // does not work if no target specified, don't know why
412 PMA_printListItem(
413 __('Official Homepage'),
414 'li_pma_homepage',
415 PMA_linkURL('https://www.phpmyadmin.net/'),
416 null,
417 '_blank'
419 PMA_printListItem(
420 __('Contribute'),
421 'li_pma_contribute',
422 PMA_linkURL('https://www.phpmyadmin.net/contribute/'),
423 null,
424 '_blank'
426 PMA_printListItem(
427 __('Get support'),
428 'li_pma_support',
429 PMA_linkURL('https://www.phpmyadmin.net/support/'),
430 null,
431 '_blank'
433 PMA_printListItem(
434 __('List of changes'),
435 'li_pma_changes',
436 'changelog.php' . URL::getCommon(),
437 null,
438 '_blank'
440 PMA_printListItem(
441 __('License'),
442 'li_pma_license',
443 'license.php' . URL::getCommon(),
444 null,
445 '_blank'
447 echo ' </ul>';
448 echo ' </div>';
450 echo '</div>';
452 echo '</div>';
455 * mbstring is used for handling multibytes inside parser, so it is good
456 * to tell user something might be broken without it, see bug #1063149.
458 if (! @extension_loaded('mbstring')) {
459 trigger_error(
461 'The mbstring PHP extension was not found and you seem to be using'
462 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
463 . ' is unable to split strings correctly and it may result in'
464 . ' unexpected results.'
466 E_USER_WARNING
471 * Missing functionality
473 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
474 trigger_error(
476 'The curl extension was not found and allow_url_fopen is '
477 . 'disabled. Due to this some features such as error reporting '
478 . 'or version check are disabled.'
483 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
485 * Check whether session.gc_maxlifetime limits session validity.
487 $gc_time = (int)@ini_get('session.gc_maxlifetime');
488 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
489 trigger_error(
491 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
492 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
493 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
494 'in phpMyAdmin, because of this, your login might expire sooner ' .
495 'than configured in phpMyAdmin.'
497 E_USER_WARNING
503 * Check whether LoginCookieValidity is limited by LoginCookieStore.
505 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
506 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
508 trigger_error(
510 'Login cookie store is lower than cookie validity configured in ' .
511 'phpMyAdmin, because of this, your login will expire sooner than ' .
512 'configured in phpMyAdmin.'
514 E_USER_WARNING
519 * Check if user does not have defined blowfish secret and it is being used.
521 if (! empty($_SESSION['encryption_key'])) {
522 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
523 trigger_error(
525 'The configuration file now needs a secret passphrase (blowfish_secret).'
527 E_USER_WARNING
529 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
530 trigger_error(
532 'The secret passphrase in configuration (blowfish_secret) is too short.'
534 E_USER_WARNING
540 * Check for existence of config directory which should not exist in
541 * production environment.
543 if (@file_exists('config')) {
544 trigger_error(
546 'Directory [code]config[/code], which is used by the setup script, ' .
547 'still exists in your phpMyAdmin directory. It is strongly ' .
548 'recommended to remove it once phpMyAdmin has been configured. ' .
549 'Otherwise the security of your server may be compromised by ' .
550 'unauthorized people downloading your configuration.'
552 E_USER_WARNING
556 if ($server > 0) {
557 $cfgRelation = PMA_getRelationsParam();
558 if (! $cfgRelation['allworks']
559 && $cfg['PmaNoRelation_DisableWarning'] == false
561 $msg_text = __(
562 'The phpMyAdmin configuration storage is not completely '
563 . 'configured, some extended features have been deactivated. '
564 . '%sFind out why%s. '
566 if ($cfg['ZeroConf'] == true) {
567 $msg_text .= '<br>' .
569 'Or alternately go to \'Operations\' tab of any database '
570 . 'to set it up there.'
573 $msg = PMA\libraries\Message::notice($msg_text);
574 $msg->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
575 $msg->addParamHtml('</a>');
576 /* Show error if user has configured something, notice elsewhere */
577 if (!empty($cfg['Servers'][$server]['pmadb'])) {
578 $msg->isError(true);
580 $msg->display();
581 } // end if
585 * Warning about Suhosin only if its simulation mode is not enabled
587 if ($cfg['SuhosinDisableWarning'] == false
588 && @ini_get('suhosin.request.max_value_length')
589 && @ini_get('suhosin.simulation') == '0'
591 trigger_error(
592 sprintf(
594 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
595 'for possible issues.'
597 '[doc@faq1-38]',
598 '[/doc]'
600 E_USER_WARNING
605 * Warning about incomplete translations.
607 * The data file is created while creating release by ./scripts/remove-incomplete-mo
609 if (@file_exists('libraries/language_stats.inc.php')) {
610 include 'libraries/language_stats.inc.php';
612 * This message is intentionally not translated, because we're
613 * handling incomplete translations here and focus on english
614 * speaking users.
616 if (isset($GLOBALS['language_stats'][$lang])
617 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
619 trigger_error(
620 'You are using an incomplete translation, please help to make it '
621 . 'better by [a@https://www.phpmyadmin.net/translate/'
622 . '@_blank]contributing[/a].',
623 E_USER_NOTICE
629 * prints list item for main page
631 * @param string $name displayed text
632 * @param string $listId id, used for css styles
633 * @param string $url make item as link with $url as target
634 * @param string $mysql_help_page display a link to MySQL's manual
635 * @param string $target special target for $url
636 * @param string $a_id id for the anchor,
637 * used for jQuery to hook in functions
638 * @param string $class class for the li element
639 * @param string $a_class class for the anchor element
641 * @return void
643 function PMA_printListItem($name, $listId = null, $url = null,
644 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
645 $a_class = null
647 echo PMA\libraries\Template::get('list/item')
648 ->render(
649 array(
650 'content' => $name,
651 'id' => $listId,
652 'class' => $class,
653 'url' => array(
654 'href' => $url,
655 'target' => $target,
656 'id' => $a_id,
657 'class' => $a_class,
659 'mysql_help_page' => $mysql_help_page,