PluginProbe
WP-DBManager / 2.50
WP-DBManager v2.50
4.0.0 trunk 1.00 2.00 2.01 2.02 2.03 2.04 2.05 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.65 2.70 2.71 2.72 2.73 2.74 2.75 2.76 2.78 All 40 releases
wp-dbmanager / database-manager.php

database-manager.php in WP-DBManager 2.50, at database-manager.php

129 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 | |
5 | WordPress 2.8 Plugin: WP-DBManager 2.50 |
6 | Copyright (c) 2009 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/wp-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('wp-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 <div id="icon-wp-dbmanager" class="icon32"><br /></div>
44 <h2><?php _e('Database', 'wp-dbmanager'); ?></h2>
45 <h3><?php _e('Database Information', 'wp-dbmanager'); ?></h3>
46 <br style="clear" />
47 <table class="widefat">
48 <thead>
49 <tr>
50 <th><?php _e('Setting', 'wp-dbmanager'); ?></th>
51 <th><?php _e('Value', 'wp-dbmanager'); ?></th>
52 </tr>
53 </thead>
54 <tr>
55 <td><?php _e('Database Host', 'wp-dbmanager'); ?></td>
56 <td><?php echo DB_HOST; ?></td>
57 </tr>
58 <tr class="alternate">
59 <td><?php _e('Database Name', 'wp-dbmanager'); ?></td>
60 <td><?php echo DB_NAME; ?></td>
61 </tr>
62 <tr>
63 <td><?php _e('Database User', 'wp-dbmanager'); ?></td>
64 <td><?php echo DB_USER; ?></td>
65 </tr>
66 <tr class="alternate">
67 <td><?php _e('Database Type', 'wp-dbmanager'); ?></td>
68 <td>MYSQL</td>
69 </tr>
70 <tr>
71 <td><?php _e('Database Version', 'wp-dbmanager'); ?></td>
72 <td>v<?php echo $sqlversion; ?></td>
73 </tr>
74 </table>
75 </div>
76 <p>&nbsp;</p>
77
78 <div class="wrap">
79 <h3><?php _e('Tables Information', 'wp-dbmanager'); ?></h3>
80 <br style="clear" />
81 <table class="widefat">
82 <thead>
83 <tr>
84 <th><?php _e('No.', 'wp-dbmanager'); ?></th>
85 <th><?php _e('Tables', 'wp-dbmanager'); ?></th>
86 <th><?php _e('Records', 'wp-dbmanager'); ?></th>
87 <th><?php _e('Data Usage', 'wp-dbmanager'); ?></th>
88 <th><?php _e('Index Usage', 'wp-dbmanager'); ?></th>
89 <th><?php _e('Overhead', 'wp-dbmanager'); ?></th>
90 </tr>
91 </thead>
92 <?php
93 // If MYSQL Version More Than 3.23, Get More Info
94 if($sqlversion >= '3.23') {
95 $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS");
96 foreach($tablesstatus as $tablestatus) {
97 if($no%2 == 0) {
98 $style = '';
99 } else {
100 $style = ' class="alternate"';
101 }
102 $no++;
103 echo "<tr$style>\n";
104 echo '<td>'.number_format_i18n($no).'</td>'."\n";
105 echo "<td>$tablestatus->Name</td>\n";
106 echo '<td>'.number_format_i18n($tablestatus->Rows).'</td>'."\n";
107 echo '<td>'.format_size($tablestatus->Data_length).'</td>'."\n";
108 echo '<td>'.format_size($tablestatus->Index_length).'</td>'."\n";;
109 echo '<td>'.format_size($tablestatus->Data_free).'</td>'."\n";
110 $row_usage += $tablestatus->Rows;
111 $data_usage += $tablestatus->Data_length;
112 $index_usage += $tablestatus->Index_length;
113 $overhead_usage += $tablestatus->Data_free;
114 echo '</tr>'."\n";
115 }
116 echo '<tr class="thead">'."\n";
117 echo '<th>'.__('Total:', 'wp-dbmanager').'</th>'."\n";
118 echo '<th>'.sprintf(_n('%s Table', '%s Tables', $no, 'wp-dbmanager'), number_format_i18n($no)).'</th>'."\n";
119 echo '<th>'.sprintf(_n('%s Record', '%s Records', $row_usage, 'wp-dbmanager'), number_format_i18n($row_usage)).'</th>'."\n";
120 echo '<th>'.format_size($data_usage).'</th>'."\n";
121 echo '<th>'.format_size($index_usage).'</th>'."\n";
122 echo '<th>'.format_size($overhead_usage).'</th>'."\n";
123 echo '</tr>';
124 } else {
125 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>';
126 }
127 ?>
128 </table>
129 </div>