update
[phpmyadmin/crack.git] / left.php3
blob6b288531edcc7094df26d991eec636989d336455
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 include('./libraries/bookmark.lib.php3');
35 require('./libraries/relation.lib.php3');
36 $cfgRelation = PMA_getRelationsParam();
38 function PMA_reduceNest($_table) {
40 if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
41 $max = $GLOBALS['cfg']['LeftFrameTableLevel'];
42 $temp_table = $_table;
43 $new_table = array();
44 $last_index = 0;
45 for ($ti = 0; $ti < $max; $ti++) {
46 if (isset($temp_table[$ti])) {
47 $new_table[$ti] = $temp_table[$ti];
48 unset($temp_table[$ti]);
49 $last_index = $ti;
53 $_table = $new_table;
56 return $_table;
59 function PMA_indent($spaces) {
60 $string = '';
61 for ($i = 0; $i <= $spaces; $i++) {
62 $string .= ' ';
65 return $string;
68 function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
69 $name = $key;
70 $id = eregi_replace('[^a-z0-9]*', '', $baseid . $keyhistory . $key) . $indent;
72 $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'] . '\')}"');
74 $countarray = $val;
75 if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
76 $counter = count($countarray['pma_name']);
77 } else {
78 unset($countarray['pma_name']);
79 if (count($countarray) > 1) {
80 unset($countarray['pma_list_item']);
82 $counter = count($countarray);
85 echo "\n";
86 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
87 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}">';
88 echo '<img name="imEx" id="el' . $id . 'Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
89 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";
90 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeaderParent">' . "\n";
91 echo "\n";
93 if ($childout) {
94 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Child" class="child" ' . $on_mouse . '>' . "\n";
98 function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
99 if ($firstGroup) {
100 PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
101 $indent++;
104 while(list($key, $val) = each($tablestack)) {
105 if ($key != 'pma_name' && $key != 'pma_list_item') {
106 if ($headerOut) {
107 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
110 if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
111 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, false, ($indent + 1));
112 } else {
113 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, true, ($indent + 1));
116 if ($headerOut) {
117 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeader">' . "\n";
122 if ($firstGroup && $firstGroupClose) {
123 echo PMA_indent($indent * 4) . '</div><id class="PMA_nestedSetHeader2">' . "\n";
124 } elseif ($firstGroup) {
125 echo PMA_indent($indent * 4) . '<id spacer="div omitted" class="PMA_nestedSetHeader2">' . "\n";
129 function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
131 if ($keyhistory == '' && $key != '__protected__') {
132 $keyhistory = $key;
135 $indent_level = 9;
137 if (isset($tablestack)
138 && isset($tablestack['pma_name'])
139 && isset($tablestack['pma_list_item'])) {
141 if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
142 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
143 $divClose = true;
144 $extra_indent = 1;
145 } else {
146 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
147 $divClose = false;
148 $extra_indent = 0;
151 $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'] . '\')}"');
153 $loops = 0;
154 while(list($tkey, $tval) = each($tablestack['pma_name'])) {
156 echo PMA_indent($indent * 5) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />';
157 $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
158 while(list($ikey, $ival) = each($items)) {
159 echo "\n";
160 echo PMA_indent(($indent * 5)) . $ival;
162 echo "\n";
164 $loops++;
167 if ($divClose) {
168 echo PMA_indent($indent * 5) . '</div><id space="putting omitted div" class="PMA_nestedSet2">';
171 } elseif (is_array($tablestack)) {
172 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut, (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
175 return true;
178 * Get the list and number of available databases.
179 * Skipped if no server selected: in this case no database should be displayed
180 * before the user choose among available ones at the welcome screen.
182 if ($server > 0) {
183 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
184 } else {
185 $num_dbs = 0;
189 // garvin: For re-usability, moved http-headers
190 // to a seperate file. It can now be included by header.inc.php3,
191 // queryframe.php3, querywindow.php3.
193 include('./libraries/header_http.inc.php3');
196 * Displays the frame
198 // Gets the font sizes to use
199 PMA_setFontSizes();
201 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
202 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
203 <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; ?>">
205 <head>
206 <title>phpMyAdmin</title>
207 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
208 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain<?php echo $hash; ?>" />
210 <script type="text/javascript" language="javascript">
211 <!--
212 <?php
213 if (isset($lightm_db) && !empty($lightm_db)) {
215 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./<?php echo $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&');?>');
216 <?php
217 } elseif (isset($lightm_db)) {
219 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./main.php3?<?php echo PMA_generate_common_url('', '', '&');?>');
220 <?php
223 //-->
224 </script>
226 <?php
227 // Expandable/collapsible databases list is only used if there is more than one
228 // database to display
229 if (($num_dbs > 1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
230 echo "\n";
232 <!-- Collapsible tables list scripts -->
233 <script type="text/javascript" language="javascript">
234 <!--
235 var isDOM = (typeof(document.getElementsByTagName) != 'undefined'
236 && typeof(document.createElement) != 'undefined')
237 ? 1 : 0;
238 var isIE4 = (typeof(document.all) != 'undefined'
239 && parseInt(navigator.appVersion) >= 4)
240 ? 1 : 0;
241 var isNS4 = (typeof(document.layers) != 'undefined')
242 ? 1 : 0;
243 var capable = (isDOM || isIE4 || isNS4)
244 ? 1 : 0;
245 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
246 if (capable) {
247 if (typeof(window.opera) != 'undefined') {
248 capable = 0;
250 else if (typeof(navigator.userAgent) != 'undefined') {
251 var browserName = ' ' + navigator.userAgent.toLowerCase();
252 if (browserName.indexOf('konqueror') > 0) {
253 capable = 0;
255 } // end if... else if...
256 } // end if
258 var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
260 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 + '" />');
261 //-->
262 </script>
263 <noscript>
264 <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" />
265 </noscript>
267 <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
268 <?php
269 } // end if ($num_dbs > 1)
271 else if ($num_dbs == 1) {
272 echo "\n";
274 <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" />
275 <?php
276 } // end if ($num_dbs == 1)
278 else {
279 echo "\n";
281 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?js_frame=left&amp;num_dbs=0" />
282 <?php
283 } // end if ($num_dbs < 1)
285 echo "\n";
287 </head>
289 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
291 <?php
292 if ($cfg['LeftDisplayLogo']) {
294 <!-- phpMyAdmin logo -->
295 <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
296 <?php
298 echo "\n";
299 if ($cfg['LeftDisplayServers']) {
301 <form method="post" action="index.php3" target="_parent">
302 <select name="server" onchange="this.form.submit();">
303 <?php
304 echo "\n";
305 reset($cfg['Servers']);
306 while (list($key, $val) = each($cfg['Servers'])) {
307 if (!empty($val['host'])) {
308 echo ' <option value="' . $key . '"';
309 if (!empty($server) && ($server == $key)) {
310 echo ' selected="selected"';
312 echo '>';
313 if (!empty($val['verbose'])) {
314 echo $val['verbose'];
315 } else {
316 echo $val['host'];
317 if (!empty($val['port'])) {
318 echo ':' . $val['port'];
320 // loic1: skip this because it's not a so good idea to display
321 // sockets used to everybody
322 // if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) {
323 // echo ':' . $val['socket'];
324 // }
326 // loic1: if 'only_db' is an array and there is more than one
327 // value, displaying such informations may not be a so good
328 // idea
329 if (!empty($val['only_db'])) {
330 echo ' - ' . (is_array($val['only_db']) ? implode(', ', $val['only_db']) : $val['only_db']);
332 if (!empty($val['user']) && ($val['auth_type'] == 'config')) {
333 echo ' (' . $val['user'] . ')';
335 echo '&nbsp;</option>' . "\n";
336 } // end if (!empty($val['host']))
337 } // end while
339 </select>
340 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
341 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
342 <noscript><input type="submit" value="<?php echo $strGo; ?>" /></noscript>
343 </form>
344 <?php
346 echo "\n";
348 <!-- Link to the welcome page -->
349 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
350 <nobr><a class="item" href="main.php3?<?php echo PMA_generate_common_url(); ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
351 </div>
354 <!-- Databases and tables list -->
355 <?php
356 // Don't display expansible/collapsible database info if:
357 // 1. $server == 0 (no server selected)
358 // This is the case when there are multiple servers and
359 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
360 // screen to appear with no database info displayed.
361 // 2. there is only one database available (ie either only one database exists
362 // or $cfg['Servers']['only_db'] is defined and is not an array)
363 // In this case, the database should not be collapsible/expandable
364 if ($num_dbs > 1) {
366 // Light mode -> beginning of the select combo for databases
367 // Note: When javascript is active, the frameset will be changed from
368 // within left.php3. With no JS (<noscript>) the whole frameset will
369 // be rebuilt with the new target frame.
370 if ($cfg['LeftFrameLight']) {
372 <script type="text/javascript" language="javascript">
373 document.writeln('<form method="post" action="left.php3" name="left" target="nav">');
374 </script>
375 <noscript>
376 <form method="post" action="index.php3" name="left" target="_parent">
377 </noscript>
378 <?php
379 echo PMA_generate_common_hidden_inputs();
380 echo ' <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
381 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
382 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
383 $table_list = '';
384 $table_list_header = '';
385 $db_name = '';
388 $selected_db = 0;
390 // Gets the tables list per database
391 for ($i = 0; $i < $num_dbs; $i++) {
392 $db = $dblist[$i];
393 $j = $i + 2;
394 if (!empty($db_start) && $db == $db_start) {
395 $selected_db = $j;
397 $tables = @PMA_mysql_list_tables($db);
398 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
399 $common_url_query = PMA_generate_common_url($db);
400 if ($num_tables) {
401 $num_tables_disp = $num_tables;
402 } else {
403 $num_tables_disp = '-';
406 // Get additional information about tables for tooltip
407 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
408 && $num_tables
409 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
410 $tooltip = array();
411 $tooltip_name = array();
412 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
413 while ($tmp = PMA_mysql_fetch_array($result)) {
414 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
415 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
417 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
418 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
419 } // end while
420 } // end if
422 // garvin: Get comments from PMA comments table
423 $db_tooltip = '';
424 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
425 $tmp_db_tooltip = PMA_getComments($db);
426 if (is_array($tmp_db_tooltip)) {
427 $db_tooltip = implode(' ', $tmp_db_tooltip);
431 // No light mode -> displays the expandible/collapsible db list
432 if ($cfg['LeftFrameLight'] == FALSE) {
434 // Displays the database name
435 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
437 echo "\n";
438 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
440 if (!empty($num_tables)) {
441 echo "\n";
443 <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}">
444 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
445 <?php
446 } else {
447 echo "\n";
449 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
450 <?php
452 echo "\n";
454 <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)}">
455 <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>
456 </div>
458 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
459 <?php
460 // Displays the list of tables from the current database
461 $tablestack = array();
462 for ($t = 0; $t < $num_tables; $t++) {
463 $table = PMA_mysql_tablename($tables, $t);
464 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
465 ? htmlspecialchars($tooltip_name[$table])
466 : '';
467 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
468 ? htmlspecialchars($tooltip[$table])
469 : '';
471 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
473 $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 . '">';
474 $list_item .= '<img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
475 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
476 $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) . '">';
477 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
479 // garvin: Check whether to display nested sets
480 if (!empty($cfg['LeftFrameTableSeparator'])) {
481 $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table));
482 if (is_array($_table)) {
483 reset($_table);
484 while(list($key, $val) = each($_table)) {
485 if ($val == '') {
486 $_table[$key] = '__protected__';
490 unset($_table[count($_table)-1]);
491 $_table = PMA_reduceNest($_table);
493 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . str_replace('\'', '\\\'', $table) . '\';';
494 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . str_replace('\'', '\\\'', $list_item) . '\';';
495 eval($eval_string);
496 } else {
497 $tablestack['__protected__']['pma_name'][] = $table;
498 $tablestack['__protected__']['pma_list_item'][] = $list_item;
500 } else {
501 $tablestack['__protected__']['pma_name'][] = $table;
502 $tablestack['__protected__']['pma_list_item'][] = $list_item;
504 } // end for $t (tables list)
506 PMA_nestedSet($j, $tablestack);
508 </div>
509 <?php
510 echo "\n";
514 // Light mode -> displays the select combo with databases names and the
515 // list of tables contained in the current database
516 else {
517 echo "\n";
519 // Builds the databases' names list
520 if (!empty($db_start) && $db == $db_start) {
521 // Gets the list of tables from the current database
522 for ($t = 0; $t < $num_tables; $t++) {
523 $table = PMA_mysql_tablename($tables, $t);
524 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
525 ? htmlentities($tooltip[$table])
526 : '';
527 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
528 ? htmlentities($tooltip_name[$table])
529 : '';
531 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
533 $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";
534 $table_list .= ' <img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
535 if (PMA_USR_BROWSER_AGENT == 'IE') {
536 $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";
537 } else {
538 $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";
540 } // end for $t (tables list)
542 if (!$table_list) {
543 $table_list = ' <br /><br />' . "\n"
544 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
546 $selected = ' selected="selected"';
548 $table_list_header .= ' <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
549 $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";
550 } else {
551 $selected = '';
552 } // end if... else...
554 if (!empty($num_tables)) {
555 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
556 } else {
557 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
558 } // end if... else...
560 } // end if (light mode)
562 } // end for $i (db list)
564 // Light mode -> end of the select combo for databases and table list for
565 // the current database
566 if ($cfg['LeftFrameLight']) {
567 echo ' </select>' . "\n";
568 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
569 echo ' </form>' . "\n";
571 if (!$table_list) {
572 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
575 // Displays the current database name and the list of tables it
576 // contains
577 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
578 echo $table_list_header;
579 echo $table_list;
580 echo "\n" . ' <hr noshade="noshade" />' . "\n";
583 // No light mode -> initialize some js variables for the
584 // expandible/collapsible stuff
585 else {
588 <!-- Arrange collapsible/expandable db list at startup -->
589 <script type="text/javascript" language="javascript1.2">
590 <!--
591 if (isNS4) {
592 firstEl = 'el1Parent';
593 firstInd = nsGetIndex(firstEl);
594 nsShowAll();
595 nsArrangeList();
597 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
598 //-->
599 </script>
600 <?php
602 } // end if... else... (light mode)
604 } // end if ($server > 1)
607 // Case where only one database has to be displayed
608 else if ($num_dbs == 1) {
609 $db = $dblist[0];
610 $tables = @PMA_mysql_list_tables($db);
611 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
612 $common_url_query = PMA_generate_common_url($db);
613 if ($num_tables) {
614 $num_tables_disp = $num_tables;
615 } else {
616 $num_tables_disp = '-';
619 // Get additional infomation about tables for tooltip
620 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
621 && $num_tables) {
622 $tooltip = array();
623 $tooltip_name = array();
624 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
625 while ($tmp = PMA_mysql_fetch_array($result)) {
626 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
627 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
629 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
630 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
631 } // end while
632 } // end if
634 // garvin: Get comments from PMA comments table
635 $db_tooltip = '';
636 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
637 $tmp_db_tooltip = PMA_getComments($db);
638 if (is_array($tmp_db_tooltip)) {
639 $db_tooltip = implode(' ', $tmp_db_tooltip);
644 // Displays the database name
645 if (!$cfg['LeftFrameLight']) {
646 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
648 echo "\n";
649 echo ' <div id="el2Parent" class="parent"' . $on_mouse . '>';
651 if (!empty($num_tables)) {
652 echo "\n";
654 <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}">
655 <img name="imEx" id="el2Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
656 <?php
657 } else {
658 echo "\n";
660 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
661 <?php
663 echo "\n";
665 <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)}">
666 <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>
667 </div>
669 <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
670 <?php
671 } else {
672 echo "\n";
674 <div id="el2Parent" class="parent">
675 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
676 <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>
677 </div>
678 <div id="el2Child" class="child" style="margin-bottom: 5px">
679 <?php
682 // Displays the list of tables from the current database
683 $tablestack = array();
684 for ($j = 0; $j < $num_tables; $j++) {
685 $table = PMA_mysql_tablename($tables, $j);
686 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
687 ? htmlentities($tooltip_name[$table])
688 : '';
689 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
690 ? htmlentities($tooltip[$table])
691 : '';
692 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
694 if ($cfg['LeftFrameLight']) {
695 echo "\n";
697 <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; ?>">
698 <img src="images/browse.png" width="8" height="8" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>">&nbsp;</bdo>
699 <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); ?>">
700 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
701 <?php
702 } else {
703 $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 . '">';
704 $list_item .= '<img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
705 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
706 $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) . '">';
707 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />';
709 // garvin: Check whether to display nested sets
710 if (!empty($cfg['LeftFrameTableSeparator'])) {
711 $_table = explode($cfg['LeftFrameTableSeparator'], $table);
712 if (is_array($_table)) {
713 reset($_table);
714 while(list($key, $val) = each($_table)) {
715 if ($val == '') {
716 $_table[$key] = '__protected__';
719 unset($_table[count($_table)-1]);
720 $_table = PMA_reduceNest($_table);
722 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . $table . '\';';
723 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . $list_item . '\';';
724 eval($eval_string);
725 } else {
726 $tablestack['__protected__']['pma_name'][] = $table;
727 $tablestack['__protected__']['pma_list_item'][] = $list_item;
729 } else {
730 $tablestack['__protected__']['pma_name'][] = $table;
731 $tablestack['__protected__']['pma_list_item'][] = $list_item;
734 } // end for $j (tables list)
736 if (!$cfg['LeftFrameLight']) {
737 PMA_nestedSet('1', $tablestack);
739 </div>
740 <!-- Arrange collapsible/expandable db list at startup -->
741 <script type="text/javascript" language="javascript1.2">
742 <!--
743 if (isNS4) {
744 firstEl = 'el1Parent';
745 firstInd = nsGetIndex(firstEl);
746 nsShowAll();
747 nsArrangeList();
749 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
750 //-->
751 </script>
752 <?php
753 } else {
754 echo ' </div>';
757 echo "\n";
758 } // end if ($num_dbs == 1)
761 // Case where no database has to be displayed
762 else {
763 echo "\n";
764 echo '<p>' . $strNoDatabases . '</p>';
765 } // end if ($num_dbs == 0)
766 echo "\n";
769 </body>
770 </html>
772 <?php
774 * Close MySql connections
776 if (isset($dbh) && $dbh) {
777 @mysql_close($dbh);
779 if (isset($userlink) && $userlink) {
780 @mysql_close($userlink);
785 * Sends bufferized data
787 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
788 && isset($ob_mode) && $ob_mode) {
789 PMA_outBufferPost($ob_mode);