PluginProbe
WP-DBManager / 2.40
WP-DBManager v2.40
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-optimize.php

database-optimize.php in WP-DBManager 2.40, at database-optimize.php

99 lines 3.6 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.7 Plugin: WP-DBManager 2.40 |
6 | Copyright (c) 2008 Lester "GaMerZ" Chan |
7 | |
8 | File Written By: |
9 | - Lester "GaMerZ" Chan |
10 | - http://lesterchan.net |
11 | |
12 | File Information: |
13 | - Database Optimize |
14 | - wp-content/plugins/wp-dbmanager/database-optimize.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
30 ### Form Processing
31 if($_POST['do']) {
32 // Lets Prepare The Variables
33 $optimize = $_POST['optimize'];
34
35 // Decide What To Do
36 switch($_POST['do']) {
37 case 'Optimize':
38 if(!empty($optimize)) {
39 foreach($optimize as $key => $value) {
40 if($value == 'yes') {
41 $tables_string .= '`, `'.$key;
42 }
43 }
44 } else {
45 $text = '<font color="red">'.__('No Tables Selected', 'wp-dbmanager').'</font>';
46 }
47 $selected_tables = substr($tables_string, 3);
48 $selected_tables .= '`';
49 if(!empty($selected_tables)) {
50 $optimize2 = $wpdb->query("OPTIMIZE TABLE $selected_tables");
51 if(!$optimize2) {
52 $text = '<font color="red">'.sprintf(__('Table(s) \'%s\' NOT Optimized', 'wp-dbmanager'), str_replace('`', '', $selected_tables)).'</font>';
53 } else {
54 $text = '<font color="green">'.sprintf(__('Table(s) \'%s\' Optimized', 'wp-dbmanager'), str_replace('`', '', $selected_tables)).'</font>';
55 }
56 }
57 break;
58 }
59 }
60
61
62 ### Show Tables
63 $tables = $wpdb->get_col("SHOW TABLES");
64 ?>
65 <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
66 <!-- Optimize Database -->
67 <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
68 <div class="wrap">
69 <div id="icon-wp-dbmanager" class="icon32"><br /></div>
70 <h2><?php _e('Optimize Database', 'wp-dbmanager'); ?></h2>
71 <br style="clear" />
72 <table class="widefat">
73 <thead>
74 <tr>
75 <th><?php _e('Tables', 'wp-dbmanager'); ?></th>
76 <th><?php _e('Options', 'wp-dbmanager'); ?></th>
77 </tr>
78 </thead>
79 <?php
80 foreach($tables as $table_name) {
81 if($no%2 == 0) {
82 $style = '';
83 } else {
84 $style = ' class="alternate"';
85 }
86 $no++;
87 echo "<tr$style><th align=\"left\" scope=\"row\">$table_name</th>\n";
88 echo "<td><input type=\"radio\" id=\"$table_name-no\" name=\"optimize[$table_name]\" value=\"no\" />&nbsp;<label for=\"$table_name-no\">".__('No', 'wp-dbmanager')."</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" id=\"$table_name-yes\" name=\"optimize[$table_name]\" value=\"yes\" checked=\"checked\" />&nbsp;<label for=\"$table_name-yes\">".__('Yes', 'wp-dbmanager').'</label></td></tr>';
89 }
90 ?>
91 <tr>
92 <td colspan="2" align="center"><?php _e('Database should be optimize once every month.', 'wp-dbmanager'); ?></td>
93 </tr>
94 <tr>
95 <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Optimize', 'wp-dbmanager'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-dbmanager'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
96 </tr>
97 </table>
98 </div>
99 </form>