Improve locales compiling
[phpmyadmin.git] / index.php
blobc1449a83833895f61ae323db950b89b59bd638f8
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 // See FAQ 1.34
57 if (! empty($_REQUEST['db'])) {
58 $page = null;
59 if (! empty($_REQUEST['table'])) {
60 $page = $GLOBALS['cfg']['DefaultTabTable'];
61 } else {
62 $page = $GLOBALS['cfg']['DefaultTabDatabase'];
64 include $page;
65 exit;
68 /**
69 * Check if it is an ajax request to reload the recent tables list.
71 require_once 'libraries/RecentFavoriteTable.class.php';
72 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
73 $response = PMA_Response::getInstance();
74 $response->addJSON(
75 'list',
76 PMA_RecentFavoriteTable::getInstance('recent')->getHtmlList()
78 exit;
81 if ($GLOBALS['PMA_Config']->isGitRevision()) {
82 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
83 PMA_printGitRevision();
84 exit;
86 echo '<div id="is_git_revision"></div>';
89 // Handles some variables that may have been sent by the calling script
90 $GLOBALS['db'] = '';
91 $GLOBALS['table'] = '';
92 $show_query = '1';
94 // Any message to display?
95 if (! empty($message)) {
96 echo PMA_Util::getMessage($message);
97 unset($message);
100 $common_url_query = PMA_URL_getCommon('', '');
102 // when $server > 0, a server has been chosen so we can display
103 // all MySQL-related information
104 if ($server > 0) {
105 include 'libraries/server_common.inc.php';
106 include 'libraries/StorageEngine.class.php';
108 // Use the verbose name of the server instead of the hostname
109 // if a value is set
110 $server_info = '';
111 if (! empty($cfg['Server']['verbose'])) {
112 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
113 if ($GLOBALS['cfg']['ShowServerInfo']) {
114 $server_info .= ' (';
117 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
118 $server_info .= $GLOBALS['dbi']->getHostInfo();
120 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
121 $server_info .= ')';
123 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
125 // should we add the port info here?
126 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
127 ? $GLOBALS['cfg']['Server']['verbose']
128 : $GLOBALS['cfg']['Server']['host']);
131 echo '<div id="maincontainer">' . "\n";
132 // Anchor for favorite tables synchronization.
133 echo PMA_RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
134 echo '<div id="main_pane_left">';
135 if ($server > 0 || count($cfg['Servers']) > 1
137 if ($cfg['DBG']['demo']) {
138 echo '<div class="group">';
139 echo '<h2>' . __('phpMyAdmin Demo Server') . '</h2>';
140 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
141 printf(
143 'You are using the demo server. You can do anything here, but '
144 . 'please do not change root, debian-sys-maint and pma users. '
145 . 'More information is available at %s.'
147 '<a href="http://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'
149 echo '</p>';
150 echo '</div>';
152 echo '<div class="group">';
153 echo '<h2>' . __('General Settings') . '</h2>';
154 echo '<ul>';
157 * Displays the MySQL servers choice form
159 if ($cfg['ServerDefault'] == 0
160 || (! $cfg['NavigationDisplayServers']
161 && (count($cfg['Servers']) > 1
162 || ($server == 0 && count($cfg['Servers']) == 1)))
164 echo '<li id="li_select_server" class="no_bullets" >';
165 include_once 'libraries/select_server.lib.php';
166 echo PMA_Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
167 echo '</li>';
171 * Displays the mysql server related links
173 if ($server > 0 && ! PMA_DRIZZLE) {
174 include_once 'libraries/check_user_privileges.lib.php';
176 // Logout for advanced authentication
177 if ($cfg['Server']['auth_type'] != 'config') {
178 if ($cfg['ShowChgPassword']) {
179 $conditional_class = 'ajax';
180 PMA_printListItem(
181 PMA_Util::getImage('s_passwd.png') . " " . __('Change password'),
182 'li_change_password',
183 'user_password.php?' . $common_url_query,
184 null,
185 null,
186 'change_password_anchor',
187 "no_bullets",
188 $conditional_class
191 } // end if
192 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
193 echo ' <form method="post" action="index.php">' . "\n"
194 . PMA_URL_getHiddenInputs(null, null, 4, 'collation_connection')
195 . ' <label for="select_collation_connection">' . "\n"
196 . ' ' . PMA_Util::getImage('s_asci.png') . " "
197 . __('Server connection collation') . "\n"
198 // put the doc link in the form so that it appears on the same line
199 . PMA_Util::showMySQLDocu('Charset-connection')
200 . ': ' . "\n"
201 . ' </label>' . "\n"
203 . PMA_generateCharsetDropdownBox(
204 PMA_CSDROPDOWN_COLLATION,
205 'collation_connection',
206 'select_collation_connection',
207 $collation_connection,
208 true,
210 true
212 . ' </form>' . "\n"
213 . ' </li>' . "\n";
214 } // end of if ($server > 0 && !PMA_DRIZZLE)
215 echo '</ul>';
216 echo '</div>';
219 echo '<div class="group">';
220 echo '<h2>' . __('Appearance Settings') . '</h2>';
221 echo ' <ul>';
223 // Displays language selection combo
224 if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
225 echo '<li id="li_select_lang" class="no_bullets">';
226 include_once 'libraries/display_select_lang.lib.php';
227 echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
228 echo '</li>';
231 // ThemeManager if available
233 if ($GLOBALS['cfg']['ThemeManager']) {
234 echo '<li id="li_select_theme" class="no_bullets">';
235 echo PMA_Util::getImage('s_theme.png') . " "
236 . $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
237 echo '</li>';
239 echo '<li id="li_select_fontsize">';
240 echo PMA_Config::getFontsizeForm();
241 echo '</li>';
243 echo '</ul>';
245 // User preferences
247 if ($server > 0) {
248 echo '<ul>';
249 PMA_printListItem(
250 PMA_Util::getImage('b_tblops.png') . " " . __('More settings'),
251 'li_user_preferences',
252 'prefs_manage.php?' . $common_url_query,
253 null,
254 null,
255 null,
256 "no_bullets"
258 echo '</ul>';
261 echo '</div>';
264 echo '</div>';
265 echo '<div id="main_pane_right">';
268 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
270 echo '<div class="group">';
271 echo '<h2>' . __('Database server') . '</h2>';
272 echo '<ul>' . "\n";
273 PMA_printListItem(
274 __('Server:') . ' ' . $server_info,
275 'li_server_info'
277 PMA_printListItem(
278 __('Server type:') . ' ' . PMA_Util::getServerType(),
279 'li_server_type'
281 PMA_printListItem(
282 __('Server version:')
283 . ' '
284 . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
285 'li_server_version'
287 PMA_printListItem(
288 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
289 'li_mysql_proto'
291 PMA_printListItem(
292 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
293 'li_user_info'
296 echo ' <li id="li_select_mysql_charset">';
297 echo ' ' . __('Server charset:') . ' '
298 . ' <span lang="en" dir="ltr">';
299 if (! PMA_DRIZZLE) {
300 echo ' '
301 . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']];
303 echo ' (' . $mysql_charset_map['utf-8'] . ')'
304 . ' </span>'
305 . ' </li>'
306 . ' </ul>'
307 . ' </div>';
310 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
311 echo '<div class="group">';
312 echo '<h2>' . __('Web server') . '</h2>';
313 echo '<ul>';
314 if ($GLOBALS['cfg']['ShowServerInfo']) {
315 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
317 if ($server > 0) {
318 $client_version_str = $GLOBALS['dbi']->getClientInfo();
319 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
320 $client_version_str = 'libmysql - ' . $client_version_str;
322 PMA_printListItem(
323 __('Database client version:') . ' ' . $client_version_str,
324 'li_mysql_client_version'
327 $php_ext_string = __('PHP extension:') . ' ';
328 if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
329 $extension = 'mysqli';
330 } else {
331 $extension = 'mysql';
333 $php_ext_string .= $extension . ' '
334 . PMA_Util::showPHPDocu('book.' . $extension . '.php');
336 PMA_printListItem(
337 $php_ext_string,
338 'li_used_php_extension'
343 if ($cfg['ShowPhpInfo']) {
344 PMA_printListItem(
345 __('Show PHP information'),
346 'li_phpinfo',
347 'phpinfo.php?' . $common_url_query,
348 null,
349 '_blank'
352 echo ' </ul>';
353 echo ' </div>';
356 echo '<div class="group pmagroup">';
357 echo '<h2>phpMyAdmin</h2>';
358 echo '<ul>';
359 $class = null;
360 // We rely on CSP to allow access to http://www.phpmyadmin.net, but IE lacks
361 // support here and does not allow request to http once using https.
362 if ($GLOBALS['cfg']['VersionCheck']
363 && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')
365 $class = 'jsversioncheck';
367 PMA_printListItem(
368 __('Version information:') . ' ' . PMA_VERSION,
369 'li_pma_version',
370 null,
371 null,
372 null,
373 null,
374 $class
376 PMA_printListItem(
377 __('Documentation'),
378 'li_pma_docs',
379 PMA_Util::getDocuLink('index'),
380 null,
381 '_blank'
383 PMA_printListItem(
384 __('Wiki'),
385 'li_pma_wiki',
386 PMA_linkURL('http://wiki.phpmyadmin.net/'),
387 null,
388 '_blank'
391 // does not work if no target specified, don't know why
392 PMA_printListItem(
393 __('Official Homepage'),
394 'li_pma_homepage',
395 PMA_linkURL('http://www.phpMyAdmin.net/'),
396 null,
397 '_blank'
399 PMA_printListItem(
400 __('Contribute'),
401 'li_pma_contribute',
402 PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'),
403 null,
404 '_blank'
406 PMA_printListItem(
407 __('Get support'),
408 'li_pma_support',
409 PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'),
410 null,
411 '_blank'
413 PMA_printListItem(
414 __('List of changes'),
415 'li_pma_changes',
416 PMA_linkURL('changelog.php'),
417 null,
418 '_blank'
420 echo ' </ul>';
421 echo ' </div>';
423 echo '</div>';
425 echo '</div>';
428 * Warning if using the default MySQL privileged account
430 if ($server != 0
431 && $cfg['Server']['user'] == 'root'
432 && $cfg['Server']['password'] == ''
434 trigger_error(
436 'Your configuration file contains settings (root with no password)'
437 . ' that correspond to the default MySQL privileged account.'
438 . ' Your MySQL server is running with this default, is open to'
439 . ' intrusion, and you really should fix this security hole by'
440 . ' setting a password for user \'root\'.'
442 E_USER_WARNING
447 * As we try to handle charsets by ourself, mbstring overloads just
448 * break it, see bug 1063821.
450 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
451 trigger_error(
453 'You have enabled mbstring.func_overload in your PHP '
454 . 'configuration. This option is incompatible with phpMyAdmin '
455 . 'and might cause some data to be corrupted!'
457 E_USER_WARNING
462 * mbstring is used for handling multibyte inside parser, so it is good
463 * to tell user something might be broken without it, see bug #1063149.
465 if (! @extension_loaded('mbstring')) {
466 trigger_error(
468 'The mbstring PHP extension was not found and you seem to be using'
469 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
470 . ' is unable to split strings correctly and it may result in'
471 . ' unexpected results.'
473 E_USER_WARNING
478 * Check whether session.gc_maxlifetime limits session validity.
480 $gc_time = (int)@ini_get('session.gc_maxlifetime');
481 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
482 trigger_error(
483 __('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.'),
484 E_USER_WARNING
489 * Check whether LoginCookieValidity is limited by LoginCookieStore.
491 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
492 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
494 trigger_error(
495 __('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than 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['auto_blowfish_secret'])
504 && empty($GLOBALS['cfg']['blowfish_secret'])
506 trigger_error(
507 __('The configuration file now needs a secret passphrase (blowfish_secret).'),
508 E_USER_WARNING
513 * Check for existence of config directory which should not exist in
514 * production environment.
516 if (file_exists('config')) {
517 trigger_error(
518 __('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.'),
519 E_USER_WARNING
523 if ($server > 0) {
524 $cfgRelation = PMA_getRelationsParam();
525 if (! $cfgRelation['allworks']
526 && $cfg['PmaNoRelation_DisableWarning'] == false
528 $msg = PMA_Message::notice(__('The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click %shere%s.'));
529 $msg->addParam(
530 '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?'
531 . $common_url_query . '">',
532 false
534 $msg->addParam('</a>', false);
535 /* Show error if user has configured something, notice elsewhere */
536 if (!empty($cfg['Servers'][$server]['pmadb'])) {
537 $msg->isError(true);
539 $msg->display();
540 } // end if
544 * Warning about different MySQL library and server version
545 * (a difference on the third digit does not count).
546 * If someday there is a constant that we can check about mysqlnd,
547 * we can use it instead of strpos().
548 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
549 * Drizzle can speak MySQL protocol, so don't warn about version mismatch for
550 * Drizzle servers.
552 if (isset($GLOBALS['dbi'])
553 && !PMA_DRIZZLE
554 && $cfg['ServerLibraryDifference_DisableWarning'] == false
556 $_client_info = $GLOBALS['dbi']->getClientInfo();
557 if ($server > 0
558 && strpos($_client_info, 'mysqlnd') === false
559 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
561 trigger_error(
562 PMA_sanitize(
563 sprintf(
564 __('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
565 $_client_info,
566 substr(
567 PMA_MYSQL_STR_VERSION,
569 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
573 E_USER_NOTICE
576 unset($_client_info);
580 * Warning about Suhosin only if its simulation mode is not enabled
582 if ($cfg['SuhosinDisableWarning'] == false
583 && @ini_get('suhosin.request.max_value_length')
584 && @ini_get('suhosin.simulation') == '0'
586 trigger_error(
587 sprintf(
588 __('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'),
589 '[doc@faq1-38]',
590 '[/doc]'
592 E_USER_WARNING
597 * Warning about incomplete translations.
599 * The data file is created while creating release by ./scripts/remove-incomplete-mo
601 if (file_exists('libraries/language_stats.inc.php')) {
602 include 'libraries/language_stats.inc.php';
604 * This message is intentionally not translated, because we're
605 * handling incomplete translations here and focus on english
606 * speaking users.
608 if (isset($GLOBALS['language_stats'][$lang])
609 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
611 trigger_error(
612 'You are using an incomplete translation, please help to make it '
613 . 'better by [a@http://www.phpmyadmin.net/home_page/improve.php'
614 . '#translate@_blank]contributing[/a].',
615 E_USER_NOTICE
621 * prints list item for main page
623 * @param string $name displayed text
624 * @param string $listId id, used for css styles
625 * @param string $url make item as link with $url as target
626 * @param string $mysql_help_page display a link to MySQL's manual
627 * @param string $target special target for $url
628 * @param string $a_id id for the anchor,
629 * used for jQuery to hook in functions
630 * @param string $class class for the li element
631 * @param string $a_class class for the anchor element
633 * @return void
635 function PMA_printListItem($name, $listId = null, $url = null,
636 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
637 $a_class = null
639 echo '<li id="' . $listId . '"';
640 if (null !== $class) {
641 echo ' class="' . $class . '"';
643 echo '>';
644 if (null !== $url) {
645 echo '<a href="' . $url . '"';
646 if (null !== $target) {
647 echo ' target="' . $target . '"';
649 if (null != $a_id) {
650 echo ' id="' . $a_id . '"';
652 if (null != $a_class) {
653 echo ' class="' . $a_class . '"';
655 echo '>';
658 echo $name;
660 if (null !== $url) {
661 echo '</a>' . "\n";
663 if (null !== $mysql_help_page) {
664 echo PMA_Util::showMySQLDocu($mysql_help_page);
666 echo '</li>';