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);
28 include('./libraries/bookmark.lib.php3');
29 require('./libraries/relation.lib.php3');
30 $cfgRelation = PMA_getRelationsParam();
33 * Get the list and number of available databases.
34 * Skipped if no server selected: in this case no database should be displayed
35 * before the user choose among available ones at the welcome screen.
38 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
44 // garvin: For re-usability, moved http-headers
45 // to a seperate file. It can now be included by header.inc.php3,
46 // queryframe.php3, querywindow.php3.
48 include('./libraries/header_http.inc.php3');
53 // Gets the font sizes to use
56 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
57 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
58 <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; ?>">
61 <title
>phpMyAdmin
</title
>
62 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
63 <base
<?php
if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?
> target
="phpmain" />
65 // Expandable/collapsible databases list is only used if there is more than one
66 // database to display
67 if ($num_dbs > 1 && !$cfg['LeftFrameLight']) {
70 <!-- Collapsible tables
list scripts
-->
71 <script type
="text/javascript" language
="javascript">
73 var isDOM
= (typeof(document
.getElementsByTagName
) != 'undefined'
74 && typeof(document
.createElement
) != 'undefined')
76 var isIE4
= (typeof(document
.all
) != 'undefined'
77 && parseInt(navigator
.appVersion
) >= 4)
79 var isNS4
= (typeof(document
.layers
) != 'undefined')
81 var capable
= (isDOM || isIE4 || isNS4
)
83 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
85 if (typeof(window
.opera
) != 'undefined') {
88 else if (typeof(navigator
.userAgent
) != 'undefined') {
89 var browserName
= ' ' + navigator
.userAgent
.toLowerCase();
90 if (browserName
.indexOf('konqueror') > 0) {
93 } // end if... else if...
96 var isServer
= <?php
echo ($server > 0) ?
'true' : 'false'; ?
>;
98 document
.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?lang=<?php echo $lang; ?>&js_frame=left&js_capable=' + capable +
'&js_isDOM=' + isDOM +
'&js_isIE4=' + isIE4 +
'" />');
102 <link rel
="stylesheet" type
="text/css" href
="./css/phpmyadmin.css.php3?lang=<?php echo $lang; ?>&js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
105 <script src
="libraries/left.js" type
="text/javascript" language
="javascript1.2"></script
>
107 } // end if ($num_dbs > 1)
109 else if ($num_dbs == 1) {
112 <link rel
="stylesheet" type
="text/css" href
="./css/phpmyadmin.css.php3?js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
114 } // end if ($num_dbs == 1)
119 <link rel
="stylesheet" type
="text/css" href
="./css/phpmyadmin.css.php3?js_frame=left&num_dbs=0" />
121 } // end if ($num_dbs < 1)
127 <body bgcolor
="<?php echo $cfg['LeftBgColor']; ?>">
130 if ($cfg['LeftDisplayLogo']) {
132 <!-- phpMyAdmin logo
-->
133 <a href
="http://www.phpmyadmin.net" target
="_blank"><img src
="./images/pma_logo.png" width
="88" height
="31" border
="0" alt
="phpMyAdmin" /></a
>
138 <!-- Link to the welcome page
-->
139 <div id
="el1Parent" class="parent" style
="margin-bottom: 5px">
140 <nobr
><a
class="item" href
="main.php3?<?php echo PMA_generate_common_url(); ?>"><span
class="heada"><b
><?php
echo $strHome; ?
></b
></span
></a
></nobr
>
144 <!-- Databases
and tables
list -->
146 // Don't display expansible/collapsible database info if:
147 // 1. $server == 0 (no server selected)
148 // This is the case when there are multiple servers and
149 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
150 // screen to appear with no database info displayed.
151 // 2. there is only one database available (ie either only one database exists
152 // or $cfg['Servers']['only_db'] is defined and is not an array)
153 // In this case, the database should not be collapsible/expandable
156 // Light mode -> beginning of the select combo for databases
157 if ($cfg['LeftFrameLight']) {
158 echo ' <form method="post" action="index.php3" name="left" target="_parent">' . "\n";
159 echo PMA_generate_common_hidden_inputs();
160 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
161 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
163 $table_list_header = '';
169 // Gets the tables list per database
170 for ($i = 0; $i < $num_dbs; $i++
) {
173 if (!empty($db_start) && $db == $db_start) {
176 $tables = @PMA_mysql_list_tables
($db);
177 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
178 $common_url_query = PMA_generate_common_url($db);
180 $num_tables_disp = $num_tables;
182 $num_tables_disp = '-';
185 // Get additional information about tables for tooltip
186 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
188 && (!$cfg['LeftFrameLight'] ||
$selected_db == $j)) {
190 $tooltip_name = array();
191 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
192 while ($tmp = PMA_mysql_fetch_array($result)) {
193 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '');
194 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ?
$tmp['Name'] : $tmp['Comment']);
196 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
197 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
201 // garvin: Get comments from PMA comments table
203 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
204 $tmp_db_tooltip = PMA_getComments($db);
205 if (is_array($tmp_db_tooltip)) {
206 $db_tooltip = implode(' ', $tmp_db_tooltip);
210 // No light mode -> displays the expandible/collapsible db list
211 if ($cfg['LeftFrameLight'] == FALSE) {
213 // Displays the database name
214 $on_mouse = (($cfg['LeftPointerColor'] == '') ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
217 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
219 if (!empty($num_tables)) {
222 <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}">
223 <img name
="imEx" id
="el<?php echo $j; ?>Img" src
="images/plus.png" border
="0" width
="9" height
="9" alt
="+" /></a
>
228 <nobr
><img name
="imEx" src
="images/minus.png" border
="0" width
="9" height
="9" alt
="-" />
233 <a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title
="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick
="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
234 <span
class="heada"><?php
echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
'<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?
><bdo dir
="<?php echo($text_dir); ?>"> 
; 
;</bdo
></span
><span
class="headaCnt">(<?php
echo $num_tables_disp; ?
>)</span
></a
></nobr
>
237 <div id
="el<?php echo $j;?>Child" class="child" style
="margin-bottom: 5px"<?php
echo $on_mouse; ?
>>
240 // Displays the list of tables from the current database
241 for ($t = 0; $t < $num_tables; $t++
) {
242 $table = PMA_mysql_tablename($tables, $t);
243 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
244 ?
htmlspecialchars($tooltip_name[$table])
246 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
247 ?
htmlspecialchars($tooltip[$table])
252 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
254 <nobr
><img src
="images/spacer.gif" border
="0" width
="9" height
="9" alt
="" />
255 <a target
="phpmain" href
="sql.php3?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title
="<?php echo $strBrowse . ': ' . htmlspecialchars($url_title); ?>">
256 <img src
="images/browse.png" width
="8" height
="8" border
="0" alt
="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a
><bdo dir
="<?php echo $text_dir; ?>"> 
;</bdo
>
257 <a
class="tblItem" id
="tbl_<?php echo md5($table); ?>" title
="<?php echo htmlspecialchars($url_title); ?>" target
="phpmain" href
="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
258 <?php
echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)); ?
></a
></nobr
><br
/>
260 } // end for $t (tables list)
269 // Light mode -> displays the select combo with databases names and the
270 // list of tables contained in the current database
274 // Builds the databases' names list
275 if (!empty($db_start) && $db == $db_start) {
276 // Gets the list of tables from the current database
277 for ($t = 0; $t < $num_tables; $t++
) {
278 $table = PMA_mysql_tablename($tables, $t);
279 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
280 ?
str_replace('"', '"', $tooltip[$table])
282 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
283 ?
str_replace('"', '"', $tooltip_name[$table])
286 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
288 $table_list .= ' <nobr><a target="phpmain" href="sql.php3?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ?
urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
289 $table_list .= ' <img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . htmlspecialchars($url_title) . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
290 if (PMA_USR_BROWSER_AGENT
== 'IE') {
291 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($url_title) . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
293 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($url_title) . '" target="phpmain" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
295 } // end for $t (tables list)
298 $table_list = ' <br /><br />' . "\n"
299 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
301 $selected = ' selected="selected"';
303 $table_list_header .= ' <a class="item" target="phpmain" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
304 $table_list_header .= ' <span class="heada"><b>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . '</b><bdo dir="' . $text_dir . '"> </bdo></span></a><br />' . "\n\n";
307 } // end if... else...
309 if (!empty($num_tables)) {
310 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
312 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
313 } // end if... else...
315 } // end if (light mode)
317 } // end for $i (db list)
319 // Light mode -> end of the select combo for databases and table list for
320 // the current database
321 if ($cfg['LeftFrameLight']) {
322 echo ' </select>' . "\n";
323 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
324 echo ' </form>' . "\n";
327 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
330 // Displays the current database name and the list of tables it
332 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
333 echo $table_list_header;
335 echo "\n" . ' <hr noshade="noshade" />' . "\n";
338 // No light mode -> initialize some js variables for the
339 // expandible/collapsible stuff
343 <!-- Arrange collapsible
/expandable db
list at startup
-->
344 <script type
="text/javascript" language
="javascript1.2">
347 firstEl
= 'el1Parent';
348 firstInd
= nsGetIndex(firstEl
);
352 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
357 } // end if... else... (light mode)
359 } // end if ($server > 1)
362 // Case where only one database has to be displayed
363 else if ($num_dbs == 1) {
365 $tables = @PMA_mysql_list_tables
($db);
366 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
367 $common_url_query = PMA_generate_common_url($db);
369 $num_tables_disp = $num_tables;
371 $num_tables_disp = '-';
374 // Get additional infomation about tables for tooltip
375 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
378 $tooltip_name = array();
379 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
380 while ($tmp = PMA_mysql_fetch_array($result)) {
381 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '');
382 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ?
$tmp['Name'] : $tmp['Comment']);
384 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
385 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
389 // garvin: Get comments from PMA comments table
391 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
392 $tmp_db_tooltip = PMA_getComments($db);
393 if (is_array($tmp_db_tooltip)) {
394 $db_tooltip = implode(' ', $tmp_db_tooltip);
398 // Displays the database name
401 <div id
="el2Parent" class="parent">
402 <nobr
><a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
403 <span
class="heada"><?php
echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)); ?
><bdo dir
="<?php echo($text_dir); ?>"> 
; 
;</bdo
></span
><span
class="headaCnt">(<?php
echo $num_tables_disp; ?
>)</span
></a
></nobr
>
405 <div id
="el2Child" class="child" style
="margin-bottom: 5px">
407 // Displays the list of tables from the current database
408 for ($j = 0; $j < $num_tables; $j++
) {
409 $table = PMA_mysql_tablename($tables, $j);
410 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
411 ?
str_replace('"', '"', $tooltip_name[$table])
413 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
414 ?
str_replace('"', '"', $tooltip[$table])
416 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
420 <nobr
><a target
="phpmain" href
="sql.php3?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title
="<?php echo $strBrowse . ': ' . htmlspecialchars($table); ?>">
421 <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
>
422 <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); ?>">
423 <?php
echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)); ?
></a
></nobr
><br
/>
425 } // end for $j (tables list)
430 } // end if ($num_dbs == 1)
433 // Case where no database has to be displayed
436 echo '<p>' . $strNoDatabases . '</p>';
437 } // end if ($num_dbs == 0)
446 * Close MySql connections
448 if (isset($dbh) && $dbh) {
451 if (isset($userlink) && $userlink) {
452 @mysql_close
($userlink);
457 * Sends bufferized data
459 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
460 && isset($ob_mode) && $ob_mode) {
461 PMA_outBufferPost($ob_mode);