home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / db_printview.php < prev    next >
PHP Script  |  2008-06-23  |  7KB  |  270 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: db_printview.php 11334 2008-06-21 13:16:05Z lem9 $
  6.  */
  7.  
  8. /**
  9.  *
  10.  */
  11. require_once './libraries/common.inc.php';
  12.  
  13. /**
  14.  * Gets the variables sent or posted to this script, then displays headers
  15.  */
  16. $print_view = true;
  17. require_once './libraries/header.inc.php';
  18.  
  19. PMA_checkParameters(array('db'));
  20.  
  21. /**
  22.  * Defines the url to return to in case of error in a sql statement
  23.  */
  24. $err_url = 'db_sql.php?' . PMA_generate_common_url($db);
  25.  
  26. /**
  27.  * Settings for relations stuff
  28.  */
  29. require_once './libraries/relation.lib.php';
  30. $cfgRelation = PMA_getRelationsParam();
  31.  
  32. /**
  33.  * Gets the list of the table in the current db and informations about these
  34.  * tables if possible
  35.  *
  36.  * @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
  37.  *
  38. // staybyte: speedup view on locked tables - 11 June 2001
  39. // Special speedup for newer MySQL Versions (in 4.0 format changed)
  40. if ($cfg['SkipLockedTables'] == true) {
  41.     $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
  42.     // Blending out tables in use
  43.     if ($result != false && PMA_DBI_num_rows($result) > 0) {
  44.         while ($tmp = PMA_DBI_fetch_row($result)) {
  45.             // if in use memorize tablename
  46.             if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
  47.                 $sot_cache[$tmp[0]] = true;
  48.             }
  49.         }
  50.         PMA_DBI_free_result($result);
  51.  
  52.         if (isset($sot_cache)) {
  53.             $result      = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
  54.             if ($result != false && PMA_DBI_num_rows($result) > 0) {
  55.                 while ($tmp = PMA_DBI_fetch_row($result)) {
  56.                     if (!isset($sot_cache[$tmp[0]])) {
  57.                         $sts_result  = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
  58.                         $sts_tmp     = PMA_DBI_fetch_assoc($sts_result);
  59.                         $tables[]    = $sts_tmp;
  60.                     } else { // table in use
  61.                         $tables[]    = array('Name' => $tmp[0]);
  62.                     }
  63.                 }
  64.                 PMA_DBI_free_result($result);
  65.                 $sot_ready = true;
  66.             }
  67.         }
  68.         unset($tmp, $result);
  69.     }
  70. }
  71.  
  72. if (! isset($sot_ready)) {
  73.     $result      = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
  74.     if (PMA_DBI_num_rows($result) > 0) {
  75.         while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
  76.             $tables[] = $sts_tmp;
  77.         }
  78.         PMA_DBI_free_result($result);
  79.         unset($res);
  80.     }
  81. }
  82.  */
  83.  
  84. /**
  85.  * If there is at least one table, displays the printer friendly view, else
  86.  * an error message
  87.  */
  88. $tables = PMA_DBI_get_tables_full($db);
  89. $num_tables = count($tables);
  90.  
  91. echo '<br />';
  92.  
  93. // 1. No table
  94. if ($num_tables == 0) {
  95.     echo $strNoTablesFound;
  96. }
  97. // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
  98. else {
  99.     ?>
  100. <table>
  101. <thead>
  102. <tr>
  103.     <th><?php echo $strTable; ?></th>
  104.     <th><?php echo $strRecords; ?></th>
  105.     <th><?php echo $strType; ?></th>
  106.     <?php
  107.     if ($cfg['ShowStats']) {
  108.         echo '<th>' . $strSize . '</th>';
  109.     }
  110.     ?>
  111.     <th><?php echo $strComments; ?></th>
  112. </tr>
  113. </thead>
  114. <tbody>
  115.     <?php
  116.     $sum_entries = $sum_size = 0;
  117.     $odd_row = true;
  118.     foreach ($tables as $sts_data) {
  119.         if (strtoupper($sts_data['ENGINE']) == 'MRG_MYISAM'
  120.          || strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
  121.             $merged_size = true;
  122.         } else {
  123.             $merged_size = false;
  124.         }
  125.         $sum_entries += $sts_data['TABLE_ROWS'];
  126.         ?>
  127. <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
  128.     <th>
  129.         <?php echo htmlspecialchars($sts_data['TABLE_NAME']); ?>
  130.     </th>
  131.         <?php
  132.  
  133.         if (isset($sts_data['TABLE_ROWS'])) {
  134.             ?>
  135.     <td align="right">
  136.             <?php
  137.             if ($merged_size) {
  138.                 echo '<i>' . PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
  139.             } else {
  140.                 echo PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
  141.             }
  142.             ?>
  143.     </td>
  144.     <td nowrap="nowrap">
  145.         <?php echo $sts_data['ENGINE']; ?>
  146.     </td>
  147.             <?php
  148.             if ($cfg['ShowStats']) {
  149.                 $tblsize =  $sts_data['Data_length'] + $sts_data['Index_length'];
  150.                 $sum_size += $tblsize;
  151.                 list($formated_size, $unit) =  PMA_formatByteDown($tblsize, 3, 1);
  152.                 ?>
  153.     <td align="right" nowrap="nowrap">
  154.         <?php echo $formated_size . ' ' . $unit; ?>
  155.     </td>
  156.                 <?php
  157.             } // end if
  158.         } else {
  159.             ?>
  160.     <td colspan="3" align="center">
  161.         <?php echo $strInUse; ?>
  162.     </td>
  163.             <?php
  164.         }
  165.         ?>
  166.     <td>
  167.         <?php
  168.         if (! empty($sts_data['Comment'])) {
  169.             echo htmlspecialchars($sts_data['Comment']);
  170.             $needs_break = '<br />';
  171.         } else {
  172.             $needs_break = '';
  173.         }
  174.  
  175.         if (! empty($sts_data['Create_time'])
  176.          || ! empty($sts_data['Update_time'])
  177.          || ! empty($sts_data['Check_time'])) {
  178.             echo $needs_break;
  179.             ?>
  180.             <table width="100%">
  181.             <?php
  182.  
  183.             if (! empty($sts_data['Create_time'])) {
  184.                 ?>
  185.                 <tr>
  186.                     <td align="right"><?php echo $strStatCreateTime . ': '; ?></td>
  187.                     <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
  188.                 </tr>
  189.                 <?php
  190.             }
  191.  
  192.             if (! empty($sts_data['Update_time'])) {
  193.                 ?>
  194.                 <tr>
  195.                     <td align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
  196.                     <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
  197.                 </tr>
  198.                 <?php
  199.             }
  200.  
  201.             if (! empty($sts_data['Check_time'])) {
  202.                 ?>
  203.                 <tr>
  204.                     <td align="right"><?php echo $strStatCheckTime . ': '; ?></td>
  205.                     <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
  206.                 </tr>
  207.                 <?php
  208.             }
  209.             ?>
  210.             </table>
  211.             <?php
  212.         }
  213.         ?>
  214.     </td>
  215. </tr>
  216.         <?php
  217.     }
  218.     ?>
  219. <tr>
  220.     <th align="center">
  221.         <?php echo sprintf($strTables, PMA_formatNumber($num_tables, 0)); ?>
  222.     </th>
  223.     <th align="right" nowrap="nowrap">
  224.         <?php echo PMA_formatNumber($sum_entries, 0); ?>
  225.     </th>
  226.     <th align="center">
  227.         --
  228.     </th>
  229.     <?php
  230.     if ($cfg['ShowStats']) {
  231.         list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
  232.         ?>
  233.     <th align="right" nowrap="nowrap">
  234.         <?php echo $sum_formated . ' ' . $unit; ?>
  235.     </th>
  236.         <?php
  237.     }
  238.     ?>
  239.     <th> </th>
  240. </tr>
  241. </tbody>
  242. </table>
  243.     <?php
  244. }
  245.  
  246. /**
  247.  * Displays the footer
  248.  */
  249. ?>
  250.  
  251. <script type="text/javascript">
  252. //<![CDATA[
  253. function printPage()
  254. {
  255.     // Do print the page
  256.     if (typeof(window.print) != 'undefined') {
  257.         window.print();
  258.     }
  259. }
  260. //]]>
  261. </script>
  262. <br /><br />
  263.  
  264. <input type="button" class="print_ignore"
  265.     id="print" value="<?php echo $strPrint; ?>" onclick="printPage()" />
  266.  
  267. <?php
  268. require_once './libraries/footer.inc.php';
  269. ?>
  270.