2.11.3-rc1, 2.11.4-dev
[phpmyadmin/crack.git] / main.php
blob5caf83edf97eb9394a9f3c585238a14854ded7d2
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
9 * Don't display the page heading
11 if (!defined('PMA_DISPLAY_HEADING')) {
12 define('PMA_DISPLAY_HEADING', 0);
15 /**
16 * Gets some core libraries and displays a top message if required
18 require_once './libraries/common.inc.php';
20 // Handles some variables that may have been sent by the calling script
21 $GLOBALS['db'] = '';
22 $GLOBALS['table'] = '';
23 $show_query = '1';
24 require_once './libraries/header.inc.php';
26 // Any message to display?
27 if (! empty($message)) {
28 PMA_showMessage($message);
29 unset($message);
32 $common_url_query = PMA_generate_common_url('', '');
34 // this div is required for containing divs can be 50%
35 echo '<div id="maincontainer">' . "\n";
37 /**
38 * Displays the mysql server related links
40 if ($server > 0) {
42 require_once './libraries/check_user_privileges.lib.php';
43 // why this? a non-priv user should be able to change his
44 // password if the configuration permits
45 //$cfg['ShowChgPassword'] = $is_superuser = PMA_isSuperuser();
46 $is_superuser = PMA_isSuperuser();
48 if ($cfg['Server']['auth_type'] == 'config') {
49 $cfg['ShowChgPassword'] = false;
54 <div id="mysqlmaininformation">
55 <?php
56 if ($server > 0) {
57 // robbat2: Use the verbose name of the server instead of the hostname
58 // if a value is set
59 $server_info = '';
60 if (!empty($cfg['Server']['verbose'])) {
61 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
62 if ($GLOBALS['cfg']['ShowServerInfo']) {
63 $server_info .= ' (';
66 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
67 $server_info .= PMA_DBI_get_host_info();
70 if (!empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
71 $server_info .= ')';
73 // loic1: skip this because it's not a so good idea to display sockets
74 // used to everybody
75 // if (!empty($cfg['Server']['socket']) && PMA_PHP_INT_VERSION >= 30010) {
76 // $server_info .= ':' . $cfg['Server']['socket'];
77 // }
78 $mysql_cur_user_and_host = PMA_DBI_fetch_value('SELECT USER();');
81 // should we add the port info here?
82 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
83 ? $GLOBALS['cfg']['Server']['verbose']
84 : $GLOBALS['cfg']['Server']['host']);
85 echo '<h1 xml:lang="en" dir="ltr">' . $short_server_info .'</h1>' . "\n";
86 unset($short_server_info);
87 } else {
88 // Case when no server selected
89 //echo '<h1 xml:lang="en" dir="ltr">MySQL</h1>' . "\n";
92 if ($server > 0) {
93 echo '<ul>' . "\n";
95 if ($GLOBALS['cfg']['ShowServerInfo']) {
96 PMA_printListItem($strServerVersion . ': ' . PMA_MYSQL_STR_VERSION, 'li_server_info');
97 PMA_printListItem($strProtocolVersion . ': ' . PMA_DBI_get_proto_info(),
98 'li_mysql_proto');
99 PMA_printListItem($strServer . ': ' . $server_info, 'li_server_info');
100 PMA_printListItem($strUser . ': ' . htmlspecialchars($mysql_cur_user_and_host),
101 'li_user_info');
102 } else {
103 PMA_printListItem($strServerVersion . ': ' . PMA_MYSQL_STR_VERSION, 'li_server_info');
104 PMA_printListItem($strServer . ': ' . $server_info, 'li_server_info');
107 if ($cfg['AllowAnywhereRecoding'] && $allow_recoding && PMA_MYSQL_INT_VERSION < 40100) {
108 echo '<li id="li_select_mysql_charset">';
110 <form method="post" action="index.php" target="_parent">
111 <input type="hidden" name="server" value="<?php echo $server; ?>" />
112 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
113 <?php echo $strMySQLCharset;?>:
114 <select name="convcharset" xml:lang="en" dir="ltr"
115 onchange="this.form.submit();">
116 <?php
117 foreach ($cfg['AvailableCharsets'] as $tmpcharset) {
118 if ($convcharset == $tmpcharset) {
119 $selected = ' selected="selected"';
120 } else {
121 $selected = '';
123 echo ' '
124 . '<option value="' . $tmpcharset . '"' . $selected . '>' . $tmpcharset . '</option>' . "\n";
127 </select>
128 <noscript><input type="submit" value="<?php echo $strGo;?>" /></noscript>
129 </form>
130 </li>
131 <?php
132 } elseif (PMA_MYSQL_INT_VERSION >= 40100) {
133 echo ' <li id="li_select_mysql_charset">';
134 echo ' ' . $strMySQLCharset . ': '
135 . ' <strong xml:lang="en" dir="ltr">'
136 . ' ' . $mysql_charsets_descriptions[$mysql_charset_map[strtolower($charset)]] . "\n"
137 . ' (' . $mysql_charset_map[strtolower($charset)] . ')' . "\n"
138 . ' </strong>' . "\n"
139 . ' </li>' . "\n"
140 . ' <li id="li_select_mysql_collation">';
141 echo ' <form method="post" action="index.php" target="_parent">' . "\n"
142 . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
143 . ' <label for="select_collation_connection">' . "\n"
144 . ' ' . $strMySQLConnectionCollation . ': ' . "\n"
145 . ' </label>' . "\n"
146 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, 4, true)
147 . ' <noscript><input type="submit" value="' . $strGo . '" /></noscript>' . "\n"
148 // put the doc link in the form so that it appears on the same line
149 . PMA_showMySQLDocu('MySQL_Database_Administration', 'Charset-connection') . "\n"
150 . ' </form>' . "\n"
151 . ' </li>' . "\n";
154 if ($cfg['ShowCreateDb']) {
155 echo '<li id="li_create_database">';
156 require './libraries/display_create_database.lib.php';
157 echo '</li>' . "\n";
160 PMA_printListItem($strMySQLShowStatus, 'li_mysql_status',
161 './server_status.php?' . $common_url_query);
162 PMA_printListItem($strMySQLShowVars, 'li_mysql_variables',
163 './server_variables.php?' . $common_url_query, 'show-variables');
164 PMA_printListItem($strProcesses, 'li_mysql_processes',
165 './server_processlist.php?' . $common_url_query, 'show-processlist');
167 if (PMA_MYSQL_INT_VERSION >= 40100) {
168 PMA_printListItem($strCharsetsAndCollations, 'li_mysql_collations',
169 './server_collations.php?' . $common_url_query);
172 PMA_printListItem($strStorageEngines, 'li_mysql_engines',
173 './server_engines.php?' . $common_url_query);
175 if ($is_reload_priv) {
176 PMA_printListItem($strReloadPrivileges, 'li_flush_privileges',
177 './server_privileges.php?flush_privileges=1&amp;' . $common_url_query, 'flush');
180 if ($is_superuser) {
181 PMA_printListItem($strPrivileges, 'li_mysql_privilegs',
182 './server_privileges.php?' . $common_url_query);
185 $binlogs = PMA_DBI_try_query('SHOW MASTER LOGS', null, PMA_DBI_QUERY_STORE);
186 if ($binlogs) {
187 if (PMA_DBI_num_rows($binlogs) > 0) {
188 PMA_printListItem($strBinaryLog, 'li_mysql_binlogs',
189 './server_binlog.php?' . $common_url_query);
191 PMA_DBI_free_result($binlogs);
193 unset($binlogs);
195 PMA_printListItem($strDatabases, 'li_mysql_databases',
196 './server_databases.php?' . $common_url_query);
197 PMA_printListItem($strExport, 'li_export',
198 './server_export.php?' . $common_url_query);
199 PMA_printListItem($strImport, 'li_import',
200 './server_import.php?' . $common_url_query);
203 * Change password
205 * @todo ? needs another message
207 if ($cfg['ShowChgPassword']) {
208 PMA_printListItem($strChangePassword, 'li_change_password',
209 './user_password.php?' . $common_url_query);
210 } // end if
212 // Logout for advanced authentication
213 if ($cfg['Server']['auth_type'] != 'config') {
214 $http_logout = ($cfg['Server']['auth_type'] == 'http')
215 ? '<a href="./Documentation.html#login_bug" target="documentation">'
216 . ($cfg['ReplaceHelpImg'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_info.png" width="11" height="11" alt="Info" />' : '(*)') . '</a>'
217 : '';
218 PMA_printListItem('<strong>' . $strLogout . '</strong> ' . $http_logout,
219 'li_log_out',
220 './index.php?' . $common_url_query . '&amp;old_usr=' . urlencode($PHP_AUTH_USER), null, '_parent');
221 } // end if
223 echo '</ul>';
224 } // end of if ($server > 0)
226 </div>
227 <div id="pmamaininformation">
228 <?php
230 echo '<h1 xml:lang="en" dir="ltr">phpMyAdmin - ' . PMA_VERSION . '</h1>'
231 . "\n";
233 echo '<ul>' . "\n";
236 * Displays the MySQL servers choice form
238 if (!$cfg['LeftDisplayServers'] && (count($cfg['Servers']) > 1 || $server == 0 && count($cfg['Servers']) == 1)) {
239 echo '<li id="li_select_server">';
240 require_once './libraries/select_server.lib.php';
241 PMA_select_server(true, true);
242 echo '</li>';
245 if ($server > 0) {
246 PMA_printListItem($strMysqlClientVersion . ': ' . PMA_DBI_get_client_info(),
247 'li_mysql_client_version');
248 PMA_printListItem($strUsedPhpExtensions . ': ' . $GLOBALS['cfg']['Server']['extension'],
249 'li_used_php_extension');
252 // Displays language selection combo
253 if (empty($cfg['Lang'])) {
254 echo '<li id="li_select_lang">';
255 require_once './libraries/display_select_lang.lib.php';
256 PMA_select_language();
257 echo '</li>';
261 if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding']
262 && $server != 0 && $allow_recoding && PMA_MYSQL_INT_VERSION < 40100) {
263 echo '<li id="li_select_charset">';
265 <form method="post" action="index.php" target="_parent">
266 <input type="hidden" name="server" value="<?php echo $server; ?>" />
267 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
268 <?php echo $strMySQLCharset;?>:
269 <select name="convcharset" xml:lang="en" dir="ltr"
270 onchange="this.form.submit();">
271 <?php
272 foreach ($cfg['AvailableCharsets'] AS $id => $tmpcharset) {
273 if ($convcharset == $tmpcharset) {
274 $selected = ' selected="selected"';
275 } else {
276 $selected = '';
278 echo ' '
279 . '<option value="' . $tmpcharset . '"' . $selected . '>' . $tmpcharset . '</option>' . "\n";
282 </select>
283 <noscript><input type="submit" value="<?php echo $strGo;?>" /></noscript>
284 </form>
285 </li>
286 <?php
289 // added by Michael Keck <mail_at_michaelkeck_dot_de>
290 // ThemeManager if available
292 if ($GLOBALS['cfg']['ThemeManager']) {
293 echo '<li id="li_select_theme">';
294 echo $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
295 echo '</li>';
297 echo '<li id="li_select_fontsize">';
298 echo PMA_Config::getFontsizeForm();
299 echo '</li>';
300 PMA_printListItem($strPmaDocumentation, 'li_pma_docs', 'Documentation.html', null, '_blank');
301 PMA_printListItem($strPmaWiki, 'li_pma_docs', 'http://wiki.cihar.com', null, '_blank');
303 if ($cfg['ShowPhpInfo']) {
304 PMA_printListItem($strShowPHPInfo, 'li_phpinfo', './phpinfo.php?' . $common_url_query);
307 // does not work if no target specified, don't know why
308 PMA_printListItem($strHomepageOfficial, 'li_pma_homepage', 'http://www.phpMyAdmin.net/', null, '_blank');
310 <li><bdo xml:lang="en" dir="ltr">
311 [<a href="changelog.php" target="_blank">ChangeLog</a>]
312 [<a href="http://phpmyadmin.svn.sourceforge.net/viewvc/phpmyadmin/"
313 target="_blank">Subversion</a>]
314 [<a href="http://sourceforge.net/mail/?group_id=23067"
315 target="_blank">Lists</a>]
316 </bdo>
317 </li>
318 </ul>
319 </div>
320 <?php
322 * BUG: MSIE needs two <br /> here, otherwise it will not extend the outer div to the
323 * full height of the inner divs
326 <br class="clearfloat" />
327 <br class="clearfloat" />
328 </div>
330 <?php
331 if (! empty($GLOBALS['PMA_errors']) && is_array($GLOBALS['PMA_errors'])) {
332 foreach ($GLOBALS['PMA_errors'] as $error) {
333 echo '<div class="error">' . $error . '</div>' . "\n";
338 * Warning if using the default MySQL privileged account
339 * modified: 2004-05-05 mkkeck
341 if ($server != 0
342 && $cfg['Server']['user'] == 'root'
343 && $cfg['Server']['password'] == '') {
344 echo '<div class="warning">' . $strInsecureMySQL . '</div>' . "\n";
348 * Warning for PHP 4.2.3
349 * modified: 2004-05-05 mkkeck
351 if (PMA_PHP_INT_VERSION == 40203 && @extension_loaded('mbstring')) {
352 echo '<div class="warning">' . $strPHP40203 . '</div>' . "\n";
356 * Nijel: As we try to handle charsets by ourself, mbstring overloads just
357 * break it, see bug 1063821.
359 if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
360 echo '<div class="warning">' . $strMbOverloadWarning . '</div>' . "\n";
364 * Nijel: mbstring is used for handling multibyte inside parser, so it is good
365 * to tell user something might be broken without it, see bug #1063149.
367 if ($GLOBALS['using_mb_charset'] && !@extension_loaded('mbstring')) {
368 echo '<div class="warning">' . $strMbExtensionMissing . '</div>' . "\n";
372 * Warning for old PHP version
374 if (PMA_PHP_INT_VERSION < 40200) {
375 echo '<div class="warning">' . sprintf($strUpgrade, 'PHP', '4.2.0') . '</div>' . "\n";
379 * Warning for old MySQL version
380 * modified: 2004-05-05 mkkeck
382 // not yet defined before the server choice
383 if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION < 32332) {
384 echo '<div class="warning">' . sprintf($strUpgrade, 'MySQL', '3.23.32') . '</div>' . "\n";
388 * Warning about different MySQL library and server version
389 * (a difference on the third digit does not count)
391 if ($server > 0 && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)) {
392 echo '<div class="notice">'
393 . PMA_sanitize(sprintf($strMysqlLibDiffersServerVersion,
394 PMA_DBI_get_client_info(),
395 substr(PMA_MYSQL_STR_VERSION, 0, strpos(PMA_MYSQL_STR_VERSION . '-', '-'))))
396 . '</div>' . "\n";
400 * Warning about wrong controluser settings
402 $strControluserFailed = 'Connection for controluser as defined in your config.inc.php failed.';
403 if (defined('PMA_DBI_CONNECT_FAILED_CONTROLUSER')) {
404 echo '<div class="warning">' . $strControluserFailed . '</div>' . "\n";
407 if (defined('PMA_WARN_FOR_MCRYPT')) {
408 echo '<div class="warning">' . PMA_sanitize(sprintf($strCantLoad, 'mcrypt')) . '</div>' . "\n";
412 * prints list item for main page
414 * @param string $name displayed text
415 * @param string $id id, used for css styles
416 * @param string $url make item as link with $url as target
417 * @param string $mysql_help_page display a link to MySQL's manual
418 * @param string $target special target for $url
420 function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null, $target = null)
422 echo '<li id="' . $id . '">';
423 if (null !== $url) {
424 echo '<a href="' . $url . '"';
425 if (null !== $target) {
426 echo ' target="' . $target . '"';
428 echo '>';
431 echo $name;
433 if (null !== $url) {
434 echo '</a>' . "\n";
436 if (null !== $mysql_help_page) {
437 echo PMA_showMySQLDocu('', $mysql_help_page);
439 echo '</li>';
443 * Displays the footer
445 require_once './libraries/footer.inc.php';