3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Gets the variables sent to this script, retains the db name that may have
8 * been defined as startup option and include a core library
10 require('./libraries/grab_globals.lib.php3');
17 * Gets a core script and starts output buffering work
19 require('./libraries/common.lib.php3');
20 require('./libraries/ob.lib.php3');
22 $ob_mode = PMA_outBufferModeGet();
24 PMA_outBufferPre($ob_mode);
30 * Get the list and number of available databases.
31 * Skipped if no server selected: in this case no database should be displayed
32 * before the user choose among available ones at the welcome screen.
35 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
44 // Don't use cache (required for Opera)
45 $now = gmdate('D, d M Y H:i:s') . ' GMT';
46 header('Expires: ' . $now);
47 header('Last-Modified: ' . $now);
48 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
49 header('Pragma: no-cache'); // HTTP/1.0
50 // Define the charset to be used
51 header('Content-Type: text/html; charset=' . $charset);
57 // Gets the font sizes to use
60 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
61 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
62 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="<?php echo $available_languages[$lang][2]; ?>" lang
="<?php echo $available_languages[$lang][2]; ?>" dir
="<?php echo $text_dir; ?>">
65 <title
>phpMyAdmin
</title
>
66 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
67 <base
<?php
if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?
> target
="phpmain" />
69 // Expandable/collapsible databases list is only used if there is more than one
70 // database to display
71 if ($num_dbs > 1 && !$cfg['LeftFrameLight']) {
74 <!-- Collapsible tables
list scripts
-->
75 <script type
="text/javascript" language
="javascript">
77 var isDOM
= (typeof(document
.getElementsByTagName
) != 'undefined'
78 && typeof(document
.createElement
) != 'undefined')
80 var isIE4
= (typeof(document
.all
) != 'undefined'
81 && parseInt(navigator
.appVersion
) >= 4)
83 var isNS4
= (typeof(document
.layers
) != 'undefined')
85 var capable
= (isDOM || isIE4 || isNS4
)
87 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
89 if (typeof(window
.opera
) != 'undefined') {
92 else if (typeof(navigator
.userAgent
) != 'undefined') {
93 var browserName
= ' ' + navigator
.userAgent
.toLowerCase();
94 if (browserName
.indexOf('konqueror') > 0) {
97 } // end if... else if...
99 var fontFamily
= '<?php echo $left_font_family; ?>';
100 var fontSize
= '<?php echo $font_size; ?>';
101 var fontBig
= '<?php echo $font_bigger; ?>';
102 var fontSmall
= '<?php echo $font_smaller; ?>';
103 var isServer
= <?php
echo ($server > 0) ?
'true' : 'false'; ?
>;
106 <script src
="libraries/left.js" type
="text/javascript" language
="javascript1.2"></script
>
108 <style type
="text/css">
110 div
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
111 .heada
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
112 .headaCnt
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #000000}
113 .parent
{font
-family
: <?php
echo $left_font_family; ?
>; color
: #000000; text-decoration: none}
114 .child
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
115 .item
, .item
:active
, .item
:hover
, .tblItem
, .tblItem
:active
{color
: #333399; text-decoration: none}
116 .tblItem
:hover
{color
: #FF0000; text-decoration: underline}
121 <style type
="text/css">
123 body
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
127 } // end if ($num_dbs > 1)
129 else if ($num_dbs == 1) {
132 <style type
="text/css">
134 body
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
135 div
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
136 .heada
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
137 .headaCnt
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #000000}
138 .parent
{font
-family
: <?php
echo $left_font_family; ?
>; color
: #000000; text-decoration: none}
139 .child
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
140 .item
, .item
:active
, .item
:hover
, .tblItem
, .tblItem
:active
{font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
141 .tblItem
:hover
{color
: #FF0000; text-decoration: underline}
145 } // end if ($num_dbs == 1)
150 <style type
="text/css">
152 body
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
153 div
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
154 input
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
155 select
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; background
-color
: #ffffff; color: #000000}
156 .heada
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
157 .parent
{font
-family
: <?php
echo $left_font_family; ?
>; color
: #000000; text-decoration: none}
158 .item
, .item
:active
, .item
:hover
, .tblItem
, .tblItem
:active
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
159 .tblItem
:hover
{color
: #FF0000; text-decoration: underline}
163 } // end if ($num_dbs < 1)
169 <body bgcolor
="<?php echo $cfg['LeftBgColor']; ?>">
172 if ($cfg['LeftDisplayLogo']) {
174 <!-- phpMyAdmin logo
-->
175 <a href
="http://www.phpmyadmin.net" target
="_blank"><img src
="./images/pma_logo.png" width
="88" height
="31" border
="0" alt
="phpMyAdmin" /></a
>
180 <!-- Link to the welcome page
-->
181 <div id
="el1Parent" class="parent" style
="margin-bottom: 5px">
182 <nobr
><a
class="item" href
="main.php3?lang=<?php echo $lang; ?>&convcharset=<?php echo $convcharset; ?>&server=<?php echo $server; ?>"><span
class="heada"><b
><?php
echo $strHome; ?
></b
></span
></a
></nobr
>
186 <!-- Databases
and tables
list -->
188 // Don't display expansible/collapsible database info if:
189 // 1. $server == 0 (no server selected)
190 // This is the case when there are multiple servers and
191 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
192 // screen to appear with no database info displayed.
193 // 2. there is only one database available (ie either only one database exists
194 // or $cfg['Servers']['only_db'] is defined and is not an array)
195 // In this case, the database should not be collapsible/expandable
198 // Light mode -> beginning of the select combo for databases
199 if ($cfg['LeftFrameLight']) {
200 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
201 echo ' <input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
202 echo ' <input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
203 echo ' <input type="hidden" name="server" value="' . $server . '" />' . "\n";
204 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
205 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
207 $table_list_header = '';
213 // Gets the tables list per database
214 for ($i = 0; $i < $num_dbs; $i++
) {
217 if (!empty($db_start) && $db == $db_start) {
220 $tables = @PMA_mysql_list_tables
($db);
221 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
222 $common_url_query = 'lang=' . $lang
223 . '&convcharset=' . $convcharset
224 . '&server=' . $server
225 . '&db=' . urlencode($db);
227 $num_tables_disp = $num_tables;
229 $num_tables_disp = '-';
232 // Get additional infomation about tables for tooltip
233 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
235 && (!$cfg['LeftFrameLight'] ||
$selected_db == $j)) {
237 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
238 while ($tmp = PMA_mysql_fetch_array($result)) {
239 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
240 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
244 // No light mode -> displays the expandible/collapsible db list
245 if ($cfg['LeftFrameLight'] == FALSE) {
247 // Displays the database name
248 $on_mouse = (($cfg['LeftPointerColor'] == '') ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
251 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
253 if (!empty($num_tables)) {
256 <nobr
><a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick
="if (capable) {expandBase('el<?php echo $j; ?>', true); return false} else {return true}">
257 <img name
="imEx" id
="el<?php echo $j; ?>Img" src
="images/plus.gif" border
="0" width
="9" height
="9" alt
="+" /></a
>
262 <nobr
><img name
="imEx" src
="images/minus.gif" border
="0" width
="9" height
="9" alt
="-" />
267 <a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick
="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
268 <span
class="heada"><?php
echo $db; ?
><bdo dir
="<?php echo($text_dir); ?>"> 
; 
;</bdo
></span
><span
class="headaCnt">(<?php
echo $num_tables_disp; ?
>)</span
></a
></nobr
>
271 <div id
="el<?php echo $j;?>Child" class="child" style
="margin-bottom: 5px"<?php
echo $on_mouse; ?
>>
274 // Displays the list of tables from the current database
275 for ($t = 0; $t < $num_tables; $t++
) {
276 $table = PMA_mysql_tablename($tables, $t);
277 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
278 ?
str_replace('"', '"', $tooltip[$table])
282 <nobr
><img src
="images/spacer.gif" border
="0" width
="9" height
="9" alt
="" />
283 <a target
="phpmain" href
="sql.php3?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>">
284 <img src
="images/browse.gif" width
="8" height
="8" border
="0" alt
="<?php echo "$strBrowse: $table"; ?>" title
="<?php echo "$strBrowse: $table"; ?>" /></a
><bdo dir
="<?php echo $text_dir; ?>"> 
;</bdo
>
285 <a
class="tblItem" id
="tbl_<?php echo md5($table); ?>" title
="<?php echo $url_title; ?>" target
="phpmain" href
="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
286 <?php
echo $table; ?
></a
></nobr
><br
/>
288 } // end for $t (tables list)
297 // Light mode -> displays the select combo with databases names and the
298 // list of tables contained in the current database
302 // Builds the databases' names list
303 if (!empty($db_start) && $db == $db_start) {
304 // Gets the list of tables from the current database
305 for ($t = 0; $t < $num_tables; $t++
) {
306 $table = PMA_mysql_tablename($tables, $t);
307 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
308 ?
str_replace('"', '"', $tooltip[$table])
310 $table_list .= ' <nobr><a target="phpmain" href="sql.php3?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($table)) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
311 $table_list .= ' <img src="images/browse.gif" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $table . '" title="' . $strBrowse . ': ' . $table . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
312 if (PMA_USR_BROWSER_AGENT
== 'IE') {
313 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . $table . '</a></span></nobr><br />' . "\n";
315 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . $table . '</a></nobr><br />' . "\n";
317 } // end for $t (tables list)
320 $table_list = ' <br /><br />' . "\n"
321 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
323 $selected = ' selected="selected"';
325 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
326 $table_list_header .= ' <span class="heada"><b>' . $db . '</b><bdo dir="' . $text_dir . '"> </bdo></span></a><br />' . "\n\n";
329 } // end if... else...
331 if (!empty($num_tables)) {
332 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (' . $num_tables . ')</option>' . "\n";
334 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (-)</option>' . "\n";
335 } // end if... else...
337 } // end if (light mode)
339 } // end for $i (db list)
341 // Light mode -> end of the select combo for databases and table list for
342 // the current database
343 if ($cfg['LeftFrameLight']) {
344 echo ' </select>' . "\n";
345 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
346 echo ' </form>' . "\n";
349 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
352 // Displays the current database name and the list of tables it
354 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
355 echo $table_list_header;
357 echo "\n" . ' <hr noshade="noshade" />' . "\n";
360 // No light mode -> initialize some js variables for the
361 // expandible/collapsible stuff
365 <!-- Arrange collapsible
/expandable db
list at startup
-->
366 <script type
="text/javascript" language
="javascript1.2">
369 firstEl
= 'el1Parent';
370 firstInd
= nsGetIndex(firstEl
);
374 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
379 } // end if... else... (light mode)
381 } // end if ($server > 1)
384 // Case where only one database has to be displayed
385 else if ($num_dbs == 1) {
387 $tables = @PMA_mysql_list_tables
($db);
388 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
389 $common_url_query = 'lang=' . $lang
390 . '&server=' . $server
391 . '&db=' . urlencode($db);
393 $num_tables_disp = $num_tables;
395 $num_tables_disp = '-';
398 // Get additional infomation about tables for tooltip
399 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
402 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
403 while ($tmp = PMA_mysql_fetch_array($result)) {
404 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
405 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
409 // Displays the database name
412 <div id
="el2Parent" class="parent">
413 <nobr
><a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
414 <span
class="heada"><?php
echo $db; ?
><bdo dir
="<?php echo($text_dir); ?>"> 
; 
;</bdo
></span
><span
class="headaCnt">(<?php
echo $num_tables_disp; ?
>)</span
></a
></nobr
>
416 <div id
="el2Child" class="child" style
="margin-bottom: 5px">
418 // Displays the list of tables from the current database
419 for ($j = 0; $j < $num_tables; $j++
) {
420 $table = PMA_mysql_tablename($tables, $j);
421 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
422 ?
str_replace('"', '"', $tooltip[$table])
426 <nobr
><a target
="phpmain" href
="sql.php3?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>">
427 <img src
="images/browse.gif" width
="8" height
="8" border
="0" alt
="<?php echo "$strBrowse: $table"; ?>" title
="<?php echo "$strBrowse: $table"; ?>" /></a
><bdo dir
="<?php echo $text_dir; ?>"> 
;</bdo
>
428 <a
class="tblItem" id
="tbl_<?php echo md5($table); ?>" title
="<?php echo $url_title; ?>" target
="phpmain" href
="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
429 <?php
echo $table; ?
></a
></nobr
><br
/>
431 } // end for $j (tables list)
436 } // end if ($num_dbs == 1)
439 // Case where no database has to be displayed
442 echo '<p>' . $strNoDatabases . '</p>';
443 } // end if ($num_dbs == 0)
452 * Close MySql connections
454 if (isset($dbh) && $dbh) {
457 if (isset($userlink) && $userlink) {
458 @mysql_close
($userlink);
463 * Sends bufferized data
465 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
466 && isset($ob_mode) && $ob_mode) {
467 PMA_outBufferPost($ob_mode);