3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Don't display the page heading
8 define('PMA_DISPLAY_HEADING', 0);
11 * Gets some core libraries and displays a top message if required
13 require_once('./libraries/grab_globals.lib.php');
14 require_once('./libraries/common.lib.php');
15 // Puts the language to use in a cookie that will expire in 30 days
16 if (!isset($pma_uri_parts)) {
17 $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
18 $cookie_path = substr($pma_uri_parts['path'], 0, strrpos($pma_uri_parts['path'], '/'));
19 $is_https = (isset($pma_uri_parts['scheme']) && $pma_uri_parts['scheme'] == 'https') ?
1 : 0;
21 setcookie('lang', $lang, time() +
60*60*24*30, $cookie_path, '', $is_https);
22 // Defines the "item" image depending on text direction
23 $item_img = 'images/item_' . $text_dir . '.png';
24 // Handles some variables that may have been sent by the calling script
32 require_once('./header.inc.php');
33 if (isset($message)) {
34 PMA_showMessage($message);
36 else if (isset($reload) && $reload) {
37 // Reloads the navigation frame via JavaScript if required
40 <script type
="text/javascript" language
="javascript1.2">
42 window
.parent
.frames
['nav'].location
.replace('./left.php?<?php echo PMA_generate_common_url('', '', '&');?>&hash=' +
<?php
echo (($cfg['QueryFrame'] && $cfg['QueryFrameJS']) ?
'window.parent.frames[\'queryframe\'].document.hashform.hash.value' : "'" . md5($cfg['PmaAbsoluteUri']) . "'"); ?
>););
51 * Displays the welcome message and the server informations
54 <h1
><?php
echo sprintf($strWelcome, ' phpMyAdmin ' . PMA_VERSION
); ?
></h1
>
57 // Don't display server info if $server == 0 (no server selected)
58 // loic1: modified in order to have a valid words order whatever is the
61 // robbat2: Use the verbose name of the server instead of the hostname
63 if(!empty($cfg['Server']['verbose'])) {
64 $server_info = $cfg['Server']['verbose'];
66 $server_info = $cfg['Server']['host'];
68 $server_info .= (empty($cfg['Server']['port']) ?
'' : ':' . $cfg['Server']['port']);
69 // loic1: skip this because it's not a so good idea to display sockets
71 // if (!empty($cfg['Server']['socket']) && PMA_PHP_INT_VERSION >= 30010) {
72 // $server_info .= ':' . $cfg['Server']['socket'];
74 $local_query = 'SELECT VERSION() as version, USER() as user';
75 $res = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, '');
76 $mysql_cur_user_and_host = PMA_mysql_result($res, 0, 'user');
77 $mysql_cur_user = substr($mysql_cur_user_and_host, 0, strrpos($mysql_cur_user_and_host, '@'));
79 $full_string = str_replace('%pma_s1%', PMA_mysql_result($res, 0, 'version'), $strMySQLServerProcess);
80 $full_string = str_replace('%pma_s2%', $server_info, $full_string);
81 $full_string = str_replace('%pma_s3%', $mysql_cur_user_and_host, $full_string);
83 echo '<p><b>' . $full_string . '</b></p><br />' . "\n";
88 * Reload mysql (flush privileges)
90 if (($server > 0) && isset($mode) && ($mode == 'reload')) {
91 $result = PMA_mysql_query('FLUSH PRIVILEGES'); // Debug: or PMA_mysqlDie('', 'FLUSH PRIVILEGES', FALSE, 'main.php?' . PMA_generate_common_url());
94 echo $strMySQLReloaded;
96 echo $strReloadFailed;
98 echo '</b></p>' . "\n\n";
103 * Displays the MySQL servers choice form
105 if ($server == 0 ||
count($cfg['Servers']) > 1) {
107 <!-- MySQL servers choice form
-->
110 <th
><?php
echo $strServerChoice; ?
></th
>
114 <form method
="post" action
="index.php" target
="_parent">
115 <select name
="server">
118 foreach($cfg['Servers'] AS $key => $val) {
119 if (!empty($val['host'])) {
120 echo ' <option value="' . $key . '"';
121 if (!empty($server) && ($server == $key)) {
122 echo ' selected="selected"';
125 if (!empty($val['verbose'])) {
126 echo $val['verbose'];
129 if (!empty($val['port'])) {
130 echo ':' . $val['port'];
133 // loic1: if 'only_db' is an array and there is more than one
134 // value, displaying such informations may not be a so good
136 if (!empty($val['only_db'])) {
137 echo ' - ' . (is_array($val['only_db']) ?
implode(', ', $val['only_db']) : $val['only_db']);
139 if (!empty($val['user']) && ($val['auth_type'] == 'config')) {
140 echo ' (' . $val['user'] . ')';
142 echo ' </option>' . "\n";
143 } // end if (!empty($val['host']))
147 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
148 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
149 <input type
="submit" value
="<?php echo $strGo; ?>" />
156 } // end of the servers choice form
159 <!-- MySQL
and phpMyAdmin related links
-->
165 * Displays the mysql server related links
167 $is_superuser = FALSE;
169 // Get user's global privileges ($dbh and $userlink are links to MySQL
170 // defined in the "common.lib.php" library)
171 // Note: if no controluser is defined, $dbh contains $userlink
173 $is_create_priv = FALSE;
174 $is_process_priv = TRUE;
175 $is_reload_priv = FALSE;
177 // We were checking privileges with 'USE mysql' but users with the global
178 // priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
179 // (even if they cannot see the tables)
180 $is_superuser = @PMA_mysql_query
('SELECT COUNT(*) FROM mysql.user', $userlink);
182 $local_query = 'SELECT Create_priv, Process_priv, Reload_priv FROM mysql.user WHERE User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\'';
183 $rs_usr = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
185 while ($result_usr = PMA_mysql_fetch_array($rs_usr)) {
186 if (!$is_create_priv) {
187 $is_create_priv = ($result_usr['Create_priv'] == 'Y');
189 /* 02-12-09 rabus: Every user has access to the process list -
190 at least to its own :-)
191 if (!$is_process_priv) {
192 $is_process_priv = ($result_usr['Process_priv'] == 'Y');
195 if (!$is_reload_priv) {
196 $is_reload_priv = ($result_usr['Reload_priv'] == 'Y');
199 mysql_free_result($rs_usr);
202 // If the user has Create priv on a inexistant db, show him in the dialog
203 // the first inexistant db name that we find, in most cases it's probably
204 // the one he just dropped :)
205 if (!$is_create_priv) {
206 $local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\'';
207 $rs_usr = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
209 $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
210 $re1 = '(^|[^\])(\\\)+'; // escaped wildcards
211 while ($row = PMA_mysql_fetch_array($rs_usr)) {
212 if (ereg($re0 . '(%|_)', $row['Db'])
213 ||
(!PMA_mysql_select_db(ereg_replace($re1 . '(%|_)', '\\1\\3', $row['Db']), $userlink) && @mysql_errno
() != 1044)) {
214 $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $row['Db']));
215 $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
216 $is_create_priv = TRUE;
220 mysql_free_result($rs_usr);
223 // Finally, let's try to get the user's privileges by using SHOW
225 // Maybe we'll find a little CREATE priv there :)
226 $local_query = 'SHOW GRANTS FOR ' . $mysql_cur_user_and_host;
227 $rs_usr = PMA_mysql_query($local_query, $dbh);
229 // OK, now we'd have to guess the user's hostname, but we
230 // only try out the 'username'@'%' case.
231 $local_query = 'SHOW GRANTS FOR ' . $mysql_cur_user;
232 $rs_usr = PMA_mysql_query($local_query, $dbh);
235 $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
236 $re1 = '(^|[^\])(\\\)+'; // escaped wildcards
237 while ($row = PMA_mysql_fetch_row($rs_usr)) {
238 $show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') +
4,(strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4));
239 $show_grants_str = substr($row[0],6,(strpos($row[0],' ON ')-6));
240 if (($show_grants_str == 'ALL') ||
($show_grants_str == 'ALL PRIVILEGES') ||
($show_grants_str == 'CREATE') ||
strpos($show_grants_str, 'CREATE')) {
241 if ($show_grants_dbname == '*') {
242 $is_create_priv = TRUE;
246 else if (ereg($re0 . '%|_', $show_grants_dbname) ||
!PMA_mysql_select_db($show_grants_dbname, $userlink) && @mysql_errno
() != 1044) {
247 $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname));
248 $db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
249 // and remove backquotes
250 $db_to_create = str_replace('`','',$db_to_create);
251 $is_create_priv = TRUE;
256 unset($show_grants_dbname, $show_grants_str);
257 mysql_free_result($rs_usr);
265 if (!$cfg['SuggestDBName']) {
269 $common_url_query = PMA_generate_common_url();
272 $cfg['ShowMysqlInfo'] = TRUE;
273 $cfg['ShowMysqlVars'] = TRUE;
274 $cfg['ShowChgPassword'] = TRUE;
276 if ($cfg['Server']['auth_type'] == 'config') {
277 $cfg['ShowChgPassword'] = FALSE;
280 // loic1: Displays the MySQL column only if at least one feature has to be
282 if ($is_superuser ||
$is_create_priv ||
$is_process_priv ||
$is_reload_priv
283 ||
$cfg['ShowMysqlInfo'] ||
$cfg['ShowMysqlVars'] ||
$cfg['ShowChgPassword']
284 ||
$cfg['Server']['auth_type'] != 'config') {
286 <!-- MySQL server related links
-->
287 <td valign
="top" align
="<?php echo $cell_align_left; ?>">
290 <th colspan
="2"> 
; 
;MySQL
</th
>
293 // The user is allowed to create a db
294 if ($is_create_priv) {
297 <!-- db creation form
-->
299 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
301 <form method
="post" action
="db_create.php">
302 <?php
echo $strCreateNewDatabase . ' ' . PMA_showMySQLDocu('Reference', 'CREATE_DATABASE'); ?
><br
/>
303 <?php
echo PMA_generate_common_hidden_inputs(); ?
>
304 <input type
="hidden" name
="reload" value
="1" />
305 <input type
="text" name
="db" value
="<?php echo $db_to_create; ?>" maxlength
="64" class="textfield" />
306 <input type
="submit" value
="<?php echo $strCreate; ?>" />
314 <!-- db creation no privileges message
-->
316 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
318 <?php
echo $strCreateNewDatabase . ': ' . PMA_showMySQLDocu('Reference', 'CREATE_DATABASE'); ?
><br
/>
319 <?php
echo '<i>' . $strNoPrivileges .'</i>'; ?
><br
/>
323 } // end create db form or message
326 // Server related links
328 <!-- server
-related links
-->
330 if ($cfg['ShowMysqlInfo']) {
334 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
336 <a href
="./server_status.php?<?php echo $common_url_query; ?>">
337 <?php
echo $strMySQLShowStatus . "\n"; ?
>
343 if ($cfg['ShowMysqlVars']) {
347 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
349 <a href
="./server_variables.php?<?php echo $common_url_query; ?>">
350 <?php
echo $strMySQLShowVars;?
></a
> 
;
351 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'SHOW_VARIABLES') . "\n"; ?
>
360 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
362 <a href
="./server_processlist.php?<?php echo $common_url_query; ?>">
363 <?php
echo $strMySQLShowProcess; ?
></a
> 
;
364 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'SHOW_PROCESSLIST') . "\n"; ?
>
369 if (PMA_MYSQL_INT_VERSION
>= 40100) {
373 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
375 <a href
="./server_collations.php?<?php echo $common_url_query; ?>">
376 <?php
echo $strCharsetsAndCollations; ?
></a
> 
;
382 if ($is_reload_priv) {
386 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
388 <a href
="main.php?<?php echo $common_url_query; ?>&mode=reload">
389 <?php
echo $strReloadMySQL; ?
></a
> 
;
390 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?
>
400 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
402 <a href
="server_privileges.php?<?php echo $common_url_query; ?>">
403 <?php
echo $strPrivileges; ?
></a
> 
;
410 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
412 <a href
="./server_databases.php?<?php echo $common_url_query; ?>">
413 <?php
echo $strDatabases; ?
></a
>
417 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
419 <a href
="./server_export.php?<?php echo $common_url_query; ?>">
420 <?php
echo $strExport; ?
></a
>
425 // Change password (needs another message)
426 if ($cfg['ShowChgPassword']) {
430 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
432 <a href
="user_password.php?<?php echo $common_url_query; ?>">
433 <?php
echo ($strChangePassword); ?
></a
>
439 // Logout for advanced authentication
440 if ($cfg['Server']['auth_type'] != 'config') {
441 $http_logout = ($cfg['Server']['auth_type'] == 'http')
442 ?
"\n" . ' <a href="./Documentation.html#login_bug" target="documentation">(*)</a>'
447 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
449 <a href
="index.php?<?php echo $common_url_query; ?>&old_usr=<?php echo urlencode($PHP_AUTH_USER); ?>" target
="_parent">
450 <b
><?php
echo $strLogout; ?
></b
></a
> 
;<?php
echo $http_logout . "\n"; ?
>
460 <td
> 
; 
; 
; 
;</td
>
463 } // end of if ($server > 0)
468 * Displays the phpMyAdmin related links
472 <!-- phpMyAdmin related links
-->
473 <td valign
="top" align
="<?php echo $cell_align_left; ?>">
476 <th colspan
="2"> 
; 
;phpMyAdmin
</th
>
480 // Displays language selection combo
481 if (empty($cfg['Lang'])) {
483 <!-- Language Selection
-->
485 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
487 <form method
="post" action
="index.php" target
="_parent">
488 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
489 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
490 Language
<a href
="./translators.html" target
="documentation">(*)</a
>:
491 <select name
="lang" dir
="ltr" onchange
="this.form.submit();">
496 * Sorts available languages by their true names
498 * @param array the array to be sorted
499 * @param mixed a required parameter
501 * @return the sorted array
505 function PMA_cmp(&$a, $b)
507 return (strcmp($a[1], $b[1]));
508 } // end of the 'PMA_cmp()' function
510 uasort($available_languages, 'PMA_cmp');
511 foreach($available_languages AS $id => $tmplang) {
512 $lang_name = ucfirst(substr(strstr($tmplang[0], '|'), 1));
514 $selected = ' selected="selected"';
519 echo '<option value="' . $id . '"' . $selected . '>' . $lang_name . ' (' . $id . ')</option>' . "\n";
523 <noscript
><input type
="submit" value
="Go" /></noscript
>
530 if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding']
531 && $allow_recoding) {
534 <!-- Charset Selection
-->
536 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
538 <form method
="post" action
="index.php" target
="_parent">
539 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
540 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
541 <?php
echo $strMySQLCharset;?
>:
542 <select name
="convcharset" dir
="ltr" onchange
="this.form.submit();">
545 foreach($cfg['AvailableCharsets'] AS $id => $tmpcharset) {
546 if ($convcharset == $tmpcharset) {
547 $selected = ' selected="selected"';
552 . '<option value="' . $tmpcharset . '"' . $selected . '>' . $tmpcharset . '</option>' . "\n";
556 <noscript
><input type
="submit" value
="Go" /></noscript
>
565 <!-- Documentation
-->
567 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
569 <a href
="Documentation.html" target
="documentation"><b
><?php
echo $strPmaDocumentation; ?
></b
></a
>
574 if ($is_superuser ||
$cfg['ShowPhpInfo']) {
576 <!-- PHP Information
-->
578 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
580 <a href
="phpinfo.php?<?php echo PMA_generate_common_url(); ?>" target
="_blank"><?php
echo $strShowPHPInfo; ?
></a
>
588 <!-- phpMyAdmin related urls
-->
590 <td valign
="baseline"><img src
="<?php echo $item_img; ?>" width
="7" height
="7" alt
="item" /></td
>
592 <a href
="http://www.phpMyAdmin.net/" target
="_blank"><?php
echo $strHomepageOfficial; ?
></a
><br
/>
593  
; 
; 
; 
; 
; 
;[<a href
="ChangeLog" target
="_blank">ChangeLog
</a
>]
594  
; 
; 
;[<a href
="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/phpmyadmin/phpMyAdmin/" target
="_blank">CVS
</a
>]
595  
; 
; 
;[<a href
="http://sourceforge.net/mail/?group_id=23067" target
="_blank">Lists
</a
>]
607 * Displays the "empty $cfg['PmaAbsoluteUri'] warning"
609 if ($display_pmaAbsoluteUri_warning) {
610 echo '<p class="warning">' . $strPmaUriError . '</p>' . "\n";
614 * Warning if using the default MySQL privileged account
617 && $cfg['Server']['user'] == 'root'
618 && $cfg['Server']['password'] == '') {
619 echo '<p class="warning">' . $strInsecureMySQL . '</p>' . "\n";
623 * Warning for PHP 4.2.3
626 if (PMA_PHP_INT_VERSION
== 40203 && @extension_loaded
('mbstring')) {
627 echo '<p class="warning">' . $strPHP40203 . '</p>' . "\n";
631 * Warning for old PHP version
634 if (PMA_PHP_INT_VERSION
< 40100) {
635 echo '<p class="warning">' . sprintf($strUpgrade, 'PHP', '4.1.0') . '</p>' . "\n";
639 * Warning for old MySQL version
642 if (PMA_MYSQL_INT_VERSION
< 32332) {
643 echo '<p class="warning">' . sprintf($strUpgrade, 'MySQL', '3.23.32') . '</p>' . "\n";
647 * Displays the footer
650 require_once('./footer.inc.php');