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']; ?>">
169 <!-- Link to the welcome page
-->
170 <div id
="el1Parent" class="parent" style
="margin-bottom: 5px">
171 <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
>
175 <!-- Databases
and tables
list -->
177 // Don't display expansible/collapsible database info if:
178 // 1. $server == 0 (no server selected)
179 // This is the case when there are multiple servers and
180 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
181 // screen to appear with no database info displayed.
182 // 2. there is only one database available (ie either only one database exists
183 // or $cfg['Servers']['only_db'] is defined and is not an array)
184 // In this case, the database should not be collapsible/expandable
187 // Light mode -> beginning of the select combo for databases
188 if ($cfg['LeftFrameLight']) {
189 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
190 echo ' <input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
191 echo ' <input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n";
192 echo ' <input type="hidden" name="server" value="' . $server . '" />' . "\n";
193 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
194 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
196 $table_list_header = '';
202 // Gets the tables list per database
203 for ($i = 0; $i < $num_dbs; $i++
) {
206 if (!empty($db_start) && $db == $db_start) {
209 $tables = @PMA_mysql_list_tables
($db);
210 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
211 $common_url_query = 'lang=' . $lang
212 . '&convcharset=' . $convcharset
213 . '&server=' . $server
214 . '&db=' . urlencode($db);
216 $num_tables_disp = $num_tables;
218 $num_tables_disp = '-';
221 // Get additional infomation about tables for tooltip
222 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
224 && (!$cfg['LeftFrameLight'] ||
$selected_db == $j)) {
226 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
227 while ($tmp = PMA_mysql_fetch_array($result)) {
228 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
229 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
233 // No light mode -> displays the expandible/collapsible db list
234 if ($cfg['LeftFrameLight'] == FALSE) {
236 // Displays the database name
237 $on_mouse = (($cfg['LeftPointerColor'] == '') ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
240 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
242 if (!empty($num_tables)) {
245 <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}">
246 <img name
="imEx" id
="el<?php echo $j; ?>Img" src
="images/plus.gif" border
="0" width
="9" height
="9" alt
="+" /></a
>
251 <nobr
><img name
="imEx" src
="images/minus.gif" border
="0" width
="9" height
="9" alt
="-" />
256 <a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick
="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
257 <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
>
260 <div id
="el<?php echo $j;?>Child" class="child" style
="margin-bottom: 5px"<?php
echo $on_mouse; ?
>>
263 // Displays the list of tables from the current database
264 for ($t = 0; $t < $num_tables; $t++
) {
265 $table = PMA_mysql_tablename($tables, $t);
266 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
267 ?
str_replace('"', '"', $tooltip[$table])
271 <nobr
><img src
="images/spacer.gif" border
="0" width
="9" height
="9" alt
="" />
272 <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']; ?>">
273 <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
>
274 <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); ?>">
275 <?php
echo $table; ?
></a
></nobr
><br
/>
277 } // end for $t (tables list)
286 // Light mode -> displays the select combo with databases names and the
287 // list of tables contained in the current database
291 // Builds the databases' names list
292 if (!empty($db_start) && $db == $db_start) {
293 // Gets the list of tables from the current database
294 for ($t = 0; $t < $num_tables; $t++
) {
295 $table = PMA_mysql_tablename($tables, $t);
296 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
297 ?
str_replace('"', '"', $tooltip[$table])
299 $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";
300 $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";
301 if (PMA_USR_BROWSER_AGENT
== 'IE') {
302 $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";
304 $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";
306 } // end for $t (tables list)
309 $table_list = ' <br /><br />' . "\n"
310 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
312 $selected = ' selected="selected"';
314 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
315 $table_list_header .= ' <span class="heada"><b>' . $db . '</b><bdo dir="' . $text_dir . '"> </bdo></span></a><br />' . "\n\n";
318 } // end if... else...
320 if (!empty($num_tables)) {
321 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (' . $num_tables . ')</option>' . "\n";
323 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (-)</option>' . "\n";
324 } // end if... else...
326 } // end if (light mode)
328 } // end for $i (db list)
330 // Light mode -> end of the select combo for databases and table list for
331 // the current database
332 if ($cfg['LeftFrameLight']) {
333 echo ' </select>' . "\n";
334 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
335 echo ' </form>' . "\n";
338 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
341 // Displays the current database name and the list of tables it
343 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
344 echo $table_list_header;
346 echo "\n" . ' <hr noshade="noshade" />' . "\n";
350 // No light mode -> initialize some js variables for the
351 // expandible/collapsible stuff
355 <!-- Arrange collapsible
/expandable db
list at startup
-->
356 <script type
="text/javascript" language
="javascript1.2">
359 firstEl
= 'el1Parent';
360 firstInd
= nsGetIndex(firstEl
);
364 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
369 } // end if... else... (light mode)
371 } // end if ($server > 1)
374 // Case where only one database has to be displayed
375 else if ($num_dbs == 1) {
377 $tables = @PMA_mysql_list_tables
($db);
378 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
379 $common_url_query = 'lang=' . $lang
380 . '&server=' . $server
381 . '&db=' . urlencode($db);
383 $num_tables_disp = $num_tables;
385 $num_tables_disp = '-';
388 // Get additional infomation about tables for tooltip
389 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
392 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
393 while ($tmp = PMA_mysql_fetch_array($result)) {
394 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
395 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
399 // Displays the database name
402 <div id
="el2Parent" class="parent">
403 <nobr
><a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
404 <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
>
406 <div id
="el2Child" class="child" style
="margin-bottom: 5px">
408 // Displays the list of tables from the current database
409 for ($j = 0; $j < $num_tables; $j++
) {
410 $table = PMA_mysql_tablename($tables, $j);
411 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
412 ?
str_replace('"', '"', $tooltip[$table])
416 <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']; ?>">
417 <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
>
418 <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); ?>">
419 <?php
echo $table; ?
></a
></nobr
><br
/>
421 } // end for $j (tables list)
426 } // end if ($num_dbs == 1)
429 // Case where no database has to be displayed
432 echo '<p>' . $strNoDatabases . '</p>';
433 } // end if ($num_dbs == 0)
442 * Close MySql connections
444 if (isset($dbh) && $dbh) {
447 if (isset($userlink) && $userlink) {
448 @mysql_close
($userlink);
453 * Sends bufferized data
455 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
456 && isset($ob_mode) && $ob_mode) {
457 PMA_outBufferPost($ob_mode);