update
[phpmyadmin/crack.git] / left.php3
blobfa9514524451a667f2e76809c469b37f39530930
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
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
9 */
10 require('./libraries/grab_globals.lib.php3');
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);
14 $db = $lightm_db;
17 if (!empty($db)) {
18 $db_start = $db;
22 /**
23 * Gets a core script and starts output buffering work
25 require('./libraries/common.lib.php3');
26 require('./libraries/ob.lib.php3');
27 if ($cfg['OBGzip']) {
28 $ob_mode = PMA_outBufferModeGet();
29 if ($ob_mode) {
30 PMA_outBufferPre($ob_mode);
34 PMA_checkParameters(array('hash'));
36 include('./libraries/bookmark.lib.php3');
37 require('./libraries/relation.lib.php3');
38 $cfgRelation = PMA_getRelationsParam();
40 function PMA_reduceNest($_table) {
42 if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
43 $max = $GLOBALS['cfg']['LeftFrameTableLevel'];
44 $temp_table = $_table;
45 $new_table = array();
46 $last_index = 0;
47 for ($ti = 0; $ti < $max; $ti++) {
48 if (isset($temp_table[$ti])) {
49 $new_table[$ti] = $temp_table[$ti];
50 unset($temp_table[$ti]);
51 $last_index = $ti;
55 $_table = $new_table;
58 return $_table;
61 function PMA_indent($spaces) {
62 $string = '';
63 for ($i = 0; $i <= $spaces; $i++) {
64 $string .= ' ';
67 return $string;
70 function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
71 $name = $key;
72 $id = eregi_replace('[^a-z0-9]*', '', $baseid . $keyhistory . $key) . $indent;
74 $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
76 $countarray = $val;
77 if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
78 $counter = count($countarray['pma_name']);
79 } else {
80 unset($countarray['pma_name']);
81 if (count($countarray) > 1) {
82 unset($countarray['pma_list_item']);
84 $counter = count($countarray);
87 echo "\n";
88 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
89 echo PMA_indent($indent * 6) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent - 1) * $indent_level) . '" height="9" alt="" /><a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '" onclick="if (capable) {expandBase(\'el' . $id . '\', true); return false} else {return true}">';
90 echo '<img name="imEx" id="el' . $id . 'Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
91 echo PMA_indent($indent * 6) . '<a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '" title="' . htmlspecialchars($name) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', false)}"><span class="heada">' . htmlspecialchars($name) . '<bdo dir="' . $GLOBALS['text_dir'] . '">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(' . $counter . ')</span></a></nobr>' . "\n";
92 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeaderParent">' . "\n";
93 echo "\n";
95 if ($childout) {
96 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Child" class="child" ' . $on_mouse . '>' . "\n";
100 function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
101 if ($firstGroup) {
102 PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
103 $indent++;
106 while(list($key, $val) = each($tablestack)) {
107 if ($key != 'pma_name' && $key != 'pma_list_item') {
108 if ($headerOut) {
109 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
112 if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
113 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, false, ($indent + 1));
114 } else {
115 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, true, ($indent + 1));
118 if ($headerOut) {
119 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeader">' . "\n";
124 if ($firstGroup && $firstGroupClose) {
125 echo PMA_indent($indent * 4) . '</div><id class="PMA_nestedSetHeader2">' . "\n";
126 } elseif ($firstGroup) {
127 echo PMA_indent($indent * 4) . '<id spacer="div omitted" class="PMA_nestedSetHeader2">' . "\n";
131 function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
133 if ($keyhistory == '' && $key != '__protected__') {
134 $keyhistory = $key;
137 $indent_level = 9;
139 if (isset($tablestack)
140 && isset($tablestack['pma_name'])
141 && isset($tablestack['pma_list_item'])) {
143 if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
144 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
145 $divClose = true;
146 $extra_indent = 1;
147 } else {
148 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
149 $divClose = false;
150 $extra_indent = 0;
153 $on_mouse = (($GLOBALS['cfg']['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
155 $loops = 0;
156 while(list($tkey, $tval) = each($tablestack['pma_name'])) {
158 echo PMA_indent($indent * 5) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />';
159 $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
160 while(list($ikey, $ival) = each($items)) {
161 echo "\n";
162 echo PMA_indent(($indent * 5)) . $ival;
164 echo "\n";
166 $loops++;
169 if ($divClose) {
170 echo PMA_indent($indent * 5) . '</div><id space="putting omitted div" class="PMA_nestedSet2">';
173 } elseif (is_array($tablestack)) {
174 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut, (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
177 return true;
180 * Get the list and number of available databases.
181 * Skipped if no server selected: in this case no database should be displayed
182 * before the user choose among available ones at the welcome screen.
184 if ($server > 0) {
185 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
186 } else {
187 $num_dbs = 0;
191 // garvin: For re-usability, moved http-headers
192 // to a seperate file. It can now be included by header.inc.php3,
193 // queryframe.php3, querywindow.php3.
195 include('./libraries/header_http.inc.php3');
198 * Displays the frame
200 // Gets the font sizes to use
201 PMA_setFontSizes();
203 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
204 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
205 <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; ?>">
207 <head>
208 <title>phpMyAdmin</title>
209 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
210 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain<?php echo $hash; ?>" />
212 <script type="text/javascript" language="javascript">
213 <!--
214 <?php
215 if (isset($lightm_db) && !empty($lightm_db)) {
217 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./<?php echo $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&');?>');
218 <?php
219 } elseif (isset($lightm_db)) {
221 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./main.php3?<?php echo PMA_generate_common_url('', '', '&');?>');
222 <?php
225 //-->
226 </script>
228 <?php
229 // Expandable/collapsible databases list is only used if there is more than one
230 // database to display
231 if (($num_dbs > 1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
232 echo "\n";
234 <!-- Collapsible tables list scripts -->
235 <script type="text/javascript" language="javascript">
236 <!--
237 var isDOM = (typeof(document.getElementsByTagName) != 'undefined'
238 && typeof(document.createElement) != 'undefined')
239 ? 1 : 0;
240 var isIE4 = (typeof(document.all) != 'undefined'
241 && parseInt(navigator.appVersion) >= 4)
242 ? 1 : 0;
243 var isNS4 = (typeof(document.layers) != 'undefined')
244 ? 1 : 0;
245 var capable = (isDOM || isIE4 || isNS4)
246 ? 1 : 0;
247 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
248 if (capable) {
249 if (typeof(window.opera) != 'undefined') {
250 capable = 0;
252 else if (typeof(navigator.userAgent) != 'undefined') {
253 var browserName = ' ' + navigator.userAgent.toLowerCase();
254 if (browserName.indexOf('konqueror') > 0) {
255 capable = 0;
257 } // end if... else if...
258 } // end if
260 var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
262 document.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?lang=<?php echo $lang; ?>&amp;js_frame=left&amp;js_capable=' + capable + '&amp;js_isDOM=' + isDOM + '&amp;js_isIE4=' + isIE4 + '" />');
263 //-->
264 </script>
265 <noscript>
266 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?lang=<?php echo $lang; ?>&amp;js_frame=left&amp;js_capable=0&amp;js_isDOM=0&amp;js_isIE4=0" />
267 </noscript>
269 <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
270 <?php
271 } // end if ($num_dbs > 1)
273 else if ($num_dbs == 1) {
274 echo "\n";
276 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?js_frame=left&amp;js_capable=0&amp;js_isDOM=0&amp;js_isIE4=0" />
277 <?php
278 } // end if ($num_dbs == 1)
280 else {
281 echo "\n";
283 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?js_frame=left&amp;num_dbs=0" />
284 <?php
285 } // end if ($num_dbs < 1)
287 echo "\n";
289 </head>
291 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
293 <?php
294 if ($cfg['LeftDisplayLogo']) {
296 <!-- phpMyAdmin logo -->
297 <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
298 <?php
300 echo "\n";
301 if ($cfg['LeftDisplayServers']) {
303 <form method="post" action="index.php3" target="_parent">
304 <select name="server" onchange="this.form.submit();">
305 <?php
306 echo "\n";
307 reset($cfg['Servers']);
308 while (list($key, $val) = each($cfg['Servers'])) {
309 if (!empty($val['host'])) {
310 echo ' <option value="' . $key . '"';
311 if (!empty($server) && ($server == $key)) {
312 echo ' selected="selected"';
314 echo '>';
315 if (!empty($val['verbose'])) {
316 echo $val['verbose'];
317 } else {
318 echo $val['host'];
319 if (!empty($val['port'])) {
320 echo ':' . $val['port'];
322 // loic1: skip this because it's not a so good idea to display
323 // sockets used to everybody
324 // if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) {
325 // echo ':' . $val['socket'];
326 // }
328 // loic1: if 'only_db' is an array and there is more than one
329 // value, displaying such informations may not be a so good
330 // idea
331 if (!empty($val['only_db'])) {
332 echo ' - ' . (is_array($val['only_db']) ? implode(', ', $val['only_db']) : $val['only_db']);
334 if (!empty($val['user']) && ($val['auth_type'] == 'config')) {
335 echo ' (' . $val['user'] . ')';
337 echo '&nbsp;</option>' . "\n";
338 } // end if (!empty($val['host']))
339 } // end while
341 </select>
342 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
343 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
344 <noscript><input type="submit" value="<?php echo $strGo; ?>" /></noscript>
345 </form>
346 <?php
348 echo "\n";
350 <!-- Link to the welcome page -->
351 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
352 <nobr><a class="item" href="main.php3?<?php echo PMA_generate_common_url(); ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
353 </div>
356 <!-- Databases and tables list -->
357 <?php
358 // Don't display expansible/collapsible database info if:
359 // 1. $server == 0 (no server selected)
360 // This is the case when there are multiple servers and
361 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
362 // screen to appear with no database info displayed.
363 // 2. there is only one database available (ie either only one database exists
364 // or $cfg['Servers']['only_db'] is defined and is not an array)
365 // In this case, the database should not be collapsible/expandable
366 if ($num_dbs > 1) {
368 // Light mode -> beginning of the select combo for databases
369 // Note: When javascript is active, the frameset will be changed from
370 // within left.php3. With no JS (<noscript>) the whole frameset will
371 // be rebuilt with the new target frame.
372 if ($cfg['LeftFrameLight']) {
374 <script type="text/javascript" language="javascript">
375 document.writeln('<form method="post" action="left.php3" name="left" target="nav">');
376 </script>
377 <noscript>
378 <form method="post" action="index.php3" name="left" target="_parent">
379 </noscript>
380 <?php
381 echo PMA_generate_common_hidden_inputs();
382 echo ' <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
383 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
384 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
385 $table_list = '';
386 $table_list_header = '';
387 $db_name = '';
390 $selected_db = 0;
392 // Gets the tables list per database
393 for ($i = 0; $i < $num_dbs; $i++) {
394 $db = $dblist[$i];
395 $j = $i + 2;
396 if (!empty($db_start) && $db == $db_start) {
397 $selected_db = $j;
399 $tables = @PMA_mysql_list_tables($db);
400 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
401 $common_url_query = PMA_generate_common_url($db);
402 if ($num_tables) {
403 $num_tables_disp = $num_tables;
404 } else {
405 $num_tables_disp = '-';
408 // Get additional information about tables for tooltip
409 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
410 && $num_tables
411 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
412 $tooltip = array();
413 $tooltip_name = array();
414 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
415 while ($tmp = PMA_mysql_fetch_array($result)) {
416 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
417 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
419 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
420 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
421 } // end while
422 } // end if
424 // garvin: Get comments from PMA comments table
425 $db_tooltip = '';
426 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
427 $tmp_db_tooltip = PMA_getComments($db);
428 if (is_array($tmp_db_tooltip)) {
429 $db_tooltip = implode(' ', $tmp_db_tooltip);
433 // No light mode -> displays the expandible/collapsible db list
434 if ($cfg['LeftFrameLight'] == FALSE) {
436 // Displays the database name
437 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
439 echo "\n";
440 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
442 if (!empty($num_tables)) {
443 echo "\n";
445 <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}">
446 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
447 <?php
448 } else {
449 echo "\n";
451 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
452 <?php
454 echo "\n";
456 <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)}">
457 <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
458 </div>
460 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
461 <?php
462 // Displays the list of tables from the current database
463 $tablestack = array();
464 for ($t = 0; $t < $num_tables; $t++) {
465 $table = PMA_mysql_tablename($tables, $t);
466 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
467 ? htmlspecialchars($tooltip_name[$table])
468 : '';
469 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
470 ? htmlspecialchars($tooltip[$table])
471 : '';
473 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
475 $list_item = '<a target="phpmain' . $hash . '" href="sql.php3?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
476 $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
477 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
478 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">';
479 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
481 // garvin: Check whether to display nested sets
482 if (!empty($cfg['LeftFrameTableSeparator'])) {
483 $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table));
484 if (is_array($_table)) {
485 reset($_table);
486 while(list($key, $val) = each($_table)) {
487 if ($val == '') {
488 $_table[$key] = '__protected__';
492 unset($_table[count($_table)-1]);
493 $_table = PMA_reduceNest($_table);
495 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . str_replace('\'', '\\\'', $table) . '\';';
496 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . str_replace('\'', '\\\'', $list_item) . '\';';
497 eval($eval_string);
498 } else {
499 $tablestack['__protected__']['pma_name'][] = $table;
500 $tablestack['__protected__']['pma_list_item'][] = $list_item;
502 } else {
503 $tablestack['__protected__']['pma_name'][] = $table;
504 $tablestack['__protected__']['pma_list_item'][] = $list_item;
506 } // end for $t (tables list)
508 PMA_nestedSet($j, $tablestack);
510 </div>
511 <?php
512 echo "\n";
516 // Light mode -> displays the select combo with databases names and the
517 // list of tables contained in the current database
518 else {
519 echo "\n";
521 // Builds the databases' names list
522 if (!empty($db_start) && $db == $db_start) {
523 // Gets the list of tables from the current database
524 for ($t = 0; $t < $num_tables; $t++) {
525 $table = PMA_mysql_tablename($tables, $t);
526 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
527 ? htmlentities($tooltip[$table])
528 : '';
529 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
530 ? htmlentities($tooltip_name[$table])
531 : '';
533 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
535 $table_list .= ' <nobr><a target="phpmain' . $hash . '" href="sql.php3?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
536 $table_list .= ' <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
537 if (PMA_USR_BROWSER_AGENT == 'IE') {
538 $table_list .= ' <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></nobr><br />' . "\n";
539 } else {
540 $table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
542 } // end for $t (tables list)
544 if (!$table_list) {
545 $table_list = ' <br /><br />' . "\n"
546 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
548 $selected = ' selected="selected"';
550 $table_list_header .= ' <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
551 $table_list_header .= ' <span class="heada"><b>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . '</b><bdo dir="' . $text_dir . '">&nbsp;&nbsp;</bdo></span></a><br />' . "\n\n";
552 } else {
553 $selected = '';
554 } // end if... else...
556 if (!empty($num_tables)) {
557 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
558 } else {
559 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
560 } // end if... else...
562 } // end if (light mode)
564 } // end for $i (db list)
566 // Light mode -> end of the select combo for databases and table list for
567 // the current database
568 if ($cfg['LeftFrameLight']) {
569 echo ' </select>' . "\n";
570 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
571 echo ' </form>' . "\n";
573 if (!$table_list) {
574 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
577 // Displays the current database name and the list of tables it
578 // contains
579 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
580 echo $table_list_header;
581 echo $table_list;
582 echo "\n" . ' <hr noshade="noshade" />' . "\n";
585 // No light mode -> initialize some js variables for the
586 // expandible/collapsible stuff
587 else {
590 <!-- Arrange collapsible/expandable db list at startup -->
591 <script type="text/javascript" language="javascript1.2">
592 <!--
593 if (isNS4) {
594 firstEl = 'el1Parent';
595 firstInd = nsGetIndex(firstEl);
596 nsShowAll();
597 nsArrangeList();
599 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
600 //-->
601 </script>
602 <?php
604 } // end if... else... (light mode)
606 } // end if ($server > 1)
609 // Case where only one database has to be displayed
610 else if ($num_dbs == 1) {
611 $db = $dblist[0];
612 $tables = @PMA_mysql_list_tables($db);
613 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
614 $common_url_query = PMA_generate_common_url($db);
615 if ($num_tables) {
616 $num_tables_disp = $num_tables;
617 } else {
618 $num_tables_disp = '-';
621 // Get additional infomation about tables for tooltip
622 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
623 && $num_tables) {
624 $tooltip = array();
625 $tooltip_name = array();
626 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
627 while ($tmp = PMA_mysql_fetch_array($result)) {
628 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
629 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
631 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
632 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
633 } // end while
634 } // end if
636 // garvin: Get comments from PMA comments table
637 $db_tooltip = '';
638 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
639 $tmp_db_tooltip = PMA_getComments($db);
640 if (is_array($tmp_db_tooltip)) {
641 $db_tooltip = implode(' ', $tmp_db_tooltip);
646 // Displays the database name
647 if (!$cfg['LeftFrameLight']) {
648 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
650 echo "\n";
651 echo ' <div id="el2Parent" class="parent"' . $on_mouse . '>';
653 if (!empty($num_tables)) {
654 echo "\n";
656 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el2', true); return false} else {return true}">
657 <img name="imEx" id="el2Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
658 <?php
659 } else {
660 echo "\n";
662 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
663 <?php
665 echo "\n";
667 <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)}">
668 <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
669 </div>
671 <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
672 <?php
673 } else {
674 echo "\n";
676 <div id="el2Parent" class="parent">
677 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
678 <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">&nbsp;&nbsp;</bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
679 </div>
680 <div id="el2Child" class="child" style="margin-bottom: 5px">
681 <?php
684 // Displays the list of tables from the current database
685 $tablestack = array();
686 for ($j = 0; $j < $num_tables; $j++) {
687 $table = PMA_mysql_tablename($tables, $j);
688 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
689 ? htmlentities($tooltip_name[$table])
690 : '';
691 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
692 ? htmlentities($tooltip[$table])
693 : '';
694 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
696 if ($cfg['LeftFrameLight']) {
697 echo "\n";
699 <nobr><a target="phpmain<?php echo $hash; ?>" href="sql.php3?<?php echo $common_url_query; ?>&amp;table=<?php echo urlencode($table); ?>&amp;sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&amp;pos=0&amp;goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . $url_title; ?>">
700 <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</bdo>
701 <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; ?>&amp;table=<?php echo urlencode($table); ?>">
702 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
703 <?php
704 } else {
705 $list_item = '<a target="phpmain' . $hash . '" href="sql.php3?' . $common_url_query . '&amp;table=' . urlencode($table) . '&amp;sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&amp;pos=0&amp;goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
706 $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
707 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
708 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">';
709 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />';
711 // garvin: Check whether to display nested sets
712 if (!empty($cfg['LeftFrameTableSeparator'])) {
713 $_table = explode($cfg['LeftFrameTableSeparator'], $table);
714 if (is_array($_table)) {
715 reset($_table);
716 while(list($key, $val) = each($_table)) {
717 if ($val == '') {
718 $_table[$key] = '__protected__';
721 unset($_table[count($_table)-1]);
722 $_table = PMA_reduceNest($_table);
724 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . $table . '\';';
725 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . $list_item . '\';';
726 eval($eval_string);
727 } else {
728 $tablestack['__protected__']['pma_name'][] = $table;
729 $tablestack['__protected__']['pma_list_item'][] = $list_item;
731 } else {
732 $tablestack['__protected__']['pma_name'][] = $table;
733 $tablestack['__protected__']['pma_list_item'][] = $list_item;
736 } // end for $j (tables list)
738 if (!$cfg['LeftFrameLight']) {
739 PMA_nestedSet('1', $tablestack);
741 </div>
742 <!-- Arrange collapsible/expandable db list at startup -->
743 <script type="text/javascript" language="javascript1.2">
744 <!--
745 if (isNS4) {
746 firstEl = 'el1Parent';
747 firstInd = nsGetIndex(firstEl);
748 nsShowAll();
749 nsArrangeList();
751 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
752 //-->
753 </script>
754 <?php
755 } else {
756 echo ' </div>';
759 echo "\n";
760 } // end if ($num_dbs == 1)
763 // Case where no database has to be displayed
764 else {
765 echo "\n";
766 echo '<p>' . $strNoDatabases . '</p>';
767 } // end if ($num_dbs == 0)
768 echo "\n";
771 </body>
772 </html>
774 <?php
776 * Close MySql connections
778 if (isset($dbh) && $dbh) {
779 @mysql_close($dbh);
781 if (isset($userlink) && $userlink) {
782 @mysql_close($userlink);
787 * Sends bufferized data
789 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
790 && isset($ob_mode) && $ob_mode) {
791 PMA_outBufferPost($ob_mode);