Merge pull request #431 from xmujay/0609_monitor
[phpmyadmin/aamir.git] / index.php
blob07acc4a2477577e5ba722609d04717803d35b826
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);
36 // If we have a valid target, let's load that script instead
37 if (! empty($_REQUEST['target'])
38 && is_string($_REQUEST['target'])
39 && ! preg_match('/^index/', $_REQUEST['target'])
40 && in_array($_REQUEST['target'], $goto_whitelist)
41 ) {
42 include $_REQUEST['target'];
43 exit;
46 /**
47 * Check if it is an ajax request to reload the recent tables list.
49 require_once 'libraries/RecentTable.class.php';
50 if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
51 $response = PMA_Response::getInstance();
52 $response->addJSON(
53 'options',
54 PMA_RecentTable::getInstance()->getHtmlSelectOption()
56 exit;
59 if ($GLOBALS['PMA_Config']->isGitRevision()) {
60 if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
61 PMA_printGitRevision();
62 exit;
64 echo '<div id="is_git_revision"></div>';
67 // Handles some variables that may have been sent by the calling script
68 $GLOBALS['db'] = '';
69 $GLOBALS['table'] = '';
70 $show_query = '1';
72 // Any message to display?
73 if (! empty($message)) {
74 echo PMA_Util::getMessage($message);
75 unset($message);
78 $common_url_query = PMA_generate_common_url('', '');
80 // when $server > 0, a server has been chosen so we can display
81 // all MySQL-related information
82 if ($server > 0) {
83 include 'libraries/server_common.inc.php';
84 include 'libraries/StorageEngine.class.php';
86 // Use the verbose name of the server instead of the hostname
87 // if a value is set
88 $server_info = '';
89 if (! empty($cfg['Server']['verbose'])) {
90 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
91 if ($GLOBALS['cfg']['ShowServerInfo']) {
92 $server_info .= ' (';
95 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
96 $server_info .= $GLOBALS['dbi']->getHostInfo();
98 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
99 $server_info .= ')';
101 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
103 // should we add the port info here?
104 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
105 ? $GLOBALS['cfg']['Server']['verbose']
106 : $GLOBALS['cfg']['Server']['host']);
109 echo '<div id="maincontainer">' . "\n";
110 echo '<div id="main_pane_left">';
111 if ($server > 0 || 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['ServerDefault'] == 0
121 || (! $cfg['NavigationDisplayServers']
122 && (count($cfg['Servers']) > 1
123 || ($server == 0 && count($cfg['Servers']) == 1)
127 echo '<li id="li_select_server" class="no_bullets" >';
128 include_once 'libraries/select_server.lib.php';
129 echo PMA_Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
130 echo '</li>';
134 * Displays the mysql server related links
136 if ($server > 0 && ! PMA_DRIZZLE) {
137 include_once 'libraries/check_user_privileges.lib.php';
139 // Logout for advanced authentication
140 if ($cfg['Server']['auth_type'] != 'config') {
141 if ($cfg['ShowChgPassword']) {
142 $conditional_class = 'ajax';
143 PMA_printListItem(
144 PMA_Util::getImage('s_passwd.png') . " " . __('Change password'),
145 'li_change_password',
146 'user_password.php?' . $common_url_query,
147 null,
148 null,
149 'change_password_anchor',
150 "no_bullets",
151 $conditional_class
154 } // end if
155 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
156 echo ' <form method="post" action="index.php">' . "\n"
157 . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
158 . ' <label for="select_collation_connection">' . "\n"
159 . ' '. PMA_Util::getImage('s_asci.png') . " "
160 . __('Server connection collation') . "\n"
161 // put the doc link in the form so that it appears on the same line
162 . PMA_Util::showMySQLDocu(
163 'MySQL_Database_Administration',
164 'Charset-connection'
166 . ': ' . "\n"
167 . ' </label>' . "\n"
169 . PMA_generateCharsetDropdownBox(
170 PMA_CSDROPDOWN_COLLATION,
171 'collation_connection',
172 'select_collation_connection',
173 $collation_connection,
174 true,
176 true
178 . ' </form>' . "\n"
179 . ' </li>' . "\n";
180 } // end of if ($server > 0 && !PMA_DRIZZLE)
181 echo '</ul>';
182 echo '</div>';
185 echo '<div class="group">';
186 echo '<h2>' . __('Appearance Settings') . '</h2>';
187 echo ' <ul>';
189 // Displays language selection combo
190 if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
191 echo '<li id="li_select_lang" class="no_bullets">';
192 include_once 'libraries/display_select_lang.lib.php';
193 echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
194 echo '</li>';
197 // ThemeManager if available
199 if ($GLOBALS['cfg']['ThemeManager']) {
200 echo '<li id="li_select_theme" class="no_bullets">';
201 echo PMA_Util::getImage('s_theme.png') . " "
202 . $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
203 echo '</li>';
205 echo '<li id="li_select_fontsize">';
206 echo PMA_Config::getFontsizeForm();
207 echo '</li>';
209 echo '</ul>';
211 // User preferences
213 if ($server > 0) {
214 echo '<ul>';
215 PMA_printListItem(
216 PMA_Util::getImage('b_tblops.png')." " .__('More settings'),
217 'li_user_preferences',
218 'prefs_manage.php?' . $common_url_query,
219 null,
220 null,
221 null,
222 "no_bullets"
224 echo '</ul>';
227 echo '</div>';
230 echo '</div>';
231 echo '<div id="main_pane_right">';
234 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
236 echo '<div class="group">';
237 echo '<h2>' . __('Database server') . '</h2>';
238 echo '<ul>' . "\n";
239 PMA_printListItem(
240 __('Server:') . ' ' . $server_info,
241 'li_server_info'
243 PMA_printListItem(
244 __('Server type:') . ' ' . PMA_Util::getServerType(),
245 'li_server_type'
247 PMA_printListItem(
248 __('Server version:') . ' ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
249 'li_server_version'
251 PMA_printListItem(
252 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
253 'li_mysql_proto'
255 PMA_printListItem(
256 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
257 'li_user_info'
260 echo ' <li id="li_select_mysql_charset">';
261 echo ' ' . __('Server charset:') . ' '
262 . ' <span lang="en" dir="ltr">'
263 . ' ' . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']] . "\n"
264 . ' (' . $mysql_charset_map['utf-8'] . ')' . "\n"
265 . ' </span>' . "\n"
266 . ' </li>' . "\n";
267 echo ' </ul>';
268 echo ' </div>';
271 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
272 echo '<div class="group">';
273 echo '<h2>' . __('Web server') . '</h2>';
274 echo '<ul>';
275 if ($GLOBALS['cfg']['ShowServerInfo']) {
276 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
278 if ($server > 0) {
279 $client_version_str = $GLOBALS['dbi']->getClientInfo();
280 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)
281 && in_array($GLOBALS['cfg']['Server']['extension'], array('mysql', 'mysqli'))
283 $client_version_str = 'libmysql - ' . $client_version_str;
285 PMA_printListItem(
286 __('Database client version:') . ' ' . $client_version_str,
287 'li_mysql_client_version'
290 $php_ext_string = __('PHP extension:') . ' '
291 . $GLOBALS['cfg']['Server']['extension'] . ' '
292 . PMA_Util::showPHPDocu(
293 'book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'
295 PMA_printListItem(
296 $php_ext_string,
297 'li_used_php_extension'
302 if ($cfg['ShowPhpInfo']) {
303 PMA_printListItem(
304 __('Show PHP information'),
305 'li_phpinfo',
306 'phpinfo.php?' . $common_url_query,
307 null,
308 '_blank'
311 echo ' </ul>';
312 echo ' </div>';
315 echo '<div class="group pmagroup">';
316 echo '<h2>phpMyAdmin</h2>';
317 echo '<ul>';
318 $class = null;
319 // We rely on CSP to allow access to http://www.phpmyadmin.net, but IE lacks
320 // support here and does not allow request to http once using https.
321 if ($GLOBALS['cfg']['VersionCheck']
322 && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')
324 $class = 'jsversioncheck';
326 PMA_printListItem(
327 __('Version information:') . ' ' . PMA_VERSION,
328 'li_pma_version',
329 null,
330 null,
331 null,
332 null,
333 $class
335 PMA_printListItem(
336 __('Documentation'),
337 'li_pma_docs',
338 PMA_Util::getDocuLink('index'),
339 null,
340 '_blank'
342 PMA_printListItem(
343 __('Wiki'),
344 'li_pma_wiki',
345 PMA_linkURL('http://wiki.phpmyadmin.net/'),
346 null,
347 '_blank'
350 // does not work if no target specified, don't know why
351 PMA_printListItem(
352 __('Official Homepage'),
353 'li_pma_homepage',
354 PMA_linkURL('http://www.phpMyAdmin.net/'),
355 null,
356 '_blank'
358 PMA_printListItem(
359 __('Contribute'),
360 'li_pma_contribute',
361 PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'),
362 null,
363 '_blank'
365 PMA_printListItem(
366 __('Get support'),
367 'li_pma_support',
368 PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'),
369 null,
370 '_blank'
372 PMA_printListItem(
373 __('List of changes'),
374 'li_pma_changes',
375 PMA_linkURL('changelog.php'),
376 null,
377 '_blank'
380 </ul>
381 </div>
383 </div>
385 </div>
387 <?php
389 * Warning if using the default MySQL privileged account
391 if ($server != 0
392 && $cfg['Server']['user'] == 'root'
393 && $cfg['Server']['password'] == ''
395 trigger_error(
397 'Your configuration file contains settings (root with no password)'
398 . ' that correspond to the default MySQL privileged account.'
399 . ' Your MySQL server is running with this default, is open to'
400 . ' intrusion, and you really should fix this security hole by'
401 . ' setting a password for user \'root\'.'
403 E_USER_WARNING
408 * As we try to handle charsets by ourself, mbstring overloads just
409 * break it, see bug 1063821.
411 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
412 trigger_error(
414 'You have enabled mbstring.func_overload in your PHP '
415 . 'configuration. This option is incompatible with phpMyAdmin '
416 . 'and might cause some data to be corrupted!'
418 E_USER_WARNING
423 * mbstring is used for handling multibyte inside parser, so it is good
424 * to tell user something might be broken without it, see bug #1063149.
426 if (! @extension_loaded('mbstring')) {
427 trigger_error(
429 'The mbstring PHP extension was not found and you seem to be using'
430 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
431 . ' is unable to split strings correctly and it may result in'
432 . ' unexpected results.'
434 E_USER_WARNING
439 * Check whether session.gc_maxlifetime limits session validity.
441 $gc_time = (int)@ini_get('session.gc_maxlifetime');
442 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
443 trigger_error(
444 __('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.'),
445 E_USER_WARNING
450 * Check whether LoginCookieValidity is limited by LoginCookieStore.
452 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
453 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
455 trigger_error(
456 __('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'),
457 E_USER_WARNING
462 * Check if user does not have defined blowfish secret and it is being used.
464 if (! empty($_SESSION['auto_blowfish_secret'])
465 && empty($GLOBALS['cfg']['blowfish_secret'])
467 trigger_error(
468 __('The configuration file now needs a secret passphrase (blowfish_secret).'),
469 E_USER_WARNING
474 * Check for existence of config directory which should not exist in
475 * production environment.
477 if (file_exists('config')) {
478 trigger_error(
479 __('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.'),
480 E_USER_WARNING
484 if ($server > 0) {
485 $cfgRelation = PMA_getRelationsParam();
486 if (! $cfgRelation['allworks']
487 && $cfg['PmaNoRelation_DisableWarning'] == false
489 $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.'));
490 $msg->addParam(
491 '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $common_url_query . '">',
492 false
494 $msg->addParam('</a>', false);
495 /* Show error if user has configured something, notice elsewhere */
496 if (!empty($cfg['Servers'][$server]['pmadb'])) {
497 $msg->isError(true);
499 $msg->display();
500 } // end if
504 * Warning about different MySQL library and server version
505 * (a difference on the third digit does not count).
506 * If someday there is a constant that we can check about mysqlnd,
507 * we can use it instead of strpos().
508 * If no default server is set, $GLOBALS['dbi'] is not defined yet.
509 * Drizzle can speak MySQL protocol, so don't warn about version mismatch for
510 * Drizzle servers.
512 if (isset($GLOBALS['dbi']) && !PMA_DRIZZLE) {
513 $_client_info = $GLOBALS['dbi']->getClientInfo();
514 if ($server > 0
515 && strpos($_client_info, 'mysqlnd') === false
516 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
518 trigger_error(
519 PMA_sanitize(
520 sprintf(
521 __('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
522 $_client_info,
523 substr(
524 PMA_MYSQL_STR_VERSION,
526 strpos(PMA_MYSQL_STR_VERSION . '-', '-')
530 E_USER_NOTICE
533 unset($_client_info);
537 * Warning about Suhosin
539 if ($cfg['SuhosinDisableWarning'] == false
540 && @ini_get('suhosin.request.max_value_length')
541 // warn about Suhosin only if its simulation mode is not enabled
542 && @ini_get('suhosin.simulation') == '0'
544 trigger_error(
545 sprintf(
546 __('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'),
547 '[doc@faq1-38]',
548 '[/doc]'
550 E_USER_WARNING
555 * Warning about mcrypt.
557 if (! function_exists('mcrypt_encrypt')
558 && ! $GLOBALS['cfg']['McryptDisableWarning']
560 PMA_warnMissingExtension('mcrypt');
564 * Warning about incomplete translations.
566 * The data file is created while creating release by ./scripts/remove-incomplete-mo
568 if (file_exists('libraries/language_stats.inc.php')) {
569 include 'libraries/language_stats.inc.php';
571 * This message is intentionally not translated, because we're
572 * handling incomplete translations here and focus on english
573 * speaking users.
575 if (isset($GLOBALS['language_stats'][$lang])
576 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
578 trigger_error(
579 '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>.',
580 E_USER_NOTICE
586 * prints list item for main page
588 * @param string $name displayed text
589 * @param string $id id, used for css styles
590 * @param string $url make item as link with $url as target
591 * @param string $mysql_help_page display a link to MySQL's manual
592 * @param string $target special target for $url
593 * @param string $a_id id for the anchor,
594 * used for jQuery to hook in functions
595 * @param string $class class for the li element
596 * @param string $a_class class for the anchor element
598 * @return void
600 function PMA_printListItem($name, $id = null, $url = null,
601 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
602 $a_class = null
604 echo '<li id="' . $id . '"';
605 if (null !== $class) {
606 echo ' class="' . $class . '"';
608 echo '>';
609 if (null !== $url) {
610 echo '<a href="' . $url . '"';
611 if (null !== $target) {
612 echo ' target="' . $target . '"';
614 if (null != $a_id) {
615 echo ' id="' . $a_id .'"';
617 if (null != $a_class) {
618 echo ' class="' . $a_class .'"';
620 echo '>';
623 echo $name;
625 if (null !== $url) {
626 echo '</a>' . "\n";
628 if (null !== $mysql_help_page) {
629 echo PMA_Util::showMySQLDocu('', $mysql_help_page);
631 echo '</li>';