Translated using Weblate (Thai)
[phpmyadmin.git] / index.php
blobf3fadcafc73578d8b337748213848a2b7eba593f
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;
14 /**
15 * Gets some core libraries and displays a top message if required
17 require_once 'libraries/common.inc.php';
19 /**
20 * display Git revision if requested
22 require_once 'libraries/display_git_revision.lib.php';
24 /**
25 * pass variables to child pages
27 $drops = array(
28 'lang',
29 'server',
30 'collation_connection',
31 'db',
32 'table'
34 foreach ($drops as $each_drop) {
35 if (array_key_exists($each_drop, $_GET)) {
36 unset($_GET[$each_drop]);
39 unset($drops, $each_drop);
42 * Black list of all scripts to which front-end must submit data.
43 * Such scripts must not be loaded on home page.
46 $target_blacklist = array (
47 'import.php', 'export.php'
50 // If we have a valid target, let's load that script instead
51 if (! empty($_REQUEST['target'])
52 && is_string($_REQUEST['target'])
53 && ! preg_match('/^index/', $_REQUEST['target'])
54 && ! in_array($_REQUEST['target'], $target_blacklist)
55 && in_array($_REQUEST['target'], $goto_whitelist)
56 ) {
57 include $_REQUEST['target'];
58 exit;
61 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
62 exit;
65 // See FAQ 1.34
66 if (! empty($_REQUEST['db'])) {
67 $page = null;
68 if (! empty($_REQUEST['table'])) {
69 $page = PMA\libraries\Util::getScriptNameForOption(
70 $GLOBALS['cfg']['DefaultTabTable'], 'table'
72 } else {
73 $page = PMA\libraries\Util::getScriptNameForOption(
74 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
77 include $page;
78 exit;
81 /**
82 * Check if it is an ajax request to reload the recent tables list.
84 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
85 $response = PMA\libraries\Response::getInstance();
86 $response->addJSON(
87 'list',
88 RecentFavoriteTable::getInstance('recent')->getHtmlList()
90 exit;
93 if ($GLOBALS['PMA_Config']->isGitRevision()) {
94 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
95 PMA_printGitRevision();
96 exit;
98 echo '<div id="is_git_revision"></div>';
101 // Handles some variables that may have been sent by the calling script
102 $GLOBALS['db'] = '';
103 $GLOBALS['table'] = '';
104 $show_query = '1';
106 // Any message to display?
107 if (! empty($message)) {
108 echo PMA\libraries\Util::getMessage($message);
109 unset($message);
112 $common_url_query = URL::getCommon();
113 $mysql_cur_user_and_host = '';
115 // when $server > 0, a server has been chosen so we can display
116 // all MySQL-related information
117 if ($server > 0) {
118 include 'libraries/server_common.inc.php';
120 // Use the verbose name of the server instead of the hostname
121 // if a value is set
122 $server_info = '';
123 if (! empty($cfg['Server']['verbose'])) {
124 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
125 if ($GLOBALS['cfg']['ShowServerInfo']) {
126 $server_info .= ' (';
129 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
130 $server_info .= $GLOBALS['dbi']->getHostInfo();
132 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
133 $server_info .= ')';
135 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
137 // should we add the port info here?
138 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
139 ? $GLOBALS['cfg']['Server']['verbose']
140 : $GLOBALS['cfg']['Server']['host']);
143 echo '<div id="maincontainer">' , "\n";
144 // Anchor for favorite tables synchronization.
145 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
146 echo '<div id="main_pane_left">';
147 if ($server > 0 || count($cfg['Servers']) > 1
149 if ($cfg['DBG']['demo']) {
150 echo '<div class="group">';
151 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
152 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
153 printf(
155 'You are using the demo server. You can do anything here, but '
156 . 'please do not change root, debian-sys-maint and pma users. '
157 . 'More information is available at %s.'
159 '<a href="url.php?url=https://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'
161 echo '</p>';
162 echo '</div>';
164 echo '<div class="group">';
165 echo '<h2>' , __('General settings') , '</h2>';
166 echo '<ul>';
169 * Displays the MySQL servers choice form
171 if ($cfg['ServerDefault'] == 0
172 || (! $cfg['NavigationDisplayServers']
173 && (count($cfg['Servers']) > 1
174 || ($server == 0 && count($cfg['Servers']) == 1)))
176 echo '<li id="li_select_server" class="no_bullets" >';
177 include_once 'libraries/select_server.lib.php';
178 echo PMA\libraries\Util::getImage('s_host.png') , " "
179 , PMA_selectServer(true, true);
180 echo '</li>';
184 * Displays the mysql server related links
186 if ($server > 0) {
187 include_once 'libraries/check_user_privileges.lib.php';
189 // Logout for advanced authentication
190 if ($cfg['Server']['auth_type'] != 'config') {
191 if ($cfg['ShowChgPassword']) {
192 $conditional_class = 'ajax';
193 PMA_printListItem(
194 PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __(
195 'Change password'
197 'li_change_password',
198 'user_password.php' . $common_url_query,
199 null,
200 null,
201 'change_password_anchor',
202 "no_bullets",
203 $conditional_class
206 } // end if
207 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
208 echo ' <form method="post" action="index.php">' , "\n"
209 . URL::getHiddenInputs(null, null, 4, 'collation_connection')
210 . ' <label for="select_collation_connection">' . "\n"
211 . ' ' . PMA\libraries\Util::getImage('s_asci.png')
212 . "&nbsp;" . __('Server connection collation') . "\n"
213 // put the doc link in the form so that it appears on the same line
214 . PMA\libraries\Util::showMySQLDocu('Charset-connection')
215 . ': ' . "\n"
216 . ' </label>' . "\n"
218 . Charsets::getCollationDropdownBox(
219 'collation_connection',
220 'select_collation_connection',
221 $collation_connection,
222 true,
223 true
225 . ' </form>' . "\n"
226 . ' </li>' . "\n";
227 } // end of if ($server > 0)
228 echo '</ul>';
229 echo '</div>';
232 echo '<div class="group">';
233 echo '<h2>' , __('Appearance settings') , '</h2>';
234 echo ' <ul>';
236 // Displays language selection combo
237 if (empty($cfg['Lang'])) {
238 echo '<li id="li_select_lang" class="no_bullets">';
239 include_once 'libraries/display_select_lang.lib.php';
240 echo PMA\libraries\Util::getImage('s_lang.png') , " "
241 , PMA_getLanguageSelectorHtml();
242 echo '</li>';
245 // ThemeManager if available
247 if ($GLOBALS['cfg']['ThemeManager']) {
248 echo '<li id="li_select_theme" class="no_bullets">';
249 echo PMA\libraries\Util::getImage('s_theme.png') , " "
250 , ThemeManager::getInstance()->getHtmlSelectBox();
251 echo '</li>';
253 echo '<li id="li_select_fontsize">';
254 echo PMA\libraries\Config::getFontsizeForm();
255 echo '</li>';
257 echo '</ul>';
259 // User preferences
261 if ($server > 0) {
262 echo '<ul>';
263 PMA_printListItem(
264 PMA\libraries\Util::getImage('b_tblops.png') . "&nbsp;" . __(
265 'More settings'
267 'li_user_preferences',
268 'prefs_manage.php' . $common_url_query,
269 null,
270 null,
271 null,
272 "no_bullets"
274 echo '</ul>';
277 echo '</div>';
280 echo '</div>';
281 echo '<div id="main_pane_right">';
284 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
286 echo '<div class="group">';
287 echo '<h2>' , __('Database server') , '</h2>';
288 echo '<ul>' , "\n";
289 PMA_printListItem(
290 __('Server:') . ' ' . $server_info,
291 'li_server_info'
293 PMA_printListItem(
294 __('Server type:') . ' ' . PMA\libraries\Util::getServerType(),
295 'li_server_type'
297 PMA_printListItem(
298 __('Server version:')
299 . ' '
300 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
301 'li_server_version'
303 PMA_printListItem(
304 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
305 'li_mysql_proto'
307 PMA_printListItem(
308 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
309 'li_user_info'
312 echo ' <li id="li_select_mysql_charset">';
313 echo ' ' , __('Server charset:') , ' '
314 . ' <span lang="en" dir="ltr">';
315 $unicode = Charsets::$mysql_charset_map['utf-8'];
316 $charsets = Charsets::getMySQLCharsetsDescriptions();
317 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
318 echo ' </span>'
319 . ' </li>'
320 . ' </ul>'
321 . ' </div>';
324 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
325 echo '<div class="group">';
326 echo '<h2>' , __('Web server') , '</h2>';
327 echo '<ul>';
328 if ($GLOBALS['cfg']['ShowServerInfo']) {
329 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
331 if ($server > 0) {
332 $client_version_str = $GLOBALS['dbi']->getClientInfo();
333 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
334 $client_version_str = 'libmysql - ' . $client_version_str;
336 PMA_printListItem(
337 __('Database client version:') . ' ' . $client_version_str,
338 'li_mysql_client_version'
341 $php_ext_string = __('PHP extension:') . ' ';
343 $extensions = PMA\libraries\Util::listPHPExtensions();
345 foreach ($extensions as $extension) {
346 $php_ext_string .= ' ' . $extension
347 . PMA\libraries\Util::showPHPDocu('book.' . $extension . '.php');
350 PMA_printListItem(
351 $php_ext_string,
352 'li_used_php_extension'
355 $php_version_string = __('PHP version:') . ' ' . phpversion();
357 PMA_printListItem(
358 $php_version_string,
359 'li_used_php_version'
364 if ($cfg['ShowPhpInfo']) {
365 PMA_printListItem(
366 __('Show PHP information'),
367 'li_phpinfo',
368 'phpinfo.php' . $common_url_query,
369 null,
370 '_blank'
373 echo ' </ul>';
374 echo ' </div>';
377 echo '<div class="group pmagroup">';
378 echo '<h2>phpMyAdmin</h2>';
379 echo '<ul>';
380 $class = null;
381 if ($GLOBALS['cfg']['VersionCheck']) {
382 $class = 'jsversioncheck';
384 PMA_printListItem(
385 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
386 'li_pma_version',
387 null,
388 null,
389 null,
390 null,
391 $class
393 PMA_printListItem(
394 __('Documentation'),
395 'li_pma_docs',
396 PMA\libraries\Util::getDocuLink('index'),
397 null,
398 '_blank'
401 // does not work if no target specified, don't know why
402 PMA_printListItem(
403 __('Official Homepage'),
404 'li_pma_homepage',
405 PMA_linkURL('https://www.phpMyAdmin.net/'),
406 null,
407 '_blank'
409 PMA_printListItem(
410 __('Contribute'),
411 'li_pma_contribute',
412 PMA_linkURL('https://www.phpmyadmin.net/contribute/'),
413 null,
414 '_blank'
416 PMA_printListItem(
417 __('Get support'),
418 'li_pma_support',
419 PMA_linkURL('https://www.phpmyadmin.net/support/'),
420 null,
421 '_blank'
423 PMA_printListItem(
424 __('List of changes'),
425 'li_pma_changes',
426 'changelog.php' . URL::getCommon(),
427 null,
428 '_blank'
430 PMA_printListItem(
431 __('License'),
432 'li_pma_license',
433 'license.php' . URL::getCommon(),
434 null,
435 '_blank'
437 echo ' </ul>';
438 echo ' </div>';
440 echo '</div>';
442 echo '</div>';
445 * As we try to handle charsets by ourself, mbstring overloads just
446 * break it, see bug 1063821.
448 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
449 trigger_error(
451 'You have enabled mbstring.func_overload in your PHP '
452 . 'configuration. This option is incompatible with phpMyAdmin '
453 . 'and might cause some data to be corrupted!'
455 E_USER_WARNING
460 * mbstring is used for handling multibytes inside parser, so it is good
461 * to tell user something might be broken without it, see bug #1063149.
463 if (! @extension_loaded('mbstring')) {
464 trigger_error(
466 'The mbstring PHP extension was not found and you seem to be using'
467 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
468 . ' is unable to split strings correctly and it may result in'
469 . ' unexpected results.'
471 E_USER_WARNING
476 * Missing functionality
478 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
479 trigger_error(
481 'The curl extension was not found and allow_url_fopen is '
482 . 'disabled. Due to this some features such as error reporting '
483 . 'or version check are disabled.'
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@https://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->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
573 $msg->addParamHtml('</a>');
574 /* Show error if user has configured something, notice elsewhere */
575 if (!empty($cfg['Servers'][$server]['pmadb'])) {
576 $msg->isError(true);
578 $msg->display();
579 } // end if
583 * Warning about different MySQL library and server version
584 * (a difference on the third digit does not count).
585 * If someday there is a constant that we can check about mysqlnd,
586 * we can use it instead of strpos().
587 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
588 * We also do not warn if MariaDB is detected, as it has its own version
589 * numbering.
591 if (isset($GLOBALS['dbi'])
592 && $cfg['ServerLibraryDifference_DisableWarning'] == false
594 $_client_info = $GLOBALS['dbi']->getClientInfo();
595 if ($server > 0
596 && mb_strpos($_client_info, 'mysqlnd') === false
597 && mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') === false
598 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(
599 PMA_MYSQL_INT_VERSION, 0, 3
602 trigger_error(
603 Sanitize::sanitize(
604 sprintf(
606 'Your PHP MySQL library version %s differs from your ' .
607 'MySQL server version %s. This may cause unpredictable ' .
608 'behavior.'
610 $_client_info,
611 substr(
612 PMA_MYSQL_STR_VERSION,
614 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
618 E_USER_NOTICE
621 unset($_client_info);
625 * Warning about Suhosin only if its simulation mode is not enabled
627 if ($cfg['SuhosinDisableWarning'] == false
628 && @ini_get('suhosin.request.max_value_length')
629 && @ini_get('suhosin.simulation') == '0'
631 trigger_error(
632 sprintf(
634 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
635 'for possible issues.'
637 '[doc@faq1-38]',
638 '[/doc]'
640 E_USER_WARNING
645 * Warning about incomplete translations.
647 * The data file is created while creating release by ./scripts/remove-incomplete-mo
649 if (@file_exists('libraries/language_stats.inc.php')) {
650 include 'libraries/language_stats.inc.php';
652 * This message is intentionally not translated, because we're
653 * handling incomplete translations here and focus on english
654 * speaking users.
656 if (isset($GLOBALS['language_stats'][$lang])
657 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
659 trigger_error(
660 'You are using an incomplete translation, please help to make it '
661 . 'better by [a@https://www.phpmyadmin.net/translate/'
662 . '@_blank]contributing[/a].',
663 E_USER_NOTICE
669 * prints list item for main page
671 * @param string $name displayed text
672 * @param string $listId id, used for css styles
673 * @param string $url make item as link with $url as target
674 * @param string $mysql_help_page display a link to MySQL's manual
675 * @param string $target special target for $url
676 * @param string $a_id id for the anchor,
677 * used for jQuery to hook in functions
678 * @param string $class class for the li element
679 * @param string $a_class class for the anchor element
681 * @return void
683 function PMA_printListItem($name, $listId = null, $url = null,
684 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
685 $a_class = null
687 echo PMA\libraries\Template::get('list/item')
688 ->render(
689 array(
690 'content' => $name,
691 'id' => $listId,
692 'class' => $class,
693 'url' => array(
694 'href' => $url,
695 'target' => $target,
696 'id' => $a_id,
697 'class' => $a_class,
699 'mysql_help_page' => $mysql_help_page,