Obey the ShowSQL directive also for inline edit
[phpmyadmin.git] / main.php
blob431f65b8740033ddb193ded17ad74888dadb8551
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 if ($GLOBALS['cfg']['AjaxEnable']) {
92 $conditional_class = 'ajax';
93 } else {
94 $conditional_class = null;
96 PMA_printListItem(__('Change password'), 'li_change_password',
97 './user_password.php?' . $common_url_query, null, null, 'change_password_anchor', null, $conditional_class);
99 } // end if
100 if (PMA_MYSQL_MAJOR_VERSION < 2009) {
101 echo ' <li id="li_select_mysql_collation">';
102 echo ' <form method="post" action="index.php" target="_parent">' . "\n"
103 . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
104 . ' <label for="select_collation_connection">' . "\n"
105 . ' ' . __('MySQL connection collation') . "\n"
106 // put the doc link in the form so that it appears on the same line
107 . PMA_showMySQLDocu('MySQL_Database_Administration', 'Charset-connection') . ': ' . "\n"
108 . ' </label>' . "\n"
110 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, 4, true)
111 . ' <noscript><input type="submit" value="' . __('Go') . '" /></noscript>' . "\n"
112 . ' </form>' . "\n"
113 . ' </li>' . "\n";
114 } // not Drizzle
115 } // end of if ($server > 0)
116 echo '</ul>';
117 echo '</div>';
120 echo '<div class="group">';
121 echo '<h2>' . __('Appearance Settings') . '</h2>';
122 echo ' <ul>';
124 // Displays language selection combo
125 if (empty($cfg['Lang'])) {
126 echo '<li id="li_select_lang">';
127 require_once './libraries/display_select_lang.lib.php';
128 PMA_select_language();
129 echo '</li>';
132 // ThemeManager if available
134 if ($GLOBALS['cfg']['ThemeManager']) {
135 echo '<li id="li_select_theme">';
136 echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
137 echo '</li>';
139 // see js/main_custom_color.js
141 * deactivated for 3.4.0-rc1
142 echo '<li id="li_custom_color" class="hide">';
143 echo __('Background color') . ': ';
144 echo '<input type="submit" name="custom_color_choose" value="' . __('Choose...') . '" />';
145 echo '<form name="colorform" id="colorform" method="post" action="index.php" target="_parent">';
146 echo PMA_generate_common_hidden_inputs();
147 echo '<input type="hidden" id="custom_color" name="custom_color" value="" />';
148 echo '<input type="submit" name="custom_color_reset" value="' . __('Reset') . '" />';
149 echo '</form>';
150 echo '</li>';
153 echo '<li id="li_select_fontsize">';
154 echo PMA_Config::getFontsizeForm();
155 echo '</li>';
157 echo '</ul>';
159 // User preferences
161 echo '<ul>';
162 echo PMA_printListItem(__('More settings'), 'li_user_preferences',
163 './prefs_manage.php?' . $common_url_query);
164 echo '</ul>';
166 echo '</div>';
169 echo '</div>';
170 echo '<div id="main_pane_right">';
173 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
174 echo '<div class="group">';
175 echo '<h2>MySQL</h2>';
176 echo '<ul>' . "\n";
177 PMA_printListItem(__('Server') . ': ' . $server_info, 'li_server_info');
178 PMA_printListItem(__('Server version') . ': ' . PMA_MYSQL_STR_VERSION, 'li_server_version');
179 PMA_printListItem(__('Protocol version') . ': ' . PMA_DBI_get_proto_info(),
180 'li_mysql_proto');
181 PMA_printListItem(__('User') . ': ' . htmlspecialchars($mysql_cur_user_and_host),
182 'li_user_info');
184 echo ' <li id="li_select_mysql_charset">';
185 echo ' ' . __('MySQL charset') . ': '
186 . ' <span xml:lang="en" dir="ltr">'
187 . ' ' . $mysql_charsets_descriptions[$mysql_charset_map[strtolower($charset)]] . "\n"
188 . ' (' . $mysql_charset_map[strtolower($charset)] . ')' . "\n"
189 . ' </span>' . "\n"
190 . ' </li>' . "\n";
191 echo ' </ul>';
192 echo ' </div>';
195 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
196 echo '<div class="group">';
197 echo '<h2>' . __('Web server') . '</h2>';
198 echo '<ul>';
199 if ($GLOBALS['cfg']['ShowServerInfo']) {
200 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
202 if ($server > 0) {
203 PMA_printListItem(__('MySQL client version') . ': ' . PMA_DBI_get_client_info(),
204 'li_mysql_client_version');
205 PMA_printListItem(__('PHP extension') . ': ' . $GLOBALS['cfg']['Server']['extension'] . ' ' . PMA_showPHPDocu('book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'),
206 'li_used_php_extension');
210 if ($cfg['ShowPhpInfo']) {
211 PMA_printListItem(__('Show PHP information'), 'li_phpinfo', './phpinfo.php?' . $common_url_query);
213 echo ' </ul>';
214 echo ' </div>';
217 echo '<div class="group pmagroup">';
218 echo '<h2>phpMyAdmin</h2>';
219 echo '<ul>';
220 $class = null;
221 if ($GLOBALS['cfg']['VersionCheck']) {
222 $class = 'jsversioncheck';
224 PMA_printListItem(__('Version information') . ': ' . PMA_VERSION, 'li_pma_version', null, null, null, null, $class);
225 PMA_printListItem(__('Documentation'), 'li_pma_docs', 'Documentation.html', null, '_blank');
226 PMA_printListItem(__('Wiki'), 'li_pma_wiki', PMA_linkURL('http://wiki.phpmyadmin.net/'), null, '_blank');
228 // does not work if no target specified, don't know why
229 PMA_printListItem(__('Official Homepage'), 'li_pma_homepage', PMA_linkURL('http://www.phpMyAdmin.net/'), null, '_blank');
230 PMA_printListItem(__('Contribute'), 'li_pma_contribute', PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'), null, '_blank');
231 PMA_printListItem(__('Get support'), 'li_pma_support', PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'), null, '_blank');
232 PMA_printListItem(__('List of changes'), 'li_pma_changes', PMA_linkURL('changelog.php'), null, '_blank');
234 </ul>
235 </div>
237 </div>
239 <?php
241 * BUG: MSIE needs two <br /> here, otherwise it will not extend the outer div to the
242 * full height of the inner divs
245 <br class="clearfloat" />
246 <br class="clearfloat" />
247 </div>
249 <?php
251 * Warning if using the default MySQL privileged account
253 if ($server != 0
254 && $cfg['Server']['user'] == 'root'
255 && $cfg['Server']['password'] == '') {
256 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);
260 * Nijel: As we try to handle charsets by ourself, mbstring overloads just
261 * break it, see bug 1063821.
263 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
264 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);
268 * Nijel: mbstring is used for handling multibyte inside parser, so it is good
269 * to tell user something might be broken without it, see bug #1063149.
271 if (! @extension_loaded('mbstring')) {
272 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);
276 * Check whether session.gc_maxlifetime limits session validity.
278 $gc_time = (int)@ini_get('session.gc_maxlifetime');
279 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
280 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);
284 * Check whether LoginCookieValidity is limited by LoginCookieStore.
286 if ($GLOBALS['cfg']['LoginCookieStore'] != 0 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']) {
287 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);
291 * Check if user does not have defined blowfish secret and it is being used.
293 if (!empty($_SESSION['auto_blowfish_secret']) &&
294 empty($GLOBALS['cfg']['blowfish_secret'])) {
295 trigger_error(__('The configuration file now needs a secret passphrase (blowfish_secret).'), E_USER_WARNING);
299 * Check for existence of config directory which should not exist in
300 * production environment.
302 if (file_exists('./config')) {
303 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);
307 * Check whether relations are supported.
309 if ($server > 0) {
310 $cfgRelation = PMA_getRelationsParam();
311 if(!$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) {
312 $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.'));
313 $message->addParam('<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $common_url_query . '">', false);
314 $message->addParam('</a>', false);
315 /* Show error if user has configured something, notice elsewhere */
316 if (!empty($cfg['Servers'][$server]['pmadb'])) {
317 $message->isError(true);
319 $message->display();
320 } // end if
324 * Show warning when javascript support is missing.
326 echo '<noscript>';
327 $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.'));
328 $message->isError(true);
329 $message->display();
330 echo '</noscript>';
333 * Warning about different MySQL library and server version
334 * (a difference on the third digit does not count).
335 * If someday there is a constant that we can check about mysqlnd, we can use it instead
336 * of strpos().
337 * If no default server is set, PMA_DBI_get_client_info() is not defined yet.
339 if (function_exists('PMA_DBI_get_client_info')) {
340 $_client_info = PMA_DBI_get_client_info();
341 if ($server > 0 && strpos($_client_info, 'mysqlnd') === false && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)) {
342 trigger_error(PMA_sanitize(sprintf(__('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
343 $_client_info,
344 substr(PMA_MYSQL_STR_VERSION, 0, strpos(PMA_MYSQL_STR_VERSION . '-', '-')))),
345 E_USER_NOTICE);
347 unset($_client_info);
351 * Warning about Suhosin
353 if ($cfg['SuhosinDisableWarning'] == false && @ini_get('suhosin.request.max_value_length')) {
354 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);
358 * prints list item for main page
360 * @param string $name displayed text
361 * @param string $id id, used for css styles
362 * @param string $url make item as link with $url as target
363 * @param string $mysql_help_page display a link to MySQL's manual
364 * @param string $target special target for $url
365 * @param string $a_id id for the anchor, used for jQuery to hook in functions
366 * @param string $class class for the li element
367 * @param string $a_class class for the anchor element
369 function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null, $a_id = null, $class = null, $a_class = null)
371 echo '<li id="' . $id . '"';
372 if (null !== $class) {
373 echo ' class="' . $class . '"';
375 echo '>';
376 if (null !== $url) {
377 echo '<a href="' . $url . '"';
378 if (null !== $target) {
379 echo ' target="' . $target . '"';
381 if (null != $a_id) {
382 echo ' id="' . $a_id .'"';
384 if (null != $a_class) {
385 echo ' class="' . $a_class .'"';
387 echo '>';
390 echo $name;
392 if (null !== $url) {
393 echo '</a>' . "\n";
395 if (null !== $mysql_help_page) {
396 echo PMA_showMySQLDocu('', $mysql_help_page);
398 echo '</li>';
402 * Displays the footer
404 require './libraries/footer.inc.php';