6 * Gets the variables sent to this script, retains the db name that may have
7 * been defined as startup option and include a core library
9 require('./libraries/grab_globals.lib.php3');
16 * Gets a core script and starts output buffering work
18 require('./libraries/common.lib.php3');
19 require('./libraries/ob.lib.php3');
21 $ob_mode = PMA_outBufferModeGet();
23 PMA_outBufferPre($ob_mode);
29 * Get the list and number of available databases.
30 * Skipped if no server selected: in this case no database should be displayed
31 * before the user choose among available ones at the welcome screen.
34 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
43 // Don't use cache (required for Opera)
44 $now = gmdate('D, d M Y H:i:s') . ' GMT';
45 header('Expires: ' . $now);
46 header('Last-Modified: ' . $now);
47 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
48 header('Pragma: no-cache'); // HTTP/1.0
49 // Define the charset to be used
50 header('Content-Type: text/html; charset=' . $charset);
56 // Gets the font sizes to use
59 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
60 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
61 <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; ?>">
64 <title
>phpMyAdmin
</title
>
65 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
66 <base
<?php
if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?
> target
="phpmain" />
68 // Expandable/collapsible databases list is only used if there is more than one
69 // database to display
70 if ($num_dbs > 1 && !$cfg['LeftFrameLight']) {
73 <!-- Collapsible tables
list scripts
-->
74 <script type
="text/javascript" language
="javascript">
76 var isDOM
= (typeof(document
.getElementsByTagName
) != 'undefined'
77 && typeof(document
.createElement
) != 'undefined')
79 var isIE4
= (typeof(document
.all
) != 'undefined'
80 && parseInt(navigator
.appVersion
) >= 4)
82 var isNS4
= (typeof(document
.layers
) != 'undefined')
84 var capable
= (isDOM || isIE4 || isNS4
)
86 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
88 if (typeof(window
.opera
) != 'undefined') {
91 else if (typeof(navigator
.userAgent
) != 'undefined') {
92 var browserName
= ' ' + navigator
.userAgent
.toLowerCase();
93 if (browserName
.indexOf('konqueror') > 0) {
96 } // end if... else if...
98 var fontFamily
= '<?php echo $left_font_family; ?>';
99 var fontSize
= '<?php echo $font_size; ?>';
100 var fontBig
= '<?php echo $font_bigger; ?>';
101 var fontSmall
= '<?php echo $font_smaller; ?>';
102 var isServer
= <?php
echo ($server > 0) ?
'true' : 'false'; ?
>;
105 <script src
="libraries/left.js" type
="text/javascript" language
="javascript1.2"></script
>
107 <style type
="text/css">
109 div
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
110 .heada
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
111 .headaCnt
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #000000}
112 .parent
{font
-family
: <?php
echo $left_font_family; ?
>; color
: #000000; text-decoration: none}
113 .child
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
114 .item
, .item
:active
, .item
:hover
, .tblItem
, .tblItem
:active
{color
: #333399; text-decoration: none}
115 .tblItem
:hover
{color
: #FF0000; text-decoration: underline}
120 <style type
="text/css">
122 body
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
126 } // end if ($num_dbs > 1)
128 else if ($num_dbs == 1) {
131 <style type
="text/css">
133 body
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
134 div
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
135 .heada
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
136 .headaCnt
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #000000}
137 .parent
{font
-family
: <?php
echo $left_font_family; ?
>; color
: #000000; text-decoration: none}
138 .child
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
139 .item
, .item
:active
, .item
:hover
, .tblItem
, .tblItem
:active
{font
-size
: <?php
echo $font_smaller; ?
>; color
: #333399; text-decoration: none}
140 .tblItem
:hover
{color
: #FF0000; text-decoration: underline}
144 } // end if ($num_dbs == 1)
149 <style type
="text/css">
151 body
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
152 div
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
153 input
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>}
154 select
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; background
-color
: #ffffff; color: #000000}
155 .heada
{font
-family
: <?php
echo $left_font_family; ?
>; font
-size
: <?php
echo $font_size; ?
>; color
: #000000}
156 .parent
{font
-family
: <?php
echo $left_font_family; ?
>; color
: #000000; text-decoration: none}
157 .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}
158 .tblItem
:hover
{color
: #FF0000; text-decoration: underline}
162 } // end if ($num_dbs < 1)
168 <body bgcolor
="<?php echo $cfg['LeftBgColor']; ?>">
171 if ($cfg['LeftDisplayLogo']) {
173 <!-- phpMyAdmin logo
-->
174 <a href
="http://www.phpmyadmin.net" target
="_blank"><img src
="./images/pma_logo.png" width
="88" height
="31" border
="0" alt
="phpMyAdmin" /></a
>
179 <!-- Link to the welcome page
-->
180 <div id
="el1Parent" class="parent" style
="margin-bottom: 5px">
181 <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
>
185 <!-- Databases
and tables
list -->
187 // Don't display expansible/collapsible database info if:
188 // 1. $server == 0 (no server selected)
189 // This is the case when there are multiple servers and
190 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
191 // screen to appear with no database info displayed.
192 // 2. there is only one database available (ie either only one database exists
193 // or $cfg['Servers']['only_db'] is defined and is not an array)
194 // In this case, the database should not be collapsible/expandable
197 // Light mode -> beginning of the select combo for databases
198 if ($cfg['LeftFrameLight']) {
199 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
200 echo ' <input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
201 echo ' <input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
202 echo ' <input type="hidden" name="server" value="' . $server . '" />' . "\n";
203 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
204 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
206 $table_list_header = '';
212 // Gets the tables list per database
213 for ($i = 0; $i < $num_dbs; $i++
) {
216 if (!empty($db_start) && $db == $db_start) {
219 $tables = @PMA_mysql_list_tables
($db);
220 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
221 $common_url_query = 'lang=' . $lang
222 . '&convcharset=' . $convcharset
223 . '&server=' . $server
224 . '&db=' . urlencode($db);
226 $num_tables_disp = $num_tables;
228 $num_tables_disp = '-';
231 // Get additional infomation about tables for tooltip
232 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
234 && (!$cfg['LeftFrameLight'] ||
$selected_db == $j)) {
236 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
237 while ($tmp = PMA_mysql_fetch_array($result)) {
238 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
239 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
243 // No light mode -> displays the expandible/collapsible db list
244 if ($cfg['LeftFrameLight'] == FALSE) {
246 // Displays the database name
247 $on_mouse = (($cfg['LeftPointerColor'] == '') ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
250 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
252 if (!empty($num_tables)) {
255 <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}">
256 <img name
="imEx" id
="el<?php echo $j; ?>Img" src
="images/plus.gif" border
="0" width
="9" height
="9" alt
="+" /></a
>
261 <nobr
><img name
="imEx" src
="images/minus.gif" border
="0" width
="9" height
="9" alt
="-" />
266 <a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick
="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
267 <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
>
270 <div id
="el<?php echo $j;?>Child" class="child" style
="margin-bottom: 5px"<?php
echo $on_mouse; ?
>>
273 // Displays the list of tables from the current database
274 for ($t = 0; $t < $num_tables; $t++
) {
275 $table = PMA_mysql_tablename($tables, $t);
276 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
277 ?
str_replace('"', '"', $tooltip[$table])
281 <nobr
><img src
="images/spacer.gif" border
="0" width
="9" height
="9" alt
="" />
282 <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']; ?>">
283 <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
>
284 <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); ?>">
285 <?php
echo $table; ?
></a
></nobr
><br
/>
287 } // end for $t (tables list)
296 // Light mode -> displays the select combo with databases names and the
297 // list of tables contained in the current database
301 // Builds the databases' names list
302 if (!empty($db_start) && $db == $db_start) {
303 // Gets the list of tables from the current database
304 for ($t = 0; $t < $num_tables; $t++
) {
305 $table = PMA_mysql_tablename($tables, $t);
306 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
307 ?
str_replace('"', '"', $tooltip[$table])
309 $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";
310 $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";
311 if (PMA_USR_BROWSER_AGENT
== 'IE') {
312 $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";
314 $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";
316 } // end for $t (tables list)
319 $table_list = ' <br /><br />' . "\n"
320 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
322 $selected = ' selected="selected"';
324 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
325 $table_list_header .= ' <span class="heada"><b>' . $db . '</b><bdo dir="' . $text_dir . '"> </bdo></span></a><br />' . "\n\n";
328 } // end if... else...
330 if (!empty($num_tables)) {
331 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (' . $num_tables . ')</option>' . "\n";
333 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (-)</option>' . "\n";
334 } // end if... else...
336 } // end if (light mode)
338 } // end for $i (db list)
340 // Light mode -> end of the select combo for databases and table list for
341 // the current database
342 if ($cfg['LeftFrameLight']) {
343 echo ' </select>' . "\n";
344 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
345 echo ' </form>' . "\n";
348 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
351 // Displays the current database name and the list of tables it
353 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
354 echo $table_list_header;
356 echo "\n" . ' <hr noshade="noshade" />' . "\n";
359 // No light mode -> initialize some js variables for the
360 // expandible/collapsible stuff
364 <!-- Arrange collapsible
/expandable db
list at startup
-->
365 <script type
="text/javascript" language
="javascript1.2">
368 firstEl
= 'el1Parent';
369 firstInd
= nsGetIndex(firstEl
);
373 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
378 } // end if... else... (light mode)
380 } // end if ($server > 1)
383 // Case where only one database has to be displayed
384 else if ($num_dbs == 1) {
386 $tables = @PMA_mysql_list_tables
($db);
387 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
388 $common_url_query = 'lang=' . $lang
389 . '&server=' . $server
390 . '&db=' . urlencode($db);
392 $num_tables_disp = $num_tables;
394 $num_tables_disp = '-';
397 // Get additional infomation about tables for tooltip
398 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
401 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
402 while ($tmp = PMA_mysql_fetch_array($result)) {
403 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
404 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
408 // Displays the database name
411 <div id
="el2Parent" class="parent">
412 <nobr
><a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
413 <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
>
415 <div id
="el2Child" class="child" style
="margin-bottom: 5px">
417 // Displays the list of tables from the current database
418 for ($j = 0; $j < $num_tables; $j++
) {
419 $table = PMA_mysql_tablename($tables, $j);
420 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
421 ?
str_replace('"', '"', $tooltip[$table])
425 <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']; ?>">
426 <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
>
427 <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); ?>">
428 <?php
echo $table; ?
></a
></nobr
><br
/>
430 } // end for $j (tables list)
435 } // end if ($num_dbs == 1)
438 // Case where no database has to be displayed
441 echo '<p>' . $strNoDatabases . '</p>';
442 } // end if ($num_dbs == 0)
451 * Close MySql connections
453 if (isset($dbh) && $dbh) {
456 if (isset($userlink) && $userlink) {
457 @mysql_close
($userlink);
462 * Sends bufferized data
464 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
465 && isset($ob_mode) && $ob_mode) {
466 PMA_outBufferPost($ob_mode);