Whitespace cleanup
[phpmyadmin-themes.git] / main.php
blob62fbc04daf48205bc4e5cb83d1332e5694234dc4
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 define('PMA_COLORPICKER', true);
12 require_once './libraries/common.inc.php';
14 $GLOBALS['js_include'][] = 'colorpicker/js/colorpicker.js';
15 $GLOBALS['js_include'][] = 'main_custom_color.js';
16 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
17 $GLOBALS['js_include'][] = 'jquery/jquery.sprintf.js';
19 // Handles some variables that may have been sent by the calling script
20 $GLOBALS['db'] = '';
21 $GLOBALS['table'] = '';
22 $show_query = '1';
23 require_once './libraries/header.inc.php';
25 // Any message to display?
26 if (! empty($message)) {
27 PMA_showMessage($message);
28 unset($message);
31 $common_url_query = PMA_generate_common_url('', '');
33 // when $server > 0, a server has been chosen so we can display
34 // all MySQL-related information
35 if ($server > 0) {
36 require './libraries/server_common.inc.php';
37 require './libraries/StorageEngine.class.php';
38 require './libraries/server_links.inc.php';
40 // Use the verbose name of the server instead of the hostname
41 // if a value is set
42 $server_info = '';
43 if (! empty($cfg['Server']['verbose'])) {
44 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
45 if ($GLOBALS['cfg']['ShowServerInfo']) {
46 $server_info .= ' (';
49 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
50 $server_info .= PMA_DBI_get_host_info();
52 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
53 $server_info .= ')';
55 $mysql_cur_user_and_host = PMA_DBI_fetch_value('SELECT USER();');
57 // should we add the port info here?
58 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
59 ? $GLOBALS['cfg']['Server']['verbose']
60 : $GLOBALS['cfg']['Server']['host']);
63 echo '<div id="maincontainer">' . "\n";
64 echo '<div id="main_pane_left">';
65 if ($server > 0
66 || (! $cfg['LeftDisplayServers'] && count($cfg['Servers']) > 1)) {
67 echo '<div class="group">';
68 echo '<h2>' . __('General Settings') . '</h2>';
69 echo '<ul>';
71 /**
72 * Displays the MySQL servers choice form
74 if (! $cfg['LeftDisplayServers']
75 && (count($cfg['Servers']) > 1 || $server == 0 && count($cfg['Servers']) == 1)) {
76 echo '<li id="li_select_server">';
77 require_once './libraries/select_server.lib.php';
78 PMA_select_server(true, true);
79 echo '</li>';
82 /**
83 * Displays the mysql server related links
85 if ($server > 0) {
86 require_once './libraries/check_user_privileges.lib.php';
88 // Logout for advanced authentication
89 if ($cfg['Server']['auth_type'] != 'config') {
90 if ($cfg['ShowChgPassword']) {
91 PMA_printListItem(__('Change password'), 'li_change_password',
92 './user_password.php?' . $common_url_query, null, null, 'change_password_anchor');
94 } // end if
95 if (PMA_MYSQL_MAJOR_VERSION < 2009) {
96 echo ' <li id="li_select_mysql_collation">';
97 echo ' <form method="post" action="index.php" target="_parent">' . "\n"
98 . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
99 . ' <label for="select_collation_connection">' . "\n"
100 . ' ' . __('MySQL connection collation') . "\n"
101 // put the doc link in the form so that it appears on the same line
102 . PMA_showMySQLDocu('MySQL_Database_Administration', 'Charset-connection') . ': ' . "\n"
103 . ' </label>' . "\n"
105 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, 4, true)
106 . ' <noscript><input type="submit" value="' . __('Go') . '" /></noscript>' . "\n"
107 . ' </form>' . "\n"
108 . ' </li>' . "\n";
109 } // not Drizzle
110 } // end of if ($server > 0)
111 echo '</ul>';
112 echo '</div>';
115 echo '<div class="group">';
116 echo '<h2>' . __('Appearance Settings') . '</h2>';
117 echo ' <ul>';
119 // Displays language selection combo
120 if (empty($cfg['Lang'])) {
121 echo '<li id="li_select_lang">';
122 require_once './libraries/display_select_lang.lib.php';
123 PMA_select_language();
124 echo '</li>';
127 // ThemeManager if available
129 if ($GLOBALS['cfg']['ThemeManager']) {
130 echo '<li id="li_select_theme">';
131 echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
132 echo '</li>';
134 // see js/main_custom_color.js
135 echo '<li id="li_custom_color" class="hide">';
136 echo __('Background color') . ': ';
137 echo '<input type="submit" name="custom_color_choose" value="' . __('Choose...') . '" />';
138 echo '<form name="colorform" id="colorform" method="post" action="index.php" target="_parent">';
139 echo PMA_generate_common_hidden_inputs();
140 echo '<input type="hidden" id="custom_color" name="custom_color" value="" />';
141 echo '<input type="submit" name="custom_color_reset" value="' . __('Reset') . '" />';
142 echo '</form>';
143 echo '</li>';
145 echo '<li id="li_select_fontsize">';
146 echo PMA_Config::getFontsizeForm();
147 echo '</li>';
149 echo '</ul>';
151 // User preferences
153 echo '<ul>';
154 echo PMA_printListItem(__('More settings'), 'li_user_preferences',
155 './prefs_manage.php?' . $common_url_query);
156 echo '</ul>';
158 echo '</div>';
161 echo '</div>';
162 echo '<div id="main_pane_right">';
165 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
166 echo '<div class="group">';
167 echo '<h2>MySQL</h2>';
168 echo '<ul>' . "\n";
169 PMA_printListItem(__('Server') . ': ' . $server_info, 'li_server_info');
170 PMA_printListItem(__('Server version') . ': ' . PMA_MYSQL_STR_VERSION, 'li_server_version');
171 PMA_printListItem(__('Protocol version') . ': ' . PMA_DBI_get_proto_info(),
172 'li_mysql_proto');
173 PMA_printListItem(__('User') . ': ' . htmlspecialchars($mysql_cur_user_and_host),
174 'li_user_info');
176 echo ' <li id="li_select_mysql_charset">';
177 echo ' ' . __('MySQL charset') . ': '
178 . ' <span xml:lang="en" dir="ltr">'
179 . ' ' . $mysql_charsets_descriptions[$mysql_charset_map[strtolower($charset)]] . "\n"
180 . ' (' . $mysql_charset_map[strtolower($charset)] . ')' . "\n"
181 . ' </span>' . "\n"
182 . ' </li>' . "\n";
183 echo ' </ul>';
184 echo ' </div>';
187 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
188 echo '<div class="group">';
189 echo '<h2>' . __('Web server') . '</h2>';
190 echo '<ul>';
191 if ($GLOBALS['cfg']['ShowServerInfo']) {
192 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
194 if ($server > 0) {
195 PMA_printListItem(__('MySQL client version') . ': ' . PMA_DBI_get_client_info(),
196 'li_mysql_client_version');
197 PMA_printListItem(__('PHP extension') . ': ' . $GLOBALS['cfg']['Server']['extension'],
198 'li_used_php_extension');
202 if ($cfg['ShowPhpInfo']) {
203 PMA_printListItem(__('Show PHP information'), 'li_phpinfo', './phpinfo.php?' . $common_url_query);
205 echo ' </ul>';
206 echo ' </div>';
209 echo '<div class="group">';
210 echo '<h2>phpMyAdmin</h2>';
211 echo '<ul>';
212 $clas = null;
213 if ($GLOBALS['cfg']['VersionCheck']) {
214 $class = 'jsversioncheck';
216 PMA_printListItem(__('Version information') . ': ' . PMA_VERSION, 'li_pma_version', null, null, null, null, $class);
217 PMA_printListItem(__('Documentation'), 'li_pma_docs', 'Documentation.html', null, '_blank');
218 PMA_printListItem(__('Wiki'), 'li_pma_wiki', PMA_linkURL('http://wiki.phpmyadmin.net/'), null, '_blank');
220 // does not work if no target specified, don't know why
221 PMA_printListItem(__('Official Homepage'), 'li_pma_homepage', PMA_linkURL('http://www.phpMyAdmin.net/'), null, '_blank');
223 <li><bdo xml:lang="en" dir="ltr">
224 [<a href="changelog.php" target="_blank">ChangeLog</a>]
225 [<a href="<?php echo PMA_linkURL('http://phpmyadmin.git.sourceforge.net/git/gitweb-index.cgi'); ?>"
226 target="_blank">Git</a>]
227 [<a href="<?php echo PMA_linkURL('http://sourceforge.net/mail/?group_id=23067'); ?>"
228 target="_blank"><?php echo __('Mailing lists'); ?></a>]
229 </bdo>
230 </li>
231 </ul>
232 </div>
234 </div>
236 <?php
238 * BUG: MSIE needs two <br /> here, otherwise it will not extend the outer div to the
239 * full height of the inner divs
242 <br class="clearfloat" />
243 <br class="clearfloat" />
244 </div>
246 <?php
248 * Warning if using the default MySQL privileged account
250 if ($server != 0
251 && $cfg['Server']['user'] == 'root'
252 && $cfg['Server']['password'] == '') {
253 trigger_error(__('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\'.'), E_USER_WARNING);
257 * Nijel: As we try to handle charsets by ourself, mbstring overloads just
258 * break it, see bug 1063821.
260 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
261 trigger_error(__('You have enabled mbstring.func_overload in your PHP configuration. This option is incompatible with phpMyAdmin and might cause some data to be corrupted!'), E_USER_WARNING);
265 * Nijel: mbstring is used for handling multibyte inside parser, so it is good
266 * to tell user something might be broken without it, see bug #1063149.
268 if (! @extension_loaded('mbstring')) {
269 trigger_error(__('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.'), E_USER_WARNING);
273 * Check whether session.gc_maxlifetime limits session validity.
275 $gc_time = (int)@ini_get('session.gc_maxlifetime');
276 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
277 trigger_error(PMA_Message::decodeBB(__('Your PHP parameter [a@http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime@]session.gc_maxlifetime[/a] is lower that cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.')), E_USER_WARNING);
281 * Check whether LoginCookieValidity is limited by LoginCookieStore.
283 if ($GLOBALS['cfg']['LoginCookieStore'] != 0 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']) {
284 trigger_error(PMA_Message::decodeBB(__('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.')), E_USER_WARNING);
288 * Check if user does not have defined blowfish secret and it is being used.
290 if (!empty($_SESSION['auto_blowfish_secret']) &&
291 empty($GLOBALS['cfg']['blowfish_secret'])) {
292 trigger_error(__('The configuration file now needs a secret passphrase (blowfish_secret).'), E_USER_WARNING);
296 * Check for existence of config directory which should not exist in
297 * production environment.
299 if (file_exists('./config')) {
300 trigger_error(__('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.'), E_USER_WARNING);
304 * Check whether relations are supported.
306 if ($server > 0) {
307 $cfgRelation = PMA_getRelationsParam();
308 if(!$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) {
309 $message = PMA_Message::notice(__('The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click %shere%s.'));
310 $message->addParam('<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $common_url_query . '">', false);
311 $message->addParam('</a>', false);
312 /* Show error if user has configured something, notice elsewhere */
313 if (!empty($cfg['Servers'][$server]['pmadb'])) {
314 $message->isError(true);
316 $message->display();
317 } // end if
321 * Show warning when javascript support is missing.
323 echo '<noscript>';
324 $message = PMA_Message::notice(__('Javascript support is missing or disabled in your browser, some phpMyAdmin functionality will be missing. For example navigation frame will not refresh automatically.'));
325 $message->isError(true);
326 $message->display();
327 echo '</noscript>';
330 * Warning about different MySQL library and server version
331 * (a difference on the third digit does not count).
332 * If someday there is a constant that we can check about mysqlnd, we can use it instead
333 * of strpos().
334 * If no default server is set, PMA_DBI_get_client_info() is not defined yet.
336 if (function_exists('PMA_DBI_get_client_info')) {
337 $_client_info = PMA_DBI_get_client_info();
338 if ($server > 0 && strpos($_client_info, 'mysqlnd') === false && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)) {
339 trigger_error(PMA_sanitize(sprintf(__('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
340 $_client_info,
341 substr(PMA_MYSQL_STR_VERSION, 0, strpos(PMA_MYSQL_STR_VERSION . '-', '-')))),
342 E_USER_NOTICE);
344 unset($_client_info);
348 * Warning about Suhosin
350 if ($cfg['SuhosinDisableWarning'] == false && @ini_get('suhosin.request.max_value_length')) {
351 trigger_error(PMA_sanitize(sprintf(__('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'), '[a@./Documentation.html#faq1_38@_blank]', '[/a]')), E_USER_WARNING);
355 * prints list item for main page
357 * @param string $name displayed text
358 * @param string $id id, used for css styles
359 * @param string $url make item as link with $url as target
360 * @param string $mysql_help_page display a link to MySQL's manual
361 * @param string $target special target for $url
362 * @param string $a_id id for the anchor, used for jQuery to hook in functions
364 function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null, $a_id = null, $class = null)
366 echo '<li id="' . $id . '"';
367 if (null !== $class) {
368 echo ' class="' . $class . '"';
370 echo '>';
371 if (null !== $url) {
372 echo '<a href="' . $url . '"';
373 if (null !== $target) {
374 echo ' target="' . $target . '"';
376 if (null != $a_id) {
377 echo ' id="' . $a_id .'"';
379 echo '>';
382 echo $name;
384 if (null !== $url) {
385 echo '</a>' . "\n";
387 if (null !== $mysql_help_page) {
388 echo PMA_showMySQLDocu('', $mysql_help_page);
390 echo '</li>';
394 * Displays the footer
396 require './libraries/footer.inc.php';