home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2004 New Year / INTERNET112.ISO / pc / software / windows / building / easy_php / easyphp16_setup.exe / {app} / phpmyadmin / left.php < prev    next >
Encoding:
PHP Script  |  2003-09-24  |  19.4 KB  |  459 lines

  1. <?php
  2. /* $Id: left.php,v 1.90 2002/04/20 07:59:57 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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  61.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  62. <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; ?>">
  63.  
  64. <head>
  65.     <title>phpMyAdmin</title>
  66.     <base<?php if (!empty($cfgPmaAbsoluteUri)) echo ' href="' . $cfgPmaAbsoluteUri . '"'; ?> target="phpmain" />
  67. <?php
  68. // Expandable/collapsible databases list is only used if there is more than one
  69. // database to display
  70. if ($num_dbs > 1 && !$cfgLeftFrameLight) {
  71.     echo "\n";
  72.     ?>
  73.     <!-- Collapsible tables list scripts -->
  74.     <script type="text/javascript" language="javascript">
  75.     <!--
  76.     var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
  77.                       && typeof(document.createElement) != 'undefined')
  78.                    ? 1 : 0;
  79.     var isIE4      = (typeof(document.all) != 'undefined'
  80.                       && parseInt(navigator.appVersion) >= 4)
  81.                    ? 1 : 0;
  82.     var isNS4      = (typeof(document.layers) != 'undefined')
  83.                    ? 1 : 0;
  84.     var capable    = (isDOM || isIE4 || isNS4)
  85.                    ? 1 : 0;
  86.     // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
  87.     if (capable) {
  88.         if (typeof(window.opera) != 'undefined') {
  89.             capable = 0;
  90.         }
  91.         else if (typeof(navigator.userAgent) != 'undefined') {
  92.             var browserName = ' ' + navigator.userAgent.toLowerCase();
  93.             if (browserName.indexOf('konqueror') > 0) {
  94.                 capable = 0;
  95.             }
  96.         } // end if... else if...
  97.     } // end if
  98.     var fontFamily  = '<?php echo $left_font_family; ?>';
  99.     var fontSize    = '<?php echo $font_size; ?>';
  100.     var fontBig     = '<?php echo $font_bigger; ?>';
  101.     var fontSmall   = '<?php echo $font_smaller; ?>';
  102.     var isServer    = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
  103.     //-->
  104.     </script>
  105.     <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
  106.     <noscript>
  107.         <style type="text/css">
  108.         <!--
  109.         div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  110.         .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  111.         .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
  112.         .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
  113.         .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
  114.         .item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}
  115.         .tblItem:hover {color: #FF0000; text-decoration: underline}
  116.         //-->
  117.         </style>
  118.     </noscript>
  119.  
  120.     <style type="text/css">
  121.     <!--
  122.     body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
  123.     //-->
  124.     </style>
  125.     <?php
  126. } // end if ($num_dbs > 1)
  127.  
  128. else if ($num_dbs == 1) {
  129.     echo "\n";
  130.     ?>
  131.     <style type="text/css">
  132.     <!--
  133.     body {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
  134.     div {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  135.     .heada {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  136.     .headaCnt {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #000000}
  137.     .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
  138.     .child {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
  139.     .item, .item:active, .item:hover, .tblItem, .tblItem:active {font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
  140.     .tblItem:hover {color: #FF0000; text-decoration: underline}
  141.     //-->
  142.     </style>
  143.     <?php
  144. } // end if ($num_dbs == 1)
  145.  
  146. else {
  147.     echo "\n";
  148.     ?>
  149.     <style type="text/css">
  150.     <!--
  151.     body    {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
  152.     div     {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  153.     input   {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>}
  154.     select  {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; background-color: #ffffff; color: #000000}
  155.     .heada  {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_size; ?>; color: #000000}
  156.     .parent {font-family: <?php echo $left_font_family; ?>; color: #000000; text-decoration: none}
  157.     .item, .item:active, .item:hover, .tblItem, .tblItem:active {font-family: <?php echo $left_font_family; ?>; font-size: <?php echo $font_smaller; ?>; color: #333399; text-decoration: none}
  158.     .tblItem:hover {color: #FF0000; text-decoration: underline}
  159.     //-->
  160.     </style>
  161.     <?php
  162. } // end if ($num_dbs < 1)
  163.  
  164. echo "\n";
  165. ?>
  166. </head>
  167.  
  168. <body bgcolor="<?php echo $cfgLeftBgColor; ?>">
  169.     <!-- Link to the welcome page -->
  170.     <div id="el1Parent" class="parent" style="margin-bottom: 5px">
  171.         <nobr><a class="item" href="main.php?lang=<?php echo $lang; ?>&server=<?php echo $server; ?>">
  172.             <span class="heada"><b><?php echo $strHome; ?></b></span></a></nobr>
  173.     </div>
  174.  
  175.  
  176.     <!-- Databases and tables list -->
  177. <?php
  178. // Don't display expansible/collapsible database info if:
  179. // 1. $server == 0 (no server selected)
  180. //    This is the case when there are multiple servers and
  181. //    '$cfgServerDefault = 0' is set. In that case, we want the welcome screen
  182. //    to appear with no database info displayed.
  183. // 2. there is only one database available (ie either only one database exists
  184. //    or $cfgServers['only_db'] is defined and is not an array)
  185. //    In this case, the database should not be collapsible/expandable
  186. if ($num_dbs > 1) {
  187.  
  188.     // Light mode -> beginning of the select combo for databases
  189.     if ($cfgLeftFrameLight) {
  190.         echo '    <form method="post" action="index.php" name="left" target="_parent">' . "\n";
  191.         echo '        <input type="hidden" name="lang" value="' . $lang . '" />' . "\n";
  192.         echo '        <input type="hidden" name="server" value="' . $server . '" />' . "\n";
  193.         echo '        <select name="lightm_db" onchange="this.form.submit()">' . "\n";
  194.         echo '            <option value=""> - </option>' . "\n";
  195.         $table_list = '';
  196.         $table_list_header = '';
  197.         $db_name    = '';
  198.     }
  199.  
  200.     $selected_db = 0;
  201.  
  202.     // Gets the tables list per database
  203.     for ($i = 0; $i < $num_dbs; $i++) {
  204.         $db = $dblist[$i];
  205.         $j  = $i + 2;
  206.         if (!empty($db_start) && $db == $db_start) {
  207.             $selected_db = $j;
  208.         }
  209.         $tables              = @mysql_list_tables($db);
  210.         $num_tables          = @mysql_numrows($tables);
  211.         $common_url_query    = 'lang=' . $lang
  212.                              . '&server=' . $server
  213.                              . '&db=' . urlencode($db);
  214.         if ($num_tables) {
  215.             $num_tables_disp = $num_tables;
  216.         } else {
  217.             $num_tables_disp = '-';
  218.         }
  219.  
  220.         // Get additional infomation about tables for tooltip
  221.         if ($cfgShowTooltip && PMA_MYSQL_INT_VERSION >= 32303
  222.             && $num_tables
  223.             && (!$cfgLeftFrameLight || $selected_db == $j)) {
  224.             $tooltip = array();
  225.             $result  = mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  226.             while ($tmp = mysql_fetch_array($result)) {
  227.                 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  228.                                        . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  229.             } // end while
  230.         } // end if
  231.  
  232.         // No light mode -> displays the expandible/collapsible db list
  233.         if ($cfgLeftFrameLight == FALSE) {
  234.  
  235.             // Displays the database name
  236.             $on_mouse = (($cfgLeftPointerColor == '') ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfgLeftPointerColor . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfgLeftBgColor . '\')}"');
  237.  
  238.             echo "\n";
  239.             echo '    <div id="el' . $j . 'Parent" class="parent"' . $on_mouse . '>';
  240.  
  241.             if (!empty($num_tables)) {
  242.                 echo "\n";
  243.                 ?>
  244.         <nobr><a class="item" href="db_details.php?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', true); return false} else {return true}">
  245.             <img name="imEx" id="el<?php echo $j; ?>Img" src="images/plus.gif" border="0" width="9" height="9" alt="+" /></a>
  246.                 <?php
  247.             } else {
  248.                 echo "\n";
  249.                 ?>
  250.         <nobr><img name="imEx" src="images/minus.gif" border="0" width="9" height="9" alt="-" />
  251.                 <?php
  252.             }
  253.             echo "\n";
  254.             ?>
  255.         <a class="item" href="db_details.php?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
  256.             <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>
  257.     </div>
  258.  
  259.     <div id="el<?php echo $j;?>Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  260.  
  261.             <?php
  262.             // Displays the list of tables from the current database
  263.             for ($t = 0; $t < $num_tables; $t++) {
  264.                 $table     = mysql_tablename($tables, $t);
  265.                 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  266.                            ? str_replace('"', '"', $tooltip[$table])
  267.                            : '';
  268.                 echo "\n";
  269.                 ?>
  270.         <nobr><img src="images/spacer.gif" border="0" width="9" height="9" alt="" />
  271.         <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">
  272.             <img src="images/browse.gif" width="8" height="8" border="0" alt="<?php echo "$strBrowse: $table"; ?>" title="<?php echo "$strBrowse: $table"; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  273.         <a class="tblItem" title="<?php echo $url_title; ?>" target="phpmain" href="tbl_properties.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
  274.             <?php echo $table; ?></a></nobr><br />
  275.                 <?php
  276.             } // end for $t (tables list)
  277.             echo "\n";
  278.             ?>
  279.     </div>
  280.             <?php
  281.             echo "\n";
  282.  
  283.         }
  284.  
  285.         // Light mode -> displays the select combo with databases names and the
  286.         // list of tables contained in the current database
  287.         else {
  288.             echo "\n";
  289.  
  290.             // Builds the databases' names list
  291.             if (!empty($db_start) && $db == $db_start) {
  292.                 // Gets the list of tables from the current database
  293.                 for ($t = 0; $t < $num_tables; $t++) {
  294.                     $table      = mysql_tablename($tables, $t);
  295.                     $url_title  = (!empty($tooltip) && isset($tooltip[$table]))
  296.                                 ? str_replace('"', '"', $tooltip[$table])
  297.                                 : '';
  298.                     $table_list .= '    <nobr><a target="phpmain" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($table)) . '&pos=0&goto=tbl_properties.php">' . "\n";
  299.                     $table_list .= '              <img src="images/browse.gif" width="8" height="8" border="0" alt="' . $strBrowse . ': ' . $table . '" title="' . $strBrowse . ': ' . $table . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  300.                     if (PMA_USR_BROWSER_AGENT == 'IE') {
  301.                         $table_list .= '          <span class="tblItem"><a class="tblItem" title="' . $url_title . '" target="phpmain" href="tbl_properties.php?' . $common_url_query . '&table=' . urlencode($table) . '">' . $table . '</a></span></nobr><br />' . "\n";
  302.                     } else {
  303.                         $table_list .= '          <a class="tblItem" title="' . $url_title . '" target="phpmain" href="tbl_properties.php?' . $common_url_query . '&table=' . urlencode($table) . '">' . $table . '</a></nobr><br />' . "\n";
  304.                     }
  305.                 } // end for $t (tables list)
  306.  
  307.                 if (!$table_list) {
  308.                     $table_list = '    <br /><br />' . "\n"
  309.                                 . '    <div>' . $strNoTablesFound . '</div>' . "\n";
  310.                 }
  311.                 $selected = ' selected="selected"';
  312.  
  313.                 $table_list_header .= '    <a class="item" target="phpmain" href="db_details.php?' . $common_url_query . '">' . "\n";
  314.                 $table_list_header .= '        <span class="heada"><b>' . $db . '</b><bdo dir="' . $text_dir . '">  </bdo></span></a><br />' . "\n\n";
  315.             } else {
  316.                 $selected = '';
  317.             } // end if... else...
  318.  
  319.             if (!empty($num_tables)) {
  320.                 echo '            <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (' . $num_tables . ')</option>' . "\n";
  321.             } else {
  322.                 echo '            <option value="' . urlencode($db) . '"' . $selected . '>' . $db . ' (-)</option>' . "\n";
  323.             } // end if... else...
  324.  
  325.         } // end if (light mode)
  326.  
  327.     } // end for $i (db list)
  328.  
  329.     // Light mode -> end of the select combo for databases and table list for
  330.     // the current database
  331.     if ($cfgLeftFrameLight) {
  332.         echo '        </select>' . "\n";
  333.         echo '        <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
  334.         echo '    </form>' . "\n";
  335.  
  336.         if (!$table_list) {
  337.             $table_list = '    <div>' . $strSelectADb . '</div>' . "\n";
  338.         }
  339.  
  340.         // Displays the current database name and the list of tables it
  341.         // contains
  342.         echo "\n" . '    <hr noshade="noshade" />' . "\n\n";
  343.         echo $table_list_header;
  344.         echo $table_list;
  345.         echo "\n" . '    <hr noshade="noshade" />' . "\n";
  346.  
  347.     }
  348.  
  349.     // No light mode -> initialize some js variables for the
  350.     // expandible/collapsible stuff
  351.     else {
  352.         ?>
  353.  
  354.     <!-- Arrange collapsible/expandable db list at startup -->
  355.     <script type="text/javascript" language="javascript1.2">
  356.     <!--
  357.     if (isNS4) {
  358.       firstEl  = 'el1Parent';
  359.       firstInd = nsGetIndex(firstEl);
  360.       nsShowAll();
  361.       nsArrangeList();
  362.     }
  363.     var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  364.     //-->
  365.     </script>
  366.         <?php
  367.  
  368.     } // end if... else... (light mode)
  369.  
  370. } // end if ($server > 1)
  371.  
  372.  
  373. // Case where only one database has to be displayed
  374. else if ($num_dbs == 1) {
  375.     $db                  = $dblist[0];
  376.     $tables              = @mysql_list_tables($db);
  377.     $num_tables          = @mysql_numrows($tables);
  378.     $common_url_query    = 'lang=' . $lang
  379.                          . '&server=' . $server
  380.                          . '&db=' . urlencode($db);
  381.     if ($num_tables) {
  382.         $num_tables_disp = $num_tables;
  383.     } else {
  384.         $num_tables_disp = '-';
  385.     }
  386.  
  387.     // Get additional infomation about tables for tooltip
  388.     if ($cfgShowTooltip && PMA_MYSQL_INT_VERSION >= 32303
  389.         && $num_tables) {
  390.         $tooltip = array();
  391.         $result  = mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  392.         while ($tmp = mysql_fetch_array($result)) {
  393.             $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  394.                                    . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  395.         } // end while
  396.     } // end if
  397.  
  398.     // Displays the database name
  399.     echo "\n";
  400.     ?>
  401.     <div id="el2Parent" class="parent">
  402.         <nobr><a class="item" href="db_details.php?<?php echo $common_url_query; ?>">
  403.             <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>
  404.     </div>
  405.     <div id="el2Child" class="child" style="margin-bottom: 5px">
  406.     <?php
  407.     // Displays the list of tables from the current database
  408.     for ($j = 0; $j < $num_tables; $j++) {
  409.         $table     = mysql_tablename($tables, $j);
  410.         $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  411.                    ? str_replace('"', '"', $tooltip[$table])
  412.                    : '';
  413.         echo "\n";
  414.         ?>
  415.         <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">
  416.                   <img src="images/browse.gif" width="8" height="8" border="0" alt="<?php echo "$strBrowse: $table"; ?>" title="<?php echo "$strBrowse: $table"; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  417.               <a class="tblItem" title="<?php echo $url_title; ?>" target="phpmain" href="tbl_properties.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
  418.                   <?php echo $table; ?></a></nobr><br />
  419.         <?php
  420.     } // end for $j (tables list)
  421.     echo "\n";
  422.     ?>
  423.     </div>
  424.     <?php
  425. } // end if ($num_dbs == 1)
  426.  
  427.  
  428. // Case where no database has to be displayed
  429. else {
  430.     echo "\n";
  431.     echo '<p>' . $strNoDatabases . '</p>';
  432. } // end if ($num_dbs == 0)
  433. echo "\n";
  434. ?>
  435.  
  436. </body>
  437. </html>
  438.  
  439. <?php
  440. /**
  441.  * Close MySql connections
  442.  */
  443. if (isset($dbh) && $dbh) {
  444.     @mysql_close($dbh);
  445. }
  446. if (isset($userlink) && $userlink) {
  447.     @mysql_close($userlink);
  448. }
  449.  
  450.  
  451. /**
  452.  * Sends bufferized data
  453.  */
  454. if (isset($cfgOBGzip) && $cfgOBGzip
  455.     && isset($ob_mode) && $ob_mode) {
  456.      PMA_outBufferPost($ob_mode);
  457. }
  458. ?>
  459.