Translated using Weblate (Slovenian)
[phpmyadmin.git] / index.php
blobd4ec7f21c0c26306e6219d69c0b32f85eadf7e68
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;
10 /**
11 * Gets some core libraries and displays a top message if required
13 require_once 'libraries/common.inc.php';
15 /**
16 * display Git revision if requested
18 require_once 'libraries/display_git_revision.lib.php';
20 /**
21 * pass variables to child pages
23 $drops = array(
24 'lang',
25 'server',
26 'collation_connection',
27 'db',
28 'table'
30 foreach ($drops as $each_drop) {
31 if (array_key_exists($each_drop, $_GET)) {
32 unset($_GET[$each_drop]);
35 unset($drops, $each_drop);
38 * Black list of all scripts to which front-end must submit data.
39 * Such scripts must not be loaded on home page.
42 $target_blacklist = array (
43 'import.php', 'export.php'
46 // If we have a valid target, let's load that script instead
47 if (! empty($_REQUEST['target'])
48 && is_string($_REQUEST['target'])
49 && ! preg_match('/^index/', $_REQUEST['target'])
50 && ! in_array($_REQUEST['target'], $target_blacklist)
51 && in_array($_REQUEST['target'], $goto_whitelist)
52 ) {
53 include $_REQUEST['target'];
54 exit;
57 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
58 exit;
61 // See FAQ 1.34
62 if (! empty($_REQUEST['db'])) {
63 $page = null;
64 if (! empty($_REQUEST['table'])) {
65 $page = PMA\libraries\Util::getScriptNameForOption(
66 $GLOBALS['cfg']['DefaultTabTable'], 'table'
68 } else {
69 $page = PMA\libraries\Util::getScriptNameForOption(
70 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
73 include $page;
74 exit;
77 /**
78 * Check if it is an ajax request to reload the recent tables list.
80 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
81 $response = PMA\libraries\Response::getInstance();
82 $response->addJSON(
83 'list',
84 RecentFavoriteTable::getInstance('recent')->getHtmlList()
86 exit;
89 if ($GLOBALS['PMA_Config']->isGitRevision()) {
90 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
91 PMA_printGitRevision();
92 exit;
94 echo '<div id="is_git_revision"></div>';
97 // Handles some variables that may have been sent by the calling script
98 $GLOBALS['db'] = '';
99 $GLOBALS['table'] = '';
100 $show_query = '1';
102 // Any message to display?
103 if (! empty($message)) {
104 echo PMA\libraries\Util::getMessage($message);
105 unset($message);
108 $common_url_query = PMA_URL_getCommon();
109 $mysql_cur_user_and_host = '';
111 // when $server > 0, a server has been chosen so we can display
112 // all MySQL-related information
113 if ($server > 0) {
114 include 'libraries/server_common.inc.php';
116 // Use the verbose name of the server instead of the hostname
117 // if a value is set
118 $server_info = '';
119 if (! empty($cfg['Server']['verbose'])) {
120 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
121 if ($GLOBALS['cfg']['ShowServerInfo']) {
122 $server_info .= ' (';
125 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
126 $server_info .= $GLOBALS['dbi']->getHostInfo();
128 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
129 $server_info .= ')';
131 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
133 // should we add the port info here?
134 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
135 ? $GLOBALS['cfg']['Server']['verbose']
136 : $GLOBALS['cfg']['Server']['host']);
139 echo '<div id="maincontainer">' . "\n";
140 // Anchor for favorite tables synchronization.
141 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
142 echo '<div id="main_pane_left">';
143 if ($server > 0 || count($cfg['Servers']) > 1
145 if ($cfg['DBG']['demo']) {
146 echo '<div class="group">';
147 echo '<h2>' . __('phpMyAdmin Demo Server') . '</h2>';
148 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
149 printf(
151 'You are using the demo server. You can do anything here, but '
152 . 'please do not change root, debian-sys-maint and pma users. '
153 . 'More information is available at %s.'
155 '<a href="http://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'
157 echo '</p>';
158 echo '</div>';
160 echo '<div class="group">';
161 echo '<h2>' . __('General settings') . '</h2>';
162 echo '<ul>';
165 * Displays the MySQL servers choice form
167 if ($cfg['ServerDefault'] == 0
168 || (! $cfg['NavigationDisplayServers']
169 && (count($cfg['Servers']) > 1
170 || ($server == 0 && count($cfg['Servers']) == 1)))
172 echo '<li id="li_select_server" class="no_bullets" >';
173 include_once 'libraries/select_server.lib.php';
174 echo PMA\libraries\Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
175 echo '</li>';
179 * Displays the mysql server related links
181 if ($server > 0) {
182 include_once 'libraries/check_user_privileges.lib.php';
184 // Logout for advanced authentication
185 if ($cfg['Server']['auth_type'] != 'config') {
186 if ($cfg['ShowChgPassword']) {
187 $conditional_class = 'ajax';
188 PMA_printListItem(
189 PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __('Change password'),
190 'li_change_password',
191 'user_password.php' . $common_url_query,
192 null,
193 null,
194 'change_password_anchor',
195 "no_bullets",
196 $conditional_class
199 } // end if
200 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
201 echo ' <form method="post" action="index.php">' . "\n"
202 . PMA_URL_getHiddenInputs(null, null, 4, 'collation_connection')
203 . ' <label for="select_collation_connection">' . "\n"
204 . ' ' . PMA\libraries\Util::getImage('s_asci.png') . "&nbsp;"
205 . __('Server connection collation') . "\n"
206 // put the doc link in the form so that it appears on the same line
207 . PMA\libraries\Util::showMySQLDocu('Charset-connection')
208 . ': ' . "\n"
209 . ' </label>' . "\n"
211 . PMA_generateCharsetDropdownBox(
212 PMA_CSDROPDOWN_COLLATION,
213 'collation_connection',
214 'select_collation_connection',
215 $collation_connection,
216 true,
217 true
219 . ' </form>' . "\n"
220 . ' </li>' . "\n";
221 } // end of if ($server > 0)
222 echo '</ul>';
223 echo '</div>';
226 echo '<div class="group">';
227 echo '<h2>' . __('Appearance settings') . '</h2>';
228 echo ' <ul>';
230 // Displays language selection combo
231 if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
232 echo '<li id="li_select_lang" class="no_bullets">';
233 include_once 'libraries/display_select_lang.lib.php';
234 echo PMA\libraries\Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
235 echo '</li>';
238 // ThemeManager if available
240 if ($GLOBALS['cfg']['ThemeManager']) {
241 echo '<li id="li_select_theme" class="no_bullets">';
242 echo PMA\libraries\Util::getImage('s_theme.png') . " "
243 . $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
244 echo '</li>';
246 echo '<li id="li_select_fontsize">';
247 echo PMA\libraries\Config::getFontsizeForm();
248 echo '</li>';
250 echo '</ul>';
252 // User preferences
254 if ($server > 0) {
255 echo '<ul>';
256 PMA_printListItem(
257 PMA\libraries\Util::getImage('b_tblops.png') . "&nbsp;" . __('More settings'),
258 'li_user_preferences',
259 'prefs_manage.php' . $common_url_query,
260 null,
261 null,
262 null,
263 "no_bullets"
265 echo '</ul>';
268 echo '</div>';
271 echo '</div>';
272 echo '<div id="main_pane_right">';
275 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
277 echo '<div class="group">';
278 echo '<h2>' . __('Database server') . '</h2>';
279 echo '<ul>' . "\n";
280 PMA_printListItem(
281 __('Server:') . ' ' . $server_info,
282 'li_server_info'
284 PMA_printListItem(
285 __('Server type:') . ' ' . PMA\libraries\Util::getServerType(),
286 'li_server_type'
288 PMA_printListItem(
289 __('Server version:')
290 . ' '
291 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
292 'li_server_version'
294 PMA_printListItem(
295 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
296 'li_mysql_proto'
298 PMA_printListItem(
299 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
300 'li_user_info'
303 echo ' <li id="li_select_mysql_charset">';
304 echo ' ' . __('Server charset:') . ' '
305 . ' <span lang="en" dir="ltr">';
306 echo ' ' . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']];
307 echo ' (' . $mysql_charset_map['utf-8'] . ')'
308 . ' </span>'
309 . ' </li>'
310 . ' </ul>'
311 . ' </div>';
314 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
315 echo '<div class="group">';
316 echo '<h2>' . __('Web server') . '</h2>';
317 echo '<ul>';
318 if ($GLOBALS['cfg']['ShowServerInfo']) {
319 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
321 if ($server > 0) {
322 $client_version_str = $GLOBALS['dbi']->getClientInfo();
323 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
324 $client_version_str = 'libmysql - ' . $client_version_str;
326 PMA_printListItem(
327 __('Database client version:') . ' ' . $client_version_str,
328 'li_mysql_client_version'
331 $php_ext_string = __('PHP extension:') . ' ';
332 if (PMA\libraries\DatabaseInterface::checkDbExtension('mysqli')) {
333 $extension = 'mysqli';
334 } else {
335 $extension = 'mysql';
337 $php_ext_string .= $extension . ' '
338 . PMA\libraries\Util::showPHPDocu('book.' . $extension . '.php');
340 PMA_printListItem(
341 $php_ext_string,
342 'li_used_php_extension'
345 $php_version_string = __('PHP version:') . ' ' . phpversion();
347 PMA_printListItem(
348 $php_version_string,
349 'li_used_php_version'
354 if ($cfg['ShowPhpInfo']) {
355 PMA_printListItem(
356 __('Show PHP information'),
357 'li_phpinfo',
358 'phpinfo.php' . $common_url_query,
359 null,
360 '_blank'
363 echo ' </ul>';
364 echo ' </div>';
367 echo '<div class="group pmagroup">';
368 echo '<h2>phpMyAdmin</h2>';
369 echo '<ul>';
370 $class = null;
371 // We rely on CSP to allow access to http://www.phpmyadmin.net, but IE lacks
372 // support here and does not allow request to http once using https.
373 if ($GLOBALS['cfg']['VersionCheck']
374 && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')
376 $class = 'jsversioncheck';
378 PMA_printListItem(
379 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
380 'li_pma_version',
381 null,
382 null,
383 null,
384 null,
385 $class
387 PMA_printListItem(
388 __('Documentation'),
389 'li_pma_docs',
390 PMA\libraries\Util::getDocuLink('index'),
391 null,
392 '_blank'
394 PMA_printListItem(
395 __('Wiki'),
396 'li_pma_wiki',
397 PMA_linkURL('http://wiki.phpmyadmin.net/'),
398 null,
399 '_blank'
402 // does not work if no target specified, don't know why
403 PMA_printListItem(
404 __('Official Homepage'),
405 'li_pma_homepage',
406 PMA_linkURL('http://www.phpMyAdmin.net/'),
407 null,
408 '_blank'
410 PMA_printListItem(
411 __('Contribute'),
412 'li_pma_contribute',
413 PMA_linkURL('https://www.phpmyadmin.net/contribute/'),
414 null,
415 '_blank'
417 PMA_printListItem(
418 __('Get support'),
419 'li_pma_support',
420 PMA_linkURL('https://www.phpmyadmin.net/support/'),
421 null,
422 '_blank'
424 PMA_printListItem(
425 __('List of changes'),
426 'li_pma_changes',
427 'changelog.php' . PMA_URL_getCommon(),
428 null,
429 '_blank'
431 echo ' </ul>';
432 echo ' </div>';
434 echo '</div>';
436 echo '</div>';
439 * Warning if using the default MySQL privileged account
441 if ($server != 0
442 && $cfg['Server']['user'] == 'root'
443 && $cfg['Server']['password'] == ''
445 trigger_error(
447 'You are connected as \'root\' with no password, which'
448 . ' corresponds to the default MySQL privileged account.'
449 . ' Your MySQL server is running with this default, is open to'
450 . ' intrusion, and you really should fix this security hole by'
451 . ' setting a password for user \'root\'.'
453 E_USER_WARNING
458 * As we try to handle charsets by ourself, mbstring overloads just
459 * break it, see bug 1063821.
461 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
462 trigger_error(
464 'You have enabled mbstring.func_overload in your PHP '
465 . 'configuration. This option is incompatible with phpMyAdmin '
466 . 'and might cause some data to be corrupted!'
468 E_USER_WARNING
473 * mbstring is used for handling multibytes inside parser, so it is good
474 * to tell user something might be broken without it, see bug #1063149.
476 if (! @extension_loaded('mbstring')) {
477 trigger_error(
479 'The mbstring PHP extension was not found and you seem to be using'
480 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
481 . ' is unable to split strings correctly and it may result in'
482 . ' unexpected results.'
484 E_USER_WARNING
488 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
490 * Check whether session.gc_maxlifetime limits session validity.
492 $gc_time = (int)@ini_get('session.gc_maxlifetime');
493 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
494 trigger_error(
496 'Your PHP parameter [a@http://php.net/manual/en/session.' .
497 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
498 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
499 'in phpMyAdmin, because of this, your login might expire sooner ' .
500 'than configured in phpMyAdmin.'
502 E_USER_WARNING
508 * Check whether LoginCookieValidity is limited by LoginCookieStore.
510 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
511 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
513 trigger_error(
515 'Login cookie store is lower than cookie validity configured in ' .
516 'phpMyAdmin, because of this, your login will expire sooner than ' .
517 'configured in phpMyAdmin.'
519 E_USER_WARNING
524 * Check if user does not have defined blowfish secret and it is being used.
526 if (! empty($_SESSION['encryption_key'])
527 && empty($GLOBALS['cfg']['blowfish_secret'])
529 trigger_error(
531 'The configuration file now needs a secret passphrase (blowfish_secret).'
533 E_USER_WARNING
538 * Check for existence of config directory which should not exist in
539 * production environment.
541 if (file_exists('config')) {
542 trigger_error(
544 'Directory [code]config[/code], which is used by the setup script, ' .
545 'still exists in your phpMyAdmin directory. It is strongly ' .
546 'recommended to remove it once phpMyAdmin has been configured. ' .
547 'Otherwise the security of your server may be compromised by ' .
548 'unauthorized people downloading your configuration.'
550 E_USER_WARNING
554 if ($server > 0) {
555 $cfgRelation = PMA_getRelationsParam();
556 if (! $cfgRelation['allworks']
557 && $cfg['PmaNoRelation_DisableWarning'] == false
559 $msg_text = __(
560 'The phpMyAdmin configuration storage is not completely '
561 . 'configured, some extended features have been deactivated. '
562 . '%sFind out why%s. '
564 if ($cfg['ZeroConf'] == true) {
565 $msg_text .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' .
567 'Or alternately go to \'Operations\' tab of any database '
568 . 'to set it up there.'
571 $msg = PMA\libraries\Message::notice($msg_text);
572 $msg->addParam(
573 '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php'
574 . $common_url_query . '">',
575 false
577 $msg->addParam('</a>', false);
578 /* Show error if user has configured something, notice elsewhere */
579 if (!empty($cfg['Servers'][$server]['pmadb'])) {
580 $msg->isError(true);
582 $msg->display();
583 } // end if
587 * Warning about different MySQL library and server version
588 * (a difference on the third digit does not count).
589 * If someday there is a constant that we can check about mysqlnd,
590 * we can use it instead of strpos().
591 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
592 * We also do not warn if MariaDB is detected, as it has its own version
593 * numbering.
595 if (isset($GLOBALS['dbi'])
596 && $cfg['ServerLibraryDifference_DisableWarning'] == false
598 /** @var String $pmaString */
599 $pmaString = $GLOBALS['PMA_String'];
601 $_client_info = $GLOBALS['dbi']->getClientInfo();
602 if ($server > 0
603 && /*overload*/mb_strpos($_client_info, 'mysqlnd') === false
604 && /*overload*/mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') === false
605 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(
606 PMA_MYSQL_INT_VERSION, 0, 3
609 trigger_error(
610 PMA_sanitize(
611 sprintf(
613 'Your PHP MySQL library version %s differs from your ' .
614 'MySQL server version %s. This may cause unpredictable ' .
615 'behavior.'
617 $_client_info,
618 substr(
619 PMA_MYSQL_STR_VERSION,
621 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
625 E_USER_NOTICE
628 unset($_client_info);
632 * Warning about Suhosin only if its simulation mode is not enabled
634 if ($cfg['SuhosinDisableWarning'] == false
635 && @ini_get('suhosin.request.max_value_length')
636 && @ini_get('suhosin.simulation') == '0'
638 trigger_error(
639 sprintf(
641 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
642 'for possible issues.'
644 '[doc@faq1-38]',
645 '[/doc]'
647 E_USER_WARNING
652 * Warning about incomplete translations.
654 * The data file is created while creating release by ./scripts/remove-incomplete-mo
656 if (file_exists('libraries/language_stats.inc.php')) {
657 include 'libraries/language_stats.inc.php';
659 * This message is intentionally not translated, because we're
660 * handling incomplete translations here and focus on english
661 * speaking users.
663 if (isset($GLOBALS['language_stats'][$lang])
664 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
666 trigger_error(
667 'You are using an incomplete translation, please help to make it '
668 . 'better by [a@https://www.phpmyadmin.net/translate/'
669 . '@_blank]contributing[/a].',
670 E_USER_NOTICE
676 * prints list item for main page
678 * @param string $name displayed text
679 * @param string $listId id, used for css styles
680 * @param string $url make item as link with $url as target
681 * @param string $mysql_help_page display a link to MySQL's manual
682 * @param string $target special target for $url
683 * @param string $a_id id for the anchor,
684 * used for jQuery to hook in functions
685 * @param string $class class for the li element
686 * @param string $a_class class for the anchor element
688 * @return void
690 function PMA_printListItem($name, $listId = null, $url = null,
691 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
692 $a_class = null
694 echo PMA\libraries\Template::get('list/item')
695 ->render(
696 array(
697 'content' => $name,
698 'id' => $listId,
699 'class' => $class,
700 'url' => array(
701 'href' => $url,
702 'target' => $target,
703 'id' => $a_id,
704 'class' => $a_class,
706 'mysql_help_page' => $mysql_help_page,