Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin...
[phpmyadmin/crack.git] / main.php
blob5f18ba82b42c38b1bc5d3cfb648b5c55277eb12c
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
140 echo '<li id="li_custom_color" class="hide">';
141 echo __('Background color') . ': ';
142 echo '<input type="submit" name="custom_color_choose" value="' . __('Choose...') . '" />';
143 echo '<form name="colorform" id="colorform" method="post" action="index.php" target="_parent">';
144 echo PMA_generate_common_hidden_inputs();
145 echo '<input type="hidden" id="custom_color" name="custom_color" value="" />';
146 echo '<input type="submit" name="custom_color_reset" value="' . __('Reset') . '" />';
147 echo '</form>';
148 echo '</li>';
150 echo '<li id="li_select_fontsize">';
151 echo PMA_Config::getFontsizeForm();
152 echo '</li>';
154 echo '</ul>';
156 // User preferences
158 echo '<ul>';
159 echo PMA_printListItem(__('More settings'), 'li_user_preferences',
160 './prefs_manage.php?' . $common_url_query);
161 echo '</ul>';
163 echo '</div>';
166 echo '</div>';
167 echo '<div id="main_pane_right">';
170 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
171 echo '<div class="group">';
172 echo '<h2>MySQL</h2>';
173 echo '<ul>' . "\n";
174 PMA_printListItem(__('Server') . ': ' . $server_info, 'li_server_info');
175 PMA_printListItem(__('Server version') . ': ' . PMA_MYSQL_STR_VERSION, 'li_server_version');
176 PMA_printListItem(__('Protocol version') . ': ' . PMA_DBI_get_proto_info(),
177 'li_mysql_proto');
178 PMA_printListItem(__('User') . ': ' . htmlspecialchars($mysql_cur_user_and_host),
179 'li_user_info');
181 echo ' <li id="li_select_mysql_charset">';
182 echo ' ' . __('MySQL charset') . ': '
183 . ' <span xml:lang="en" dir="ltr">'
184 . ' ' . $mysql_charsets_descriptions[$mysql_charset_map[strtolower($charset)]] . "\n"
185 . ' (' . $mysql_charset_map[strtolower($charset)] . ')' . "\n"
186 . ' </span>' . "\n"
187 . ' </li>' . "\n";
188 echo ' </ul>';
189 echo ' </div>';
192 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
193 echo '<div class="group">';
194 echo '<h2>' . __('Web server') . '</h2>';
195 echo '<ul>';
196 if ($GLOBALS['cfg']['ShowServerInfo']) {
197 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
199 if ($server > 0) {
200 PMA_printListItem(__('MySQL client version') . ': ' . PMA_DBI_get_client_info(),
201 'li_mysql_client_version');
202 PMA_printListItem(__('PHP extension') . ': ' . $GLOBALS['cfg']['Server']['extension'] . ' ' . PMA_showPHPDocu('book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'),
203 'li_used_php_extension');
207 if ($cfg['ShowPhpInfo']) {
208 PMA_printListItem(__('Show PHP information'), 'li_phpinfo', './phpinfo.php?' . $common_url_query);
210 echo ' </ul>';
211 echo ' </div>';
214 echo '<div class="group pmagroup">';
215 echo '<h2>phpMyAdmin</h2>';
216 echo '<ul>';
217 $class = null;
218 if ($GLOBALS['cfg']['VersionCheck']) {
219 $class = 'jsversioncheck';
221 PMA_printListItem(__('Version information') . ': ' . PMA_VERSION, 'li_pma_version', null, null, null, null, $class);
222 PMA_printListItem(__('Documentation'), 'li_pma_docs', 'Documentation.html', null, '_blank');
223 PMA_printListItem(__('Wiki'), 'li_pma_wiki', PMA_linkURL('http://wiki.phpmyadmin.net/'), null, '_blank');
225 // does not work if no target specified, don't know why
226 PMA_printListItem(__('Official Homepage'), 'li_pma_homepage', PMA_linkURL('http://www.phpMyAdmin.net/'), null, '_blank');
227 PMA_printListItem(__('Contribute'), 'li_pma_contribute', PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'), null, '_blank');
228 PMA_printListItem(__('Get support'), 'li_pma_support', PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'), null, '_blank');
229 PMA_printListItem(__('List of changes'), 'li_pma_changes', PMA_linkURL('changelog.php'), null, '_blank');
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
363 * @param string $class class for the li element
364 * @param string $a_class class for the anchor element
366 function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null, $a_id = null, $class = null, $a_class = null)
368 echo '<li id="' . $id . '"';
369 if (null !== $class) {
370 echo ' class="' . $class . '"';
372 echo '>';
373 if (null !== $url) {
374 echo '<a href="' . $url . '"';
375 if (null !== $target) {
376 echo ' target="' . $target . '"';
378 if (null != $a_id) {
379 echo ' id="' . $a_id .'"';
381 if (null != $a_class) {
382 echo ' class="' . $a_class .'"';
384 echo '>';
387 echo $name;
389 if (null !== $url) {
390 echo '</a>' . "\n";
392 if (null !== $mysql_help_page) {
393 echo PMA_showMySQLDocu('', $mysql_help_page);
395 echo '</li>';
399 * Displays the footer
401 require './libraries/footer.inc.php';