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_once('./libraries/grab_globals.lib.php');
11 if (isset($lightm_db) && !empty($lightm_db)) {
12 // no longer urlencoded because of html entities in the db name
13 // $db = urldecode($lightm_db);
23 * Gets a core script and starts output buffering work
25 require_once('./libraries/common.lib.php');
26 require_once('./libraries/ob.lib.php');
28 $ob_mode = PMA_outBufferModeGet();
30 PMA_outBufferPre($ob_mode);
34 // This check had been put here to avoid revealing the full path
35 // of the phpMyAdmin directory in case this script is called
36 // directly. But some users report a "Missing hash" message and
37 // I cannot reproduce it, so let's define $hash to a dummy value
38 // and hope some other clue will surface, to sort this bug.
39 //PMA_checkParameters(array('hash'));
44 require_once('./libraries/bookmark.lib.php');
45 require_once('./libraries/relation.lib.php');
46 $cfgRelation = PMA_getRelationsParam();
48 function PMA_multimerge(&$stack, &$table) {
49 global $list_item, $table_item;
51 $key = array_shift($table);
53 if (count($table) > 0) {
54 if (!isset($stack[$key])) {
57 PMA_multimerge($stack[$key], $table);
59 $stack['pma_name'][] = $table_item;
60 $stack['pma_list_item'][] = $list_item;
64 /* This will take a 1-dimensional array, and shift as many elemnts off
65 * the end, until the allowed maximum level is reached */
66 function PMA_reduceNest(&$_table) {
67 if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
68 $elements = count($_table);
69 for ($ti = $elements; $ti > $GLOBALS['cfg']['LeftFrameTableLevel']; $ti--) {
75 function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
77 //$id = preg_replace('@[^a-z0-9]*@i', '', $baseid . $keyhistory . $key) . $indent;
78 $id = base64_encode($baseid . $keyhistory . $key) . $indent;
80 $groupkey = $keyhistory . ($key != $keyhistory ?
$GLOBALS['cfg']['LeftFrameTableSeparator'] . $key : '');
82 $on_mouse = (($GLOBALS['cfg']['LeftPointerEnable'] == FALSE) ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
85 if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
86 $counter = count($countarray['pma_name']);
88 unset($countarray['pma_name']);
89 if (count($countarray) > 1) {
90 unset($countarray['pma_list_item']);
92 $counter = count($countarray);
96 echo str_repeat(' ', $indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
97 echo str_repeat(' ', $indent * 6) . '<div class="nowrap"><img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" border="0" width="' . (($indent - 1) * $indent_level) . '" height="9" alt="" /><a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '&tbl_group=' . htmlspecialchars($groupkey) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', true); return false} else {return true}">';
98 echo '<img name="imEx" id="el' . $id . 'Img" src="' . $GLOBALS['pmaThemeImage'] . 'b_plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
99 echo str_repeat(' ', $indent * 6) . '<a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '&tbl_group=' . htmlspecialchars($groupkey) . '" title="' . htmlspecialchars($name) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', false)}"><span class="heada">' . htmlspecialchars($name) . '<bdo dir="' . $GLOBALS['text_dir'] . '"> </bdo></span><span class="headaCnt">(' . $counter . ')</span></a></div>' . "\n";
100 echo str_repeat(' ', $indent * 5) . '</div><!-- class="PMA_nestedSetHeaderParent" -->' . "\n";
104 echo str_repeat(' ', $indent * 5) . '<div id="el' . $id . 'Child" class="child nowrap" ' . $on_mouse . '>' . "\n";
108 function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
110 PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
114 foreach ($tablestack AS $key => $val) {
115 if ($key != 'pma_name' && $key != 'pma_list_item') {
117 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
120 if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
121 PMA_nestedSet($baseid, $val, $key, $keyhistory . ($keyhistory != '' ?
$GLOBALS['cfg']['LeftFrameTableSeparator'] : '') . $key, false, ($indent +
1));
123 PMA_nestedSet($baseid, $val, $key, $keyhistory . ($keyhistory != '' ?
$GLOBALS['cfg']['LeftFrameTableSeparator'] : '') . $key, true, ($indent +
1));
127 echo str_repeat(' ', $indent * 5) . '</div><!-- class="PMA_nestedSetHeader" -->' . "\n";
132 if ($firstGroup && $firstGroupClose) {
133 echo str_repeat(' ', $indent * 4) . '</div><!-- class="PMA_nestedSetHeader2" -->' . "\n";
134 } elseif ($firstGroup) {
135 echo str_repeat(' ', $indent * 4) . '<!-- spacer="div omitted" class="PMA_nestedSetHeader2" -->' . "\n";
139 function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
141 if ($keyhistory == '' && $key != '__protected__') {
147 if (isset($tablestack)
148 && isset($tablestack['pma_name'])
149 && isset($tablestack['pma_list_item'])) {
151 if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
152 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+
1), $indent_level, $headerOut, $key, false);
156 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
161 $on_mouse = (($GLOBALS['cfg']['LeftPointerEnable'] == FALSE) ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
164 foreach ($tablestack['pma_name'] AS $tkey => $tval) {
166 echo str_repeat(' ', $indent * 5) . '<img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' .'" border="0" width="' . (($indent+
$extra_indent) * $indent_level) . '" height="9" alt="" />';
167 $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
168 foreach ($items AS $ikey => $ival) {
170 echo str_repeat(' ', ($indent * 5)) . $ival;
178 echo str_repeat(' ', $indent * 5) . '</div><!-- space="putting omitted div" class="PMA_nestedSet2" -->';
181 } elseif (is_array($tablestack)) {
182 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )?
($indent-1) : ($indent +
1)), $indent_level, $headerOut, (($key == '__protected__' && $indent == 1) ||
($indent > 1) ?
false : $key));
188 * Get the list and number of available databases.
189 * Skipped if no server selected: in this case no database should be displayed
190 * before the user choose among available ones at the welcome screen.
193 PMA_availableDatabases(); // this function is defined in "common.lib.php"
199 // garvin: For re-usability, moved http-headers
200 // to a seperate file. It can now be included by header.inc.php,
201 // queryframe.php, querywindow.php.
203 require_once('./libraries/header_http.inc.php');
208 // Gets the font sizes to use
210 echo "<?xml version=\"1.0\" encoding=\"" . $GLOBALS['charset'] . "\"?".">"; // remove vertical scroll bar bug in ie
212 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
213 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
214 <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; ?>">
217 <title
>phpMyAdmin
</title
>
218 <meta http
-equiv
="Content-Type" content
="text/html; charset=<?php echo $charset; ?>" />
219 <base
<?php
if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?
> target
="phpmain<?php echo $hash; ?>" />
221 <script type
="text/javascript" language
="javascript">
223 function goTo(targeturl
, targetframe
) {
229 <?php
if (PMA_USR_BROWSER_AGENT
!= 'SAFARI') { ?
>
230 targetframe
.location
.replace(targeturl
);
232 targetframe
.location
.href
= targeturl
;
240 if (isset($lightm_db) && !empty($lightm_db)) {
242 goTo('./<?php echo $cfg['DefaultTabDatabase
'] . '?
' . PMA_generate_common_url($db, '', '&');?>', window
.parent
.frames
['phpmain<?php echo $hash; ?>']);
244 } elseif (isset($lightm_db)) {
246 goTo('./main.php?<?php echo PMA_generate_common_url('', '', '&');?>', window
.parent
.frames
['phpmain<?php echo $hash; ?>']);
254 // Expandable/collapsible databases list is only used if there is more than one
255 // database to display
256 if (($num_dbs > 1 ||
!empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
259 <!-- Collapsible tables
list scripts
-->
260 <script type
="text/javascript" language
="javascript">
262 var imgUrlPlus
= "<?php echo $GLOBALS['pmaThemeImage'] . 'b_plus.png'; ?>";
263 var imgUrlMinus
= "<?php echo $GLOBALS['pmaThemeImage'] . 'b_minus.png'; ?>";
264 var isDOM
= (typeof(document
.getElementsByTagName
) != 'undefined'
265 && typeof(document
.createElement
) != 'undefined')
267 var isIE4
= (typeof(document
.all
) != 'undefined'
268 && parseInt(navigator
.appVersion
) >= 4)
270 var isNS4
= (typeof(document
.layers
) != 'undefined')
272 var capable
= (isDOM || isIE4 || isNS4
)
274 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
276 if (typeof(window
.opera
) != 'undefined') {
277 var browserName
= ' ' + navigator
.userAgent
.toLowerCase();
278 if ((browserName
.indexOf('konqueror 7') == 0)) {
282 else if (typeof(navigator
.userAgent
) != 'undefined') {
283 var browserName
= ' ' + navigator
.userAgent
.toLowerCase();
284 if ((browserName
.indexOf('konqueror') > 0) && (browserName
.indexOf('konqueror/3') == 0)) {
287 } // end if... else if...
290 var isServer
= <?php
echo ($server > 0) ?
'true' : 'false'; ?
>;
292 document
.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&js_frame=left&js_capable=' + capable +
'&js_isDOM=' + isDOM +
'&js_isIE4=' + isIE4 +
'" />');
296 <link rel
="stylesheet" type
="text/css" href
="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
299 <script src
="libraries/left.js" type
="text/javascript" language
="javascript1.2"></script
>
301 } // end if ($num_dbs > 1)
303 else if ($num_dbs == 1) {
306 <link rel
="stylesheet" type
="text/css" href
="./css/phpmyadmin.css.php?js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
308 } // end if ($num_dbs == 1)
313 <link rel
="stylesheet" type
="text/css" href
="./css/phpmyadmin.css.php?js_frame=left&num_dbs=0" />
315 } // end if ($num_dbs < 1)
321 <body bgcolor
="<?php echo $cfg['LeftBgColor']; ?>" id
="body_leftFrame">
324 if ($cfg['LeftDisplayLogo'] && !$cfg['QueryFrame']) {
326 <!-- phpMyAdmin logo
-->
328 if (@file_exists
($pmaThemeImage . 'logo_left.png')) {
331 <a href
="http://www.phpmyadmin.net" target
="_blank"><img src
="<?php echo '' . $pmaThemeImage . 'logo_left.png'; ?>" alt
="phpMyAdmin" vspace
="3" border
="0" /></a
>
335 echo '<div align="center"><a href="http://www.phpmyadmin.net" target="_blank">';
336 echo '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png' . '" alt="phpMyAdmin" border="0" />';
337 echo '</a></div>' . "\n";
340 } // end of display logo
343 if (!$cfg['QueryFrame']) {
346 <!-- Link to the welcome page
-->
347 <div id
="el1Parent" class="parent nowrap" align
="center">
349 if ($cfg['MainPageIconic']) {
350 $str_spacer_links='';
352 $str_spacer_links=' - ';
354 echo '<a class="item" href="main.php?' . PMA_generate_common_url() . '" target="phpmain' . $hash . '">'
355 . ($cfg['MainPageIconic']
356 ?
'<img src="' . $pmaThemeImage . 'b_home.png" width="16" height="16" border="0" hspace="2" alt="' . $strHome . '" title="' . $strHome . '"'
357 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
358 : '<b>' . $strHome . '</b>')
360 // if we have chosen server show logout for advanced authentication
361 if ($server != 0 && $cfg['Server']['auth_type'] != 'config') {
362 echo $str_spacer_links;
363 echo '<a class="item" href="index.php?' . PMA_generate_common_url() . '&old_usr=' . urlencode($PHP_AUTH_USER) . '" target="_parent">'
364 . ($cfg['MainPageIconic']
365 ?
'<img src="' . $pmaThemeImage . 's_loggoff.png" width="16" height="16" border="0" hspace="2" alt="' . $strLogout . '" title="' . $strLogout . '"'
366 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
367 : '<b>' . $strLogout . '</b>')
370 if ($cfg['MainPageIconic']) {
371 echo '<img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="2" height="1" border="0" />'
372 . '<a href="Documentation.html" target="documentation" class="item">'
373 . '<img src="' . $pmaThemeImage . 'b_docs.png" border="0" hspace="1" width="16" height="16" alt="' . $strPmaDocumentation . '" title="' . $strPmaDocumentation . '"'
374 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
377 . '<a href="' . $cfg['MySQLManualBase'] . '" target="documentation" class="item">'
378 . '<img src="' . $pmaThemeImage . 'b_sqlhelp.png" border="0" hspace="1" width="16" height="16" alt="MySQL - ' . $strDocu . '" title="MySQL - ' . $strDocu . '"'
379 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
386 if ($cfg['LeftDisplayServers']) {
387 $show_server_left = TRUE;
388 include('./libraries/select_server.lib.php');
390 } // end !$cfg['QueryFrame']
393 <!-- Databases
and tables
list -->
394 <div id
="left_tableList">
396 // Don't display expansible/collapsible database info if:
397 // 1. $server == 0 (no server selected)
398 // This is the case when there are multiple servers and
399 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
400 // screen to appear with no database info displayed.
401 // 2. there is only one database available (ie either only one database exists
402 // or $cfg['Servers']['only_db'] is defined and is not an array)
403 // In this case, the database should not be collapsible/expandable
406 // Light mode -> beginning of the select combo for databases
407 // Note: When javascript is active, the frameset will be changed from
408 // within left.php. With no JS (<noscript>) the whole frameset will
409 // be rebuilt with the new target frame.
410 if ($cfg['LeftFrameLight']) {
411 if (!$cfg['QueryFrame']) {
413 <script type
="text/javascript" language
="javascript">
415 document
.writeln('<form method="post" action="left.php" name="left" target="nav" style="margin: 0px; padding: 0px;">');
419 <form method
="post" action
="index.php" name
="left" target
="_parent" style
="margin: 0px; padding: 0px;">
422 echo PMA_generate_common_hidden_inputs();
423 echo ' <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
424 echo ' <span class="heada"><b>' . $strDatabase . ':</b></span><br />';
425 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
426 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
427 } // end !$cfg['QueryFrame']
430 $table_list_header = '';
436 // natural order for db list; but do not sort if user asked
437 // for a specific order with the 'only_db' mechanism
439 if (!is_array($cfg['Server']['only_db']) && $cfg['NaturalOrder'] && $num_dbs > 0) {
440 $dblist_temp = $dblist;
441 natsort($dblist_temp);
443 foreach ($dblist_temp as $each) {
449 // Gets the tables list per database
450 for ($i = 0; $i < $num_dbs; $i++
) {
453 if (!empty($db_start) && $db == $db_start) {
457 * The query below will return a result set with a single field under
458 * MySQL versions before 5.0 and one with two fields under MySQL 5.0
459 * and above. The MySQL 5 result set also includes the table type
460 * ('BASE TABLE', 'VIEW' or 'TEMPORARY').
461 * MySQL 4 does neither know about views nor differ between permanent
462 * and temporary tables, so the table type is irrelevant here.
464 $tables = PMA_DBI_try_query('SHOW ' . (PMA_MYSQL_INT_VERSION
>= 50000 ?
'FULL ' : '') . 'TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE
);
465 $num_tables = ($tables) ? @PMA_DBI_num_rows
($tables) : 0;
466 $common_url_query = PMA_generate_common_url($db);
468 $num_tables_disp = $num_tables;
470 $num_tables_disp = '-';
473 // Get additional information about tables for tooltip
474 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
476 && (!$cfg['LeftFrameLight'] ||
$selected_db == $j)) {
478 $tooltip_name = array();
479 $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
480 while ($tmp = PMA_DBI_fetch_assoc($result)) {
481 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '');
482 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ?
$tmp['Name'] : $tmp['Comment']);
484 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
485 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
489 // garvin: Get comments from PMA comments table
491 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
492 $tmp_db_tooltip = PMA_getComments($db);
493 if (is_array($tmp_db_tooltip)) {
494 $db_tooltip = implode(' ', $tmp_db_tooltip);
498 // No light mode -> displays the expandible/collapsible db list
499 if ($cfg['LeftFrameLight'] == FALSE) {
501 // Displays the database name
502 $on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
505 echo ' <div id="el' . $j . 'Parent" class="parent nowrap"' . $on_mouse . '>';
507 if (!empty($num_tables)) {
510 <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}">
511 <img name
="imEx" id
="el<?php echo $j; ?>Img" src
="<?php echo $pmaThemeImage; ?>b_plus.png" border
="0" width
="9" height
="9" alt
="+" /></a
>
516 <img name
="imEx" src
="<?php echo $pmaThemeImage; ?>b_minus.png" border
="0" width
="9" height
="9" alt
="-" />
521 <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)}">
522 <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
>
525 <div id
="el<?php echo $j;?>Child" class="child nowrap" style
="margin-bottom: 5px"<?php
echo $on_mouse; ?
>>
527 // Displays the list of tables from the current database
528 $tablestack = array();
529 $table_array = array();
530 $table_types = array();
531 while (@list
($table, $type) = PMA_DBI_fetch_row($tables)) {
532 $table_item = (!empty($tooltip_name) && isset($tooltip_name[$table]) && !empty($tooltip_name[$table]) && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
533 ?
htmlspecialchars($tooltip_name[$table])
534 : htmlspecialchars($table));
535 $table_array[$table] = $table_item;
536 $table_types[$table] = empty($type) ?
'BASE TABLE' : $type;
539 if ($cfg['NaturalOrder']) {
540 natsort($table_array);
543 $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
544 foreach ($table_array as $table => $table_sortkey) {
545 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
546 ?
htmlspecialchars($tooltip_name[$table])
548 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
549 ?
htmlspecialchars($tooltip[$table])
551 $table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
553 : htmlspecialchars($table));
554 $tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
556 : htmlspecialchars($table));
558 $book_sql_query = (isset($book_sql_cache[$table]) ?
$book_sql_cache[$table] : FALSE);
560 $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $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'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
561 $list_item .= '<img src="' . $pmaThemeImage . ($table_types[$table] == 'VIEW' ?
's_views' : 'b_sbrowse') . '.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
562 $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
563 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
564 $list_item .= $table_item . '</a><br />' . "\n";
566 // garvin: Check whether to display nested sets
567 if (!empty($cfg['LeftFrameTableSeparator'])) {
568 $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'', $tablename));
569 if (is_array($_table)) {
570 foreach ($_table AS $key => $val) {
572 $_table[$key] = '__protected__';
575 PMA_reduceNest($_table);
577 if (count($_table) == 1) {
578 array_unshift($_table, '');
580 PMA_multimerge($tablestack, $_table);
582 $tablestack['']['pma_name'][] = $table_item;
583 $tablestack['']['pma_list_item'][] = $list_item;
586 $tablestack['']['pma_name'][] = $table_item;
587 $tablestack['']['pma_list_item'][] = $list_item;
589 } // end while (tables list)
591 PMA_nestedSet($j, $tablestack);
598 // Light mode -> displays the select combo with databases names and the
599 // list of tables contained in the current database
603 // Builds the databases' names list
604 if (!empty($db_start) && $db == $db_start) {
605 $table_title = array();
606 $table_array = array();
607 // Gets the list of tables from the current database
608 $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
609 while (@list
($table, $type) = PMA_DBI_fetch_row($tables)) {
610 $table_array[$table] = '';
611 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
612 ?
htmlspecialchars($tooltip[$table])
614 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
615 ?
htmlspecialchars($tooltip_name[$table])
618 $book_sql_query = (isset($book_sql_cache[$table]) ?
$book_sql_cache[$table] : FALSE);
620 // natural order or not, use an array for the table list
622 $table_array[$table] .= ' <div class="nowrap"><a target="phpmain' . $hash . '" href="sql.php?' . $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";
623 $table_array[$table] .= ' <img src="' . $pmaThemeImage . (!empty($type) && $type == 'VIEW' ?
's_views' : 'b_sbrowse') . '.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
625 if (PMA_USR_BROWSER_AGENT
== 'IE') {
626 $table_array[$table] .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)) . '</a></span></div>' . "\n";
628 $table_array[$table] .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ?
$alias : htmlspecialchars($table)) . '</a></div>' . "\n";
631 $table_title[$table] = htmlspecialchars($table);
633 } // end while (tables list)
635 if (count($table_title) > 0) {
636 if ($cfg['NaturalOrder'] && $num_tables > 0) {
637 natsort($table_title);
640 foreach ($table_title as $each_key => $each_val) {
641 $table_list .= ' ' . $table_array[$each_key];
644 $table_list = ' <br /><br />' . "\n"
645 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
647 $selected = ' selected="selected"';
649 $table_list_header .= ' <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
650 $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";
653 } // end if... else...
654 if (!$cfg['QueryFrame']) {
655 if (!empty($num_tables)) {
656 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>'
657 . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
659 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>'
660 . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ?
htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
662 } // end !$cfg['QueryFrame']
664 } // end if (light mode)
666 } // end for $i (db list)
668 // Light mode -> end of the select combo for databases and table list for
669 // the current database
670 if ($cfg['LeftFrameLight']) {
671 if (!$cfg['QueryFrame']) {
672 echo ' </select>' . "\n";
673 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
674 echo ' </form>' . "\n";
677 $table_list = ' <div align="center"><b>' . $strSelectADb . '</b></div>' . "\n";
680 // Displays the current database name and the list of tables it
682 if (!$cfg['QueryFrame']) {
685 echo $table_list_header;
689 // No light mode -> initialize some js variables for the
690 // expandible/collapsible stuff
694 <!-- Arrange collapsible
/expandable db
list at startup
-->
695 <script type
="text/javascript" language
="javascript1.2">
698 firstEl
= 'el1Parent';
699 firstInd
= nsGetIndex(firstEl
);
703 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
708 } // end if... else... (light mode)
710 } // end if ($server > 1)
713 // Case where only one database has to be displayed
714 else if ($num_dbs == 1) {
716 $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE
);
717 $num_tables = ($tables) ? @PMA_DBI_num_rows
($tables) : 0;
718 $common_url_query = PMA_generate_common_url($db);
720 $num_tables_disp = $num_tables;
722 $num_tables_disp = '-';
725 // Get additional infomation about tables for tooltip
726 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION
>= 32303
729 $tooltip_name = array();
730 $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE
);
731 while ($tmp = PMA_DBI_fetch_assoc($result)) {
732 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '');
733 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ?
$tmp['Name'] : $tmp['Comment']);
735 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ?
$tmp['Comment'] . ' ' : '')
736 . '(' . (isset($tmp['Rows']) ?
$tmp['Rows'] : '0') . ' ' . $strRows . ')';
740 // garvin: Get comments from PMA comments table
742 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
743 $tmp_db_tooltip = PMA_getComments($db);
744 if (is_array($tmp_db_tooltip)) {
745 $db_tooltip = implode(' ', $tmp_db_tooltip);
750 // Displays the database name
751 if (!$cfg['LeftFrameLight']) {
752 $on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ?
'' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
755 echo ' <div id="el2Parent" class="parent"' . $on_mouse . '>';
757 if (!empty($num_tables)) {
760 <div
class="nowrap"><a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick
="if (capable) {expandBase('el2', true); return false} else {return true}">
761 <img name
="imEx" id
="el2Img" src
="<?php echo $pmaThemeImage; ?>b_plus.png" border
="0" width
="9" height
="9" alt
="+" /></a
>
766 <div
class="nowrap"><img name
="imEx" src
="<?php echo $pmaThemeImage; ?>b_minus.png" border
="0" width
="9" height
="9" alt
="-" />
771 <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('el2', false)}">
772 <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
></div
>
775 <div id
="el2Child" class="child" style
="margin-bottom: 5px"<?php
echo $on_mouse; ?
>>
780 <div id
="el2Parent" class="parent nowrap">
781 <a
class="item" href
="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
782 <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
>
784 <div id
="el2Child" class="child nowrap" style
="margin-bottom: 5px">
788 // Displays the list of tables from the current database
789 $tablestack = array();
790 $table_array = array();
791 while (list($table) = PMA_DBI_fetch_row($tables)) {
792 $table_item = (!empty($tooltip_name) && isset($tooltip_name[$table]) && !empty($tooltip_name[$table]) && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
793 ?
htmlspecialchars($tooltip_name[$table])
794 : htmlspecialchars($table));
795 $table_array[$table] = $table_item;
798 if ($cfg['NaturalOrder']) {
799 natcasesort($table_array);
802 $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
803 foreach ($table_array as $table => $table_sortkey) {
804 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
805 ?
htmlspecialchars($tooltip_name[$table])
807 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
808 ?
htmlspecialchars($tooltip[$table])
810 $table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
812 : htmlspecialchars($table));
813 $tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
815 : htmlspecialchars($table));
817 $book_sql_query = (isset($book_sql_cache[$table]) ?
$book_sql_cache[$table] : FALSE);
819 if ($cfg['LeftFrameLight']) {
822 <a target
="phpmain<?php echo $hash; ?>" href
="sql.php?<?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 . ': ' . $url_title; ?>">
823 <img src
="<?php echo $pmaThemeImage . 'b_sbrowse.png'; ?>" width
="10" height
="10" border
="0" alt
="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a
><bdo dir
="<?php echo $text_dir; ?>"> 
;</bdo
>
824 <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); ?>">
825 <?php
echo $table_item; ?
></a
><br
/>
828 $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $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'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
829 $list_item .= '<img src="' . $pmaThemeImage . 'b_sbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
830 $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
831 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
832 $list_item .= $table_item . '</a><br />';
834 // garvin: Check whether to display nested sets
835 if (!empty($cfg['LeftFrameTableSeparator'])) {
836 $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'', $tablename));
837 if (is_array($_table)) {
838 foreach ($_table AS $key => $val) {
840 $_table[$key] = '__protected__';
843 PMA_reduceNest($_table);
845 if (count($_table) == 1) {
846 array_unshift($_table, '');
848 PMA_multimerge($tablestack, $_table);
850 $tablestack['']['pma_name'][] = $table_item;
851 $tablestack['']['pma_list_item'][] = $list_item;
854 $tablestack['']['pma_name'][] = $table_item;
855 $tablestack['']['pma_list_item'][] = $list_item;
858 } // end for $j (tables list)
860 if (!$cfg['LeftFrameLight']) {
861 PMA_nestedSet('1', $tablestack);
864 <!-- Arrange collapsible
/expandable db
list at startup
-->
865 <script type
="text/javascript" language
="javascript1.2">
868 firstEl
= 'el1Parent';
869 firstInd
= nsGetIndex(firstEl
);
873 var expandedDb
= '<?php echo (empty($selected_db)) ? '' : 'el
' . $selected_db . 'Child
'; ?>';
882 } // end if ($num_dbs == 1)
885 // Case where no database has to be displayed
888 echo '<p>' . $strNoDatabases . '</p>';
889 } // end if ($num_dbs == 0)
892 // 2004-08-05 added by Michael Keck
893 // reload queryframe if it exists and we delete a database
894 // or select a database from the db_list.
896 if (isset($lightm_db) && $lightm_db!='') {
897 $my_lightm_db = $lightm_db;
900 if ($cfg['LeftFrameLight'] && $cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
901 if (!isset($table_array) ||
count($table_array)==0) {
902 $my_url_query = PMA_generate_common_url('', '', '&');
904 <script language
="JavaScript" type
="text/javascript">
906 function check_queryframe_reload() {
907 if (typeof(window
.parent
.frames
['queryframe'])!='undefined' && typeof(window
.parent
.frames
['queryframe'].document
.forms
['left'])!='undefined') {
908 if (window
.parent
.frames
['queryframe'].document
.forms
['left'].elements
['lightm_db'].value
!='<?php echo $my_lightm_db; ?>') {
909 window
.parent
.frames
['queryframe'].location
.replace('<?php echo 'queryframe
.php?
' . $my_url_query . '&hash
=' . $hash; ?>');
913 // This is a workaround for the problem in Safari 1.2.3 where the
914 // top left frame does not load.
915 // If we call this right away it usually prevents the top-left frame from
916 // loading in Safari, so call it delayed. -Ryan Schmidt 2004-08-15
917 setTimeout('check_queryframe_reload()', 1000);
931 * Close MySql connections
933 if (isset($dbh) && $dbh) {
934 @PMA_DBI_close
($dbh);
936 if (isset($userlink) && $userlink) {
937 @PMA_DBI_close
($userlink);
942 * Sends bufferized data
944 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
945 && isset($ob_mode) && $ob_mode) {
946 PMA_outBufferPost($ob_mode);