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?<?php echo PMA_generate_common_url(); ?>"><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 PMA_generate_common_hidden_inputs();
202 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
203 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
205 $table_list_header = '';
211 // Gets the tables list per database
212 for ($i = 0; $i < $num_dbs; $i++
) {
215 if (!empty($db_start) && $db == $db_start) {
218 $tables = @PMA_mysql_list_tables
($db);
219 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
220 $common_url_query = PMA_generate_common_url($db);
222 $num_tables_disp = $num_tables;
224 $num_tables_disp = '-';
227 // Get additional infomation about tables for tooltip
228 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
230 && (!$cfg['LeftFrameLight'] ||
$selected_db == $j)) {
232 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
233 while ($tmp = PMA_mysql_fetch_array($result)) {
234 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
235 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
239 // No light mode -> displays the expandible/collapsible db list
240 if ($cfg['LeftFrameLight'] == FALSE) {
242 // Displays the database name
243 $on_mouse = (($cfg['LeftPointerColor'] == '') ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
246 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
248 if (!empty($num_tables)) {
251 <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}">
252 <img name
="imEx" id
="el<?php echo $j; ?>Img" src
="images/plus.png" border
="0" width
="9" height
="9" alt
="+" /></a
>
257 <nobr
><img name
="imEx" src
="images/minus.png" border
="0" width
="9" height
="9" alt
="-" />
262 <a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick
="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
263 <span
class="heada"><?php
echo htmlspecialchars($db); ?
><bdo dir
="<?php echo($text_dir); ?>"> 
; 
;</bdo
></span
><span
class="headaCnt">(<?php
echo $num_tables_disp; ?
>)</span
></a
></nobr
>
266 <div id
="el<?php echo $j;?>Child" class="child" style
="margin-bottom: 5px"<?php
echo $on_mouse; ?
>>
269 // Displays the list of tables from the current database
270 for ($t = 0; $t < $num_tables; $t++
) {
271 $table = PMA_mysql_tablename($tables, $t);
272 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
273 ?
htmlspecialchars($tooltip[$table])
277 <nobr
><img src
="images/spacer.gif" border
="0" width
="9" height
="9" alt
="" />
278 <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']; ?>" title
="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>">
279 <img src
="images/browse.png" width
="8" height
="8" border
="0" alt
="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>" /></a
><bdo dir
="<?php echo $text_dir; ?>"> 
;</bdo
>
280 <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); ?>">
281 <?php
echo htmlspecialchars($table); ?
></a
></nobr
><br
/>
283 } // end for $t (tables list)
292 // Light mode -> displays the select combo with databases names and the
293 // list of tables contained in the current database
297 // Builds the databases' names list
298 if (!empty($db_start) && $db == $db_start) {
299 // Gets the list of tables from the current database
300 for ($t = 0; $t < $num_tables; $t++
) {
301 $table = PMA_mysql_tablename($tables, $t);
302 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
303 ?
str_replace('"', '"', $tooltip[$table])
305 $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";
306 $table_list .= ' <img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $table . '" title="' . $strBrowse . ': ' . htmlspecialchars($table) . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
307 if (PMA_USR_BROWSER_AGENT
== 'IE') {
308 $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) . '">' . htmlspecialchars($table) . '</a></span></nobr><br />' . "\n";
310 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . htmlspecialchars($table) . '</a></nobr><br />' . "\n";
312 } // end for $t (tables list)
315 $table_list = ' <br /><br />' . "\n"
316 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
318 $selected = ' selected="selected"';
320 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
321 $table_list_header .= ' <span class="heada"><b>' . htmlspecialchars($db) . '</b><bdo dir="' . $text_dir . '"> </bdo></span></a><br />' . "\n\n";
324 } // end if... else...
326 if (!empty($num_tables)) {
327 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . htmlspecialchars($db) . ' (' . $num_tables . ')</option>' . "\n";
329 echo ' <option value="' . urlencode($db) . '"' . $selected . '>' . htmlspecialchars($db) . ' (-)</option>' . "\n";
330 } // end if... else...
332 } // end if (light mode)
334 } // end for $i (db list)
336 // Light mode -> end of the select combo for databases and table list for
337 // the current database
338 if ($cfg['LeftFrameLight']) {
339 echo ' </select>' . "\n";
340 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
341 echo ' </form>' . "\n";
344 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
347 // Displays the current database name and the list of tables it
349 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
350 echo $table_list_header;
352 echo "\n" . ' <hr noshade="noshade" />' . "\n";
355 // No light mode -> initialize some js variables for the
356 // expandible/collapsible stuff
360 <!-- Arrange collapsible
/expandable db
list at startup
-->
361 <script type
="text/javascript" language
="javascript1.2">
364 firstEl
= 'el1Parent';
365 firstInd
= nsGetIndex(firstEl
);
369 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
374 } // end if... else... (light mode)
376 } // end if ($server > 1)
379 // Case where only one database has to be displayed
380 else if ($num_dbs == 1) {
382 $tables = @PMA_mysql_list_tables
($db);
383 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
384 $common_url_query = PMA_generate_common_url($db);
386 $num_tables_disp = $num_tables;
388 $num_tables_disp = '-';
391 // Get additional infomation about tables for tooltip
392 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
395 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
396 while ($tmp = PMA_mysql_fetch_array($result)) {
397 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
398 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
402 // Displays the database name
405 <div id
="el2Parent" class="parent">
406 <nobr
><a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
407 <span
class="heada"><?php
echo htmlspecialchars($db); ?
><bdo dir
="<?php echo($text_dir); ?>"> 
; 
;</bdo
></span
><span
class="headaCnt">(<?php
echo $num_tables_disp; ?
>)</span
></a
></nobr
>
409 <div id
="el2Child" class="child" style
="margin-bottom: 5px">
411 // Displays the list of tables from the current database
412 for ($j = 0; $j < $num_tables; $j++
) {
413 $table = PMA_mysql_tablename($tables, $j);
414 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
415 ?
str_replace('"', '"', $tooltip[$table])
419 <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']; ?>" title
="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>">
420 <img src
="images/browse.png" width
="8" height
="8" border
="0" alt
="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>" /></a
><bdo dir
="<?php echo $text_dir; ?>"> 
;</bdo
>
421 <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); ?>">
422 <?php
echo htmlspecialchars($table); ?
></a
></nobr
><br
/>
424 } // end for $j (tables list)
429 } // end if ($num_dbs == 1)
432 // Case where no database has to be displayed
435 echo '<p>' . $strNoDatabases . '</p>';
436 } // end if ($num_dbs == 0)
445 * Close MySql connections
447 if (isset($dbh) && $dbh) {
450 if (isset($userlink) && $userlink) {
451 @mysql_close
($userlink);
456 * Sends bufferized data
458 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
459 && isset($ob_mode) && $ob_mode) {
460 PMA_outBufferPost($ob_mode);