home *** CD-ROM | disk | FTP | other *** search
/ Freelog 70 / Freelog070.iso / Internet / EasyPHP / easyphp1-8_setup.exe / {app} / phpmyadmin / left.php < prev    next >
Encoding:
PHP Script  |  2004-11-19  |  42.8 KB  |  937 lines

  1. <?php
  2. /* $Id: left.php,v 2.41 2004/11/19 14:04:02 garvinhicking Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  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;
  15. }
  16.  
  17. if (!empty($db)) {
  18.     $db_start = $db;
  19. }
  20.  
  21.  
  22. /**
  23.  * Gets a core script and starts output buffering work
  24.  */
  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);
  31.     }
  32. }
  33.  
  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='';
  42. }
  43.  
  44. require_once('./libraries/bookmark.lib.php');
  45. require_once('./libraries/relation.lib.php');
  46. $cfgRelation = PMA_getRelationsParam();
  47.  
  48. function PMA_multimerge(&$stack, &$table) {
  49. global $list_item, $table_item;
  50.  
  51.     $key = array_shift($table);
  52.  
  53.     if (count($table) > 0) {
  54.         if (!isset($stack[$key])) {
  55.             $stack[$key] = '';
  56.         }
  57.         PMA_multimerge($stack[$key], $table);
  58.     } else {
  59.         $stack['pma_name'][]      = $table_item;
  60.         $stack['pma_list_item'][] = $list_item;
  61.     }
  62. }
  63.  
  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]);
  71.         }
  72.     }
  73. }
  74.  
  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;
  79.  
  80.     $groupkey = $keyhistory . ($key != $keyhistory ? $GLOBALS['cfg']['LeftFrameTableSeparator'] . $key : '');
  81.  
  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'] . '\')}"');
  83.  
  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']);
  91.         }
  92.         $counter = count($countarray);
  93.     }
  94.  
  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'] . '&tbl_group=' . htmlspecialchars($groupkey) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', true); return false} else {return true}">';
  98.     echo '<img name="imEx" id="el' . $id . 'Img" src="' . $GLOBALS['pmaThemeImage'] . 'b_plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
  99.     echo str_repeat(' ', $indent * 6) . '<a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '&tbl_group=' . htmlspecialchars($groupkey) . '" title="' . htmlspecialchars($name) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', false)}"><span class="heada">' . htmlspecialchars($name) . '<bdo dir="' . $GLOBALS['text_dir'] . '">  </bdo></span><span class="headaCnt">(' . $counter . ')</span></a></div>' . "\n";
  100.     echo str_repeat(' ', $indent * 5) . '</div><!-- class="PMA_nestedSetHeaderParent" -->' . "\n";
  101.     echo "\n";
  102.  
  103.     if ($childout) {
  104.         echo str_repeat(' ', $indent * 5) . '<div id="el' . $id . 'Child" class="child nowrap" ' . $on_mouse . '>' . "\n";
  105.     }
  106. }
  107.  
  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++;
  112.     }
  113.  
  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);
  118.             }
  119.  
  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));
  124.             }
  125.  
  126.             if ($headerOut) {
  127.                 echo str_repeat(' ', $indent * 5) . '</div><!-- class="PMA_nestedSetHeader" -->' . "\n";
  128.             }
  129.         }
  130.     }
  131.  
  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";
  136.     }
  137. }
  138.  
  139. function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
  140.  
  141.     if ($keyhistory == '' && $key != '__protected__') {
  142.         $keyhistory = $key;
  143.     }
  144.  
  145.     $indent_level = 9;
  146.  
  147.     if (isset($tablestack)
  148.         && isset($tablestack['pma_name'])
  149.         && isset($tablestack['pma_list_item'])) {
  150.  
  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;
  159.         }
  160.  
  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'] . '\')}"');
  162.  
  163.         $loops = 0;
  164.         foreach ($tablestack['pma_name'] AS $tkey => $tval) {
  165.  
  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;
  171.             }
  172.             echo "\n";
  173.  
  174.             $loops++;
  175.         }
  176.  
  177.         if ($divClose) {
  178.             echo str_repeat(' ', $indent * 5) . '</div><!-- space="putting omitted div" class="PMA_nestedSet2" -->';
  179.         }
  180.  
  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));
  183.     }
  184.  
  185.     return true;
  186. }
  187. /**
  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.
  191.  */
  192. if ($server > 0) {
  193.     PMA_availableDatabases(); // this function is defined in "common.lib.php"
  194. } else {
  195.     $num_dbs = 0;
  196. }
  197.  
  198.  
  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.
  202.  
  203. require_once('./libraries/header_http.inc.php');
  204.  
  205. /**
  206.  * Displays the frame
  207.  */
  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
  211. ?>
  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; ?>">
  215.  
  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; ?>" />
  220.  
  221.     <script type="text/javascript" language="javascript">
  222.     <!--
  223.     function goTo(targeturl, targetframe) {
  224.         if (!targetframe) {
  225.             targetframe = self;
  226.         }
  227.  
  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 } ?>
  234.         }
  235.  
  236.         return true;
  237.     }
  238.  
  239. <?php
  240. if (isset($lightm_db) && !empty($lightm_db)) {
  241. ?>
  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)) {
  245. ?>
  246.     goTo('./main.php?<?php echo PMA_generate_common_url('', '', '&');?>', window.parent.frames['phpmain<?php echo $hash; ?>']);
  247. <?php
  248. }
  249. ?>
  250.     //-->
  251.     </script>
  252.  
  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";
  258.     ?>
  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;
  280.             }
  281.         }
  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;
  286.             }
  287.         } // end if... else if...
  288.     } // end if
  289.  
  290.     var isServer    = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
  291.  
  292.     document.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&js_frame=left&js_capable=' + capable + '&js_isDOM=' + isDOM + '&js_isIE4=' + isIE4 + '" />');
  293.     //-->
  294.     </script>
  295. <noscript>
  296.         <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?lang=<?php echo $lang; ?>&js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
  297. </noscript>
  298.  
  299.     <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
  300.     <?php
  301. } // end if ($num_dbs > 1)
  302.  
  303. else if ($num_dbs == 1) {
  304.     echo "\n";
  305.     ?>
  306.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
  307.     <?php
  308. } // end if ($num_dbs == 1)
  309.  
  310. else {
  311.     echo "\n";
  312.     ?>
  313.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&num_dbs=0" />
  314.     <?php
  315. } // end if ($num_dbs < 1)
  316.  
  317. echo "\n";
  318. ?>
  319. </head>
  320.  
  321. <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" id="body_leftFrame">
  322.  
  323. <?php
  324. if ($cfg['LeftDisplayLogo'] && !$cfg['QueryFrame']) {
  325. ?>
  326. <!-- phpMyAdmin logo -->
  327. <?php
  328.     if (@file_exists($pmaThemeImage . 'logo_left.png')) {
  329. ?>
  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";
  338.     }
  339.     echo '<hr />';
  340. } // end of display logo
  341. echo "\n";
  342.  
  343. if (!$cfg['QueryFrame']) {
  344.     echo "\n";
  345. ?>
  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=' - ';
  353.     }
  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() . '&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>';
  381.     }
  382. ?>
  383.     </div>
  384.     <hr />
  385. <?php
  386.     if ($cfg['LeftDisplayServers']) {
  387.         $show_server_left = TRUE;
  388.         include('./libraries/select_server.lib.php');
  389.     }
  390. } // end !$cfg['QueryFrame']
  391.  
  392. ?>
  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) {
  405.  
  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']) {
  412.         ?>
  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']
  428.  
  429.         $table_list = '';
  430.         $table_list_header = '';
  431.         $db_name    = '';
  432.     } // end FrameLight
  433.  
  434.     $selected_db = 0;
  435.  
  436.     // natural order for db list
  437.     if ($cfg['NaturalOrder'] && $num_dbs > 0) {
  438.         $dblist_temp = $dblist;
  439.         natsort($dblist_temp);
  440.         $i = 0;
  441.         foreach ($dblist_temp as $each) {
  442.             $dblist[$i] = $each;
  443.             $i++;
  444.         }
  445.     }
  446.  
  447.     // Gets the tables list per database
  448.     for ($i = 0; $i < $num_dbs; $i++) {
  449.         $db = $dblist[$i];
  450.         $j  = $i + 2;
  451.         if (!empty($db_start) && $db == $db_start) {
  452.             $selected_db = $j;
  453.         }
  454.         $tables              = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
  455.         $num_tables          = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
  456.         $common_url_query    = PMA_generate_common_url($db);
  457.         if ($num_tables) {
  458.             $num_tables_disp = $num_tables;
  459.         } else {
  460.             $num_tables_disp = '-';
  461.         }
  462.  
  463.         // Get additional information about tables for tooltip
  464.         if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  465.             && $num_tables
  466.             && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
  467.             $tooltip = array();
  468.             $tooltip_name = array();
  469.             $result  = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  470.             while ($tmp = PMA_DBI_fetch_assoc($result)) {
  471.                 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  472.                 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
  473.  
  474.                 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  475.                                        . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  476.             } // end while
  477.         } // end if
  478.  
  479.         // garvin: Get comments from PMA comments table
  480.         $db_tooltip = '';
  481.         if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  482.             $tmp_db_tooltip = PMA_getComments($db);
  483.             if (is_array($tmp_db_tooltip)) {
  484.                 $db_tooltip = implode(' ', $tmp_db_tooltip);
  485.             }
  486.         }
  487.  
  488.         // No light mode -> displays the expandible/collapsible db list
  489.         if ($cfg['LeftFrameLight'] == FALSE) {
  490.  
  491.             // Displays the database name
  492.             $on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
  493.  
  494.             echo "\n";
  495.             echo '    <div id="el' . $j . 'Parent" class="parent nowrap"' . $on_mouse . '>';
  496.  
  497.             if (!empty($num_tables)) {
  498.                 echo "\n";
  499.             ?>
  500.             <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}">
  501.             <img name="imEx" id="el<?php echo $j; ?>Img" src="<?php echo $pmaThemeImage; ?>b_plus.png" border="0" width="9" height="9" alt="+" /></a>
  502.             <?php
  503.             } else {
  504.                 echo "\n";
  505.             ?>
  506.             <img name="imEx" src="<?php echo $pmaThemeImage; ?>b_minus.png" border="0" width="9" height="9" alt="-" />
  507.             <?php
  508.             }
  509.             echo "\n";
  510.             ?>
  511.             <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)}">
  512.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a>
  513.         </div>
  514.  
  515.         <div id="el<?php echo $j;?>Child" class="child nowrap" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  516.         <?php
  517.             // Displays the list of tables from the current database
  518.             $tablestack  = array();
  519.             $table_array = array();
  520.             while (list($table) = PMA_DBI_fetch_row($tables)) {
  521.                 $table_item = (!empty($tooltip_name) && isset($tooltip_name[$table]) && !empty($tooltip_name[$table]) && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  522.                             ? htmlspecialchars($tooltip_name[$table])
  523.                             : htmlspecialchars($table));
  524.                 $table_array[$table] = $table_item;
  525.             }
  526.  
  527.             if ($cfg['NaturalOrder']) {
  528.                 natsort($table_array);
  529.             }
  530.  
  531.             $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
  532.             foreach ($table_array as $table => $table_sortkey) {
  533.                 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  534.                            ? htmlspecialchars($tooltip_name[$table])
  535.                            : '';
  536.                 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  537.                            ? htmlspecialchars($tooltip[$table])
  538.                            : '';
  539.                 $table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  540.                             ? $alias
  541.                             : htmlspecialchars($table));
  542.                 $tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
  543.                            ? $alias
  544.                            : htmlspecialchars($table));
  545.  
  546.                 $book_sql_query = (isset($book_sql_cache[$table]) ? $book_sql_cache[$table] : FALSE);
  547.  
  548.                 $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
  549.                 $list_item .= '<img src="' . $pmaThemeImage . 'b_sbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  550.                 $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  551.                 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  552.                 $list_item .= $table_item . '</a><br />' . "\n";
  553.  
  554.                 // garvin: Check whether to display nested sets
  555.                 if (!empty($cfg['LeftFrameTableSeparator'])) {
  556.                     $_table = explode($cfg['LeftFrameTableSeparator'],  str_replace('\'', '\\\'', $tablename));
  557.                     if (is_array($_table)) {
  558.                         foreach ($_table AS $key => $val) {
  559.                             if ($val == '') {
  560.                                 $_table[$key] = '__protected__';
  561.                             }
  562.                         }
  563.                         PMA_reduceNest($_table);
  564.  
  565.                         if (count($_table) == 1) {
  566.                             array_unshift($_table, '');
  567.                         }
  568.                         PMA_multimerge($tablestack, $_table);
  569.                     } else {
  570.                         $tablestack['']['pma_name'][] = $table_item;
  571.                         $tablestack['']['pma_list_item'][] = $list_item;
  572.                     }
  573.                 } else {
  574.                     $tablestack['']['pma_name'][] = $table_item;
  575.                     $tablestack['']['pma_list_item'][] = $list_item;
  576.                 }
  577.             } // end while (tables list)
  578.  
  579.             PMA_nestedSet($j, $tablestack);
  580.         ?>
  581.         </div>
  582.         <?php
  583.             echo "\n";
  584.         }
  585.  
  586.         // Light mode -> displays the select combo with databases names and the
  587.         // list of tables contained in the current database
  588.         else {
  589.             echo "\n";
  590.  
  591.             // Builds the databases' names list
  592.             if (!empty($db_start) && $db == $db_start) {
  593.                 $table_title = array();
  594.                 $table_array = array();
  595.                 // Gets the list of tables from the current database
  596.                 $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
  597.                 while (list($table) = PMA_DBI_fetch_row($tables)) {
  598.                     $table_array[$table] = '';
  599.                     $url_title  = (!empty($tooltip) && isset($tooltip[$table]))
  600.                                 ? htmlspecialchars($tooltip[$table])
  601.                                 : '';
  602.                     $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  603.                                ? htmlspecialchars($tooltip_name[$table])
  604.                                : '';
  605.  
  606.                     $book_sql_query = (isset($book_sql_cache[$table]) ? $book_sql_cache[$table] : FALSE);
  607.  
  608.                     // natural order or not, use an array for the table list
  609.  
  610.                     $table_array[$table] .= '    <div class="nowrap"><a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
  611.                     $table_array[$table] .= '              <img src="' . $pmaThemeImage . 'b_sbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  612.  
  613.                     if (PMA_USR_BROWSER_AGENT == 'IE') {
  614.                         $table_array[$table] .= '          <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></div>' . "\n";
  615.                     } else {
  616.                         $table_array[$table] .= '          <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></div>' . "\n";
  617.                     }
  618.  
  619.                     $table_title[$table] = htmlspecialchars($table);
  620.  
  621.                 } // end while (tables list)
  622.  
  623.                 if (count($table_title) > 0) {
  624.                     if ($cfg['NaturalOrder'] && $num_tables > 0) {
  625.                         natsort($table_title);
  626.                     }
  627.  
  628.                     foreach ($table_title as $each_key => $each_val) {
  629.                         $table_list .= ' ' . $table_array[$each_key];
  630.                     }
  631.                 } else {
  632.                     $table_list = '    <br /><br />' . "\n"
  633.                                 . '    <div>' . $strNoTablesFound . '</div>' . "\n";
  634.                 }
  635.                 $selected = ' selected="selected"';
  636.  
  637.                 $table_list_header .= '    <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
  638.                 $table_list_header .= '        <span class="heada"><b>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . '</b><bdo dir="' . $text_dir . '">  </bdo></span></a><br />' . "\n\n";
  639.             } else {
  640.                 $selected = '';
  641.             } // end if... else...
  642.             if (!$cfg['QueryFrame']) {
  643.                 if (!empty($num_tables)) {
  644.                     echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>'
  645.                        . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
  646.                 } else {
  647.                     echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>'
  648.                        . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
  649.                 }
  650.             } // end !$cfg['QueryFrame']
  651.  
  652.         } // end if (light mode)
  653.  
  654.     } // end for $i (db list)
  655.  
  656.     // Light mode -> end of the select combo for databases and table list for
  657.     // the current database
  658.     if ($cfg['LeftFrameLight']) {
  659.         if (!$cfg['QueryFrame']) {
  660.             echo '        </select>' . "\n";
  661.             echo '        <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
  662.             echo '    </form>' . "\n";
  663.         }
  664.         if (!$table_list) {
  665.             $table_list = '    <div align="center"><b>' . $strSelectADb . '</b></div>' . "\n";
  666.         }
  667.  
  668.         // Displays the current database name and the list of tables it
  669.         // contains
  670.         if (!$cfg['QueryFrame']) {
  671.            echo '<hr />';
  672.         }
  673.         echo $table_list_header;
  674.         echo $table_list;
  675.     }
  676.  
  677.     // No light mode -> initialize some js variables for the
  678.     // expandible/collapsible stuff
  679.     else {
  680.     ?>
  681.  
  682.     <!-- Arrange collapsible/expandable db list at startup -->
  683.     <script type="text/javascript" language="javascript1.2">
  684.     <!--
  685.         if (isNS4) {
  686.             firstEl  = 'el1Parent';
  687.             firstInd = nsGetIndex(firstEl);
  688.             nsShowAll();
  689.             nsArrangeList();
  690.         }
  691.         var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  692.     //-->
  693.     </script>
  694.     <?php
  695.  
  696.     } // end if... else... (light mode)
  697.  
  698. } // end if ($server > 1)
  699.  
  700.  
  701. // Case where only one database has to be displayed
  702. else if ($num_dbs == 1) {
  703.     $db                  = $dblist[0];
  704.     $tables              = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
  705.     $num_tables          = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
  706.     $common_url_query    = PMA_generate_common_url($db);
  707.     if ($num_tables) {
  708.         $num_tables_disp = $num_tables;
  709.     } else {
  710.         $num_tables_disp = '-';
  711.     }
  712.  
  713.     // Get additional infomation about tables for tooltip
  714.     if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  715.         && $num_tables) {
  716.         $tooltip = array();
  717.         $tooltip_name = array();
  718.         $result  = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE);
  719.         while ($tmp = PMA_DBI_fetch_assoc($result)) {
  720.             $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  721.             $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
  722.  
  723.             $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  724.                                    . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  725.         } // end while
  726.     } // end if
  727.  
  728.     // garvin: Get comments from PMA comments table
  729.     $db_tooltip = '';
  730.     if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  731.         $tmp_db_tooltip = PMA_getComments($db);
  732.         if (is_array($tmp_db_tooltip)) {
  733.             $db_tooltip = implode(' ', $tmp_db_tooltip);
  734.         }
  735.     }
  736.  
  737.  
  738.     // Displays the database name
  739.     if (!$cfg['LeftFrameLight']) {
  740.             $on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
  741.  
  742.             echo "\n";
  743.             echo '    <div id="el2Parent" class="parent"' . $on_mouse . '>';
  744.  
  745.             if (!empty($num_tables)) {
  746.                 echo "\n";
  747.                 ?>
  748.         <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}">
  749.             <img name="imEx" id="el2Img" src="<?php echo $pmaThemeImage; ?>b_plus.png" border="0" width="9" height="9" alt="+" /></a>
  750.                 <?php
  751.             } else {
  752.                 echo "\n";
  753.                 ?>
  754.         <div class="nowrap"><img name="imEx" src="<?php echo $pmaThemeImage; ?>b_minus.png" border="0" width="9" height="9" alt="-" />
  755.                 <?php
  756.             }
  757.             echo "\n";
  758.             ?>
  759.         <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)}">
  760.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></div>
  761.     </div>
  762.  
  763.     <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  764.     <?php
  765.     } else {
  766.         echo "\n";
  767.         ?>
  768.     <div id="el2Parent" class="parent nowrap">
  769.         <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
  770.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a>
  771.     </div>
  772.     <div id="el2Child" class="child nowrap" style="margin-bottom: 5px">
  773.         <?php
  774.     }
  775.  
  776.     // Displays the list of tables from the current database
  777.     $tablestack = array();
  778.     $table_array = array();
  779.     while (list($table) = PMA_DBI_fetch_row($tables)) {
  780.         $table_item = (!empty($tooltip_name) && isset($tooltip_name[$table]) && !empty($tooltip_name[$table]) && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  781.                     ? htmlspecialchars($tooltip_name[$table])
  782.                     : htmlspecialchars($table));
  783.         $table_array[$table] = $table_item;
  784.     }
  785.  
  786.     if ($cfg['NaturalOrder']) {
  787.         natcasesort($table_array);
  788.     }
  789.  
  790.     $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
  791.     foreach ($table_array as $table => $table_sortkey) {
  792.         $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  793.                    ? htmlspecialchars($tooltip_name[$table])
  794.                    : '';
  795.         $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  796.                    ? htmlspecialchars($tooltip[$table])
  797.                    : '';
  798.         $table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  799.                     ? $alias
  800.                     : htmlspecialchars($table));
  801.         $tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
  802.                    ? $alias
  803.                    : htmlspecialchars($table));
  804.  
  805.         $book_sql_query = (isset($book_sql_cache[$table]) ? $book_sql_cache[$table] : FALSE);
  806.  
  807.         if ($cfg['LeftFrameLight']) {
  808.         echo "\n";
  809.         ?>
  810.             <a target="phpmain<?php echo $hash; ?>" href="sql.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . $url_title; ?>">
  811.                   <img src="<?php echo $pmaThemeImage . 'b_sbrowse.png'; ?>" width="10" height="10" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  812.               <a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo $url_title; ?>" target="phpmain<?php echo $hash; ?>" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
  813.                   <?php echo $table_item; ?></a><br />
  814.         <?php
  815.         } else {
  816.             $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
  817.             $list_item .= '<img src="' . $pmaThemeImage . 'b_sbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  818.             $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  819.             $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  820.             $list_item .= $table_item . '</a><br />';
  821.  
  822.             // garvin: Check whether to display nested sets
  823.             if (!empty($cfg['LeftFrameTableSeparator'])) {
  824.                 $_table = explode($cfg['LeftFrameTableSeparator'],  str_replace('\'', '\\\'', $tablename));
  825.                 if (is_array($_table)) {
  826.                     foreach ($_table AS $key => $val) {
  827.                         if ($val == '') {
  828.                             $_table[$key] = '__protected__';
  829.                         }
  830.                     }
  831.                     PMA_reduceNest($_table);
  832.  
  833.                     if (count($_table) == 1) {
  834.                         array_unshift($_table, '');
  835.                     }
  836.                     PMA_multimerge($tablestack, $_table);
  837.                 } else {
  838.                     $tablestack['']['pma_name'][] = $table_item;
  839.                     $tablestack['']['pma_list_item'][] = $list_item;
  840.                 }
  841.             } else {
  842.                 $tablestack['']['pma_name'][] = $table_item;
  843.                 $tablestack['']['pma_list_item'][] = $list_item;
  844.             }
  845.         }
  846.     } // end for $j (tables list)
  847.  
  848.     if (!$cfg['LeftFrameLight']) {
  849.         PMA_nestedSet('1', $tablestack);
  850.         ?>
  851.     </div>
  852.     <!-- Arrange collapsible/expandable db list at startup -->
  853.     <script type="text/javascript" language="javascript1.2">
  854.     <!--
  855.     if (isNS4) {
  856.       firstEl  = 'el1Parent';
  857.       firstInd = nsGetIndex(firstEl);
  858.       nsShowAll();
  859.       nsArrangeList();
  860.     }
  861.     var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  862.     //-->
  863.     </script>
  864.         <?php
  865.     } else {
  866.         echo '    </div>';
  867.     }
  868.  
  869.     echo "\n";
  870. } // end if ($num_dbs == 1)
  871.  
  872.  
  873. // Case where no database has to be displayed
  874. else {
  875.     echo "\n";
  876.     echo '<p>' . $strNoDatabases . '</p>';
  877. } // end if ($num_dbs == 0)
  878. echo "\n";
  879.  
  880. // 2004-08-05 added by Michael Keck
  881. //            reload queryframe if it exists and we delete a database
  882. //            or select a database from the db_list.
  883. $my_lightm_db = '';
  884. if (isset($lightm_db) && $lightm_db!='') {
  885.     $my_lightm_db = $lightm_db;
  886. }
  887.  
  888. if ($cfg['LeftFrameLight'] && $cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
  889.     if (!isset($table_array) || count($table_array)==0) {
  890.         $my_url_query = PMA_generate_common_url('', '', '&');
  891. ?>
  892. <script language="JavaScript" type="text/javascript">
  893. <!--
  894. function check_queryframe_reload() {
  895.     if (typeof(window.parent.frames['queryframe'])!='undefined' && typeof(window.parent.frames['queryframe'].document.forms['left'])!='undefined') {
  896.         if (window.parent.frames['queryframe'].document.forms['left'].elements['lightm_db'].value!='<?php echo $my_lightm_db; ?>') {
  897.             window.parent.frames['queryframe'].location.replace('<?php echo 'queryframe.php?' . $my_url_query . '&hash=' . $hash; ?>');
  898.         }
  899.     }
  900. }
  901. // This is a workaround for the problem in Safari 1.2.3 where the
  902. // top left frame does not load.
  903. // If we call this right away it usually prevents the top-left frame from
  904. // loading in Safari, so call it delayed. -Ryan Schmidt 2004-08-15
  905. setTimeout('check_queryframe_reload()', 1000);
  906.  
  907. //-->
  908. </script>
  909. <?php
  910.     }
  911. }
  912. ?>
  913. </div>
  914. </body>
  915. </html>
  916.  
  917. <?php
  918. /**
  919.  * Close MySql connections
  920.  */
  921. if (isset($dbh) && $dbh) {
  922.     @PMA_DBI_close($dbh);
  923. }
  924. if (isset($userlink) && $userlink) {
  925.     @PMA_DBI_close($userlink);
  926. }
  927.  
  928.  
  929. /**
  930.  * Sends bufferized data
  931.  */
  932. if (isset($cfg['OBGzip']) && $cfg['OBGzip']
  933.     && isset($ob_mode) && $ob_mode) {
  934.      PMA_outBufferPost($ob_mode);
  935. }
  936. ?>
  937.