Translated using Weblate (Slovenian)
[phpmyadmin.git] / index.php
blob69f697438d62f283eb143ad87106f0390f0b41af
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;
13 use PMA\libraries\LanguageManager;
15 /**
16 * Gets some core libraries and displays a top message if required
18 require_once 'libraries/common.inc.php';
20 /**
21 * display Git revision if requested
23 require_once 'libraries/display_git_revision.lib.php';
25 /**
26 * pass variables to child pages
28 $drops = array(
29 'lang',
30 'server',
31 'collation_connection',
32 'db',
33 'table'
35 foreach ($drops as $each_drop) {
36 if (array_key_exists($each_drop, $_GET)) {
37 unset($_GET[$each_drop]);
40 unset($drops, $each_drop);
43 * Black list of all scripts to which front-end must submit data.
44 * Such scripts must not be loaded on home page.
47 $target_blacklist = array (
48 'import.php', 'export.php'
51 // If we have a valid target, let's load that script instead
52 if (! empty($_REQUEST['target'])
53 && is_string($_REQUEST['target'])
54 && ! preg_match('/^index/', $_REQUEST['target'])
55 && ! in_array($_REQUEST['target'], $target_blacklist)
56 && in_array($_REQUEST['target'], $goto_whitelist)
57 ) {
58 include $_REQUEST['target'];
59 exit;
62 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
63 exit;
66 // See FAQ 1.34
67 if (! empty($_REQUEST['db'])) {
68 $page = null;
69 if (! empty($_REQUEST['table'])) {
70 $page = PMA\libraries\Util::getScriptNameForOption(
71 $GLOBALS['cfg']['DefaultTabTable'], 'table'
73 } else {
74 $page = PMA\libraries\Util::getScriptNameForOption(
75 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
78 include $page;
79 exit;
82 /**
83 * Check if it is an ajax request to reload the recent tables list.
85 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
86 $response = PMA\libraries\Response::getInstance();
87 $response->addJSON(
88 'list',
89 RecentFavoriteTable::getInstance('recent')->getHtmlList()
91 exit;
94 if ($GLOBALS['PMA_Config']->isGitRevision()) {
95 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
96 PMA_printGitRevision();
97 exit;
99 echo '<div id="is_git_revision"></div>';
102 // Handles some variables that may have been sent by the calling script
103 $GLOBALS['db'] = '';
104 $GLOBALS['table'] = '';
105 $show_query = '1';
107 // Any message to display?
108 if (! empty($message)) {
109 echo PMA\libraries\Util::getMessage($message);
110 unset($message);
113 $common_url_query = URL::getCommon();
114 $mysql_cur_user_and_host = '';
116 // when $server > 0, a server has been chosen so we can display
117 // all MySQL-related information
118 if ($server > 0) {
119 include 'libraries/server_common.inc.php';
121 // Use the verbose name of the server instead of the hostname
122 // if a value is set
123 $server_info = '';
124 if (! empty($cfg['Server']['verbose'])) {
125 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
126 if ($GLOBALS['cfg']['ShowServerInfo']) {
127 $server_info .= ' (';
130 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
131 $server_info .= $GLOBALS['dbi']->getHostInfo();
133 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
134 $server_info .= ')';
136 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
138 // should we add the port info here?
139 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
140 ? $GLOBALS['cfg']['Server']['verbose']
141 : $GLOBALS['cfg']['Server']['host']);
144 echo '<div id="maincontainer">' , "\n";
145 // Anchor for favorite tables synchronization.
146 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
147 echo '<div id="main_pane_left">';
148 if ($server > 0 || count($cfg['Servers']) > 1
150 if ($cfg['DBG']['demo']) {
151 echo '<div class="group">';
152 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
153 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
154 printf(
156 'You are using the demo server. You can do anything here, but '
157 . 'please do not change root, debian-sys-maint and pma users. '
158 . 'More information is available at %s.'
160 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
162 echo '</p>';
163 echo '</div>';
165 echo '<div class="group">';
166 echo '<h2>' , __('General settings') , '</h2>';
167 echo '<ul>';
170 * Displays the MySQL servers choice form
172 if ($cfg['ServerDefault'] == 0
173 || (! $cfg['NavigationDisplayServers']
174 && (count($cfg['Servers']) > 1
175 || ($server == 0 && count($cfg['Servers']) == 1)))
177 echo '<li id="li_select_server" class="no_bullets" >';
178 include_once 'libraries/select_server.lib.php';
179 echo PMA\libraries\Util::getImage('s_host.png') , " "
180 , PMA_selectServer(true, true);
181 echo '</li>';
185 * Displays the mysql server related links
187 if ($server > 0) {
188 include_once 'libraries/check_user_privileges.lib.php';
190 // Logout for advanced authentication
191 if ($cfg['Server']['auth_type'] != 'config') {
192 if ($cfg['ShowChgPassword']) {
193 $conditional_class = 'ajax';
194 PMA_printListItem(
195 PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __(
196 'Change password'
198 'li_change_password',
199 'user_password.php' . $common_url_query,
200 null,
201 null,
202 'change_password_anchor',
203 "no_bullets",
204 $conditional_class
207 } // end if
208 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
209 echo ' <form method="post" action="index.php">' , "\n"
210 . URL::getHiddenInputs(null, null, 4, 'collation_connection')
211 . ' <label for="select_collation_connection">' . "\n"
212 . ' ' . PMA\libraries\Util::getImage('s_asci.png')
213 . "&nbsp;" . __('Server connection collation') . "\n"
214 // put the doc link in the form so that it appears on the same line
215 . PMA\libraries\Util::showMySQLDocu('Charset-connection')
216 . ': ' . "\n"
217 . ' </label>' . "\n"
219 . Charsets::getCollationDropdownBox(
220 'collation_connection',
221 'select_collation_connection',
222 $collation_connection,
223 true,
224 true
226 . ' </form>' . "\n"
227 . ' </li>' . "\n";
228 } // end of if ($server > 0)
229 echo '</ul>';
230 echo '</div>';
233 echo '<div class="group">';
234 echo '<h2>' , __('Appearance settings') , '</h2>';
235 echo ' <ul>';
237 // Displays language selection combo
238 if (empty($cfg['Lang'])) {
239 echo '<li id="li_select_lang" class="no_bullets">';
241 echo PMA\libraries\Util::getImage('s_lang.png') , " "
242 , LanguageManager::getInstance()->getSelectorDisplay();
243 echo '</li>';
246 // ThemeManager if available
248 if ($GLOBALS['cfg']['ThemeManager']) {
249 echo '<li id="li_select_theme" class="no_bullets">';
250 echo PMA\libraries\Util::getImage('s_theme.png') , " "
251 , ThemeManager::getInstance()->getHtmlSelectBox();
252 echo '</li>';
254 echo '<li id="li_select_fontsize">';
255 echo PMA\libraries\Config::getFontsizeForm();
256 echo '</li>';
258 echo '</ul>';
260 // User preferences
262 if ($server > 0) {
263 echo '<ul>';
264 PMA_printListItem(
265 PMA\libraries\Util::getImage('b_tblops.png') . "&nbsp;" . __(
266 'More settings'
268 'li_user_preferences',
269 'prefs_manage.php' . $common_url_query,
270 null,
271 null,
272 null,
273 "no_bullets"
275 echo '</ul>';
278 echo '</div>';
281 echo '</div>';
282 echo '<div id="main_pane_right">';
285 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
287 echo '<div class="group">';
288 echo '<h2>' , __('Database server') , '</h2>';
289 echo '<ul>' , "\n";
290 PMA_printListItem(
291 __('Server:') . ' ' . $server_info,
292 'li_server_info'
294 PMA_printListItem(
295 __('Server type:') . ' ' . PMA\libraries\Util::getServerType(),
296 'li_server_type'
298 PMA_printListItem(
299 __('Server version:')
300 . ' '
301 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
302 'li_server_version'
304 PMA_printListItem(
305 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
306 'li_mysql_proto'
308 PMA_printListItem(
309 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
310 'li_user_info'
313 echo ' <li id="li_select_mysql_charset">';
314 echo ' ' , __('Server charset:') , ' '
315 . ' <span lang="en" dir="ltr">';
316 $unicode = Charsets::$mysql_charset_map['utf-8'];
317 $charsets = Charsets::getMySQLCharsetsDescriptions();
318 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
319 echo ' </span>'
320 . ' </li>'
321 . ' </ul>'
322 . ' </div>';
325 if ($GLOBALS['cfg']['ShowServerInfo']) {
326 echo '<div class="group">';
327 echo '<h2>' , __('Web server') , '</h2>';
328 echo '<ul>';
329 if ($GLOBALS['cfg']['ShowServerInfo']) {
330 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
332 if ($server > 0) {
333 $client_version_str = $GLOBALS['dbi']->getClientInfo();
334 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
335 $client_version_str = 'libmysql - ' . $client_version_str;
337 PMA_printListItem(
338 __('Database client version:') . ' ' . $client_version_str,
339 'li_mysql_client_version'
342 $php_ext_string = __('PHP extension:') . ' ';
344 $extensions = PMA\libraries\Util::listPHPExtensions();
346 foreach ($extensions as $extension) {
347 $php_ext_string .= ' ' . $extension
348 . PMA\libraries\Util::showPHPDocu('book.' . $extension . '.php');
351 PMA_printListItem(
352 $php_ext_string,
353 'li_used_php_extension'
356 $php_version_string = __('PHP version:') . ' ' . phpversion();
358 PMA_printListItem(
359 $php_version_string,
360 'li_used_php_version'
365 echo ' </ul>';
366 echo ' </div>';
369 echo '<div class="group pmagroup">';
370 echo '<h2>phpMyAdmin</h2>';
371 echo '<ul>';
372 $class = null;
373 if ($GLOBALS['cfg']['VersionCheck']) {
374 $class = 'jsversioncheck';
376 PMA_printListItem(
377 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
378 'li_pma_version',
379 null,
380 null,
381 null,
382 null,
383 $class
385 PMA_printListItem(
386 __('Documentation'),
387 'li_pma_docs',
388 PMA\libraries\Util::getDocuLink('index'),
389 null,
390 '_blank'
393 // does not work if no target specified, don't know why
394 PMA_printListItem(
395 __('Official Homepage'),
396 'li_pma_homepage',
397 PMA_linkURL('https://www.phpMyAdmin.net/'),
398 null,
399 '_blank'
401 PMA_printListItem(
402 __('Contribute'),
403 'li_pma_contribute',
404 PMA_linkURL('https://www.phpmyadmin.net/contribute/'),
405 null,
406 '_blank'
408 PMA_printListItem(
409 __('Get support'),
410 'li_pma_support',
411 PMA_linkURL('https://www.phpmyadmin.net/support/'),
412 null,
413 '_blank'
415 PMA_printListItem(
416 __('List of changes'),
417 'li_pma_changes',
418 'changelog.php' . URL::getCommon(),
419 null,
420 '_blank'
422 PMA_printListItem(
423 __('License'),
424 'li_pma_license',
425 'license.php' . URL::getCommon(),
426 null,
427 '_blank'
429 echo ' </ul>';
430 echo ' </div>';
432 echo '</div>';
434 echo '</div>';
437 * mbstring is used for handling multibytes inside parser, so it is good
438 * to tell user something might be broken without it, see bug #1063149.
440 if (! @extension_loaded('mbstring')) {
441 trigger_error(
443 'The mbstring PHP extension was not found and you seem to be using'
444 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
445 . ' is unable to split strings correctly and it may result in'
446 . ' unexpected results.'
448 E_USER_WARNING
453 * Missing functionality
455 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
456 trigger_error(
458 'The curl extension was not found and allow_url_fopen is '
459 . 'disabled. Due to this some features such as error reporting '
460 . 'or version check are disabled.'
465 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
467 * Check whether session.gc_maxlifetime limits session validity.
469 $gc_time = (int)@ini_get('session.gc_maxlifetime');
470 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
471 trigger_error(
473 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
474 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
475 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
476 'in phpMyAdmin, because of this, your login might expire sooner ' .
477 'than configured in phpMyAdmin.'
479 E_USER_WARNING
485 * Check whether LoginCookieValidity is limited by LoginCookieStore.
487 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
488 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
490 trigger_error(
492 'Login cookie store is lower than cookie validity configured in ' .
493 'phpMyAdmin, because of this, your login will expire sooner than ' .
494 'configured in phpMyAdmin.'
496 E_USER_WARNING
501 * Check if user does not have defined blowfish secret and it is being used.
503 if (! empty($_SESSION['encryption_key'])) {
504 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
505 trigger_error(
507 'The configuration file now needs a secret passphrase (blowfish_secret).'
509 E_USER_WARNING
511 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
512 trigger_error(
514 'The secret passphrase in configuration (blowfish_secret) is too short.'
516 E_USER_WARNING
522 * Check for existence of config directory which should not exist in
523 * production environment.
525 if (@file_exists('config')) {
526 trigger_error(
528 'Directory [code]config[/code], which is used by the setup script, ' .
529 'still exists in your phpMyAdmin directory. It is strongly ' .
530 'recommended to remove it once phpMyAdmin has been configured. ' .
531 'Otherwise the security of your server may be compromised by ' .
532 'unauthorized people downloading your configuration.'
534 E_USER_WARNING
538 if ($server > 0) {
539 $cfgRelation = PMA_getRelationsParam();
540 if (! $cfgRelation['allworks']
541 && $cfg['PmaNoRelation_DisableWarning'] == false
543 $msg_text = __(
544 'The phpMyAdmin configuration storage is not completely '
545 . 'configured, some extended features have been deactivated. '
546 . '%sFind out why%s. '
548 if ($cfg['ZeroConf'] == true) {
549 $msg_text .= '<br>' .
551 'Or alternately go to \'Operations\' tab of any database '
552 . 'to set it up there.'
555 $msg = PMA\libraries\Message::notice($msg_text);
556 $msg->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
557 $msg->addParamHtml('</a>');
558 /* Show error if user has configured something, notice elsewhere */
559 if (!empty($cfg['Servers'][$server]['pmadb'])) {
560 $msg->isError(true);
562 $msg->display();
563 } // end if
567 * Warning about different MySQL library and server version
568 * (a difference on the third digit does not count).
569 * If someday there is a constant that we can check about mysqlnd,
570 * we can use it instead of strpos().
571 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
572 * We also do not warn if MariaDB is detected, as it has its own version
573 * numbering.
575 if (isset($GLOBALS['dbi'])
576 && $cfg['ServerLibraryDifference_DisableWarning'] == false
578 $_client_info = $GLOBALS['dbi']->getClientInfo();
579 if ($server > 0
580 && mb_strpos($_client_info, 'mysqlnd') === false
581 && mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') === false
582 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(
583 PMA_MYSQL_INT_VERSION, 0, 3
586 trigger_error(
587 Sanitize::sanitize(
588 sprintf(
590 'Your PHP MySQL library version %s differs from your ' .
591 'MySQL server version %s. This may cause unpredictable ' .
592 'behavior.'
594 $_client_info,
595 substr(
596 PMA_MYSQL_STR_VERSION,
598 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
602 E_USER_NOTICE
605 unset($_client_info);
609 * Warning about Suhosin only if its simulation mode is not enabled
611 if ($cfg['SuhosinDisableWarning'] == false
612 && @ini_get('suhosin.request.max_value_length')
613 && @ini_get('suhosin.simulation') == '0'
615 trigger_error(
616 sprintf(
618 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
619 'for possible issues.'
621 '[doc@faq1-38]',
622 '[/doc]'
624 E_USER_WARNING
629 * Warning about incomplete translations.
631 * The data file is created while creating release by ./scripts/remove-incomplete-mo
633 if (@file_exists('libraries/language_stats.inc.php')) {
634 include 'libraries/language_stats.inc.php';
636 * This message is intentionally not translated, because we're
637 * handling incomplete translations here and focus on english
638 * speaking users.
640 if (isset($GLOBALS['language_stats'][$lang])
641 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
643 trigger_error(
644 'You are using an incomplete translation, please help to make it '
645 . 'better by [a@https://www.phpmyadmin.net/translate/'
646 . '@_blank]contributing[/a].',
647 E_USER_NOTICE
653 * prints list item for main page
655 * @param string $name displayed text
656 * @param string $listId id, used for css styles
657 * @param string $url make item as link with $url as target
658 * @param string $mysql_help_page display a link to MySQL's manual
659 * @param string $target special target for $url
660 * @param string $a_id id for the anchor,
661 * used for jQuery to hook in functions
662 * @param string $class class for the li element
663 * @param string $a_class class for the anchor element
665 * @return void
667 function PMA_printListItem($name, $listId = null, $url = null,
668 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
669 $a_class = null
671 echo PMA\libraries\Template::get('list/item')
672 ->render(
673 array(
674 'content' => $name,
675 'id' => $listId,
676 'class' => $class,
677 'url' => array(
678 'href' => $url,
679 'target' => $target,
680 'id' => $a_id,
681 'class' => $a_class,
683 'mysql_help_page' => $mysql_help_page,