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