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<?php echo $hash; ?>" />
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<?php echo $hash; ?>" 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); ?>"
258 target
="phpmain<?php echo $hash; ?>" href
="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
259 <?php
echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)); ?
></a
></nobr
><br
/>
261 } // end for $t (tables list)
270 // Light mode -> displays the select combo with databases names and the
271 // list of tables contained in the current database
275 // Builds the databases' names list
276 if (!empty($db_start) && $db == $db_start) {
277 // Gets the list of tables from the current database
278 for ($t = 0; $t < $num_tables; $t++
) {
279 $table = PMA_mysql_tablename($tables, $t);
280 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
281 ?
str_replace('"', '"', $tooltip[$table])
283 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
284 ?
str_replace('"', '"', $tooltip_name[$table])
287 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
289 $table_list .= ' <nobr><a target="phpmain' . $hash . '" 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";
290 $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";
291 if (PMA_USR_BROWSER_AGENT
== 'IE') {
292 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($url_title) . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
294 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . htmlspecialchars($url_title) . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
296 } // end for $t (tables list)
299 $table_list = ' <br /><br />' . "\n"
300 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
302 $selected = ' selected="selected"';
304 $table_list_header .= ' <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
305 $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";
308 } // end if... else...
310 if (!empty($num_tables)) {
311 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
313 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
314 } // end if... else...
316 } // end if (light mode)
318 } // end for $i (db list)
320 // Light mode -> end of the select combo for databases and table list for
321 // the current database
322 if ($cfg['LeftFrameLight']) {
323 echo ' </select>' . "\n";
324 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
325 echo ' </form>' . "\n";
328 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
331 // Displays the current database name and the list of tables it
333 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
334 echo $table_list_header;
336 echo "\n" . ' <hr noshade="noshade" />' . "\n";
339 // No light mode -> initialize some js variables for the
340 // expandible/collapsible stuff
344 <!-- Arrange collapsible
/expandable db
list at startup
-->
345 <script type
="text/javascript" language
="javascript1.2">
348 firstEl
= 'el1Parent';
349 firstInd
= nsGetIndex(firstEl
);
353 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
358 } // end if... else... (light mode)
360 } // end if ($server > 1)
363 // Case where only one database has to be displayed
364 else if ($num_dbs == 1) {
366 $tables = @PMA_mysql_list_tables
($db);
367 $num_tables = ($tables) ? @mysql_numrows
($tables) : 0;
368 $common_url_query = PMA_generate_common_url($db);
370 $num_tables_disp = $num_tables;
372 $num_tables_disp = '-';
375 // Get additional infomation about tables for tooltip
376 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
379 $tooltip_name = array();
380 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
381 while ($tmp = PMA_mysql_fetch_array($result)) {
382 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '');
383 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ?
$tmp['Name'] : $tmp['Comment']);
385 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
386 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
390 // garvin: Get comments from PMA comments table
392 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
393 $tmp_db_tooltip = PMA_getComments($db);
394 if (is_array($tmp_db_tooltip)) {
395 $db_tooltip = implode(' ', $tmp_db_tooltip);
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_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
>
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 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
412 ?
str_replace('"', '"', $tooltip_name[$table])
414 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
415 ?
str_replace('"', '"', $tooltip[$table])
417 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
421 <nobr
><a target
="phpmain<?php echo $hash; ?>" 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); ?>">
422 <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
>
423 <a
class="tblItem" id
="tbl_<?php echo md5($table); ?>" title
="<?php echo $url_title; ?>" target
="phpmain<?php echo $hash; ?>" href
="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
424 <?php
echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)); ?
></a
></nobr
><br
/>
426 } // end for $j (tables list)
431 } // end if ($num_dbs == 1)
434 // Case where no database has to be displayed
437 echo '<p>' . $strNoDatabases . '</p>';
438 } // end if ($num_dbs == 0)
442 <form name
="hashform" action
="left.php3">
443 <input type
="hidden" name
="hash" value
="<?php echo $hash; ?>">
450 * Close MySql connections
452 if (isset($dbh) && $dbh) {
455 if (isset($userlink) && $userlink) {
456 @mysql_close
($userlink);
461 * Sends bufferized data
463 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
464 && isset($ob_mode) && $ob_mode) {
465 PMA_outBufferPost($ob_mode);