update
[phpmyadmin/crack.git] / left.php3
blob9c8fbe4555c18c51bcafcce37ad502a5619a8c7b
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 /* DEBUGGING ONLY - REMOVE WHEN PATCH ACCEPTED
69 $path = '';
70 $functioncalls = '';
72 function functioncalls($name, $args, $array) {
73 $GLOBALS['functioncalls'] .= $name . "\n------------------------\n";
74 foreach($array AS $xkey => $key) {
75 $defvals = explode(':' , $key);
76 $key=$defvals[0];
78 $val = (isset($args[$xkey]) ? $args[$xkey] : $defvals[1]);
79 if (is_array($val)) {
80 $GLOBALS['functioncalls'] .= $key . "\n";
81 foreach($val AS $skey => $sval) {
82 if (!is_array($val)) {
83 $GLOBALS['functioncalls'] .= "\t" . $skey . "\n\t\t" . stripslashes(var_export($sval)) . "\n";
84 } else {
85 $GLOBALS['functioncalls'] .= "\t" . $skey . "\n\t\t[ARRAY]\n";
88 } else {
89 $GLOBALS['functioncalls'] .= $key . "\n\t" . stripslashes(var_export($val, true)) . "\n";
93 $GLOBALS['functioncalls'] .= "\n\n";
95 return true;
99 function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
100 /* DEBUGGING ONLY - REMOVE WHEN PATCH ACCEPTED
101 $args = func_get_args();
102 functioncalls('PMA_nestedSetHeaderParent', $args, array('baseid', 'key','keyhistory','indent','indent_level','val','childout:true'));
105 $name = $key;
106 $id = eregi_replace('[^a-z0-9]*', '', $baseid . $keyhistory . $key) . $indent;
108 $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'] . '\')}"');
110 $countarray = $val;
111 if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
112 $counter = count($countarray['pma_name']);
113 } else {
114 unset($countarray['pma_name']);
115 if (count($countarray) > 1) {
116 unset($countarray['pma_list_item']);
118 $counter = count($countarray);
121 echo "\n";
122 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
123 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}">';
124 echo '<img name="imEx" id="el' . $id . 'Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
125 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";
126 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeaderParent">' . "\n";
127 echo "\n";
129 if ($childout) {
130 echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Child" class="child" ' . $on_mouse . '>' . "\n";
134 function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
135 /* DEBUGGING ONLY - REMOVE WHEN PATCH ACCEPTED
136 $args = func_get_args();
137 functioncalls('PMA_nestedSetHeader', $args, array('baseid', 'tablestack','keyhistory','indent','indent_level','headerOut','firstGroup:false'));
139 if ($firstGroup) {
140 PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
141 $indent++;
144 while(list($key, $val) = each($tablestack)) {
145 if ($key != 'pma_name' && $key != 'pma_list_item') {
146 if ($headerOut) {
147 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
150 if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
151 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, false, ($indent + 1));
152 } else {
153 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, true, ($indent + 1));
156 if ($headerOut) {
157 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeader">' . "\n";
162 if ($firstGroup && $firstGroupClose) {
163 echo PMA_indent($indent * 4) . '</div><id class="PMA_nestedSetHeader2">' . "\n";
164 } elseif ($firstGroup) {
165 echo PMA_indent($indent * 4) . '<id spacer="div omitted" class="PMA_nestedSetHeader2">' . "\n";
169 function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
170 /* DEBUGGING ONLY - REMOVE WHEN PATCH ACCEPTED
171 $args = func_get_args();
172 functioncalls('PMA_nestedSet', $args, array('baseid', 'tablestack', 'key:__protected__', 'keyhistory:\'\'', 'headerOut:false', 'indent:1'));
175 if ($keyhistory == '' && $key != '__protected__') {
176 $keyhistory = $key;
179 $indent_level = 9;
181 if (isset($tablestack)
182 && isset($tablestack['pma_name'])
183 && isset($tablestack['pma_list_item'])) {
185 if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
186 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
187 $divClose = true;
188 $extra_indent = 1;
189 } else {
190 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
191 $divClose = false;
192 $extra_indent = 0;
195 $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'] . '\')}"');
197 $loops = 0;
198 while(list($tkey, $tval) = each($tablestack['pma_name'])) {
200 echo PMA_indent($indent * 5) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />';
201 $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
202 while(list($ikey, $ival) = each($items)) {
203 echo "\n";
204 echo PMA_indent(($indent * 5)) . $ival;
206 echo "\n";
208 $loops++;
211 if ($divClose) {
212 echo PMA_indent($indent * 5) . '</div><id space="putting omitted div" class="PMA_nestedSet2">';
215 } elseif (is_array($tablestack)) {
216 PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut, (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
219 return true;
222 * Get the list and number of available databases.
223 * Skipped if no server selected: in this case no database should be displayed
224 * before the user choose among available ones at the welcome screen.
226 if ($server > 0) {
227 PMA_availableDatabases(); // this function is defined in "common.lib.php3"
228 } else {
229 $num_dbs = 0;
233 // garvin: For re-usability, moved http-headers
234 // to a seperate file. It can now be included by header.inc.php3,
235 // queryframe.php3, querywindow.php3.
237 include('./libraries/header_http.inc.php3');
240 * Displays the frame
242 // Gets the font sizes to use
243 PMA_setFontSizes();
245 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
246 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
247 <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; ?>">
249 <head>
250 <title>phpMyAdmin</title>
251 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
252 <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain<?php echo $hash; ?>" />
254 <script type="text/javascript" language="javascript">
255 <!--
256 <?php
257 if (isset($lightm_db) && !empty($lightm_db)) {
259 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./<?php echo $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&');?>');
260 <?php
261 } elseif (isset($lightm_db)) {
263 window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./main.php3?<?php echo PMA_generate_common_url('', '', '&');?>');
264 <?php
267 //-->
268 </script>
270 <?php
271 // Expandable/collapsible databases list is only used if there is more than one
272 // database to display
273 if (($num_dbs > 1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
274 echo "\n";
276 <!-- Collapsible tables list scripts -->
277 <script type="text/javascript" language="javascript">
278 <!--
279 var isDOM = (typeof(document.getElementsByTagName) != 'undefined'
280 && typeof(document.createElement) != 'undefined')
281 ? 1 : 0;
282 var isIE4 = (typeof(document.all) != 'undefined'
283 && parseInt(navigator.appVersion) >= 4)
284 ? 1 : 0;
285 var isNS4 = (typeof(document.layers) != 'undefined')
286 ? 1 : 0;
287 var capable = (isDOM || isIE4 || isNS4)
288 ? 1 : 0;
289 // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
290 if (capable) {
291 if (typeof(window.opera) != 'undefined') {
292 capable = 0;
294 else if (typeof(navigator.userAgent) != 'undefined') {
295 var browserName = ' ' + navigator.userAgent.toLowerCase();
296 if (browserName.indexOf('konqueror') > 0) {
297 capable = 0;
299 } // end if... else if...
300 } // end if
302 var isServer = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
304 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 + '" />');
305 //-->
306 </script>
307 <noscript>
308 <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" />
309 </noscript>
311 <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
312 <?php
313 } // end if ($num_dbs > 1)
315 else if ($num_dbs == 1) {
316 echo "\n";
318 <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" />
319 <?php
320 } // end if ($num_dbs == 1)
322 else {
323 echo "\n";
325 <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php3?js_frame=left&amp;num_dbs=0" />
326 <?php
327 } // end if ($num_dbs < 1)
329 echo "\n";
331 </head>
333 <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
335 <?php
336 if ($cfg['LeftDisplayLogo']) {
338 <!-- phpMyAdmin logo -->
339 <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
340 <?php
342 echo "\n";
344 <!-- Link to the welcome page -->
345 <div id="el1Parent" class="parent" style="margin-bottom: 5px">
346 <nobr><a class="item" href="main.php3?<?php echo PMA_generate_common_url(); ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
347 </div>
350 <!-- Databases and tables list -->
351 <?php
352 // Don't display expansible/collapsible database info if:
353 // 1. $server == 0 (no server selected)
354 // This is the case when there are multiple servers and
355 // '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
356 // screen to appear with no database info displayed.
357 // 2. there is only one database available (ie either only one database exists
358 // or $cfg['Servers']['only_db'] is defined and is not an array)
359 // In this case, the database should not be collapsible/expandable
360 if ($num_dbs > 1) {
362 // Light mode -> beginning of the select combo for databases
363 // Note: When javascript is active, the frameset will be changed from
364 // within left.php3. With no JS (<noscript>) the whole frameset will
365 // be rebuilt with the new target frame.
366 if ($cfg['LeftFrameLight']) {
368 <script type="text/javascript" language="javascript">
369 document.writeln('<form method="post" action="left.php3" name="left" target="nav">');
370 </script>
371 <noscript>
372 <form method="post" action="index.php3" name="left" target="_parent">
373 </noscript>
374 <?php
375 echo PMA_generate_common_hidden_inputs();
376 echo ' <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
377 echo ' <select name="lightm_db" onchange="this.form.submit()">' . "\n";
378 echo ' <option value="">(' . $strDatabases . ') ...</option>' . "\n";
379 $table_list = '';
380 $table_list_header = '';
381 $db_name = '';
384 $selected_db = 0;
386 // Gets the tables list per database
387 for ($i = 0; $i < $num_dbs; $i++) {
388 $db = $dblist[$i];
389 $j = $i + 2;
390 if (!empty($db_start) && $db == $db_start) {
391 $selected_db = $j;
393 $tables = @PMA_mysql_list_tables($db);
394 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
395 $common_url_query = PMA_generate_common_url($db);
396 if ($num_tables) {
397 $num_tables_disp = $num_tables;
398 } else {
399 $num_tables_disp = '-';
402 // Get additional information about tables for tooltip
403 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
404 && $num_tables
405 && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
406 $tooltip = array();
407 $tooltip_name = array();
408 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
409 while ($tmp = PMA_mysql_fetch_array($result)) {
410 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
411 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
413 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
414 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
415 } // end while
416 } // end if
418 // garvin: Get comments from PMA comments table
419 $db_tooltip = '';
420 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
421 $tmp_db_tooltip = PMA_getComments($db);
422 if (is_array($tmp_db_tooltip)) {
423 $db_tooltip = implode(' ', $tmp_db_tooltip);
427 // No light mode -> displays the expandible/collapsible db list
428 if ($cfg['LeftFrameLight'] == FALSE) {
430 // Displays the database name
431 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
433 echo "\n";
434 echo ' <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
436 if (!empty($num_tables)) {
437 echo "\n";
439 <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}">
440 <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
441 <?php
442 } else {
443 echo "\n";
445 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
446 <?php
448 echo "\n";
450 <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)}">
451 <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>
452 </div>
454 <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
455 <?php
456 // Displays the list of tables from the current database
457 $tablestack = array();
458 for ($t = 0; $t < $num_tables; $t++) {
459 $table = PMA_mysql_tablename($tables, $t);
460 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
461 ? htmlspecialchars($tooltip_name[$table])
462 : '';
463 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
464 ? htmlspecialchars($tooltip[$table])
465 : '';
467 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
469 $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 . '">';
470 $list_item .= '<img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
471 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
472 $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) . '">';
473 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
475 // garvin: Check whether to display nested sets
476 if (!empty($cfg['LeftFrameTableSeparator'])) {
477 $_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table));
478 if (is_array($_table)) {
479 reset($_table);
480 while(list($key, $val) = each($_table)) {
481 if ($val == '') {
482 $_table[$key] = '__protected__';
486 unset($_table[count($_table)-1]);
487 $_table = PMA_reduceNest($_table);
489 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . str_replace('\'', '\\\'', $table) . '\';';
490 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . str_replace('\'', '\\\'', $list_item) . '\';';
491 eval($eval_string);
492 } else {
493 $tablestack['__protected__']['pma_name'][] = $table;
494 $tablestack['__protected__']['pma_list_item'][] = $list_item;
496 } else {
497 $tablestack['__protected__']['pma_name'][] = $table;
498 $tablestack['__protected__']['pma_list_item'][] = $list_item;
500 } // end for $t (tables list)
502 PMA_nestedSet($j, $tablestack);
504 </div>
505 <?php
506 echo "\n";
510 // Light mode -> displays the select combo with databases names and the
511 // list of tables contained in the current database
512 else {
513 echo "\n";
515 // Builds the databases' names list
516 if (!empty($db_start) && $db == $db_start) {
517 // Gets the list of tables from the current database
518 for ($t = 0; $t < $num_tables; $t++) {
519 $table = PMA_mysql_tablename($tables, $t);
520 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
521 ? htmlentities($tooltip[$table])
522 : '';
523 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
524 ? htmlentities($tooltip_name[$table])
525 : '';
527 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
529 $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";
530 $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";
531 if (PMA_USR_BROWSER_AGENT == 'IE') {
532 $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";
533 } else {
534 $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";
536 } // end for $t (tables list)
538 if (!$table_list) {
539 $table_list = ' <br /><br />' . "\n"
540 . ' <div>' . $strNoTablesFound . '</div>' . "\n";
542 $selected = ' selected="selected"';
544 $table_list_header .= ' <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
545 $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";
546 } else {
547 $selected = '';
548 } // end if... else...
550 if (!empty($num_tables)) {
551 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
552 } else {
553 echo ' <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
554 } // end if... else...
556 } // end if (light mode)
558 } // end for $i (db list)
560 // Light mode -> end of the select combo for databases and table list for
561 // the current database
562 if ($cfg['LeftFrameLight']) {
563 echo ' </select>' . "\n";
564 echo ' <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
565 echo ' </form>' . "\n";
567 if (!$table_list) {
568 $table_list = ' <div>' . $strSelectADb . '</div>' . "\n";
571 // Displays the current database name and the list of tables it
572 // contains
573 echo "\n" . ' <hr noshade="noshade" />' . "\n\n";
574 echo $table_list_header;
575 echo $table_list;
576 echo "\n" . ' <hr noshade="noshade" />' . "\n";
579 // No light mode -> initialize some js variables for the
580 // expandible/collapsible stuff
581 else {
584 <!-- Arrange collapsible/expandable db list at startup -->
585 <script type="text/javascript" language="javascript1.2">
586 <!--
587 if (isNS4) {
588 firstEl = 'el1Parent';
589 firstInd = nsGetIndex(firstEl);
590 nsShowAll();
591 nsArrangeList();
593 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
594 //-->
595 </script>
596 <?php
598 } // end if... else... (light mode)
600 } // end if ($server > 1)
603 // Case where only one database has to be displayed
604 else if ($num_dbs == 1) {
605 $db = $dblist[0];
606 $tables = @PMA_mysql_list_tables($db);
607 $num_tables = ($tables) ? @mysql_numrows($tables) : 0;
608 $common_url_query = PMA_generate_common_url($db);
609 if ($num_tables) {
610 $num_tables_disp = $num_tables;
611 } else {
612 $num_tables_disp = '-';
615 // Get additional infomation about tables for tooltip
616 if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
617 && $num_tables) {
618 $tooltip = array();
619 $tooltip_name = array();
620 $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
621 while ($tmp = PMA_mysql_fetch_array($result)) {
622 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
623 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
625 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
626 . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
627 } // end while
628 } // end if
630 // garvin: Get comments from PMA comments table
631 $db_tooltip = '';
632 if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
633 $tmp_db_tooltip = PMA_getComments($db);
634 if (is_array($tmp_db_tooltip)) {
635 $db_tooltip = implode(' ', $tmp_db_tooltip);
640 // Displays the database name
641 if (!$cfg['LeftFrameLight']) {
642 $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
644 echo "\n";
645 echo ' <div id="el2Parent" class="parent"' . $on_mouse . '>';
647 if (!empty($num_tables)) {
648 echo "\n";
650 <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}">
651 <img name="imEx" id="el2Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
652 <?php
653 } else {
654 echo "\n";
656 <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
657 <?php
659 echo "\n";
661 <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)}">
662 <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>
663 </div>
665 <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
666 <?php
667 } else {
668 echo "\n";
670 <div id="el2Parent" class="parent">
671 <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
672 <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>
673 </div>
674 <div id="el2Child" class="child" style="margin-bottom: 5px">
675 <?php
678 // Displays the list of tables from the current database
679 $tablestack = array();
680 for ($j = 0; $j < $num_tables; $j++) {
681 $table = PMA_mysql_tablename($tables, $j);
682 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
683 ? htmlentities($tooltip_name[$table])
684 : '';
685 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
686 ? htmlentities($tooltip[$table])
687 : '';
688 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
690 if ($cfg['LeftFrameLight']) {
691 echo "\n";
693 <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; ?>">
694 <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>
695 <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); ?>">
696 <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
697 <?php
698 } else {
699 $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 . '">';
700 $list_item .= '<img src="images/browse.png" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
701 $list_item .= '<bdo dir="' . $text_dir . '">&nbsp;</bdo>' . "\n";
702 $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) . '">';
703 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />';
705 // garvin: Check whether to display nested sets
706 if (!empty($cfg['LeftFrameTableSeparator'])) {
707 $_table = explode($cfg['LeftFrameTableSeparator'], $table);
708 if (is_array($_table)) {
709 reset($_table);
710 while(list($key, $val) = each($_table)) {
711 if ($val == '') {
712 $_table[$key] = '__protected__';
715 unset($_table[count($_table)-1]);
716 $_table = PMA_reduceNest($_table);
718 $eval_string = '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_name\'][] = \'' . $table . '\';';
719 $eval_string .= '$tablestack[\'' . implode('\'][\'', $_table) . '\'][\'pma_list_item\'][] = \'' . $list_item . '\';';
720 eval($eval_string);
721 } else {
722 $tablestack['__protected__']['pma_name'][] = $table;
723 $tablestack['__protected__']['pma_list_item'][] = $list_item;
725 } else {
726 $tablestack['__protected__']['pma_name'][] = $table;
727 $tablestack['__protected__']['pma_list_item'][] = $list_item;
730 } // end for $j (tables list)
732 if (!$cfg['LeftFrameLight']) {
733 PMA_nestedSet('1', $tablestack);
735 </div>
736 <!-- Arrange collapsible/expandable db list at startup -->
737 <script type="text/javascript" language="javascript1.2">
738 <!--
739 if (isNS4) {
740 firstEl = 'el1Parent';
741 firstInd = nsGetIndex(firstEl);
742 nsShowAll();
743 nsArrangeList();
745 var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
746 //-->
747 </script>
748 <?php
749 } else {
750 echo ' </div>';
753 echo "\n";
754 } // end if ($num_dbs == 1)
757 // Case where no database has to be displayed
758 else {
759 echo "\n";
760 echo '<p>' . $strNoDatabases . '</p>';
761 } // end if ($num_dbs == 0)
762 echo "\n";
765 </body>
766 </html>
768 <?php
770 * Close MySql connections
772 if (isset($dbh) && $dbh) {
773 @mysql_close($dbh);
775 if (isset($userlink) && $userlink) {
776 @mysql_close($userlink);
781 * Sends bufferized data
783 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
784 && isset($ob_mode) && $ob_mode) {
785 PMA_outBufferPost($ob_mode);