Translated using Weblate (Thai)
[phpmyadmin.git] / index.php
blob96f6969710c2d7d019c5d8916fc8bfe17561660b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
8 /**
9 * Gets some core libraries and displays a top message if required
11 require_once 'libraries/common.inc.php';
13 /**
14 * display Git revision if requested
16 require_once 'libraries/display_git_revision.lib.php';
18 /**
19 * pass variables to child pages
21 $drops = array(
22 'lang',
23 'server',
24 'collation_connection',
25 'db',
26 'table'
28 foreach ($drops as $each_drop) {
29 if (array_key_exists($each_drop, $_GET)) {
30 unset($_GET[$each_drop]);
33 unset($drops, $each_drop);
35 // If we have a valid target, let's load that script instead
36 if (! empty($_REQUEST['target'])
37 && is_string($_REQUEST['target'])
38 && ! preg_match('/^index/', $_REQUEST['target'])
39 && in_array($_REQUEST['target'], $goto_whitelist)
40 ) {
41 include $_REQUEST['target'];
42 exit;
45 /**
46 * Check if it is an ajax request to reload the recent tables list.
48 require_once 'libraries/RecentTable.class.php';
49 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
50 $response = PMA_Response::getInstance();
51 $response->addJSON(
52 'options',
53 PMA_RecentTable::getInstance()->getHtmlSelectOption()
55 exit;
58 if ($GLOBALS['PMA_Config']->isGitRevision()) {
59 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
60 PMA_printGitRevision();
61 exit;
63 echo '<div id="is_git_revision"></div>';
66 // Handles some variables that may have been sent by the calling script
67 $GLOBALS['db'] = '';
68 $GLOBALS['table'] = '';
69 $show_query = '1';
71 // Any message to display?
72 if (! empty($message)) {
73 echo PMA_Util::getMessage($message);
74 unset($message);
77 $common_url_query = PMA_generate_common_url('', '');
79 // when $server > 0, a server has been chosen so we can display
80 // all MySQL-related information
81 if ($server > 0) {
82 include 'libraries/server_common.inc.php';
83 include 'libraries/StorageEngine.class.php';
85 // Use the verbose name of the server instead of the hostname
86 // if a value is set
87 $server_info = '';
88 if (! empty($cfg['Server']['verbose'])) {
89 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
90 if ($GLOBALS['cfg']['ShowServerInfo']) {
91 $server_info .= ' (';
94 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
95 $server_info .= PMA_DBI_get_host_info();
97 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
98 $server_info .= ')';
100 $mysql_cur_user_and_host = PMA_DBI_fetch_value('SELECT USER();');
102 // should we add the port info here?
103 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
104 ? $GLOBALS['cfg']['Server']['verbose']
105 : $GLOBALS['cfg']['Server']['host']);
108 echo '<div id="maincontainer">' . "\n";
109 echo '<div id="main_pane_left">';
110 if ($server > 0
111 || (! $cfg['NavigationDisplayServers'] && count($cfg['Servers']) > 1)
113 echo '<div class="group">';
114 echo '<h2>' . __('General Settings') . '</h2>';
115 echo '<ul>';
118 * Displays the MySQL servers choice form
120 if (! $cfg['NavigationDisplayServers']
121 && (count($cfg['Servers']) > 1 || $server == 0 && count($cfg['Servers']) == 1)
123 echo '<li id="li_select_server" class="no_bullets" >';
124 include_once 'libraries/select_server.lib.php';
125 echo PMA_Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
126 echo '</li>';
130 * Displays the mysql server related links
132 if ($server > 0 && ! PMA_DRIZZLE) {
133 include_once 'libraries/check_user_privileges.lib.php';
135 // Logout for advanced authentication
136 if ($cfg['Server']['auth_type'] != 'config') {
137 if ($cfg['ShowChgPassword']) {
138 $conditional_class = 'ajax';
139 PMA_printListItem(
140 PMA_Util::getImage('s_passwd.png') . " " . __('Change password'),
141 'li_change_password',
142 'user_password.php?' . $common_url_query,
143 null,
144 null,
145 'change_password_anchor',
146 "no_bullets",
147 $conditional_class
150 } // end if
151 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
152 echo ' <form method="post" action="index.php">' . "\n"
153 . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
154 . ' <label for="select_collation_connection">' . "\n"
155 . ' '. PMA_Util::getImage('s_asci.png') . " "
156 . __('Server connection collation') . "\n"
157 // put the doc link in the form so that it appears on the same line
158 . PMA_Util::showMySQLDocu(
159 'MySQL_Database_Administration',
160 'Charset-connection'
162 . ': ' . "\n"
163 . ' </label>' . "\n"
165 . PMA_generateCharsetDropdownBox(
166 PMA_CSDROPDOWN_COLLATION,
167 'collation_connection',
168 'select_collation_connection',
169 $collation_connection,
170 true,
172 true
174 . ' </form>' . "\n"
175 . ' </li>' . "\n";
176 } // end of if ($server > 0 && !PMA_DRIZZLE)
177 echo '</ul>';
178 echo '</div>';
181 echo '<div class="group">';
182 echo '<h2>' . __('Appearance Settings') . '</h2>';
183 echo ' <ul>';
185 // Displays language selection combo
186 if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
187 echo '<li id="li_select_lang" class="no_bullets">';
188 include_once 'libraries/display_select_lang.lib.php';
189 echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
190 echo '</li>';
193 // ThemeManager if available
195 if ($GLOBALS['cfg']['ThemeManager']) {
196 echo '<li id="li_select_theme" class="no_bullets">';
197 echo PMA_Util::getImage('s_theme.png') . " "
198 . $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
199 echo '</li>';
201 echo '<li id="li_select_fontsize">';
202 echo PMA_Config::getFontsizeForm();
203 echo '</li>';
205 echo '</ul>';
207 // User preferences
209 if ($server > 0) {
210 echo '<ul>';
211 PMA_printListItem(
212 PMA_Util::getImage('b_tblops.png')." " .__('More settings'),
213 'li_user_preferences',
214 'prefs_manage.php?' . $common_url_query,
215 null,
216 null,
217 null,
218 "no_bullets"
220 echo '</ul>';
223 echo '</div>';
226 echo '</div>';
227 echo '<div id="main_pane_right">';
230 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
232 echo '<div class="group">';
233 echo '<h2>' . __('Database server') . '</h2>';
234 echo '<ul>' . "\n";
235 PMA_printListItem(
236 __('Server') . ': ' . $server_info,
237 'li_server_info'
239 PMA_printListItem(
240 __('Server type') . ': ' . PMA_Util::getServerType(),
241 'li_server_type'
243 PMA_printListItem(
244 __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
245 'li_server_version'
247 PMA_printListItem(
248 __('Protocol version') . ': ' . PMA_DBI_get_proto_info(),
249 'li_mysql_proto'
251 PMA_printListItem(
252 __('User') . ': ' . htmlspecialchars($mysql_cur_user_and_host),
253 'li_user_info'
256 echo ' <li id="li_select_mysql_charset">';
257 echo ' ' . __('Server charset') . ': '
258 . ' <span lang="en" dir="ltr">'
259 . ' ' . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']] . "\n"
260 . ' (' . $mysql_charset_map['utf-8'] . ')' . "\n"
261 . ' </span>' . "\n"
262 . ' </li>' . "\n";
263 echo ' </ul>';
264 echo ' </div>';
267 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
268 echo '<div class="group">';
269 echo '<h2>' . __('Web server') . '</h2>';
270 echo '<ul>';
271 if ($GLOBALS['cfg']['ShowServerInfo']) {
272 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
274 if ($server > 0) {
275 $client_version_str = PMA_DBI_get_client_info();
276 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)
277 && in_array($GLOBALS['cfg']['Server']['extension'], array('mysql', 'mysqli'))
279 $client_version_str = 'libmysql - ' . $client_version_str;
281 PMA_printListItem(
282 __('Database client version') . ': ' . $client_version_str,
283 'li_mysql_client_version'
286 $php_ext_string = __('PHP extension') . ': '
287 . $GLOBALS['cfg']['Server']['extension'] . ' '
288 . PMA_Util::showPHPDocu(
289 'book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'
291 PMA_printListItem(
292 $php_ext_string,
293 'li_used_php_extension'
298 if ($cfg['ShowPhpInfo']) {
299 PMA_printListItem(
300 __('Show PHP information'),
301 'li_phpinfo',
302 'phpinfo.php?' . $common_url_query,
303 null,
304 '_blank'
307 echo ' </ul>';
308 echo ' </div>';
311 echo '<div class="group pmagroup">';
312 echo '<h2>phpMyAdmin</h2>';
313 echo '<ul>';
314 $class = null;
315 // We rely on CSP to allow access to http://www.phpmyadmin.net, but IE lacks
316 // support here and does not allow request to http once using https.
317 if ($GLOBALS['cfg']['VersionCheck']
318 && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')
320 $class = 'jsversioncheck';
322 PMA_printListItem(
323 __('Version information') . ': ' . PMA_VERSION,
324 'li_pma_version',
325 null,
326 null,
327 null,
328 null,
329 $class
331 PMA_printListItem(
332 __('Documentation'),
333 'li_pma_docs',
334 PMA_Util::getDocuLink('index'),
335 null,
336 '_blank'
338 PMA_printListItem(
339 __('Wiki'),
340 'li_pma_wiki',
341 PMA_linkURL('http://wiki.phpmyadmin.net/'),
342 null,
343 '_blank'
346 // does not work if no target specified, don't know why
347 PMA_printListItem(
348 __('Official Homepage'),
349 'li_pma_homepage',
350 PMA_linkURL('http://www.phpMyAdmin.net/'),
351 null,
352 '_blank'
354 PMA_printListItem(
355 __('Contribute'),
356 'li_pma_contribute',
357 PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'),
358 null,
359 '_blank'
361 PMA_printListItem(
362 __('Get support'),
363 'li_pma_support',
364 PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'),
365 null,
366 '_blank'
368 PMA_printListItem(
369 __('List of changes'),
370 'li_pma_changes',
371 PMA_linkURL('changelog.php'),
372 null,
373 '_blank'
376 </ul>
377 </div>
379 </div>
381 </div>
383 <?php
385 * Warning if using the default MySQL privileged account
387 if ($server != 0
388 && $cfg['Server']['user'] == 'root'
389 && $cfg['Server']['password'] == ''
391 trigger_error(
392 __('Your configuration file contains settings (root with no password) that correspond to the default MySQL privileged account. Your MySQL server is running with this default, is open to intrusion, and you really should fix this security hole by setting a password for user \'root\'.'),
393 E_USER_WARNING
398 * Nijel: As we try to handle charsets by ourself, mbstring overloads just
399 * break it, see bug 1063821.
401 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
402 trigger_error(
403 __('You have enabled mbstring.func_overload in your PHP configuration. This option is incompatible with phpMyAdmin and might cause some data to be corrupted!'),
404 E_USER_WARNING
409 * Nijel: mbstring is used for handling multibyte inside parser, so it is good
410 * to tell user something might be broken without it, see bug #1063149.
412 if (! @extension_loaded('mbstring')) {
413 trigger_error(
414 __('The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.'),
415 E_USER_WARNING
420 * Check whether session.gc_maxlifetime limits session validity.
422 $gc_time = (int)@ini_get('session.gc_maxlifetime');
423 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
424 trigger_error(
425 __('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.'),
426 E_USER_WARNING
431 * Check whether LoginCookieValidity is limited by LoginCookieStore.
433 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
434 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
436 trigger_error(
437 __('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'),
438 E_USER_WARNING
443 * Check if user does not have defined blowfish secret and it is being used.
445 if (! empty($_SESSION['auto_blowfish_secret'])
446 && empty($GLOBALS['cfg']['blowfish_secret'])
448 trigger_error(
449 __('The configuration file now needs a secret passphrase (blowfish_secret).'),
450 E_USER_WARNING
455 * Check for existence of config directory which should not exist in
456 * production environment.
458 if (file_exists('config')) {
459 trigger_error(
460 __('Directory [code]config[/code], which is used by the setup script, still exists in your phpMyAdmin directory. You should remove it once phpMyAdmin has been configured.'),
461 E_USER_WARNING
465 if ($server > 0) {
466 $cfgRelation = PMA_getRelationsParam();
467 if (! $cfgRelation['allworks']
468 && $cfg['PmaNoRelation_DisableWarning'] == false
470 $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.'));
471 $msg->addParam(
472 '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $common_url_query . '">',
473 false
475 $msg->addParam('</a>', false);
476 /* Show error if user has configured something, notice elsewhere */
477 if (!empty($cfg['Servers'][$server]['pmadb'])) {
478 $msg->isError(true);
480 $msg->display();
481 } // end if
485 * Warning about different MySQL library and server version
486 * (a difference on the third digit does not count).
487 * If someday there is a constant that we can check about mysqlnd,
488 * we can use it instead of strpos().
489 * If no default server is set, PMA_DBI_get_client_info() is not defined yet.
490 * Drizzle can speak MySQL protocol, so don't warn about version mismatch for
491 * Drizzle servers.
493 if (function_exists('PMA_DBI_get_client_info') && !PMA_DRIZZLE) {
494 $_client_info = PMA_DBI_get_client_info();
495 if ($server > 0
496 && strpos($_client_info, 'mysqlnd') === false
497 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
499 trigger_error(
500 PMA_sanitize(
501 sprintf(
502 __('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
503 $_client_info,
504 substr(
505 PMA_MYSQL_STR_VERSION,
507 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
511 E_USER_NOTICE
514 unset($_client_info);
518 * Warning about Suhosin
520 if ($cfg['SuhosinDisableWarning'] == false
521 && @ini_get('suhosin.request.max_value_length')
523 trigger_error(
524 sprintf(
525 __('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'),
526 '[doc@faq1-38]',
527 '[/doc]'
529 E_USER_WARNING
534 * Warning about mcrypt.
536 if (! function_exists('mcrypt_encrypt')
537 && ! $GLOBALS['cfg']['McryptDisableWarning']
539 PMA_warnMissingExtension('mcrypt');
543 * Warning about incomplete translations.
545 * The data file is created while creating release by ./scripts/remove-incomplete-mo
547 if (file_exists('libraries/language_stats.inc.php')) {
548 include 'libraries/language_stats.inc.php';
550 * This message is intentionally not translated, because we're
551 * handling incomplete translations here and focus on english
552 * speaking users.
554 if (isset($GLOBALS['language_stats'][$lang])
555 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
557 trigger_error(
558 'You are using an incomplete translation, please help to make it better by <a href="http://www.phpmyadmin.net/home_page/improve.php#translate" target="_blank">contributing</a>.',
559 E_USER_NOTICE
565 * prints list item for main page
567 * @param string $name displayed text
568 * @param string $id id, used for css styles
569 * @param string $url make item as link with $url as target
570 * @param string $mysql_help_page display a link to MySQL's manual
571 * @param string $target special target for $url
572 * @param string $a_id id for the anchor,
573 * used for jQuery to hook in functions
574 * @param string $class class for the li element
575 * @param string $a_class class for the anchor element
577 * @return void
579 function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null,
580 $target = null, $a_id = null, $class = null, $a_class = null
582 echo '<li id="' . $id . '"';
583 if (null !== $class) {
584 echo ' class="' . $class . '"';
586 echo '>';
587 if (null !== $url) {
588 echo '<a href="' . $url . '"';
589 if (null !== $target) {
590 echo ' target="' . $target . '"';
592 if (null != $a_id) {
593 echo ' id="' . $a_id .'"';
595 if (null != $a_class) {
596 echo ' class="' . $a_class .'"';
598 echo '>';
601 echo $name;
603 if (null !== $url) {
604 echo '</a>' . "\n";
606 if (null !== $mysql_help_page) {
607 echo PMA_Util::showMySQLDocu('', $mysql_help_page);
609 echo '</li>';