home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Plugins / wp-dbmanager / dbmanager / database-manager.php < prev    next >
PHP Script  |  2008-02-19  |  5KB  |  119 lines

  1. <?php
  2. /*
  3. +----------------------------------------------------------------+
  4. |                                                                                            |
  5. |    WordPress 2.1 Plugin: WP-DBManager 2.20                                |
  6. |    Copyright (c) 2007 Lester "GaMerZ" Chan                                    |
  7. |                                                                                            |
  8. |    File Written By:                                                                    |
  9. |    - Lester "GaMerZ" Chan                                                            |
  10. |    - http://lesterchan.net                                                            |
  11. |                                                                                            |
  12. |    File Information:                                                                    |
  13. |    - Database Manager                                                                |
  14. |    - wp-content/plugins/dbmanager/database-manager.php                |
  15. |                                                                                            |
  16. +----------------------------------------------------------------+
  17. */
  18.  
  19.  
  20. ### Check Whether User Can Manage Database
  21. if(!current_user_can('manage_database')) {
  22.     die('Access Denied');
  23. }
  24.  
  25.  
  26. ### Variables Variables Variables
  27. $base_name = plugin_basename('dbmanager/database-manager.php');
  28. $base_page = 'admin.php?page='.$base_name;
  29. $backup = array();
  30. $backup_options = get_option('dbmanager_options');
  31. $backup['date'] = current_time('timestamp');
  32. $backup['mysqldumppath'] = $backup_options['mysqldumppath'];
  33. $backup['mysqlpath'] = $backup_options['mysqlpath'];
  34. $backup['path'] = $backup_options['path'];
  35.  
  36.  
  37. ### Get MYSQL Version
  38. $sqlversion = $wpdb->get_var("SELECT VERSION() AS version");
  39. ?>
  40. <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
  41. <!-- Database Information -->
  42. <div class="wrap">
  43.     <h2><?php _e('Database Information', 'wp-dbmanager'); ?></h2>
  44.     <table width="100%" cellspacing="3" cellpadding="3" border="0">
  45.         <tr class="thead">
  46.             <th align="left"><?php _e('Setting', 'wp-dbmanager'); ?></th>
  47.             <th align="left"><?php _e('Value', 'wp-dbmanager'); ?></th>
  48.         </tr>
  49.         <tr>
  50.             <td><?php _e('Database Host', 'wp-dbmanager'); ?></td>
  51.             <td><?php echo DB_HOST; ?></td>
  52.         </tr>
  53.         <tr style="background-color: #eee;">
  54.             <td><?php _e('Database Name', 'wp-dbmanager'); ?></td>
  55.             <td><?php echo DB_NAME; ?></td>
  56.         </tr>    
  57.         <tr>
  58.             <td><?php _e('Database User', 'wp-dbmanager'); ?></td>
  59.             <td><?php echo DB_USER; ?></td>
  60.         </tr>
  61.         <tr style="background-color: #eee;">
  62.             <td><?php _e('Database Type', 'wp-dbmanager'); ?></td>
  63.             <td>MYSQL</td>
  64.         </tr>    
  65.         <tr>
  66.             <td><?php _e('Database Version', 'wp-dbmanager'); ?></td>
  67.             <td>v<?php echo $sqlversion; ?></td>
  68.         </tr>    
  69.     </table>
  70. </div>
  71. <div class="wrap">
  72.     <h2><?php _e('Tables Information', 'wp-dbmanager'); ?></h2>
  73.     <table width="100%" cellspacing="3" cellpadding="3" border="0">
  74.         <tr class="thead">
  75.             <th align="left"><?php _e('No.', 'wp-dbmanager'); ?></th>
  76.             <th align="left"><?php _e('Tables', 'wp-dbmanager'); ?></th>
  77.             <th align="left"><?php _e('Records', 'wp-dbmanager'); ?></th>
  78.             <th align="left"><?php _e('Data Usage', 'wp-dbmanager'); ?></th>
  79.             <th align="left"><?php _e('Index Usage', 'wp-dbmanager'); ?></th>
  80.             <th align="left"><?php _e('Overhead', 'wp-dbmanager'); ?></th>
  81.         </tr>
  82. <?php
  83. // If MYSQL Version More Than 3.23, Get More Info
  84. if($sqlversion >= '3.23') {
  85.     $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS");
  86.     foreach($tablesstatus as  $tablestatus) {
  87.         if($no%2 == 0) {
  88.             $style = 'style=\'background: none;\'';
  89.         } else {
  90.             $style = 'style=\'background-color: #eee;\'';
  91.         }
  92.         $no++;
  93.         echo "<tr $style>\n";
  94.         echo "<td>$no</td>\n";
  95.         echo "<td>$tablestatus->Name</td>\n";
  96.         echo '<td>'.number_format($tablestatus->Rows).'</td>'."\n";
  97.         echo '<td>'.format_size($tablestatus->Data_length).'</td>'."\n";
  98.         echo '<td>'.format_size($tablestatus->Index_length).'</td>'."\n";;
  99.         echo '<td>'.format_size($tablestatus->Data_free).'</td>'."\n";
  100.         $row_usage += $tablestatus->Rows;
  101.         $data_usage += $tablestatus->Data_length;
  102.         $index_usage +=  $tablestatus->Index_length;
  103.         $overhead_usage += $tablestatus->Data_free;
  104.         echo '</tr>'."\n";
  105.     }    
  106.     echo '<tr class="thead">'."\n";
  107.     echo '<th align="left">'.__('Total:', 'wp-dbmanager').'</th>'."\n";
  108.     echo '<th align="left">'.$no.' '.__('Tables', 'wp-dbmanager').'</th>'."\n";
  109.     echo '<th align="left">'.number_format($row_usage).'</th>'."\n";
  110.     echo '<th align="left">'.format_size($data_usage).'</th>'."\n";
  111.     echo '<th align="left">'.format_size($index_usage).'</th>'."\n";
  112.     echo '<th align="left">'.format_size($overhead_usage).'</th>'."\n";
  113.     echo '</tr>';
  114. } else {
  115.     echo '<tr><td colspan="6" align="center"><strong>'.__('Could Not Show Table Status Due To Your MYSQL Version Is Lower Than 3.23.', 'wp-dbmanager').'</strong></td></tr>';
  116. }
  117. ?>
  118.     </table>
  119. </div>