home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 March / PCWorld_2003-03_cd.bin / Software / Vyzkuste / phptriad / phptriad2-2-1.exe / htdocs / phpmyadmin / left.php < prev    next >
Encoding:
PHP Script  |  2002-01-06  |  13.6 KB  |  358 lines

  1. <?php
  2. /* $Id: left.php,v 1.60 2001/12/08 08:59:14 loic1 Exp $ */
  3.  
  4.  
  5. /**
  6.  * Gets the variables sent to this script, retains the db name that may have
  7.  * been defined as startup option and include a core library
  8.  */
  9. require('./libraries/grab_globals.lib.php');
  10. if (!empty($db)) {
  11.     $db_start = $db;
  12. }
  13.  
  14.  
  15. /**
  16.  * Gets a core script and starts output buffering work 
  17.  */
  18. require('./libraries/common.lib.php');
  19. require('./libraries/ob.lib.php');
  20. if ($cfgOBGzip) {
  21.     $ob_mode = PMA_outBufferModeGet();
  22.     if ($ob_mode) {
  23.         PMA_outBufferPre($ob_mode);
  24.     }
  25. }
  26.  
  27.  
  28. /**
  29.  * Get the list and number of available databases.
  30.  * Skipped if no server selected: in this case no database should be displayed
  31.  * before the user choose among available ones at the welcome screen.
  32.  */
  33. if ($server > 0) {
  34.     PMA_availableDatabases(); // this function is defined in "common.lib.php"
  35. } else {
  36.     $num_dbs = 0;
  37. }
  38.  
  39.  
  40. /**
  41.  * Send http headers
  42.  */
  43. // Don't use cache (required for Opera)
  44. $now = gmdate('D, d M Y H:i:s') . ' GMT';
  45. header('Expires: ' . $now);
  46. header('Last-Modified: ' . $now);
  47. header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
  48. header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
  49. header('Pragma: no-cache'); // HTTP/1.0
  50. // Define the charset to be used
  51. header('Content-Type: text/html; charset=' . $charset);
  52.  
  53.  
  54. /**
  55.  * Displays the frame
  56.  */
  57. // Gets the font sizes to use
  58. PMA_setFontSizes();
  59. ?>
  60. <!DOCTYPE html
  61.     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  62.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  63. <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; ?>">
  64.  
  65. <head>
  66.     <title>phpMyAdmin</title>
  67.     <base target="phpmain" />
  68. <?php
  69. // Expandable/collapsible databases list is only used if there is more than one
  70. // database to display
  71. if ($num_dbs > 1) {
  72.     echo "\n";
  73.     ?>
  74.     <!-- Collapsible tables list scripts -->
  75.     <script type="text/javascript" language="javascript">
  76.     <!--
  77.     var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
  78.                       && typeof(document.createElement) != 'undefined')
  79.                    ? 1 : 0;
  80.     var isIE4      = (typeof(document.all) != 'undefined'
  81.                       && parseInt(navigator.appVersion) >= 4)
  82.                    ? 1 : 0;
  83.     var isNS4      = (typeof(document.layers) != 'undefined')
  84.                    ? 1 : 0;
  85.     var capable    = (isDOM || isIE4 || isNS4)
  86.                    ? 1 : 0;
  87.     // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
  88.     if (capable) {
  89.         if (typeof(window.opera) != 'undefined') {
  90.             capable = 0;
  91.         }
  92.         else if (typeof(navigator.userAgent) != 'undefined') {
  93.             var browserName = ' ' + navigator.userAgent.toLowerCase();
  94.             if (browserName.indexOf('konqueror') > 0) {
  95.                 capable = 0;
  96.             }
  97.         } // end if... else if...
  98.     } // end if
  99.     var fontFamily = '<?php echo $left_font_family; ?>';
  100.     var fontSize   = '<?php echo $font_size; ?>';
  101.     var fontBig    = '<?php echo $font_bigger; ?>';
  102.     var fontSmall  = '<?php echo $font_smaller; ?>';
  103.     var isServer   = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
  104.     //-->
  105.     </script>
  106.     <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
  107.     <noscript>
  108.         <style type="text/css">
  109.         <!--
  110.         div {color: #000000}
  111.         .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  112.         .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
  113.         .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
  114.         .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
  115.         .item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}
  116.         .tblItem:hover {color: #FF0000; text-decoration: underline}
  117.         //-->
  118.         </style>
  119.     </noscript>
  120.  
  121.     <style type="text/css">
  122.     <!--
  123.     body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
  124.     //-->
  125.     </style>
  126.     <?php
  127. } // end if ($num_dbs > 1)
  128.  
  129. else if ($num_dbs == 1) {
  130.     echo "\n";
  131.     ?>
  132.     <style type="text/css">
  133.     <!--
  134.     body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
  135.     div {color: #000000}
  136.     .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  137.     .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
  138.     .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
  139.     .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
  140.     .item, .item:active, .item:hover, .tblItem, .tblItem:active {font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
  141.     .tblItem:hover {color: #FF0000; text-decoration: underline}
  142.     //-->
  143.     </style>
  144.     <?php
  145. } // end if ($num_dbs == 1)
  146.  
  147. else {
  148.     echo "\n";
  149.     ?>
  150.     <style type="text/css">
  151.     <!--
  152.     body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
  153.     div {color: #000000}
  154.     .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  155.     .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
  156.     .item, .item:active, .item:hover {color: #333399; text-decoration: none}
  157.     //-->
  158.     </style>
  159.     <?php
  160. } // end if ($num_dbs < 1)
  161.  
  162. echo "\n";
  163. ?>
  164. </head>
  165.  
  166. <body bgcolor="<?php echo $cfgLeftBgColor; ?>">
  167.     <!-- Link to the welcome page -->
  168.     <div id="el1Parent" class="parent" style="margin-bottom: 5px">
  169.         <nobr><a class="item" href="main.php?lang=<?php echo $lang; ?>&server=<?php echo $server; ?>">
  170.             <span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
  171.     </div>
  172.  
  173.    
  174.     <!-- Databases and tables list -->
  175. <?php
  176. // Don't display expansible/collapsible database info if:
  177. // 1. $server == 0 (no server selected)
  178. //    This is the case when there are multiple servers and
  179. //    '$cfgServerDefault = 0' is set. In that case, we want the welcome screen
  180. //    to appear with no database info displayed.
  181. // 2. there is only one database available (ie either only one database exists
  182. //    or $cfgServers['only_db'] is defined and is not an array)
  183. //    In this case, the database should not be collapsible/expandable
  184. if ($num_dbs > 1) {
  185.     $selected_db = 0;
  186.  
  187.     // Gets the tables list per database
  188.     for ($i = 0; $i < $num_dbs; $i++) {
  189.         $db = $dblist[$i];
  190.         $j  = $i + 2;
  191.         if (!empty($db_start) && $db == $db_start) {
  192.             $selected_db = $j;
  193.         }
  194.         $tables              = @mysql_list_tables($db);
  195.         $num_tables          = @mysql_numrows($tables);
  196.         $common_url_query    = 'lang=' . $lang
  197.                              . '&server=' . $server
  198.                              . '&db=' . urlencode($db);
  199.         if ($num_tables) {
  200.             $num_tables_disp = $num_tables;
  201.         } else {
  202.             $num_tables_disp = '-';
  203.         }
  204.  
  205.         // Get additional infomation about tables for tooltip
  206.         if ($cfgShowTooltip && PMA_MYSQL_INT_VERSION >= 32303
  207.             && $num_tables) {
  208.             $tooltip = array();
  209.             $result  = mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  210.             while ($tmp = mysql_fetch_array($result)) {
  211.                 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  212.                                        . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  213.             } // end while
  214.         } // end if
  215.  
  216.         // Displays the database name
  217.         $on_mouse = (($cfgLeftPointerColor == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfgLeftPointerColor . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfgLeftBgColor . '\')}"');
  218.         echo "\n";
  219.         echo '    <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
  220.  
  221.         if (!empty($num_tables)) {
  222.             echo "\n";
  223.             ?>
  224.         <nobr><a class="item" href="db_details.php?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', true); return false;}">
  225.             <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.gif" border="0" width="9" height="9" alt="+" /></a>
  226.             <?php
  227.         } else {
  228.             echo "\n";
  229.             ?>
  230.         <nobr><img name="imEx" src="images/minus.gif" border="0" width="9" height="9" />
  231.             <?php
  232.         }
  233.         echo "\n";
  234.         ?>
  235.         <a class="item" href="db_details.php?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
  236.             <span class="heada"><?php echo $db; ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
  237.     </div>
  238.  
  239.     <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  240.  
  241.         <?php
  242.         // Displays the list of tables from the current database
  243.         for ($j = 0; $j < $num_tables; $j++) {
  244.             $table = mysql_tablename($tables, $j);
  245.             echo "\n";
  246.             ?>
  247.         <nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
  248.         <a target="phpmain" href="sql.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0&goto=tbl_properties.php">
  249.             <img src="images/browse.gif" border="0" alt="<?php echo "$strBrowse: $table"; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  250.         <a class="tblItem" title="<?php echo str_replace('"', '"', $tooltip[$table]); ?>" target="phpmain" href="tbl_properties.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
  251.             <?php echo $table; ?></a></nobr><br />
  252.             <?php
  253.         } // end for $j (tables list)
  254.         echo "\n";
  255.         ?>
  256.     </div>
  257.         <?php
  258.         echo "\n";
  259.     } // end for $t (db list)
  260.     ?>
  261.  
  262.  
  263.     <!-- Arrange collapsible/expandable db list at startup -->
  264.     <script type="text/javascript" language="javascript1.2">
  265.     <!--
  266.     if (isNS4) {
  267.       firstEl  = 'el1Parent';
  268.       firstInd = nsGetIndex(firstEl);
  269.       nsShowAll();
  270.       nsArrangeList();
  271.     }
  272.     expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  273.     //-->
  274.     </script>
  275.     <?php
  276. } // end if ($server > 1)
  277.  
  278. // Case where only one database has to be displayed
  279. else if ($num_dbs == 1) {
  280.     $db                  = $dblist[0];
  281.     $tables              = @mysql_list_tables($db);
  282.     $num_tables          = @mysql_numrows($tables);
  283.     $common_url_query    = 'lang=' . $lang
  284.                          . '&server=' . $server
  285.                          . '&db=' . urlencode($db);
  286.     if ($num_tables) {
  287.         $num_tables_disp = $num_tables;
  288.     } else {
  289.         $num_tables_disp = '-';
  290.     }
  291.  
  292.     // Get additional infomation about tables for tooltip
  293.     if ($cfgShowTooltip && PMA_MYSQL_INT_VERSION >= 32303
  294.         && $num_tables) {
  295.         $tooltip = array();
  296.         $result  = mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  297.         while ($tmp = mysql_fetch_array($result)) {
  298.             $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  299.                                    . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  300.         } // end while
  301.     } // end if
  302.  
  303.     // Displays the database name
  304.     echo "\n";
  305.     ?>
  306.     <div id="el2Parent" class="parent">
  307.         <nobr><a class="item" href="db_details.php?<?php echo $common_url_query; ?>">
  308.             <span class="heada"><?php echo $db; ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></nobr>
  309.     </div>
  310.     <div id="el2Child" class="child" style="margin-bottom: 5px">
  311.     <?php
  312.     // Displays the list of tables from the current database
  313.     for ($j = 0; $j < $num_tables; $j++) {
  314.         $table = mysql_tablename($tables, $j);
  315.         echo "\n";
  316.         ?>
  317.         <nobr><a target="phpmain" href="sql.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0&goto=tbl_properties.php">
  318.                   <img src="images/browse.gif" border="0" alt="<?php echo "$strBrowse: $table"; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  319.               <a class="tblItem" title="<?php echo str_replace('"', '"', $tooltip[$table]); ?>" target="phpmain" href="tbl_properties.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
  320.                   <?php echo $table; ?></a></nobr><br />
  321.         <?php
  322.     } // end for $j (tables list)
  323.     echo "\n";
  324.     ?>
  325.     </div>
  326.     <?php
  327. } // end if ($num_dbs == 1)
  328. else {
  329.     echo "\n";
  330.     echo '<p>' . $strNoDatabases . '</p>';
  331. } // end if ($num_dbs == 0)
  332. echo "\n";
  333. ?>
  334.  
  335. </body>
  336. </html>
  337.  
  338. <?php
  339. /**
  340.  * Close MySql connections
  341.  */
  342. if (isset($dbh) && $dbh) {
  343.     @mysql_close($dbh);
  344. }
  345. if (isset($userlink) && $userlink) {
  346.     @mysql_close($userlink);
  347. }
  348.  
  349.  
  350. /**
  351.  * Sends bufferized data
  352.  */
  353. if (isset($cfgOBGzip) && $cfgOBGzip
  354.     && isset($ob_mode) && $ob_mode) {
  355.      PMA_outBufferPost($ob_mode);
  356. }
  357. ?>
  358.