Translated using Weblate (Bulgarian)
[phpmyadmin.git] / index.php
blob2d33c3939b07d65ae84a3145fff947b17b2cf6b3
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Main loader script
6 * @package PhpMyAdmin
7 */
9 /**
10 * Gets some core libraries and displays a top message if required
12 require_once 'libraries/common.inc.php';
14 /**
15 * display Git revision if requested
17 require_once 'libraries/display_git_revision.lib.php';
19 /**
20 * pass variables to child pages
22 $drops = array(
23 'lang',
24 'server',
25 'collation_connection',
26 'db',
27 'table'
29 foreach ($drops as $each_drop) {
30 if (array_key_exists($each_drop, $_GET)) {
31 unset($_GET[$each_drop]);
34 unset($drops, $each_drop);
37 * Black list of all scripts to which front-end must submit data.
38 * Such scripts must not be loaded on home page.
41 $target_blacklist = array (
42 'import.php', 'export.php'
45 // If we have a valid target, let's load that script instead
46 if (! empty($_REQUEST['target'])
47 && is_string($_REQUEST['target'])
48 && ! preg_match('/^index/', $_REQUEST['target'])
49 && ! in_array($_REQUEST['target'], $target_blacklist)
50 && in_array($_REQUEST['target'], $goto_whitelist)
51 ) {
52 include $_REQUEST['target'];
53 exit;
56 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
57 exit;
59 /**
60 * Check if it is an ajax request to reload the recent tables list.
62 require_once 'libraries/RecentFavoriteTable.class.php';
63 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
64 $response = PMA_Response::getInstance();
65 $response->addJSON(
66 'list',
67 PMA_RecentFavoriteTable::getInstance('recent')->getHtmlList()
69 exit;
72 if ($GLOBALS['PMA_Config']->isGitRevision()) {
73 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
74 PMA_printGitRevision();
75 exit;
77 echo '<div id="is_git_revision"></div>';
80 // Handles some variables that may have been sent by the calling script
81 $GLOBALS['db'] = '';
82 $GLOBALS['table'] = '';
83 $show_query = '1';
85 // Any message to display?
86 if (! empty($message)) {
87 echo PMA_Util::getMessage($message);
88 unset($message);
91 $common_url_query = PMA_URL_getCommon('', '');
92 $mysql_cur_user_and_host = '';
94 // when $server > 0, a server has been chosen so we can display
95 // all MySQL-related information
96 if ($server > 0) {
97 include 'libraries/server_common.inc.php';
98 include 'libraries/StorageEngine.class.php';
100 // Use the verbose name of the server instead of the hostname
101 // if a value is set
102 $server_info = '';
103 if (! empty($cfg['Server']['verbose'])) {
104 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
105 if ($GLOBALS['cfg']['ShowServerInfo']) {
106 $server_info .= ' (';
109 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
110 $server_info .= $GLOBALS['dbi']->getHostInfo();
112 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
113 $server_info .= ')';
115 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
117 // should we add the port info here?
118 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
119 ? $GLOBALS['cfg']['Server']['verbose']
120 : $GLOBALS['cfg']['Server']['host']);
123 echo '<div id="maincontainer">' . "\n";
124 // Anchor for favorite tables synchronization.
125 echo PMA_RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
126 echo '<div id="main_pane_left">';
127 if ($server > 0 || count($cfg['Servers']) > 1
129 if ($cfg['DBG']['demo']) {
130 echo '<div class="group">';
131 echo '<h2>' . __('phpMyAdmin Demo Server') . '</h2>';
132 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
133 printf(
135 'You are using the demo server. You can do anything here, but '
136 . 'please do not change root, debian-sys-maint and pma users. '
137 . 'More information is available at %s.'
139 '<a href="http://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'
141 echo '</p>';
142 echo '</div>';
144 echo '<div class="group">';
145 echo '<h2>' . __('General Settings') . '</h2>';
146 echo '<ul>';
149 * Displays the MySQL servers choice form
151 if ($cfg['ServerDefault'] == 0
152 || (! $cfg['NavigationDisplayServers']
153 && (count($cfg['Servers']) > 1
154 || ($server == 0 && count($cfg['Servers']) == 1)))
156 echo '<li id="li_select_server" class="no_bullets" >';
157 include_once 'libraries/select_server.lib.php';
158 echo PMA_Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
159 echo '</li>';
163 * Displays the mysql server related links
165 if ($server > 0 && ! PMA_DRIZZLE) {
166 include_once 'libraries/check_user_privileges.lib.php';
168 // Logout for advanced authentication
169 if ($cfg['Server']['auth_type'] != 'config') {
170 if ($cfg['ShowChgPassword']) {
171 $conditional_class = 'ajax';
172 PMA_printListItem(
173 PMA_Util::getImage('s_passwd.png') . " " . __('Change password'),
174 'li_change_password',
175 'user_password.php?' . $common_url_query,
176 null,
177 null,
178 'change_password_anchor',
179 "no_bullets",
180 $conditional_class
183 } // end if
184 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
185 echo ' <form method="post" action="index.php">' . "\n"
186 . PMA_URL_getHiddenInputs(null, null, 4, 'collation_connection')
187 . ' <label for="select_collation_connection">' . "\n"
188 . ' ' . PMA_Util::getImage('s_asci.png') . " "
189 . __('Server connection collation') . "\n"
190 // put the doc link in the form so that it appears on the same line
191 . PMA_Util::showMySQLDocu('Charset-connection')
192 . ': ' . "\n"
193 . ' </label>' . "\n"
195 . PMA_generateCharsetDropdownBox(
196 PMA_CSDROPDOWN_COLLATION,
197 'collation_connection',
198 'select_collation_connection',
199 $collation_connection,
200 true,
201 true
203 . ' </form>' . "\n"
204 . ' </li>' . "\n";
205 } // end of if ($server > 0 && !PMA_DRIZZLE)
206 echo '</ul>';
207 echo '</div>';
210 echo '<div class="group">';
211 echo '<h2>' . __('Appearance Settings') . '</h2>';
212 echo ' <ul>';
214 // Displays language selection combo
215 if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
216 echo '<li id="li_select_lang" class="no_bullets">';
217 include_once 'libraries/display_select_lang.lib.php';
218 echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
219 echo '</li>';
222 // ThemeManager if available
224 if ($GLOBALS['cfg']['ThemeManager']) {
225 echo '<li id="li_select_theme" class="no_bullets">';
226 echo PMA_Util::getImage('s_theme.png') . " "
227 . $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
228 echo '</li>';
230 echo '<li id="li_select_fontsize">';
231 echo PMA_Config::getFontsizeForm();
232 echo '</li>';
234 echo '</ul>';
236 // User preferences
238 if ($server > 0) {
239 echo '<ul>';
240 PMA_printListItem(
241 PMA_Util::getImage('b_tblops.png') . " " . __('More settings'),
242 'li_user_preferences',
243 'prefs_manage.php?' . $common_url_query,
244 null,
245 null,
246 null,
247 "no_bullets"
249 echo '</ul>';
252 echo '</div>';
255 echo '</div>';
256 echo '<div id="main_pane_right">';
259 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
261 echo '<div class="group">';
262 echo '<h2>' . __('Database server') . '</h2>';
263 echo '<ul>' . "\n";
264 PMA_printListItem(
265 __('Server:') . ' ' . $server_info,
266 'li_server_info'
268 PMA_printListItem(
269 __('Server type:') . ' ' . PMA_Util::getServerType(),
270 'li_server_type'
272 PMA_printListItem(
273 __('Server version:')
274 . ' '
275 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
276 'li_server_version'
278 PMA_printListItem(
279 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
280 'li_mysql_proto'
282 PMA_printListItem(
283 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
284 'li_user_info'
287 echo ' <li id="li_select_mysql_charset">';
288 echo ' ' . __('Server charset:') . ' '
289 . ' <span lang="en" dir="ltr">';
290 if (! PMA_DRIZZLE) {
291 echo ' '
292 . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']];
294 echo ' (' . $mysql_charset_map['utf-8'] . ')'
295 . ' </span>'
296 . ' </li>'
297 . ' </ul>'
298 . ' </div>';
301 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
302 echo '<div class="group">';
303 echo '<h2>' . __('Web server') . '</h2>';
304 echo '<ul>';
305 if ($GLOBALS['cfg']['ShowServerInfo']) {
306 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
308 if ($server > 0) {
309 $client_version_str = $GLOBALS['dbi']->getClientInfo();
310 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
311 $client_version_str = 'libmysql - ' . $client_version_str;
313 PMA_printListItem(
314 __('Database client version:') . ' ' . $client_version_str,
315 'li_mysql_client_version'
318 $php_ext_string = __('PHP extension:') . ' ';
319 if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
320 $extension = 'mysqli';
321 } else {
322 $extension = 'mysql';
324 $php_ext_string .= $extension . ' '
325 . PMA_Util::showPHPDocu('book.' . $extension . '.php');
327 PMA_printListItem(
328 $php_ext_string,
329 'li_used_php_extension'
334 if ($cfg['ShowPhpInfo']) {
335 PMA_printListItem(
336 __('Show PHP information'),
337 'li_phpinfo',
338 'phpinfo.php?' . $common_url_query,
339 null,
340 '_blank'
343 echo ' </ul>';
344 echo ' </div>';
347 echo '<div class="group pmagroup">';
348 echo '<h2>phpMyAdmin</h2>';
349 echo '<ul>';
350 $class = null;
351 // We rely on CSP to allow access to http://www.phpmyadmin.net, but IE lacks
352 // support here and does not allow request to http once using https.
353 if ($GLOBALS['cfg']['VersionCheck']
354 && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')
356 $class = 'jsversioncheck';
358 PMA_printListItem(
359 __('Version information:') . ' ' . PMA_VERSION,
360 'li_pma_version',
361 null,
362 null,
363 null,
364 null,
365 $class
367 PMA_printListItem(
368 __('Documentation'),
369 'li_pma_docs',
370 PMA_Util::getDocuLink('index'),
371 null,
372 '_blank'
374 PMA_printListItem(
375 __('Wiki'),
376 'li_pma_wiki',
377 PMA_linkURL('http://wiki.phpmyadmin.net/'),
378 null,
379 '_blank'
382 // does not work if no target specified, don't know why
383 PMA_printListItem(
384 __('Official Homepage'),
385 'li_pma_homepage',
386 PMA_linkURL('http://www.phpMyAdmin.net/'),
387 null,
388 '_blank'
390 PMA_printListItem(
391 __('Contribute'),
392 'li_pma_contribute',
393 PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'),
394 null,
395 '_blank'
397 PMA_printListItem(
398 __('Get support'),
399 'li_pma_support',
400 PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'),
401 null,
402 '_blank'
404 PMA_printListItem(
405 __('List of changes'),
406 'li_pma_changes',
407 PMA_linkURL('changelog.php'),
408 null,
409 '_blank'
411 echo ' </ul>';
412 echo ' </div>';
414 echo '</div>';
416 echo '</div>';
419 * Warning if using the default MySQL privileged account
421 if ($server != 0
422 && $cfg['Server']['user'] == 'root'
423 && $cfg['Server']['password'] == ''
425 trigger_error(
427 'Your configuration file contains settings (root with no password)'
428 . ' that correspond to the default MySQL privileged account.'
429 . ' Your MySQL server is running with this default, is open to'
430 . ' intrusion, and you really should fix this security hole by'
431 . ' setting a password for user \'root\'.'
433 E_USER_WARNING
438 * As we try to handle charsets by ourself, mbstring overloads just
439 * break it, see bug 1063821.
441 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
442 trigger_error(
444 'You have enabled mbstring.func_overload in your PHP '
445 . 'configuration. This option is incompatible with phpMyAdmin '
446 . 'and might cause some data to be corrupted!'
448 E_USER_WARNING
453 * mbstring is used for handling multibyte inside parser, so it is good
454 * to tell user something might be broken without it, see bug #1063149.
456 if (! @extension_loaded('mbstring')) {
457 trigger_error(
459 'The mbstring PHP extension was not found and you seem to be using'
460 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
461 . ' is unable to split strings correctly and it may result in'
462 . ' unexpected results.'
464 E_USER_WARNING
469 * Check whether session.gc_maxlifetime limits session validity.
471 $gc_time = (int)@ini_get('session.gc_maxlifetime');
472 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
473 trigger_error(
474 __('Your PHP parameter [a@http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime@_blank]session.gc_maxlifetime[/a] is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'),
475 E_USER_WARNING
480 * Check whether LoginCookieValidity is limited by LoginCookieStore.
482 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
483 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
485 trigger_error(
486 __('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'),
487 E_USER_WARNING
492 * Check if user does not have defined blowfish secret and it is being used.
494 if (! empty($_SESSION['encryption_key'])
495 && empty($GLOBALS['cfg']['blowfish_secret'])
497 trigger_error(
498 __('The configuration file now needs a secret passphrase (blowfish_secret).'),
499 E_USER_WARNING
504 * Check for existence of config directory which should not exist in
505 * production environment.
507 if (file_exists('config')) {
508 trigger_error(
509 __('Directory [code]config[/code], which is used by the setup script, still exists in your phpMyAdmin directory. It is strongly recommended to remove it once phpMyAdmin has been configured. Otherwise the security of your server may be compromised by unauthorized people downloading your configuration.'),
510 E_USER_WARNING
514 if ($server > 0) {
515 $cfgRelation = PMA_getRelationsParam();
516 if (! $cfgRelation['allworks']
517 && $cfg['PmaNoRelation_DisableWarning'] == false
519 $msg_text = __(
520 'The phpMyAdmin configuration storage is not completely '
521 . 'configured, some extended features have been deactivated. '
522 . '%sFind out why%s. '
524 if ($cfg['ZeroConf'] == true) {
525 $msg_text .= __(
526 '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
527 . 'Or alternately go to \'Operations\' tab of any database '
528 . 'to set it up there.'
531 $msg = PMA_Message::notice($msg_text);
532 $msg->addParam(
533 '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?'
534 . $common_url_query . '">',
535 false
537 $msg->addParam('</a>', false);
538 /* Show error if user has configured something, notice elsewhere */
539 if (!empty($cfg['Servers'][$server]['pmadb'])) {
540 $msg->isError(true);
542 $msg->display();
543 } // end if
547 * Warning about different MySQL library and server version
548 * (a difference on the third digit does not count).
549 * If someday there is a constant that we can check about mysqlnd,
550 * we can use it instead of strpos().
551 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
552 * Drizzle can speak MySQL protocol, so don't warn about version mismatch for
553 * Drizzle servers.
555 if (isset($GLOBALS['dbi'])
556 && !PMA_DRIZZLE
557 && $cfg['ServerLibraryDifference_DisableWarning'] == false
559 /** @var PMA_String $pmaString */
560 $pmaString = $GLOBALS['PMA_String'];
562 $_client_info = $GLOBALS['dbi']->getClientInfo();
563 if ($server > 0
564 && $pmaString->strpos($_client_info, 'mysqlnd') === false
565 && $pmaString->substr(PMA_MYSQL_CLIENT_API, 0, 3) != $pmaString->substr(
566 PMA_MYSQL_INT_VERSION, 0, 3
569 trigger_error(
570 PMA_sanitize(
571 sprintf(
572 __('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
573 $_client_info,
574 $pmaString->substr(
575 PMA_MYSQL_STR_VERSION,
577 $pmaString->strpos(PMA_MYSQL_STR_VERSION . '-', '-')
581 E_USER_NOTICE
584 unset($_client_info);
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(
596 __('Server running with Suhosin. Please refer to %sdocumentation%s 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@http://www.phpmyadmin.net/home_page/improve.php'
622 . '#translate@_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 '<li id="' . $listId . '"';
648 if (null !== $class) {
649 echo ' class="' . $class . '"';
651 echo '>';
652 if (null !== $url) {
653 echo '<a href="' . $url . '"';
654 if (null !== $target) {
655 echo ' target="' . $target . '"';
657 if (null != $a_id) {
658 echo ' id="' . $a_id . '"';
660 if (null != $a_class) {
661 echo ' class="' . $a_class . '"';
663 echo '>';
666 echo $name;
668 if (null !== $url) {
669 echo '</a>' . "\n";
671 if (null !== $mysql_help_page) {
672 echo PMA_Util::showMySQLDocu($mysql_help_page);
674 echo '</li>';