PluginProbe
Optimize Database after Deleting Revisions / 5.2
Optimize Database after Deleting Revisions v5.2
3.4.7 3.4.8 3.4.9 3.5 3.5.1 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.3 All 144 releases
rvg-optimize-database / classes / odb-logger.php

odb-logger.php in Optimize Database after Deleting Revisions 5.2, at classes/odb-logger.php

194 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /************************************************************************************************
3 *
4 * LOGGER CLASS
5 *
6 ************************************************************************************************/
7 ?>
8 <?php
9 class ODB_Logger {
10
11 var $sql = '';
12 var $res = array();
13
14 /********************************************************************************************
15 * CONSTRUCTOR
16 ********************************************************************************************/
17 function __construct() {
18 } // __construct()
19
20
21 /********************************************************************************************
22 * WRITE RESULTS TO LOG TABLE - v4.6
23 ********************************************************************************************/
24 function odb_add_log() {
25 global $odb_class, $wpdb;
26
27 // IS LOGGING ENABLED?
28 if($odb_class->odb_rvg_options['logging_on'] == "Y") {
29
30 // CONVERT A TIMESTAMP TO THE mm/dd/yyyy hh:mm:ss format
31 $d = $odb_class->odb_utilities_obj->odb_parse_timestamp($odb_class->log_arr['timestamp']);
32
33 $this->sql = "
34 INSERT INTO `" . $odb_class->odb_logtable_name . "`
35 (
36 odb_timestamp,
37 odb_revisions,
38 odb_trash,
39 odb_spam,
40 odb_tags,
41 odb_transients,
42 odb_pingbacks,
43 odb_oembeds,
44 odb_orphans,
45 odb_tables,
46 odb_before,
47 odb_after,
48 odb_savings
49 )
50 VALUES
51 (
52 '" . $d . "',
53 ". $odb_class->log_arr['revisions'] . ",
54 ". $odb_class->log_arr['trash'] . ",
55 ". $odb_class->log_arr['spam'] . ",
56 ". $odb_class->log_arr['tags'] . ",
57 ". $odb_class->log_arr['transients'] . ",
58 ". $odb_class->log_arr['pingbacks'] . ",
59 ". $odb_class->log_arr['oembeds'] . ",
60 ". $odb_class->log_arr['orphans'] . ",
61 ". $odb_class->log_arr['tables'] . ",
62 '". $odb_class->log_arr['before'] . "',
63 '". $odb_class->log_arr['after'] . "',
64 '". $odb_class->log_arr['savings'] . "'
65 )
66 ";
67 $wpdb->get_results($this->sql);
68 } // if($odb_class->odb_rvg_options['logging_on'] == "Y")
69 } // odb_add_log()
70
71
72 /********************************************************************************************
73 * TRUNCATE THE LOG TABLE - v4.6
74 ********************************************************************************************/
75 function odb_clear_log() {
76 global $odb_class, $wpdb;
77
78 $this->sql = "
79 TRUNCATE TABLE `" . $odb_class->odb_logtable_name . "`
80 ";
81
82 $wpdb->get_results($this->sql);
83 } // clear_log()
84
85
86 /********************************************************************************************
87 * VIEW THE LOGS - v4.6.1
88 ********************************************************************************************/
89 function odb_view_log() {
90 global $odb_class, $wpdb;
91
92 $this->sql = "
93 SELECT * FROM `" . $odb_class->odb_logtable_name . "` ORDER BY odb_id ASC
94 ";
95 $this->res = $wpdb->get_results($this->sql, ARRAY_A);
96
97 $odb_class->odb_displayer_obj->display_header();
98 ?>
99 <div class="odb-title-bar">
100 <h2><?php _e('Logs','rvg-optimize-database')?></h2>
101 </div>
102 <br>
103 <br>
104 <div class="odb-log-table">
105 <table width="97%" border="0" cellspacing="6" cellpadding="0">
106 <?php
107
108 echo '
109 <tr valign="top">
110 ';
111
112 echo '<th align="left">'.__('date','rvg-optimize-database').'</th>';
113 echo '<th align="right">'.__('deleted<br>revisions','rvg-optimize-database').'</th>';
114 echo '<th align="right">'.__('deleted<br>trash','rvg-optimize-database').'</th>';
115 echo '<th align="right">'.__('deleted<br>spam','rvg-optimize-database').'</th>';
116 echo '<th align="right">'.__('deleted<br>tags','rvg-optimize-database').'</th>';
117 echo '<th align="right">'.__('deleted<br>transients','rvg-optimize-database').'</th>';
118 echo '<th align="right">'.__('deleted<br>pingbacks<br>trackbacks','rvg-optimize-database').'</th>';
119 echo '<th align="right">'.__('deleted<br>oEmbed<br>records','rvg-optimize-database').'</th>';
120 echo '<th align="right">'.__('deleted<br>orphans','rvg-optimize-database').'</th>';
121 echo '<th align="right">'.__('nr of<br>optimized<br>tables','rvg-optimize-database').'</th>';
122 echo '<th align="right">'.__('database<br> size<br>BEFORE','rvg-optimize-database').'</th>';
123 echo '<th align="right">'.__('database<br>size<br>AFTER','rvg-optimize-database').'</th>';
124 echo '<th align="right">'.__('SAVINGS','rvg-optimize-database').'</th>';
125 echo '
126 </tr>
127 ';
128
129 for($i = 0; $i < count($this->res); $i++) {
130 echo '
131 <tr valign="top">
132 ';
133 echo '<td>' . $this->res[$i]['odb_timestamp'] .'</td>';
134 echo '<td align="right">' . $this->res[$i]['odb_revisions'].'</td>';
135 echo '<td align="right">' . $this->res[$i]['odb_trash'].'</td>';
136 echo '<td align="right">' . $this->res[$i]['odb_spam'].'</td>';
137 echo '<td align="right">' . $this->res[$i]['odb_tags'].'</td>';
138 echo '<td align="right">' . $this->res[$i]['odb_transients'].'</td>';
139 echo '<td align="right">' . $this->res[$i]['odb_pingbacks'].'</td>';
140 echo '<td align="right">' . $this->res[$i]['odb_oembeds'].'</td>';
141 echo '<td align="right">' . $this->res[$i]['odb_orphans'].'</td>';
142 echo '<td align="right">' . $this->res[$i]['odb_tables'].'</td>';
143 echo '<td align="right">' . $this->res[$i]['odb_before'].'</td>';
144 echo '<td align="right">' . $this->res[$i]['odb_after'].'</td>';
145 echo '<td align="right">' . $this->res[$i]['odb_savings'].'</td>';
146 echo '
147 </tr>
148 ';
149 }
150
151 echo '
152 </table>
153 ';
154 // v4.6.2
155 $msg = str_replace("'", "\'", __('Clear the log?', 'rvg-optimize-database'));
156 ?>
157 <script>
158 function odb_confirm_delete() {
159 if(confirm('<?php echo $msg?>')) {
160 self.location = 'tools.php?page=rvg-optimize-database&action=clear_log'
161 return;
162 }
163 } // function odb_confirm_delete()
164 </script>
165 <br>
166 <input class="button odb-normal" type="button" name="change_options" value="<?php _e('Change Settings', 'rvg-optimize-database')?>" onclick="self.location='options-general.php?page=odb_settings_page'" />
167 &nbsp;
168 <input class="button odb-normal" type="button" name="clear_log" value="<?php _e('Clear Log', 'rvg-optimize-database') ?>" onclick="return odb_confirm_delete();" />
169 &nbsp;&nbsp;
170 <input class="button-primary button-large" type="button" name="optimize_summary" value="<?php _e('Optimize (summary)', 'rvg-optimize-database')?>" onclick="self.location='tools.php?page=rvg-optimize-database&action=run_summary'" class="odb-bold" />
171 &nbsp;
172 <input class="button-primary button-large" type="button" name="optimize_detail" value="<?php _e('Optimize (detail)', 'rvg-optimize-database')?>" onclick="self.location='tools.php?page=rvg-optimize-database&action=run_summary'" class="odb-bold" />
173 <?php
174 } // odb_view_log()
175
176
177 /********************************************************************************************
178 * GET THE NUMBER OF LOG RECORDS - v4.6
179 ********************************************************************************************/
180 function odb_log_count() {
181 global $odb_class, $wpdb;
182
183 $this->sql = "
184 SELECT COUNT(*) AS logcnt FROM `" . $odb_class->odb_logtable_name . "`
185 ";
186 $this->res = $wpdb->get_results($this->sql, ARRAY_A);
187 return $this->res[0]['logcnt'];
188 } // odb_log_count()
189
190 } // ODB_Logger
191
192
193
194