home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / left.php < prev    next >
Encoding:
PHP Script  |  2004-06-30  |  36.3 KB  |  819 lines

  1. <?php
  2. /* $Id: left.php,v 2.5.4.1 2004/06/30 18:42:18 lem9 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. function PMA_reduceNest($_table) {
  65.  
  66.     if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
  67.         $max = $GLOBALS['cfg']['LeftFrameTableLevel'];
  68.         $temp_table = $_table;
  69.         $new_table = array();
  70.         $last_index = 0;
  71.         for ($ti = 0; $ti <= $max; $ti++) {
  72.             if (isset($temp_table[$ti])) {
  73.                 $new_table[$ti] = $temp_table[$ti];
  74.                 unset($temp_table[$ti]);
  75.                 $last_index = $ti;
  76.             }
  77.         }
  78.  
  79.         $_table = $new_table;
  80.     }
  81.  
  82.     return $_table;
  83. }
  84.  
  85. function PMA_indent($spaces) {
  86.     $string = '';
  87.     for ($i = 0; $i <= $spaces; $i++) {
  88.         $string .= ' ';
  89.     }
  90.  
  91.     return $string;
  92. }
  93.  
  94. function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
  95.     $name = $key;
  96.     $id = preg_replace('@[^a-z0-9]*@i', '', $baseid . $keyhistory . $key) . $indent;
  97.  
  98.     $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'] . '\')}"');
  99.  
  100.     $countarray = $val;
  101.     if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
  102.         $counter = count($countarray['pma_name']);
  103.     } else {
  104.         unset($countarray['pma_name']);
  105.         if (count($countarray) > 1) {
  106.             unset($countarray['pma_list_item']);
  107.         }
  108.         $counter = count($countarray);
  109.     }
  110.  
  111.     echo "\n";
  112.     echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
  113.     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}">';
  114.     echo '<img name="imEx" id="el' . $id . 'Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
  115.     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'] . '">  </bdo></span><span class="headaCnt">(' . $counter . ')</span></a></nobr>' . "\n";
  116.     echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeaderParent">' . "\n";
  117.     echo "\n";
  118.  
  119.     if ($childout) {
  120.         echo PMA_indent($indent * 5) . '<div id="el' . $id . 'Child" class="child" ' . $on_mouse . '>' . "\n";
  121.     }
  122. }
  123.  
  124. function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
  125.     if ($firstGroup) {
  126.         PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
  127.         $indent++;
  128.     }
  129.  
  130.     foreach($tablestack AS $key => $val) {
  131.         if ($key != 'pma_name' && $key != 'pma_list_item') {
  132.             if ($headerOut) {
  133.                 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
  134.             }
  135.  
  136.             if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
  137.                 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, false, ($indent + 1));
  138.             } else {
  139.                 PMA_nestedSet($baseid, $val, $key, $keyhistory . $key, true, ($indent + 1));
  140.             }
  141.  
  142.             if ($headerOut) {
  143.                 echo PMA_indent($indent * 5) . '</div><id class="PMA_nestedSetHeader">' . "\n";
  144.             }
  145.         }
  146.     }
  147.  
  148.     if ($firstGroup && $firstGroupClose) {
  149.         echo PMA_indent($indent * 4) . '</div><id class="PMA_nestedSetHeader2">' . "\n";
  150.     } elseif ($firstGroup) {
  151.         echo PMA_indent($indent * 4) . '<id spacer="div omitted" class="PMA_nestedSetHeader2">' . "\n";
  152.     }
  153. }
  154.  
  155. function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
  156.  
  157.     if ($keyhistory == '' && $key != '__protected__') {
  158.         $keyhistory = $key;
  159.     }
  160.  
  161.     $indent_level = 9;
  162.  
  163.     if (isset($tablestack)
  164.         && isset($tablestack['pma_name'])
  165.         && isset($tablestack['pma_list_item'])) {
  166.  
  167.         if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
  168.             PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
  169.             $divClose = true;
  170.             $extra_indent = 1;
  171.         } else {
  172.             PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
  173.             $divClose = false;
  174.             $extra_indent = 0;
  175.         }
  176.  
  177.         $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'] . '\')}"');
  178.  
  179.         $loops = 0;
  180.         foreach($tablestack['pma_name'] AS $tkey => $tval) {
  181.  
  182.             echo PMA_indent($indent * 5) . '<nobr><img src="images/spacer.gif" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />';
  183.             $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
  184.             foreach($items AS $ikey => $ival) {
  185.                 echo "\n";
  186.                 echo PMA_indent(($indent * 5)) . $ival;
  187.             }
  188.             echo "\n";
  189.  
  190.             $loops++;
  191.         }
  192.  
  193.         if ($divClose) {
  194.             echo PMA_indent($indent * 5) . '</div><id space="putting omitted div" class="PMA_nestedSet2">';
  195.         }
  196.  
  197.     } elseif (is_array($tablestack)) {
  198.         PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut,  (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
  199.     }
  200.  
  201.     return true;
  202. }
  203. /**
  204.  * Get the list and number of available databases.
  205.  * Skipped if no server selected: in this case no database should be displayed
  206.  * before the user choose among available ones at the welcome screen.
  207.  */
  208. if ($server > 0) {
  209.     PMA_availableDatabases(); // this function is defined in "common.lib.php"
  210. } else {
  211.     $num_dbs = 0;
  212. }
  213.  
  214.  
  215. // garvin: For re-usability, moved http-headers
  216. // to a seperate file. It can now be included by header.inc.php,
  217. // queryframe.php, querywindow.php.
  218.  
  219. require_once('./libraries/header_http.inc.php');
  220.  
  221. /**
  222.  * Displays the frame
  223.  */
  224. // Gets the font sizes to use
  225. PMA_setFontSizes();
  226. ?>
  227. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  228.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  229. <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; ?>">
  230.  
  231. <head>
  232.     <title>phpMyAdmin</title>
  233.     <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
  234.     <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain<?php echo $hash; ?>" />
  235.  
  236.     <script type="text/javascript" language="javascript">
  237.     <!--
  238. <?php
  239. if (isset($lightm_db) && !empty($lightm_db)) {
  240. ?>
  241.     window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./<?php echo $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&');?>');
  242. <?php
  243. } elseif (isset($lightm_db)) {
  244. ?>
  245.     window.parent.frames['phpmain<?php echo $hash; ?>'].location.replace('./main.php?<?php echo PMA_generate_common_url('', '', '&');?>');
  246. <?php
  247. }
  248. ?>
  249.     //-->
  250.     </script>
  251.  
  252. <?php
  253. // Expandable/collapsible databases list is only used if there is more than one
  254. // database to display
  255. if (($num_dbs > 1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
  256.     echo "\n";
  257.     ?>
  258.     <!-- Collapsible tables list scripts -->
  259.     <script type="text/javascript" language="javascript">
  260.     <!--
  261.     var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
  262.                       && typeof(document.createElement) != 'undefined')
  263.                    ? 1 : 0;
  264.     var isIE4      = (typeof(document.all) != 'undefined'
  265.                       && parseInt(navigator.appVersion) >= 4)
  266.                    ? 1 : 0;
  267.     var isNS4      = (typeof(document.layers) != 'undefined')
  268.                    ? 1 : 0;
  269.     var capable    = (isDOM || isIE4 || isNS4)
  270.                    ? 1 : 0;
  271.     // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
  272.     if (capable) {
  273.         if (typeof(window.opera) != 'undefined') {
  274.             var browserName = ' ' + navigator.userAgent.toLowerCase();
  275.             if ((browserName.indexOf('konqueror 7') == 0)) {
  276.                 capable = 0;
  277.             }
  278.         }
  279.         else if (typeof(navigator.userAgent) != 'undefined') {
  280.             var browserName = ' ' + navigator.userAgent.toLowerCase();
  281.             if ((browserName.indexOf('konqueror') > 0) && (browserName.indexOf('konqueror/3') == 0)) {
  282.                 capable = 0;
  283.             }
  284.         } // end if... else if...
  285.     } // end if
  286.  
  287.     var isServer    = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
  288.  
  289.     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 + '" />');
  290.     //-->
  291.     </script>
  292.     <noscript>
  293.         <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" />
  294.     </noscript>
  295.  
  296.     <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
  297.     <?php
  298. } // end if ($num_dbs > 1)
  299.  
  300. else if ($num_dbs == 1) {
  301.     echo "\n";
  302.     ?>
  303.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
  304.     <?php
  305. } // end if ($num_dbs == 1)
  306.  
  307. else {
  308.     echo "\n";
  309.     ?>
  310.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&num_dbs=0" />
  311.     <?php
  312. } // end if ($num_dbs < 1)
  313.  
  314. echo "\n";
  315. ?>
  316. </head>
  317.  
  318. <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>">
  319.  
  320. <?php
  321. if ($cfg['LeftDisplayLogo']) {
  322.     ?>
  323.     <!-- phpMyAdmin logo -->
  324.     <a href="http://www.phpmyadmin.net" target="_blank"><img src="./images/pma_logo.png" width="88" height="31" border="0" alt="phpMyAdmin" /></a>
  325.     <?php
  326. }
  327. echo "\n";
  328. if ($cfg['LeftDisplayServers']) {
  329. ?>
  330.         <form method="post" action="index.php" target="_parent">
  331.             <select name="server" onchange="this.form.submit();">
  332.     <?php
  333.     echo "\n";
  334.     foreach($cfg['Servers'] AS $key => $val) {
  335.         if (!empty($val['host'])) {
  336.             echo '                <option value="' . $key . '"';
  337.             if (!empty($server) && ($server == $key)) {
  338.                 echo ' selected="selected"';
  339.             }
  340.             echo '>';
  341.             if (!empty($val['verbose'])) {
  342.                 echo $val['verbose'];
  343.             } else {
  344.                 echo $val['host'];
  345.                 if (!empty($val['port'])) {
  346.                     echo ':' . $val['port'];
  347.                 }
  348.                 // loic1: skip this because it's not a so good idea to display
  349.                 //        sockets used to everybody
  350.                 // if (!empty($val['socket']) && PMA_PHP_INT_VERSION >= 30010) {
  351.                 //     echo ':' . $val['socket'];
  352.                 // }
  353.             }
  354.             // loic1: if 'only_db' is an array and there is more than one
  355.             //        value, displaying such informations may not be a so good
  356.             //        idea
  357.             if (!empty($val['only_db'])) {
  358.                 echo ' - ' . (is_array($val['only_db']) ? implode(', ', $val['only_db']) : $val['only_db']);
  359.             }
  360.             if (!empty($val['user']) && ($val['auth_type'] == 'config')) {
  361.                 echo '  (' . $val['user'] . ')';
  362.             }
  363.             echo ' </option>' . "\n";
  364.         } // end if (!empty($val['host']))
  365.     } // end while
  366.     ?>
  367.             </select>
  368.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  369.             <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
  370.             <noscript><input type="submit" value="<?php echo $strGo; ?>" /></noscript>
  371.         </form>
  372. <?php
  373. }
  374. echo "\n";
  375. ?>
  376.     <!-- Link to the welcome page -->
  377.     <div id="el1Parent" class="parent" style="margin-bottom: 5px">
  378.         <nobr><a class="item" href="main.php?<?php echo PMA_generate_common_url(); ?>"><span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
  379.     </div>
  380.  
  381.  
  382.     <!-- Databases and tables list -->
  383. <?php
  384. // Don't display expansible/collapsible database info if:
  385. // 1. $server == 0 (no server selected)
  386. //    This is the case when there are multiple servers and
  387. //    '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
  388. //    screen to appear with no database info displayed.
  389. // 2. there is only one database available (ie either only one database exists
  390. //    or $cfg['Servers']['only_db'] is defined and is not an array)
  391. //    In this case, the database should not be collapsible/expandable
  392. if ($num_dbs > 1) {
  393.  
  394.     // Light mode -> beginning of the select combo for databases
  395.     // Note: When javascript is active, the frameset will be changed from
  396.     // within left.php. With no JS (<noscript>) the whole frameset will
  397.     // be rebuilt with the new target frame.
  398.     if ($cfg['LeftFrameLight']) {
  399.         ?>
  400.         <script type="text/javascript" language="javascript">
  401.             document.writeln('<form method="post" action="left.php" name="left" target="nav">');
  402.         </script>
  403.         <noscript>
  404.             <form method="post" action="index.php" name="left" target="_parent">
  405.         </noscript>
  406.         <?php
  407.         echo PMA_generate_common_hidden_inputs();
  408.         echo '        <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
  409.         echo '        <select name="lightm_db" onchange="this.form.submit()">' . "\n";
  410.         echo '            <option value="">(' . $strDatabases . ') ...</option>' . "\n";
  411.         $table_list = '';
  412.         $table_list_header = '';
  413.         $db_name    = '';
  414.     }
  415.  
  416.     $selected_db = 0;
  417.  
  418.     // Gets the tables list per database
  419.     for ($i = 0; $i < $num_dbs; $i++) {
  420.         $db = $dblist[$i];
  421.         $j  = $i + 2;
  422.         if (!empty($db_start) && $db == $db_start) {
  423.             $selected_db = $j;
  424.         }
  425.         $tables              = @PMA_mysql_list_tables($db);
  426.         $num_tables          = ($tables) ? @mysql_numrows($tables) : 0;
  427.         $common_url_query    = PMA_generate_common_url($db);
  428.         if ($num_tables) {
  429.             $num_tables_disp = $num_tables;
  430.         } else {
  431.             $num_tables_disp = '-';
  432.         }
  433.  
  434.         // Get additional information about tables for tooltip
  435.         if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  436.             && $num_tables
  437.             && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
  438.             $tooltip = array();
  439.             $tooltip_name = array();
  440.             $result  = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  441.             while ($tmp = PMA_mysql_fetch_array($result)) {
  442.                 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  443.                 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
  444.  
  445.                 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  446.                                        . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  447.             } // end while
  448.         } // end if
  449.  
  450.         // garvin: Get comments from PMA comments table
  451.         $db_tooltip = '';
  452.         if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  453.             $tmp_db_tooltip = PMA_getComments($db);
  454.             if (is_array($tmp_db_tooltip)) {
  455.                 $db_tooltip = implode(' ', $tmp_db_tooltip);
  456.             }
  457.         }
  458.  
  459.         // No light mode -> displays the expandible/collapsible db list
  460.         if ($cfg['LeftFrameLight'] == FALSE) {
  461.  
  462.             // Displays the database name
  463.             $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
  464.  
  465.             echo "\n";
  466.             echo '    <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
  467.  
  468.             if (!empty($num_tables)) {
  469.                 echo "\n";
  470.                 ?>
  471.         <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}">
  472.             <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
  473.                 <?php
  474.             } else {
  475.                 echo "\n";
  476.                 ?>
  477.         <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
  478.                 <?php
  479.             }
  480.             echo "\n";
  481.             ?>
  482.         <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)}">
  483.             <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></nobr>
  484.     </div>
  485.  
  486.     <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  487. <?php
  488.             // Displays the list of tables from the current database
  489.             $tablestack = array();
  490.             for ($t = 0; $t < $num_tables; $t++) {
  491.                 $table     = PMA_mysql_tablename($tables, $t);
  492.                 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  493.                            ? htmlspecialchars($tooltip_name[$table])
  494.                            : '';
  495.                 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  496.                            ? htmlspecialchars($tooltip[$table])
  497.                            : '';
  498.  
  499.                 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
  500.  
  501.                 $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 . '">';
  502.                 $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  503.                 $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  504.                 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  505.                 $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
  506.  
  507.                 // garvin: Check whether to display nested sets
  508.                 if (!empty($cfg['LeftFrameTableSeparator'])) {
  509.                     $_table = explode($cfg['LeftFrameTableSeparator'],  str_replace('\'', '\\\'',$table));
  510.                     if (is_array($_table)) {
  511.                         foreach($_table AS $key => $val) {
  512.                             if ($val == '') {
  513.                                 $_table[$key] = '__protected__';
  514.                             }
  515.                         }
  516.  
  517.                         $_table = PMA_reduceNest($_table);
  518.  
  519.                         if (count($_table) == 1) {
  520.                             array_unshift($_table, '');
  521.                         }
  522.                         PMA_multimerge($tablestack, $_table);
  523.                     } else {
  524.                         $tablestack['']['pma_name'][] = $table;
  525.                         $tablestack['']['pma_list_item'][] = $list_item;
  526.                     }
  527.                 } else {
  528.                     $tablestack['']['pma_name'][] = $table;
  529.                     $tablestack['']['pma_list_item'][] = $list_item;
  530.                 }
  531.             } // end for $t (tables list)
  532.  
  533.             PMA_nestedSet($j, $tablestack);
  534.             ?>
  535.     </div>
  536.             <?php
  537.             echo "\n";
  538.  
  539.         }
  540.  
  541.         // Light mode -> displays the select combo with databases names and the
  542.         // list of tables contained in the current database
  543.         else {
  544.             echo "\n";
  545.  
  546.             // Builds the databases' names list
  547.             if (!empty($db_start) && $db == $db_start) {
  548.                 // Gets the list of tables from the current database
  549.                 for ($t = 0; $t < $num_tables; $t++) {
  550.                     $table      = PMA_mysql_tablename($tables, $t);
  551.                     $url_title  = (!empty($tooltip) && isset($tooltip[$table]))
  552.                                 ? htmlentities($tooltip[$table])
  553.                                 : '';
  554.                     $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  555.                                ? htmlentities($tooltip_name[$table])
  556.                                : '';
  557.  
  558.                     $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
  559.  
  560.                     $table_list .= '    <nobr><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";
  561.                     $table_list .= '              <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  562.                     if (PMA_USR_BROWSER_AGENT == 'IE') {
  563.                         $table_list .= '          <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></nobr><br />' . "\n";
  564.                     } else {
  565.                         $table_list .= '          <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></nobr><br />' . "\n";
  566.                     }
  567.                 } // end for $t (tables list)
  568.  
  569.                 if (!$table_list) {
  570.                     $table_list = '    <br /><br />' . "\n"
  571.                                 . '    <div>' . $strNoTablesFound . '</div>' . "\n";
  572.                 }
  573.                 $selected = ' selected="selected"';
  574.  
  575.                 $table_list_header .= '    <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
  576.                 $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";
  577.             } else {
  578.                 $selected = '';
  579.             } // end if... else...
  580.  
  581.             if (!empty($num_tables)) {
  582.                 echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
  583.             } else {
  584.                 echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
  585.             } // end if... else...
  586.  
  587.         } // end if (light mode)
  588.  
  589.     } // end for $i (db list)
  590.  
  591.     // Light mode -> end of the select combo for databases and table list for
  592.     // the current database
  593.     if ($cfg['LeftFrameLight']) {
  594.         echo '        </select>' . "\n";
  595.         echo '        <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
  596.         echo '    </form>' . "\n";
  597.  
  598.         if (!$table_list) {
  599.             $table_list = '    <div>' . $strSelectADb . '</div>' . "\n";
  600.         }
  601.  
  602.         // Displays the current database name and the list of tables it
  603.         // contains
  604.         echo "\n" . '    <hr noshade="noshade" />' . "\n\n";
  605.         echo $table_list_header;
  606.         echo $table_list;
  607.         echo "\n" . '    <hr noshade="noshade" />' . "\n";
  608.     }
  609.  
  610.     // No light mode -> initialize some js variables for the
  611.     // expandible/collapsible stuff
  612.     else {
  613.         ?>
  614.  
  615.     <!-- Arrange collapsible/expandable db list at startup -->
  616.     <script type="text/javascript" language="javascript1.2">
  617.     <!--
  618.     if (isNS4) {
  619.       firstEl  = 'el1Parent';
  620.       firstInd = nsGetIndex(firstEl);
  621.       nsShowAll();
  622.       nsArrangeList();
  623.     }
  624.     var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  625.     //-->
  626.     </script>
  627.         <?php
  628.  
  629.     } // end if... else... (light mode)
  630.  
  631. } // end if ($server > 1)
  632.  
  633.  
  634. // Case where only one database has to be displayed
  635. else if ($num_dbs == 1) {
  636.     $db                  = $dblist[0];
  637.     $tables              = @PMA_mysql_list_tables($db);
  638.     $num_tables          = ($tables) ? @mysql_numrows($tables) : 0;
  639.     $common_url_query    = PMA_generate_common_url($db);
  640.     if ($num_tables) {
  641.         $num_tables_disp = $num_tables;
  642.     } else {
  643.         $num_tables_disp = '-';
  644.     }
  645.  
  646.     // Get additional infomation about tables for tooltip
  647.     if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  648.         && $num_tables) {
  649.         $tooltip = array();
  650.         $tooltip_name = array();
  651.         $result  = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  652.         while ($tmp = PMA_mysql_fetch_array($result)) {
  653.                 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  654.                 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
  655.  
  656.             $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  657.                                    . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  658.         } // end while
  659.     } // end if
  660.  
  661.     // garvin: Get comments from PMA comments table
  662.     $db_tooltip = '';
  663.     if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  664.         $tmp_db_tooltip = PMA_getComments($db);
  665.         if (is_array($tmp_db_tooltip)) {
  666.             $db_tooltip = implode(' ', $tmp_db_tooltip);
  667.         }
  668.     }
  669.  
  670.  
  671.     // Displays the database name
  672.     if (!$cfg['LeftFrameLight']) {
  673.             $on_mouse = (($cfg['LeftPointerColor'] == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
  674.  
  675.             echo "\n";
  676.             echo '    <div id="el2Parent" class="parent"' . $on_mouse . '>';
  677.  
  678.             if (!empty($num_tables)) {
  679.                 echo "\n";
  680.                 ?>
  681.         <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}">
  682.             <img name="imEx" id="el2Img" src="images/plus.png" border="0" width="9" height="9" alt="+" /></a>
  683.                 <?php
  684.             } else {
  685.                 echo "\n";
  686.                 ?>
  687.         <nobr><img name="imEx" src="images/minus.png" border="0" width="9" height="9" alt="-" />
  688.                 <?php
  689.             }
  690.             echo "\n";
  691.             ?>
  692.         <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)}">
  693.             <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></nobr>
  694.     </div>
  695.  
  696.     <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  697.     <?php
  698.     } else {
  699.         echo "\n";
  700.         ?>
  701.     <div id="el2Parent" class="parent">
  702.         <nobr><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
  703.             <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></nobr>
  704.     </div>
  705.     <div id="el2Child" class="child" style="margin-bottom: 5px">
  706.         <?php
  707.     }
  708.  
  709.     // Displays the list of tables from the current database
  710.     $tablestack = array();
  711.     for ($j = 0; $j < $num_tables; $j++) {
  712.         $table     = PMA_mysql_tablename($tables, $j);
  713.         $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  714.                    ? htmlentities($tooltip_name[$table])
  715.                    : '';
  716.         $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  717.                    ? htmlentities($tooltip[$table])
  718.                    : '';
  719.         $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
  720.  
  721.         if ($cfg['LeftFrameLight']) {
  722.         echo "\n";
  723.         ?>
  724.         <nobr><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; ?>">
  725.                   <img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  726.               <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); ?>">
  727.                   <?php echo ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)); ?></a></nobr><br />
  728.         <?php
  729.         } else {
  730.             $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 . '">';
  731.             $list_item .= '<img src="images/button_smallbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  732.             $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  733.             $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  734.             $list_item .= ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />';
  735.  
  736.             // garvin: Check whether to display nested sets
  737.             if (!empty($cfg['LeftFrameTableSeparator'])) {
  738.                 $_table = explode($cfg['LeftFrameTableSeparator'],  str_replace('\'', '\\\'',$table));
  739.                 if (is_array($_table)) {
  740.                     foreach($_table AS $key => $val) {
  741.                         if ($val == '') {
  742.                             $_table[$key] = '__protected__';
  743.                         }
  744.                     }
  745.  
  746.                     $_table = PMA_reduceNest($_table);
  747.  
  748.                     if (count($_table) == 1) {
  749.                         array_unshift($_table, '');
  750.                     }
  751.                     PMA_multimerge($tablestack, $_table);
  752.                 } else {
  753.                     $tablestack['']['pma_name'][] = $table;
  754.                     $tablestack['']['pma_list_item'][] = $list_item;
  755.                 }
  756.             } else {
  757.                 $tablestack['']['pma_name'][] = $table;
  758.                 $tablestack['']['pma_list_item'][] = $list_item;
  759.             }
  760.         }
  761.     } // end for $j (tables list)
  762.  
  763.     if (!$cfg['LeftFrameLight']) {
  764.         PMA_nestedSet('1', $tablestack);
  765.         ?>
  766.     </div>
  767.     <!-- Arrange collapsible/expandable db list at startup -->
  768.     <script type="text/javascript" language="javascript1.2">
  769.     <!--
  770.     if (isNS4) {
  771.       firstEl  = 'el1Parent';
  772.       firstInd = nsGetIndex(firstEl);
  773.       nsShowAll();
  774.       nsArrangeList();
  775.     }
  776.     var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  777.     //-->
  778.     </script>
  779.         <?php
  780.     } else {
  781.         echo '    </div>';
  782.     }
  783.  
  784.     echo "\n";
  785. } // end if ($num_dbs == 1)
  786.  
  787.  
  788. // Case where no database has to be displayed
  789. else {
  790.     echo "\n";
  791.     echo '<p>' . $strNoDatabases . '</p>';
  792. } // end if ($num_dbs == 0)
  793. echo "\n";
  794. ?>
  795.  
  796. </body>
  797. </html>
  798.  
  799. <?php
  800. /**
  801.  * Close MySql connections
  802.  */
  803. if (isset($dbh) && $dbh) {
  804.     @mysql_close($dbh);
  805. }
  806. if (isset($userlink) && $userlink) {
  807.     @mysql_close($userlink);
  808. }
  809.  
  810.  
  811. /**
  812.  * Sends bufferized data
  813.  */
  814. if (isset($cfg['OBGzip']) && $cfg['OBGzip']
  815.     && isset($ob_mode) && $ob_mode) {
  816.      PMA_outBufferPost($ob_mode);
  817. }
  818. ?>
  819.