| @@ -5,53 +5,71 @@ | ||
| 5 | 5 | * |
| 6 | 6 | ************************************************************************************************/ |
| 7 | 7 | ?> |
| 8 | 8 | <?php |
| 9 | -class ODB_Cleaner | |
| 10 | -{ | |
| 9 | +class ODB_Cleaner { | |
| 11 | 10 | var $start_size; |
| 11 | + var $log_arr; | |
| 12 | 12 | var $nr_of_optimized_tables; |
| 13 | + var $grand_total = 0; | |
| 13 | 14 | |
| 14 | 15 | |
| 15 | 16 | /******************************************************************************************** |
| 17 | + * | |
| 16 | 18 | * CONSTRUCTOR |
| 17 | - ********************************************************************************************/ | |
| 18 | - function __construct() | |
| 19 | - { | |
| 19 | + * | |
| 20 | + ********************************************************************************************/ | |
| 21 | + function __construct() { | |
| 20 | 22 | } // __construct() |
| 21 | 23 | |
| 22 | 24 | |
| 23 | 25 | /******************************************************************************************** |
| 26 | + * | |
| 24 | 27 | * RUN CLEANER |
| 28 | + * | |
| 25 | 29 | ********************************************************************************************/ |
| 26 | - function odb_run_cleaner($scheduler) | |
| 27 | - { | |
| 30 | + function odb_run_cleaner($scheduler, $action = 'run_detail') { | |
| 28 | 31 | global $odb_class; |
| 29 | 32 | |
| 30 | - if(!$scheduler) | |
| 31 | - { | |
| 32 | - echo ' | |
| 33 | - <div id="odb-cleaner" class="odb-padding-left"> | |
| 34 | - <div class="odb-title-bar"> | |
| 35 | - <h2>'.__('Cleaning Database', $odb_class->odb_txt_domain).'</h2> | |
| 36 | - </div> | |
| 37 | - <br> | |
| 38 | - <br> | |
| 39 | - '; | |
| 40 | - } | |
| 41 | - | |
| 33 | + if(!$scheduler) { | |
| 34 | + if ($action == 'analyze_summary' || $action == 'analyze_detail') { | |
| 35 | + if ($action == 'analyze_summary') { | |
| 36 | + $txt = 'Analyzing (summary)'; | |
| 37 | + } else if ($action == 'analyze_detail') { | |
| 38 | + $txt = 'Analyzing (detail)'; | |
| 39 | + } | |
| 40 | + echo ' | |
| 41 | + <div id="odb-cleaner" class="odb-padding-left"> | |
| 42 | + <div class="odb-title-bar"> | |
| 43 | + <h2>'.__($txt, 'rvg-optimize-database').'</h2> | |
| 44 | + </div> | |
| 45 | + <br> | |
| 46 | + <br> | |
| 47 | + '; | |
| 48 | + } else { | |
| 49 | + echo ' | |
| 50 | + <div id="odb-cleaner" class="odb-padding-left"> | |
| 51 | + <div class="odb-title-bar"> | |
| 52 | + <h2>'.__('Cleaning Database', 'rvg-optimize-database').'</h2> | |
| 53 | + </div> | |
| 54 | + <br> | |
| 55 | + <br> | |
| 56 | + '; | |
| 57 | + } | |
| 58 | + } // if(!$scheduler) | |
| 59 | + | |
| 42 | 60 | // GET THE SIZE OF THE DATABASE BEFORE OPTIMIZATION |
| 43 | 61 | $this->start_size = $odb_class->odb_utilities_obj->odb_get_db_size(); |
| 44 | - | |
| 45 | - // TIMESTAMP FOR LOG FILE | |
| 62 | + | |
| 63 | + // TIMESTAMP FOR LOG FILE - v4.6 | |
| 46 | 64 | $ct = ($scheduler) ? ' (cron)' : ''; |
| 47 | - $current_datetime = Date('m/d/YH:i:s'); | |
| 48 | - $odb_class->log_arr = array("time" => substr($current_datetime, 0, 10).'<br>'.substr($current_datetime,10).$ct); | |
| 49 | 65 | |
| 66 | + $odb_class->log_arr["timestamp"] = current_time('YmdHis', 0); | |
| 50 | 67 | $odb_class->log_arr["after"] = 0; |
| 51 | 68 | $odb_class->log_arr["before"] = 0; |
| 69 | + $odb_class->log_arr["pingbacks"] = 0; | |
| 70 | + $odb_class->log_arr["oembeds"] = 0; | |
| 52 | 71 | $odb_class->log_arr["orphans"] = 0; |
| 53 | - $odb_class->log_arr["pingbacks"] = 0; | |
| 54 | 72 | $odb_class->log_arr["revisions"] = 0; |
| 55 | 73 | $odb_class->log_arr["savings"] = 0; |
| 56 | 74 | $odb_class->log_arr["spam"] = 0; |
| 57 | 75 | $odb_class->log_arr["tables"] = 0; |
| @@ -56,342 +74,751 @@ | ||
| 56 | 74 | $odb_class->log_arr["spam"] = 0; |
| 57 | 75 | $odb_class->log_arr["tables"] = 0; |
| 58 | 76 | $odb_class->log_arr["tags"] = 0; |
| 59 | 77 | $odb_class->log_arr["transients"] = 0; |
| 60 | - $odb_class->log_arr["trash"] = 0; | |
| 61 | - | |
| 78 | + $odb_class->log_arr["trash"] = 0; | |
| 79 | + | |
| 62 | 80 | /**************************************************************************************** |
| 81 | + * | |
| 63 | 82 | * DELETE REVISIONS |
| 83 | + * | |
| 64 | 84 | ****************************************************************************************/ |
| 65 | - | |
| 66 | - // FIND REVISIONS | |
| 67 | - $results = $this->odb_get_revisions(); | |
| 68 | - | |
| 69 | - $total_deleted = 0; | |
| 70 | - if(count($results)>0) | |
| 71 | - { // WE HAVE REVISIONS TO DELETE! | |
| 72 | - if(!$scheduler) | |
| 73 | - { | |
| 85 | + if($odb_class->odb_rvg_options['delete_older'] == 'Y' || $odb_class->odb_rvg_options['rvg_revisions'] == 'Y') { | |
| 86 | + | |
| 87 | + // FIND REVISIONS | |
| 88 | + $results_older_than = array(); | |
| 89 | + if($odb_class->odb_rvg_options['delete_older'] == 'Y') { | |
| 90 | + $results_older_than = $this->odb_get_revisions_older_than(); | |
| 91 | + } // if($odb_class->odb_rvg_options['delete_older'] == 'Y') | |
| 92 | + | |
| 93 | + $results_keep_revisions = array(); | |
| 94 | + if($odb_class->odb_rvg_options['rvg_revisions'] == 'Y') { | |
| 95 | + $results_keep_revisions = $this->odb_get_revisions_keep_revisions(); | |
| 96 | + } // if($odb_class->odb_rvg_options['rvg_revisions'] == 'Y') | |
| 97 | + | |
| 98 | + if (count($results_older_than) > 0 || count($results_keep_revisions) > 0) { | |
| 99 | + // REVISIONS FOUND | |
| 100 | + $this->grand_total += count($results_older_than) + count($results_keep_revisions); | |
| 101 | + | |
| 102 | + if ($action == 'analyze_summary') { | |
| 74 | 103 | ?> |
| 104 | + <div class="odb-found-number"> | |
| 105 | + <?php _e('REVISIONS found to delete: ', 'rvg-optimize-database');?> | |
| 106 | + <?php echo (count($results_older_than) + count($results_keep_revisions)) . '<br>';?> | |
| 107 | + </div> | |
| 108 | + <?php | |
| 109 | + } // if ($action == 'analyze_summary') | |
| 110 | + | |
| 111 | + if ($action == 'run_summary') { | |
| 112 | + ?> | |
| 113 | + <div class="odb-found-number"> | |
| 114 | + <?php _e('REVISIONS deleted: ', 'rvg-optimize-database');?> | |
| 115 | + <?php echo (count($results_older_than) + count($results_keep_revisions)) . '<br>';?> | |
| 116 | + </div> | |
| 117 | + <?php | |
| 118 | + } // if ($action == 'run_summary') | |
| 119 | + | |
| 120 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 121 | + // 'ANALYZE_DETAIL', 'RUN_SUMMARY' or 'RUN_DETAIL' | |
| 122 | + if ($action == 'analyze_detail') { | |
| 123 | + $msg1 = __('REVISIONS', 'rvg-optimize-database'); | |
| 124 | + $msg2 = __('total number of revisions', 'rvg-optimize-database'); | |
| 125 | + } else { | |
| 126 | + // 'RUN_SUMMARY' or 'RUN_DETAIL' | |
| 127 | + if ($action == 'run_detail') { | |
| 128 | + $msg1 = __('DELETED REVISIONS', 'rvg-optimize-database'); | |
| 129 | + $msg2 = __('total number of revisions deleted', 'rvg-optimize-database'); | |
| 130 | + } // if ($action == 'run_detail') | |
| 131 | + } // if ($action == 'analyze_detail') | |
| 132 | + ?> | |
| 75 | 133 | <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> |
| 76 | 134 | <tr> |
| 77 | 135 | <td colspan="4"><div class="odb-found"> |
| 78 | - <?php _e('DELETED REVISIONS','rvg-optimize-database');?> | |
| 136 | + <?php echo $msg1 ?> | |
| 79 | 137 | </div></td> |
| 80 | 138 | </tr> |
| 81 | 139 | <tr> |
| 82 | 140 | <th align="right" class="odb-border-bottom">#</th> |
| 83 | - <th align="left" class="odb-border-bottom"><?php _e('prefix', $odb_class->odb_txt_domain);?></th> | |
| 84 | - <th align="left" class="odb-border-bottom"><?php _e('post / page', $odb_class->odb_txt_domain);?></th> | |
| 85 | - <th align="left" class="odb-border-bottom"><?php _e('revision date', $odb_class->odb_txt_domain);?></th> | |
| 86 | - <th align="right" class="odb-border-bottom"><?php _e('revisions deleted', $odb_class->odb_txt_domain);?></th> | |
| 141 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 142 | + <th align="left" class="odb-border-bottom"><?php _e('post / page', 'rvg-optimize-database');?></th> | |
| 143 | + <th align="left" class="odb-border-bottom"><?php _e('revision date', 'rvg-optimize-database');?></th> | |
| 144 | + <th align="right" class="odb-border-bottom"><?php echo $msg2?></th> | |
| 87 | 145 | </tr> |
| 88 | 146 | <?php |
| 89 | - } // if(!$scheduler) | |
| 90 | - | |
| 91 | - // LOOP THROUGH THE REVISIONS AND DELETE THEM | |
| 92 | - $total_deleted = $this->odb_delete_revisions($results, $scheduler); | |
| 93 | - | |
| 94 | - if(!$scheduler) | |
| 95 | - { | |
| 96 | - ?> | |
| 147 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 148 | + | |
| 149 | + // LOOP THROUGH THE REVISIONS AND DELETE THEM | |
| 150 | + $total_deleted = $this->odb_delete_revisions($scheduler, $action); | |
| 151 | + | |
| 152 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 153 | +?> | |
| 97 | 154 | <tr> |
| 98 | - <td colspan="4" align="right" class="odb-border-top odb-bold"><?php _e('total number of revisions deleted', $odb_class->odb_txt_domain);?></td> | |
| 99 | - <td align="right" class="odb-border-top odb-bold"><?php echo $total_deleted?></td> | |
| 155 | + <td colspan="5" align="right" class="odb-border-top odb-bold"><?php echo $msg2 ?>: <?php echo $total_deleted?></td> | |
| 100 | 156 | </tr> |
| 101 | - </table> | |
| 102 | - <?php | |
| 103 | - } // if(!$scheduler) | |
| 104 | - } | |
| 105 | - else | |
| 106 | - { if(!$scheduler) | |
| 107 | - { | |
| 108 | - ?> | |
| 157 | + </table> | |
| 158 | +<?php | |
| 159 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 160 | + | |
| 161 | + if ($scheduler) $odb_class->log_arr["revisions"] = $total_deleted; | |
| 162 | + | |
| 163 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 164 | + // NUMBER OF DELETED REVISIONS FOR LOG FILE | |
| 165 | + $odb_class->log_arr["revisions"] = $total_deleted; | |
| 166 | + } // if ($action == 'analyze_detail' || $action == 'run_summary' || $action == 'run_detail') | |
| 167 | + } else { | |
| 168 | + // NO REVISIONS FOUND | |
| 169 | + if (!$scheduler) { | |
| 170 | +?> | |
| 109 | 171 | <div class="odb-not-found"> |
| 110 | - <?php _e('No REVISIONS found to delete', $odb_class->odb_txt_domain);?> | |
| 172 | + <?php _e('No REVISIONS found to delete', 'rvg-optimize-database');?> | |
| 111 | 173 | </div> |
| 112 | - <?php | |
| 113 | - } // if(!$scheduler) | |
| 114 | - } // if(count($results)>0) | |
| 115 | - | |
| 116 | - // NUMBER OF DELETED REVISIONS FOR LOG FILE | |
| 117 | - $odb_class->log_arr["revisions"] = $total_deleted; | |
| 118 | - | |
| 119 | - | |
| 174 | +<?php | |
| 175 | + } // if (!$scheduler) | |
| 176 | + } // if (count($results) > 0) | |
| 177 | + } // if($odb_class->odb_rvg_options['delete_older'] == 'Y' || $odb_class->odb_rvg_options['rvg_revisions'] == 'Y') | |
| 178 | + | |
| 179 | + | |
| 120 | 180 | /**************************************************************************************** |
| 181 | + * | |
| 121 | 182 | * DELETE TRASHED ITEMS |
| 183 | + * | |
| 122 | 184 | ****************************************************************************************/ |
| 123 | - if($odb_class->odb_rvg_options['clear_trash'] == 'Y') | |
| 124 | - { | |
| 125 | - // GET TRASHED POSTS / PAGES AND COMMENTS | |
| 185 | + if ($odb_class->odb_rvg_options['clear_trash'] == 'Y') { | |
| 126 | 186 | $results = $this->odb_get_trash(); |
| 127 | - | |
| 128 | - $total_deleted = 0; | |
| 129 | - if(count($results)>0) | |
| 130 | - { // WE HAVE TRASH TO DELETE! | |
| 131 | - if(!$scheduler) | |
| 132 | - { | |
| 187 | + if (count($results) > 0) { | |
| 188 | + // TRASHED ITEMS FOUNE | |
| 189 | + $this->grand_total += count($results); | |
| 190 | + | |
| 191 | + // TRASH FOUND | |
| 192 | + if ($action == 'analyze_summary') { | |
| 133 | 193 | ?> |
| 194 | + <div class="odb-found-number"> | |
| 195 | + <?php _e('TRASHED ITEMS found to delete: ', 'rvg-optimize-database');?> | |
| 196 | + <?php echo count($results) . '<br>';?> | |
| 197 | + </div> | |
| 198 | + <?php | |
| 199 | + } // if ($action == 'analyze_summary') | |
| 200 | + | |
| 201 | + if ($action == 'run_summary') { | |
| 202 | + ?> | |
| 203 | + <div class="odb-found-number"> | |
| 204 | + <?php _e('TRASHED ITEMS deleted: ', 'rvg-optimize-database');?> | |
| 205 | + <?php echo count($results) . '<br>';?> | |
| 206 | + </div> | |
| 207 | + <?php | |
| 208 | + } // if ($action == 'run_summary') | |
| 209 | + | |
| 210 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 211 | + // 'RUN' or 'ANALYZE_DETAIL | |
| 212 | + if ($action == 'analyze_detail') { | |
| 213 | + $msg1 = __('TRASHED ITEMS', 'rvg-optimize-database'); | |
| 214 | + $msg2 = __('total number of trashed items', 'rvg-optimize-database'); | |
| 215 | + } else { | |
| 216 | + // ACTION = 'RUN_DETAIL' | |
| 217 | + $msg1 = __('DELETED TRASHED ITEMS', 'rvg-optimize-database'); | |
| 218 | + $msg2 = __('total number of trashed items deleted', 'rvg-optimize-database'); | |
| 219 | + } // if ($action == 'analyze_detail') | |
| 220 | + ?> | |
| 134 | 221 | <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> |
| 135 | 222 | <tr> |
| 136 | 223 | <td colspan="4"><div class="odb-found"> |
| 137 | - <?php _e('DELETED TRASHED ITEMS', $odb_class->odb_txt_domain);?> | |
| 224 | + <?php echo $msg1 ?> | |
| 138 | 225 | </div></td> |
| 139 | 226 | </tr> |
| 140 | 227 | <tr> |
| 141 | 228 | <th align="right" class="odb-border-bottom">#</th> |
| 142 | - <th align="left" class="odb-border-bottom"><?php _e('prefix', $odb_class->odb_txt_domain);?></th> | |
| 143 | - <th align="left" class="odb-border-bottom"><?php _e('type', $odb_class->odb_txt_domain);?></th> | |
| 144 | - <th align="left" class="odb-border-bottom"><?php _e('IP address / title', $odb_class->odb_txt_domain);?></th> | |
| 145 | - <th align="left" nowrap="nowrap" class="odb-border-bottom"><?php _e('date', $odb_class->odb_txt_domain);?></th> | |
| 229 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 230 | + <th align="left" class="odb-border-bottom"><?php _e('type', 'rvg-optimize-database');?></th> | |
| 231 | + <th align="left" class="odb-border-bottom"><?php _e('IP address / title', 'rvg-optimize-database');?></th> | |
| 232 | + <th align="left" nowrap="nowrap" class="odb-border-bottom"><?php _e('date', 'rvg-optimize-database');?></th> | |
| 146 | 233 | </tr> |
| 147 | 234 | <?php |
| 148 | - } // if(!$scheduler) | |
| 149 | - | |
| 235 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 236 | + | |
| 150 | 237 | // LOOP THROUGH THE TRASHED ITEMS AND DELETE THEM |
| 151 | - $total_deleted = $this->odb_delete_trash($results, $scheduler); | |
| 152 | - | |
| 153 | - if(!$scheduler) | |
| 154 | - { | |
| 155 | - ?> | |
| 156 | - <tr> | |
| 157 | - <td colspan="4" align="right" class="odb-border-top odb-bold"><?php _e('total number of trashed items deleted', $odb_class->odb_txt_domain);?></td> | |
| 158 | - <td align="right" class="odb-border-top odb-bold"><?php echo $total_deleted?></td> | |
| 159 | - </tr> | |
| 160 | - </table> | |
| 161 | - <?php | |
| 162 | - } // if(!$scheduler) | |
| 163 | - } | |
| 164 | - else | |
| 165 | - { | |
| 166 | - if(!$scheduler) | |
| 167 | - { | |
| 168 | - ?> | |
| 238 | + $total_deleted = $this->odb_delete_trash($results, $scheduler, $action); | |
| 239 | + | |
| 240 | + if ($scheduler) $odb_class->log_arr["trash"] = $total_deleted; | |
| 241 | + | |
| 242 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 243 | + // NUMBER OF DELETED TRASH FOR LOG FILE | |
| 244 | + $odb_class->log_arr["trash"] = $total_deleted; | |
| 245 | + } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail')) | |
| 246 | + | |
| 247 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 248 | +?> | |
| 249 | + </table> | |
| 250 | +<?php | |
| 251 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 252 | + } else { | |
| 253 | + // NO TRASH FOUND | |
| 254 | + if (!$scheduler) { | |
| 255 | +?> | |
| 169 | 256 | <div class="odb-not-found"> |
| 170 | - <?php _e('No TRASHED ITEMS found to delete', $odb_class->odb_txt_domain);?> | |
| 257 | + <?php _e('No TRASHED ITEMS found to delete', 'rvg-optimize-database');?> | |
| 171 | 258 | </div> |
| 172 | - <?php | |
| 173 | - } // if(!$scheduler) | |
| 174 | - } // if(count($results)>0) | |
| 175 | - | |
| 176 | - // NUMBER OF DELETED TRASH FOR LOG FILE | |
| 177 | - $odb_class->log_arr["trash"] = $total_deleted; | |
| 259 | +<?php | |
| 260 | + } // if (!$scheduler) | |
| 261 | + } // if (count($results) > 0) | |
| 178 | 262 | } // if($odb_class->odb_rvg_options['clear_trash'] == 'Y') |
| 179 | - | |
| 180 | - | |
| 263 | + | |
| 264 | + | |
| 181 | 265 | /**************************************************************************************** |
| 266 | + * | |
| 182 | 267 | * DELETE SPAMMED ITEMS |
| 268 | + * | |
| 183 | 269 | ****************************************************************************************/ |
| 184 | - if($odb_class->odb_rvg_options['clear_spam'] == 'Y') | |
| 185 | - { | |
| 186 | - // GET SPAMMED COMMENTS | |
| 187 | - $results = $this->odb_get_spam(); | |
| 188 | - | |
| 189 | - $total_deleted = 0; | |
| 190 | - if(count($results)>0) | |
| 191 | - { // WE HAVE SPAM TO DELETE! | |
| 192 | - if (!$scheduler) | |
| 193 | - { | |
| 270 | + if ($odb_class->odb_rvg_options['clear_spam'] == 'Y') { | |
| 271 | + $results = $this->odb_get_spam(); | |
| 272 | + | |
| 273 | + if (count($results) > 0) { | |
| 274 | + // SPAM FOUND | |
| 275 | + $this->grand_total += count($results); | |
| 276 | + | |
| 277 | + if ($action == 'analyze_summary') { | |
| 194 | 278 | ?> |
| 279 | + <div class="odb-found-number"> | |
| 280 | + <?php _e('SPAMMED ITEMS found to delete: ', 'rvg-optimize-database');?> | |
| 281 | + <?php echo count($results) . '<br>';?> | |
| 282 | + </div> | |
| 283 | + <?php | |
| 284 | + } // if ($action == 'analyze_summary') | |
| 285 | + | |
| 286 | + if ($action == 'run_summary') { | |
| 287 | + ?> | |
| 288 | + <div class="odb-found-number"> | |
| 289 | + <?php _e('SPAMMED ITEMS deleted: ', 'rvg-optimize-database');?> | |
| 290 | + <?php echo count($results) . '<br>';?> | |
| 291 | + </div> | |
| 292 | + <?php | |
| 293 | + } // if ($action == 'run_summary') | |
| 294 | + | |
| 295 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 296 | + if ($action == 'analyze_detail') { | |
| 297 | + $msg1 = __('SPAMMED ITEMS', 'rvg-optimize-database'); | |
| 298 | + $msg2 = __('total number of spammed items', 'rvg-optimize-database'); | |
| 299 | + } // if ($action == 'analyze_detail') | |
| 300 | + | |
| 301 | + if ($action == 'run_detail') { | |
| 302 | + $msg1 = __('DELETED SPAMMED ITEMS', 'rvg-optimize-database'); | |
| 303 | + $msg2 = __('total number of spammed items deleted', 'rvg-optimize-database'); | |
| 304 | + } // if ($action == 'run_detail') | |
| 305 | + ?> | |
| 195 | 306 | <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> |
| 196 | 307 | <tr> |
| 197 | 308 | <td colspan="4"><div class="odb-found"> |
| 198 | - <?php _e('DELETEED SPAMMED ITEMS', $odb_class->odb_txt_domain);?> | |
| 309 | + <?php echo $msg1 ?> | |
| 199 | 310 | </div></td> |
| 200 | 311 | </tr> |
| 201 | 312 | <tr> |
| 202 | 313 | <th align="right" class="odb-border-bottom">#</th> |
| 203 | - <th align="left" class="odb-border-bottom"><?php _e('prefix', $odb_class->odb_txt_domain);?></th> | |
| 204 | - <th align="left" class="odb-border-bottom"><?php _e('comment author', $odb_class->odb_txt_domain);?></th> | |
| 205 | - <th align="left" class="odb-border-bottom"><?php _e('comment author email', $odb_class->odb_txt_domain);?></th> | |
| 206 | - <th align="left" nowrap="nowrap" class="odb-border-bottom"><?php _e('comment date', $odb_class->odb_txt_domain);?></th> | |
| 314 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 315 | + <th align="left" class="odb-border-bottom"><?php _e('comment author', 'rvg-optimize-database');?></th> | |
| 316 | + <th align="left" class="odb-border-bottom"><?php _e('comment author email', 'rvg-optimize-database');?></th> | |
| 317 | + <th align="left" nowrap="nowrap" class="odb-border-bottom"><?php _e('comment date', 'rvg-optimize-database');?></th> | |
| 207 | 318 | </tr> |
| 208 | 319 | <?php |
| 320 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 321 | + | |
| 322 | + // LOOP THROUGH THE SPAMMED ITEMS AND DELETE THEM | |
| 323 | + $total_deleted = $this->odb_delete_spam($results, $scheduler, $action); | |
| 324 | + | |
| 325 | + if ($scheduler) $odb_class->log_arr["spam"] = $total_deleted; | |
| 326 | + | |
| 327 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 328 | + // NUMBER OF DELETED SPAM FOR LOG FILE | |
| 329 | + $odb_class->log_arr["spam"] = $total_deleted; | |
| 330 | + } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail')) | |
| 331 | + | |
| 332 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 333 | +?> | |
| 334 | + </table> | |
| 335 | +<?php | |
| 336 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 337 | + } else { | |
| 338 | + // NO SPAM FOUND | |
| 339 | + if (!$scheduler) { | |
| 340 | +?> | |
| 341 | + <div class="odb-not-found"> | |
| 342 | + <?php _e('No SPAMMED ITEMS found to delete', 'rvg-optimize-database');?> | |
| 343 | + </div> | |
| 344 | +<?php | |
| 209 | 345 | } // if (!$scheduler) |
| 210 | - | |
| 211 | - // LOOP THROUGH SPAMMED ITEMS AND DELETE THEM | |
| 212 | - $total_deleted = $this->odb_delete_spam($results, $scheduler); | |
| 213 | - | |
| 214 | - if (!$scheduler) | |
| 215 | - { | |
| 346 | + } // if (count($results) > 0) | |
| 347 | + } // if ($odb_class->odb_rvg_options['clear_spam'] == 'Y') | |
| 348 | + | |
| 349 | + | |
| 350 | + /**************************************************************************************** | |
| 351 | + * | |
| 352 | + * DELETE UNUSED TAGS | |
| 353 | + * | |
| 354 | + ****************************************************************************************/ | |
| 355 | + if ($odb_class->odb_rvg_options['clear_tags'] == 'Y') { | |
| 356 | + // GET UNUSED TAGS | |
| 357 | + $results = $this->odb_get_unused_tags(); | |
| 358 | + | |
| 359 | + if (count($results) > 0) { | |
| 360 | + // UNUSED TAGS FOUND | |
| 361 | + $this->grand_total += count($results); | |
| 362 | + | |
| 363 | + if ($action == 'analyze_summary' || $action == 'run_summary') { | |
| 364 | + if ($action == 'analyze_summary') { | |
| 216 | 365 | ?> |
| 366 | + <div class="odb-found-number"> | |
| 367 | + <?php _e('UNUSED TAGS found to delete: ', 'rvg-optimize-database');?> | |
| 368 | + <?php echo count($results) . '<br>';?> | |
| 369 | + </div> | |
| 370 | + <?php | |
| 371 | + } // if ($action == 'analyze_summary') | |
| 372 | + | |
| 373 | + if ($action == 'run_summary') { | |
| 374 | + ?> | |
| 375 | + <div class="odb-found-number"> | |
| 376 | + <?php _e('UNUSED TAGS deleted: ', 'rvg-optimize-database');?> | |
| 377 | + <?php echo count($results) . '<br>';?> | |
| 378 | + </div> | |
| 379 | + <?php | |
| 380 | + } // if ($action == 'run_summary') | |
| 381 | + } // if ($action == 'analyze_summary' || $action == 'run_summary') | |
| 382 | + | |
| 383 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 384 | + if ($action == 'analyze_detail') { | |
| 385 | + $msg1 = __('UNUSED TAGS', 'rvg-optimize-database'); | |
| 386 | + $msg2 = __('total number of unused tags', 'rvg-optimize-database'); | |
| 387 | + } else { | |
| 388 | + // ACTION = 'RUN_detail' | |
| 389 | + $msg1 = __('DELETED UNUSED TAGS', 'rvg-optimize-database'); | |
| 390 | + $msg2 = __('total number of unused tags deleted', 'rvg-optimize-database'); | |
| 391 | + } // if ($action == 'analyze_detail') | |
| 392 | + ?> | |
| 393 | + <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> | |
| 217 | 394 | <tr> |
| 218 | - <td colspan="4" align="right" class="odb-border-top odb-bold"><?php _e('total number of spammed items deleted', $odb_class->odb_txt_domain);?></td> | |
| 219 | - <td align="right" class="odb-border-top odb-bold"><?php echo $total_deleted?></td> | |
| 395 | + <td colspan="4"><div class="odb-found"> | |
| 396 | + <?php echo $msg1 ?> | |
| 397 | + </div></td> | |
| 220 | 398 | </tr> |
| 221 | - </table> | |
| 222 | - <?php | |
| 223 | - } // if (!$scheduler) | |
| 224 | - } | |
| 225 | - else | |
| 226 | - { | |
| 227 | - if (!$scheduler) | |
| 228 | - { | |
| 229 | - ?> | |
| 399 | + <tr> | |
| 400 | + <th align="right" class="odb-border-bottom">#</th> | |
| 401 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 402 | + <th align="left" class="odb-border-bottom"><?php _e('tag', 'rvg-optimize-database');?></th> | |
| 403 | + </tr> | |
| 404 | + <?php | |
| 405 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 406 | + | |
| 407 | + // LOOP THROUGH THE UNUSED TAGS AND DELETE THEM | |
| 408 | + $total_deleted = $this->odb_delete_unused_tags($results, $scheduler, $action); | |
| 409 | + | |
| 410 | + if ($scheduler) $odb_class->log_arr["tags"] = $total_deleted; | |
| 411 | + | |
| 412 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 413 | + // NUMBER OF UNUSED TAGS FOR LOG FILE | |
| 414 | + $odb_class->log_arr["tags"] = $total_deleted; | |
| 415 | + } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail')) | |
| 416 | + | |
| 417 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 418 | +?> | |
| 419 | + </table> | |
| 420 | +<?php | |
| 421 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 422 | + } else { | |
| 423 | + // NO UNUSED TAGS FOUND | |
| 424 | + if (!$scheduler) { | |
| 425 | +?> | |
| 230 | 426 | <div class="odb-not-found"> |
| 231 | - <?php _e('No SPAMMED ITEMS found to delete', $odb_class->odb_txt_domain);?> | |
| 427 | + <?php _e('No UNUSED TAGS found to delete', 'rvg-optimize-database');?> | |
| 232 | 428 | </div> |
| 233 | - <?php | |
| 429 | +<?php | |
| 234 | 430 | } // if (!$scheduler) |
| 235 | - } // if(count($results)>0) | |
| 236 | - | |
| 237 | - } // if($odb_class->odb_rvg_options['clear_spam'] == 'Y') | |
| 238 | - | |
| 239 | - // NUMBER OF SPAM DELETED FOR LOG FILE | |
| 240 | - $odb_class->log_arr["spam"] = $total_deleted; | |
| 241 | - | |
| 242 | - | |
| 431 | + } // if (count($results) > 0) | |
| 432 | + } // if ($odb_class->odb_rvg_options['clear_tags'] == 'Y') | |
| 433 | + | |
| 434 | + | |
| 243 | 435 | /**************************************************************************************** |
| 244 | - * DELETE UNUSED TAGS | |
| 436 | + * | |
| 437 | + * DELETE TRANSIENTS | |
| 438 | + * | |
| 245 | 439 | ****************************************************************************************/ |
| 246 | - if($odb_class->odb_rvg_options['clear_tags'] == 'Y') | |
| 247 | - { | |
| 248 | - // DELETE UNUSED TAGS | |
| 249 | - $total_deleted = $this->odb_delete_tags(); | |
| 250 | - if($total_deleted>0) | |
| 251 | - { // TAGS DELETED | |
| 252 | - if (!$scheduler) | |
| 253 | - { | |
| 440 | + if ($odb_class->odb_rvg_options['clear_transients'] !== 'N') { | |
| 441 | + | |
| 442 | + if ($odb_class->odb_rvg_options['clear_transients'] == 'Y') { | |
| 443 | + $type = 'EXPIRED'; | |
| 444 | + $typeLc = 'expired'; | |
| 445 | + $option = 'Y'; | |
| 446 | + } else { | |
| 447 | + $type = ''; | |
| 448 | + $typeLc = ''; | |
| 449 | + $option = 'A'; | |
| 450 | + } | |
| 451 | + | |
| 452 | + $results = $this->odb_get_transients($option); | |
| 453 | + | |
| 454 | + if (count($results) > 0) { | |
| 455 | + // TRANSIENTS FOUND | |
| 456 | + $this->grand_total += count($results); | |
| 457 | + | |
| 458 | + if ($action == 'analyze_summary' || $action == 'run_summary') { | |
| 459 | + if ($action == 'analyze_summary') { | |
| 254 | 460 | ?> |
| 255 | - <div class="odb-found-number"> | |
| 256 | - <?php _e('NUMBER OF UNUSED TAGS DELETED', $odb_class->odb_txt_domain);?>: <span class="odb-blue"><?php echo $total_deleted;?></span> </div> | |
| 461 | + <div class="odb-found-number"> | |
| 462 | + <?php _e($type . ' TRANSIENTS found to delete: ', 'rvg-optimize-database');?> | |
| 463 | + <?php echo count($results) . '<br>';?> | |
| 464 | + </div> | |
| 257 | 465 | <?php |
| 258 | - } // if (!$scheduler) | |
| 259 | - } | |
| 260 | - else | |
| 261 | - { | |
| 262 | - if (!$scheduler) | |
| 263 | - { | |
| 466 | + } // if ($action == 'analyze_summary') | |
| 467 | + | |
| 468 | + if ($action == 'run_summary') { | |
| 264 | 469 | ?> |
| 470 | + <div class="odb-found-number"> | |
| 471 | + <?php _e($type . ' TRANSIENTS deleted: ', 'rvg-optimize-database');?> | |
| 472 | + <?php echo count($results) . '<br>';?> | |
| 473 | + </div> | |
| 474 | + <?php | |
| 475 | + } // if ($action == 'run_summary') | |
| 476 | + } // if ($action == 'analyze_summary' || $action == 'run_summary') | |
| 477 | + | |
| 478 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 479 | + // 'RUN' or 'ANALYZE_DETAIL | |
| 480 | + if ($action == 'analyze_detail') { | |
| 481 | + $msg1 = __($type . ' TRANSIENTS', 'rvg-optimize-database'); | |
| 482 | + $msg2 = __('total number of ' . $typeLc . ' transients', 'rvg-optimize-database'); | |
| 483 | + } else { | |
| 484 | + // ACTION = 'RUN_DETAIL' | |
| 485 | + $msg1 = __('DELETED ' . $type . ' TRANSIENTS', 'rvg-optimize-database'); | |
| 486 | + $msg2 = __('total number of ' . $typeLc . ' deleted', 'rvg-optimize-database'); | |
| 487 | + } // if ($action == 'analyze_detail') | |
| 488 | + ?> | |
| 489 | + <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> | |
| 490 | + <tr> | |
| 491 | + <td colspan="4"><div class="odb-found"> | |
| 492 | + <?php echo $msg1 ?> | |
| 493 | + </div></td> | |
| 494 | + </tr> | |
| 495 | + <tr> | |
| 496 | + <th align="right" class="odb-border-bottom">#</th> | |
| 497 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 498 | + <th align="left" class="odb-border-bottom"><?php _e('option name', 'rvg-optimize-database');?></th> | |
| 499 | + </tr> | |
| 500 | + <?php | |
| 501 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 502 | + | |
| 503 | + // LOOP THROUGH THE TRANSIENTS AND DELETE THEM | |
| 504 | + $total_deleted = $this->odb_delete_transients($results, $scheduler, $action, $option); | |
| 505 | + | |
| 506 | + if ($scheduler) $odb_class->log_arr["transients"] = $total_deleted; | |
| 507 | + | |
| 508 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 509 | + // NUMBER OF DELETED SPAM FOR LOG FILE | |
| 510 | + $odb_class->log_arr["transients"] = $total_deleted; | |
| 511 | + } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail')) | |
| 512 | + | |
| 513 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 514 | +?> | |
| 515 | + </table> | |
| 516 | +<?php | |
| 517 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 518 | + } else { | |
| 519 | + // NO TRANSIENTS FOUND | |
| 520 | + if (!$scheduler) { | |
| 521 | + if ($option == 'Y') { | |
| 522 | + $msg = 'No EXPIRED TRANSIENTS found to delete'; | |
| 523 | + } else { | |
| 524 | + $msg = 'No TRANSIENTS found to delete'; | |
| 525 | + } // if ($option == 'Y') | |
| 526 | +?> | |
| 265 | 527 | <div class="odb-not-found"> |
| 266 | - <?php _e('No UNUSED TAGS found to delete', $odb_class->odb_txt_domain);?> | |
| 528 | + <?php _e($msg, 'rvg-optimize-database');?> | |
| 267 | 529 | </div> |
| 268 | - <?php | |
| 530 | +<?php | |
| 269 | 531 | } // if (!$scheduler) |
| 270 | - } // if(count($results)>0) | |
| 271 | - } // if($odb_class->odb_rvg_options['clear_tags'] == 'Y') | |
| 272 | - | |
| 273 | - // NUMBER OF tags DELETED FOR LOG FILE | |
| 274 | - $odb_class->log_arr["tags"] = $total_deleted; | |
| 275 | - | |
| 276 | - | |
| 532 | + } // if (count($results) > 0) | |
| 533 | + } // if ($odb_class->odb_rvg_options['clear_transients'] !== 'N') | |
| 534 | + | |
| 535 | + | |
| 277 | 536 | /**************************************************************************************** |
| 278 | - * DELETE EXPIRED TRANSIENTS | |
| 537 | + * | |
| 538 | + * DELETE PINGBACKS AND TRACKBACKS | |
| 539 | + * | |
| 279 | 540 | ****************************************************************************************/ |
| 280 | - if($odb_class->odb_rvg_options['clear_transients'] == 'Y') | |
| 281 | - { | |
| 282 | - // DELETE UNUSED TAGS | |
| 283 | - $total_deleted = $this->odb_delete_transients(); | |
| 284 | - if($total_deleted>0) | |
| 285 | - { // TRANSIENTS DELETED | |
| 286 | - if (!$scheduler) | |
| 287 | - { | |
| 541 | + if ($odb_class->odb_rvg_options['clear_pingbacks'] == 'Y') { | |
| 542 | + // GET PINGBACKS AND TRACKBACKS | |
| 543 | + $results = $this->odb_get_pingbacks(); | |
| 544 | + | |
| 545 | + if (count($results) > 0) { | |
| 546 | + // PINGBACKS AND/OR TRACKBACKS FOUND FOUND | |
| 547 | + $this->grand_total += count($results); | |
| 548 | + | |
| 549 | + if ($action == 'analyze_summary' || $action == 'run_summary') { | |
| 550 | + if ($action == 'analyze_summary') { | |
| 288 | 551 | ?> |
| 289 | - <div class="odb-found-number"> | |
| 290 | - <?php _e('NUMBER OF EXPIRED TRANSIENTS DELETED', $odb_class->odb_txt_domain);?>: <span class="odb-blue"><?php echo $total_deleted;?></span> </div> | |
| 552 | + <div class="odb-found-number"> | |
| 553 | + <?php _e('PINGBACKS AND/OR TRACKBACKS found to delete: ', 'rvg-optimize-database');?> | |
| 554 | + <?php echo count($results) . '<br>';?> | |
| 555 | + </div> | |
| 291 | 556 | <?php |
| 292 | - } // if (!$scheduler) | |
| 293 | - } | |
| 294 | - else | |
| 295 | - { | |
| 296 | - if (!$scheduler) | |
| 297 | - { | |
| 557 | + } // if ($action == 'analyze_summary') | |
| 558 | + | |
| 559 | + if ($action == 'run_summary') { | |
| 298 | 560 | ?> |
| 561 | + <div class="odb-found-number"> | |
| 562 | + <?php _e('PINGBACKS AND/OR TRACKBACKS deleted: ', 'rvg-optimize-database');?> | |
| 563 | + <?php echo count($results) . '<br>';?> | |
| 564 | + </div> | |
| 565 | + <?php | |
| 566 | + } // if ($action == 'run_summary') | |
| 567 | + } // if ($action == 'analyze_summary' || $action == 'run_summary') | |
| 568 | + | |
| 569 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 570 | + if ($action == 'analyze_detail') { | |
| 571 | + $msg1 = __('PINGBACKS AND TRACKBACKS', 'rvg-optimize-database'); | |
| 572 | + $msg2 = __('total number of pingbacks and trackbacks', 'rvg-optimize-database'); | |
| 573 | + } else { | |
| 574 | + // ACTION = 'RUN' | |
| 575 | + $msg1 = __('DELETED PINGBACKS AND TRACKBACKS', 'rvg-optimize-database'); | |
| 576 | + $msg2 = __('total number of pingbacks and trackbacks deleted', 'rvg-optimize-database'); | |
| 577 | + } // if ($action == 'analyze_detail') | |
| 578 | + ?> | |
| 579 | + <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> | |
| 580 | + <tr> | |
| 581 | + <td colspan="4"><div class="odb-found"> | |
| 582 | + <?php echo $msg1 ?> | |
| 583 | + </div></td> | |
| 584 | + </tr> | |
| 585 | + <tr> | |
| 586 | + <th align="right" class="odb-border-bottom">#</th> | |
| 587 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 588 | + <th align="left" class="odb-border-bottom"><?php _e('type', 'rvg-optimize-database');?></th> | |
| 589 | + <th align="left" class="odb-border-bottom"><?php _e('comment_author', 'rvg-optimize-database');?></th> | |
| 590 | + <th align="left" nowrap="nowrap" class="odb-border-bottom"><?php _e('date', 'rvg-optimize-database');?></th> | |
| 591 | + </tr> | |
| 592 | + <?php | |
| 593 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 594 | + | |
| 595 | + // LOOP THROUGH THE PINGBACKS AND TRACKBACKS AND DELETE THEM | |
| 596 | + $total_deleted = $this->odb_delete_pingbacks($results, $scheduler, $action); | |
| 597 | + | |
| 598 | + if ($scheduler) $odb_class->log_arr["pingbacks"] = $total_deleted; | |
| 599 | + | |
| 600 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 601 | + // NUMBER OF DELETED PINGBACKS AND TRACKBACKS FOR LOG FILE | |
| 602 | + $odb_class->log_arr["pingbacks"] = $total_deleted; | |
| 603 | + } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail')) | |
| 604 | + | |
| 605 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 606 | +?> | |
| 607 | + </table> | |
| 608 | +<?php | |
| 609 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 610 | + | |
| 611 | + } else { | |
| 612 | + // NO PINGBACKS NOR TRACKBACKS FOUND | |
| 613 | + if (!$scheduler) { | |
| 614 | +?> | |
| 299 | 615 | <div class="odb-not-found"> |
| 300 | - <?php _e('No EXPIRED TRANSIENTS found to delete', $odb_class->odb_txt_domain);?> | |
| 616 | + <?php _e('No PINGBACKS nor TRACKBACKS found to delete', 'rvg-optimize-database');?> | |
| 301 | 617 | </div> |
| 302 | - <?php | |
| 618 | +<?php | |
| 303 | 619 | } // if (!$scheduler) |
| 304 | - } // if(count($results)>0) | |
| 305 | - } // if($odb_class->odb_rvg_options['clear_transients'] == 'Y') | |
| 306 | - | |
| 307 | - // NUMBER OF transients DELETED FOR LOG FILE | |
| 308 | - $odb_class->log_arr["transients"] = $total_deleted; | |
| 309 | - | |
| 310 | - | |
| 620 | + } // if (count($results) > 0) | |
| 621 | + } // if ($odb_class->odb_rvg_options['clear_pingbacks'] == 'Y') | |
| 622 | + | |
| 623 | + | |
| 311 | 624 | /**************************************************************************************** |
| 312 | - * DELETE PINGBACKS AND TRACKBACKS | |
| 313 | - ****************************************************************************************/ | |
| 314 | - if($odb_class->odb_rvg_options['clear_pingbacks'] == 'Y') | |
| 315 | - { | |
| 316 | - // DELETE UNUSED TAGS | |
| 317 | - $total_deleted = $this->odb_delete_pingbacks(); | |
| 318 | - if($total_deleted>0) | |
| 319 | - { // PINGBACKS / TRACKBACKS DELETED\ | |
| 320 | - if (!$scheduler) | |
| 321 | - { | |
| 625 | + * | |
| 626 | + * DELETE OEMBED CACHE | |
| 627 | + * | |
| 628 | + ****************************************************************************************/ | |
| 629 | + if ($odb_class->odb_rvg_options['clear_oembed'] == 'Y') { | |
| 630 | + | |
| 631 | + // GET OEMBED CACHE | |
| 632 | + $results = $this->odb_get_oembed(); | |
| 633 | + | |
| 634 | + if (count($results) > 0) { | |
| 635 | + // OEMBED CACHE FOUND | |
| 636 | + $this->grand_total += count($results); | |
| 637 | + | |
| 638 | + if ($action == 'analyze_summary' || $action == 'run_summary') { | |
| 639 | + if ($action == 'analyze_summary') { | |
| 322 | 640 | ?> |
| 323 | - <div class="odb-found-number"> | |
| 324 | - <?php _e('NUMBER OF PINGBACKS AND TRACKBACKS DELETED', $odb_class->odb_txt_domain);?>: <span class="odb-blue"><?php echo $total_deleted;?></span> </div> | |
| 641 | + <div class="odb-found-number"> | |
| 642 | + <?php _e('OEMBED CACHE ITEMS found to delete: ', 'rvg-optimize-database');?> | |
| 643 | + <?php echo count($results) . '<br>';?> | |
| 644 | + </div> | |
| 325 | 645 | <?php |
| 326 | - } // if (!$scheduler) | |
| 327 | - } | |
| 328 | - else | |
| 329 | - { | |
| 330 | - if (!$scheduler) | |
| 331 | - { | |
| 646 | + } // if ($action == 'analyze_summary') | |
| 647 | + | |
| 648 | + if ($action == 'run_summary') { | |
| 332 | 649 | ?> |
| 650 | + <div class="odb-found-number"> | |
| 651 | + <?php _e('OEMBED CACHE ITEMS deleted: ', 'rvg-optimize-database');?> | |
| 652 | + <?php echo count($results) . '<br>';?> | |
| 653 | + </div> | |
| 654 | + <?php | |
| 655 | + } // if ($action == 'run_summary') | |
| 656 | + } // if ($action == 'analyze_summary' || $action == 'run_summary') | |
| 657 | + | |
| 658 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 659 | + if ($action == 'analyze_detail') { | |
| 660 | + $msg1 = __('OEMBED CACHE items', 'rvg-optimize-database'); | |
| 661 | + $msg2 = __('total number of oembed cache items', 'rvg-optimize-database'); | |
| 662 | + } else { | |
| 663 | + // ACTION = 'RUN' | |
| 664 | + $msg1 = __('DELETED OEMBED CACHE ITEMS', 'rvg-optimize-database'); | |
| 665 | + $msg2 = __('total number of oembed cache items deleted', 'rvg-optimize-database'); | |
| 666 | + } // if ($action == 'analyze_detail') | |
| 667 | + ?> | |
| 668 | + <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> | |
| 669 | + <tr> | |
| 670 | + <td colspan="4"><div class="odb-found"> | |
| 671 | + <?php echo $msg1 ?> | |
| 672 | + </div></td> | |
| 673 | + </tr> | |
| 674 | + <tr> | |
| 675 | + <th align="right" class="odb-border-bottom">#</th> | |
| 676 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 677 | + <th align="left" class="odb-border-bottom"><?php _e('meta key', 'rvg-optimize-database');?></th> | |
| 678 | + <th align="left" class="odb-border-bottom"><?php _e('meta value', 'rvg-optimize-database');?></th> | |
| 679 | + </tr> | |
| 680 | + <?php | |
| 681 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 682 | + | |
| 683 | + // LOOP THROUGH THE OEMBEDS | |
| 684 | + $total_deleted = $this->odb_delete_oembed($results, $scheduler, $action); | |
| 685 | + | |
| 686 | + if ($scheduler) $odb_class->log_arr["oembeds"] = $total_deleted; | |
| 687 | + | |
| 688 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 689 | + // NUMBER OF OEMBED CACHE ITEMS FOR LOG FILE | |
| 690 | + $odb_class->log_arr["oembeds"] = $total_deleted; | |
| 691 | + } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail') | |
| 692 | + | |
| 693 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 694 | +?> | |
| 695 | + </table> | |
| 696 | +<?php | |
| 697 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 698 | + } else { | |
| 699 | + // NO OEMBED CACHE ITEMS FOUND | |
| 700 | + if (!$scheduler) { | |
| 701 | +?> | |
| 333 | 702 | <div class="odb-not-found"> |
| 334 | - <?php _e('No PINGBACKS nor TRACKBACKS found to delete', $odb_class->odb_txt_domain);?> | |
| 703 | + <?php _e('No OEMBED CACHE ITEMS found to delete', 'rvg-optimize-database');?> | |
| 335 | 704 | </div> |
| 336 | - <?php | |
| 705 | +<?php | |
| 337 | 706 | } // if (!$scheduler) |
| 338 | - } // if(count($results)>0) | |
| 339 | - } // if($odb_class->odb_rvg_options['clear_pingbacks'] == 'Y') | |
| 340 | - | |
| 341 | - // NUMBER OF pingbacks / trackbacks DELETED (FOR LOG FILE) | |
| 342 | - $odb_class->log_arr["pingbacks"] = $total_deleted; | |
| 343 | - | |
| 344 | - | |
| 707 | + } // if (count($results) > 0) | |
| 708 | + } // if ($odb_class->odb_rvg_options['clear_oembed'] == 'Y') | |
| 709 | + | |
| 710 | + | |
| 345 | 711 | /**************************************************************************************** |
| 712 | + * | |
| 346 | 713 | * DELETE ORPHANS |
| 347 | - ****************************************************************************************/ | |
| 348 | - $total_deleted = $this->odb_delete_orphans(); | |
| 349 | - if($total_deleted > 0) | |
| 350 | - { | |
| 351 | - if (!$scheduler) | |
| 352 | - { | |
| 714 | + * | |
| 715 | + ****************************************************************************************/ | |
| 716 | + if($odb_class->odb_rvg_options['clear_orphans'] == 'Y') { | |
| 717 | + | |
| 718 | + // POSTMETA AND MEDIA ORPHANS | |
| 719 | + $results = $this->odb_get_orphans($scheduler); | |
| 720 | + | |
| 721 | + if (count($results) > 0) { | |
| 722 | + // ORPHANS FOUND | |
| 723 | + $this->grand_total += count($results); | |
| 724 | + | |
| 725 | + if ($action == 'analyze_summary' || $action == 'run_summary') { | |
| 726 | + if ($action == 'analyze_summary') { | |
| 353 | 727 | ?> |
| 354 | - <div class="odb-found-number"> | |
| 355 | - <?php _e('NUMBER OF POSTMETA ORPHANS DELETED', $odb_class->odb_txt_domain);?>: <span class="odb-blue"><?php echo $total_deleted;?></span> </div> | |
| 728 | + <div class="odb-found-number"> | |
| 729 | + <?php _e('ORPHANS found to delete: ', 'rvg-optimize-database');?> | |
| 730 | + <?php echo count($results) . '<br>';?> | |
| 731 | + </div> | |
| 356 | 732 | <?php |
| 357 | - } // if (!$scheduler) | |
| 358 | - } | |
| 359 | - else | |
| 360 | - { | |
| 361 | - if (!$scheduler) | |
| 362 | - { | |
| 733 | + } // if ($action == 'analyze_summary') | |
| 734 | + | |
| 735 | + if ($action == 'run_summary') { | |
| 363 | 736 | ?> |
| 737 | + <div class="odb-found-number"> | |
| 738 | + <?php _e('ORPHANS deleted: ', 'rvg-optimize-database');?> | |
| 739 | + <?php echo count($results) . '<br>';?> | |
| 740 | + </div> | |
| 741 | + <?php | |
| 742 | + } // if ($action == 'run_summary') | |
| 743 | + } // if ($action == 'analyze_summary' || $action == 'run_summary') | |
| 744 | + | |
| 745 | + if ($action == 'analyze_detail' || $action == 'run_detail') { | |
| 746 | + | |
| 747 | + if ($action == 'analyze_detail') { | |
| 748 | + $msg1 = __('ORPHANS', 'rvg-optimize-database'); | |
| 749 | + $msg2 = __('total number of orphans', 'rvg-optimize-database'); | |
| 750 | + } else { | |
| 751 | + // ACTION = 'RUN_DETAIL' | |
| 752 | + $msg1 = __('DELETED ORPHANS', 'rvg-optimize-database'); | |
| 753 | + $msg2 = __('total number of orphans deleted', 'rvg-optimize-database'); | |
| 754 | + } // if ($action == 'analyze_detail') | |
| 755 | + ?> | |
| 756 | + <table border="0" cellspacing="8" cellpadding="2" class="odb-result-table"> | |
| 757 | + <tr> | |
| 758 | + <td colspan="4"><div class="odb-found"> | |
| 759 | + <?php echo $msg1 ?> | |
| 760 | + </div></td> | |
| 761 | + </tr> | |
| 762 | + <tr> | |
| 763 | + <th align="right" class="odb-border-bottom">#</th> | |
| 764 | + <th align="left" class="odb-border-bottom"><?php _e('prefix', 'rvg-optimize-database');?></th> | |
| 765 | + <th align="left" class="odb-border-bottom"><?php _e('type', 'rvg-optimize-database');?></th> | |
| 766 | + <th align="left" class="odb-border-bottom"><?php _e('id', 'rvg-optimize-database');?></th> | |
| 767 | + <th align="left" class="odb-border-bottom"><?php _e('title', 'rvg-optimize-database');?></th> | |
| 768 | + <th align="left" nowrap="nowrap" class="odb-border-bottom"><?php _e('modified', 'rvg-optimize-database');?></th> | |
| 769 | + <th align="left" class="odb-border-bottom"><?php _e('taxonomy', 'rvg-optimize-database');?></th> | |
| 770 | + <th align="left" class="odb-border-bottom"><?php _e('meta key', 'rvg-optimize-database');?></th> | |
| 771 | + <th align="left" class="odb-border-bottom"><?php _e('meta value', 'rvg-optimize-database');?></th> | |
| 772 | + </tr> | |
| 773 | + <?php | |
| 774 | + } // if ($action == 'analyze_detail' || $action == 'run_detail') | |
| 775 | + | |
| 776 | + // LOOP THROUGH THE ORPHANS AND DELETE THEM | |
| 777 | + $total_deleted = $this->odb_delete_orphans($results, $scheduler, $action); | |
| 778 | + | |
| 779 | + if ($scheduler) $odb_class->log_arr["orphans"] = $total_deleted; | |
| 780 | + | |
| 781 | + if ($action == 'run_summary' || $action == 'run_detail') { | |
| 782 | + // NUMBER OF ORPHANS FOR LOG FILE | |
| 783 | + $odb_class->log_arr["orphans"] = $total_deleted; | |
| 784 | + } // if (!$scheduler && ($action == 'run_summary' || $action == 'run_detail') | |
| 785 | +?> | |
| 786 | + </table> | |
| 787 | +<?php | |
| 788 | + } else { | |
| 789 | + // NO ORPHANS FOUND | |
| 790 | + if (!$scheduler) { | |
| 791 | +?> | |
| 364 | 792 | <div class="odb-not-found"> |
| 365 | - <?php _e('No POSTMETA ORPHANS found to delete', $odb_class->odb_txt_domain);?> | |
| 793 | + <?php _e('No ORPHANS found to delete', 'rvg-optimize-database');?> | |
| 366 | 794 | </div> |
| 795 | +<?php | |
| 796 | + } // if (!$scheduler) | |
| 797 | + } // if (count($results) > 0) | |
| 798 | + } // if($odb_class->odb_rvg_options['clear_orphans'] == 'Y') | |
| 799 | + ?> | |
| 800 | + <div class="odb-found-number"> | |
| 801 | + <?php _e('TOTAL NUMBER OF ITEMS: ', 'rvg-optimize-database');?> | |
| 802 | + <?php echo '<span class="odb-blue">' . $this->grand_total . '</span><br>';?> | |
| 803 | + </div> | |
| 367 | 804 | <?php |
| 368 | - } // if (!$scheduler) | |
| 369 | - } // if($total_deleted > 0) | |
| 370 | - // FOR LOG FILE | |
| 371 | - $odb_class->log_arr["orphans"] = $total_deleted; | |
| 372 | - | |
| 373 | - if (!$scheduler) | |
| 374 | - { | |
| 375 | - ?> | |
| 376 | - </div><!-- /odb-cleaner --> | |
| 377 | -<?php | |
| 378 | - } | |
| 379 | 805 | } // odb_run_cleaner() |
| 380 | 806 | |
| 381 | 807 | |
| 382 | 808 | /******************************************************************************************** |
| 809 | + * | |
| 383 | 810 | * RUN OPTIMIZER |
| 384 | - ********************************************************************************************/ | |
| 385 | - function odb_run_optimizer($scheduler) | |
| 386 | - { global $odb_class; | |
| 387 | - | |
| 388 | - if(!$scheduler) | |
| 389 | - { | |
| 811 | + * | |
| 812 | + ********************************************************************************************/ | |
| 813 | + function odb_run_optimizer($scheduler, $action) { | |
| 814 | + global $odb_class; | |
| 815 | + | |
| 816 | + if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 390 | 817 | ?> |
| 391 | 818 | <div class="odb-optimizing-table" class="odb-padding-left"> |
| 392 | 819 | <div class="odb-title-bar"> |
| 393 | - <h2><?php _e('Optimizing Database Tables', $odb_class->odb_txt_domain);?></h2> | |
| 820 | + <h2><?php _e('Optimizing Database Tables', 'rvg-optimize-database');?></h2> | |
| 394 | 821 | </div> |
| 395 | 822 | <br> |
| 396 | 823 | <br> |
| 397 | 824 | <table border="0" cellspacing="8" cellpadding="2"> |
| @@ -396,35 +823,36 @@ | ||
| 396 | 823 | <br> |
| 397 | 824 | <table border="0" cellspacing="8" cellpadding="2"> |
| 398 | 825 | <tr> |
| 399 | 826 | <th class="odb-border-bottom" align="right">#</th> |
| 400 | - <th class="odb-border-bottom" align="left"><?php _e('table name', $odb_class->odb_txt_domain);?></th> | |
| 401 | - <th class="odb-border-bottom" align="left"><?php _e('optimization result', $odb_class->odb_txt_domain);?></th> | |
| 402 | - <th class="odb-border-bottom" align="left"><?php _e('engine', $odb_class->odb_txt_domain);?></th> | |
| 403 | - <th class="odb-border-bottom" align="right"><?php _e('table rows', $odb_class->odb_txt_domain);?></th> | |
| 404 | - <th class="odb-border-bottom" align="right"><?php _e('table size', $odb_class->odb_txt_domain);?></th> | |
| 827 | + <th class="odb-border-bottom" align="left"><?php _e('table name', 'rvg-optimize-database');?></th> | |
| 828 | + <th class="odb-border-bottom" align="left"><?php _e('optimization result', 'rvg-optimize-database');?></th> | |
| 829 | + <th class="odb-border-bottom" align="left"><?php _e('engine', 'rvg-optimize-database');?></th> | |
| 830 | + <th class="odb-border-bottom" align="right"><?php _e('table rows', 'rvg-optimize-database');?></th> | |
| 831 | + <th class="odb-border-bottom" align="right"><?php _e('table size', 'rvg-optimize-database');?></th> | |
| 405 | 832 | </tr> |
| 406 | 833 | <?php |
| 407 | - } // if(!$scheduler) | |
| 408 | - | |
| 834 | + } // if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 835 | + | |
| 409 | 836 | # OPTIMIZE THE DATABASE TABLES |
| 410 | - $this->nr_of_optimized_tables = $this->odb_optimize_tables($scheduler); | |
| 411 | - | |
| 412 | - if(!$scheduler) | |
| 413 | - { | |
| 837 | + $this->nr_of_optimized_tables = $this->odb_optimize_tables($scheduler, $action); | |
| 838 | + | |
| 839 | + if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 414 | 840 | ?> |
| 415 | 841 | </table> |
| 416 | - </div><!-- /odb-optimizing-table --> | |
| 842 | + </div><!-- /odb-optimizing-table --> | |
| 417 | 843 | <?php |
| 418 | - } // if(!$scheduler) | |
| 844 | + } // if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 419 | 845 | } // odb_run_optimizer() |
| 420 | 846 | |
| 421 | 847 | |
| 422 | 848 | /******************************************************************************************** |
| 849 | + * | |
| 423 | 850 | * CALCULATE AND DISPLAY SAVINGS |
| 424 | - ********************************************************************************************/ | |
| 425 | - function odb_savings($scheduler) | |
| 426 | - { global $odb_class; | |
| 851 | + * | |
| 852 | + ********************************************************************************************/ | |
| 853 | + function odb_savings($scheduler, $action) { | |
| 854 | + global $odb_class; | |
| 427 | 855 | global $odb_logger_obj; |
| 428 | 856 | |
| 429 | 857 | // NUMBER OF TABLES |
| 430 | 858 | $odb_class->log_arr["tables"] = $this->nr_of_optimized_tables; |
| @@ -434,23 +862,25 @@ | ||
| 434 | 862 | $end_size = $odb_class->odb_utilities_obj->odb_get_db_size(); |
| 435 | 863 | $odb_class->log_arr["after"] = $odb_class->odb_utilities_obj->odb_format_size($end_size,3); |
| 436 | 864 | // TOTAL SAVING |
| 437 | 865 | $odb_class->log_arr["savings"] = $odb_class->odb_utilities_obj->odb_format_size(($this->start_size - $end_size),3); |
| 438 | - // WRITE RESULTS TO LOG FILE | |
| 439 | - $odb_class->odb_logger_obj->write_log($odb_class->log_arr); | |
| 440 | - | |
| 866 | + | |
| 867 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 868 | + // WRITE RESULTS TO THE DATABASE - v4.6 | |
| 869 | + $odb_class->odb_logger_obj->odb_add_log($odb_class->log_arr); | |
| 870 | + } | |
| 871 | + | |
| 441 | 872 | $total_savings = $odb_class->odb_rvg_options['total_savings']; |
| 442 | 873 | $total_savings += ($this->start_size - $end_size); |
| 443 | - $odb_class->odb_rvg_options['total_savings'] = $total_savings; | |
| 444 | - | |
| 874 | + $odb_class->odb_rvg_options['total_savings'] = $total_savings; | |
| 875 | + | |
| 445 | 876 | $odb_class->odb_multisite_obj->odb_ms_update_option('odb_rvg_options', $odb_class->odb_rvg_options); |
| 446 | - | |
| 447 | - if(!$scheduler) | |
| 448 | - { | |
| 877 | + | |
| 878 | + if(!$scheduler) { | |
| 449 | 879 | ?> |
| 450 | 880 | <div id="odb-savings" class="odb-padding-left"> |
| 451 | 881 | <div class="odb-title-bar"> |
| 452 | - <h2><?php _e('Savings', $odb_class->odb_txt_domain);?></h2> | |
| 882 | + <h2><?php _e('Savings', 'rvg-optimize-database');?></h2> | |
| 453 | 883 | </div> |
| 454 | 884 | <br> |
| 455 | 885 | <br> |
| 456 | 886 | <table border="0" cellspacing="8" cellpadding="2"> |
| @@ -455,225 +885,413 @@ | ||
| 455 | 885 | <br> |
| 456 | 886 | <table border="0" cellspacing="8" cellpadding="2"> |
| 457 | 887 | <tr> |
| 458 | 888 | <th> </th> |
| 459 | - <th class="odb-border-bottom"><?php _e('size of the database', $odb_class->odb_txt_domain);?></th> | |
| 889 | + <th class="odb-border-bottom"><?php _e('size of the database', 'rvg-optimize-database');?></th> | |
| 460 | 890 | </tr> |
| 461 | 891 | <tr> |
| 462 | - <td align="right"><?php _e('BEFORE optimization', $odb_class->odb_txt_domain);?></td> | |
| 892 | + <td align="right"><?php _e('BEFORE optimization', 'rvg-optimize-database');?></td> | |
| 463 | 893 | <td align="right" class="odb-bold"><?php echo $odb_class->odb_utilities_obj->odb_format_size($this->start_size,3); ?></td> |
| 464 | 894 | </tr> |
| 465 | 895 | <tr> |
| 466 | - <td align="right"><?php _e('AFTER optimization', $odb_class->odb_txt_domain);?></td> | |
| 896 | + <td align="right"><?php _e('AFTER optimization', 'rvg-optimize-database');?></td> | |
| 467 | 897 | <td align="right" class="odb-bold"><?php echo $odb_class->odb_utilities_obj->odb_format_size($end_size,3); ?></td> |
| 468 | 898 | </tr> |
| 469 | 899 | <tr> |
| 470 | - <td align="right" class="odb-bold"><?php _e('SAVINGS THIS TIME', $odb_class->odb_txt_domain);?></td> | |
| 900 | + <td align="right" class="odb-bold"><?php _e('SAVINGS THIS TIME', 'rvg-optimize-database');?></td> | |
| 471 | 901 | <td align="right" class="odb-border-top odb-bold"><?php echo $odb_class->odb_utilities_obj->odb_format_size(($this->start_size - $end_size),3); ?></td> |
| 472 | 902 | </tr> |
| 473 | 903 | <tr> |
| 474 | - <td align="right" class="odb-bold"><?php _e('TOTAL SAVINGS SINCE THE FIRST RUN', $odb_class->odb_txt_domain);?></td> | |
| 904 | + <td align="right" class="odb-bold"><?php _e('TOTAL SAVINGS SINCE THE FIRST RUN', 'rvg-optimize-database');?></td> | |
| 475 | 905 | <td align="right" class="odb-border-top odb-bold"><?php echo $odb_class->odb_utilities_obj->odb_format_size($total_savings,3); ?></td> |
| 476 | 906 | </tr> |
| 477 | - </table> | |
| 907 | + </table> | |
| 478 | 908 | </div><!-- /odb-savings --> |
| 479 | 909 | <?php |
| 480 | 910 | } // if(!$scheduler) |
| 481 | 911 | } // odb_savings() |
| 482 | - | |
| 483 | 912 | |
| 913 | + | |
| 484 | 914 | /******************************************************************************************** |
| 915 | + * | |
| 485 | 916 | * SHOW LOADING TIME |
| 486 | - ********************************************************************************************/ | |
| 487 | - function odb_done() | |
| 488 | - { | |
| 917 | + * | |
| 918 | + ********************************************************************************************/ | |
| 919 | + function odb_done($analyze = false) { | |
| 489 | 920 | global $odb_class; |
| 490 | - | |
| 921 | + | |
| 491 | 922 | $time = microtime(); |
| 492 | 923 | $time = explode(' ', $time); |
| 493 | 924 | $time = $time[1] + $time[0]; |
| 494 | 925 | $finish = $time; |
| 495 | - | |
| 926 | + | |
| 496 | 927 | $total_time = round(($finish - $odb_class->odb_start_time), 4); |
| 497 | 928 | ?> |
| 498 | 929 | <div id="odb-done" class="odb-padding-left"> |
| 499 | 930 | <div class="odb-title-bar"> |
| 500 | 931 | <h2> |
| 501 | - <?php _e('DONE!', $odb_class->odb_txt_domain);?> | |
| 932 | + <?php _e('DONE!', 'rvg-optimize-database');?> | |
| 502 | 933 | </h2> |
| 503 | 934 | </div> |
| 504 | - <br /> | |
| 505 | - <br /> | |
| 506 | - <span class="odb-padding-left"><?php _e('Optimization took', $odb_class->odb_txt_domain)?> <strong><?php echo $total_time;?></strong> <?php _e('seconds', $odb_class->odb_txt_domain)?>.</span> | |
| 935 | + <br> | |
| 936 | + <br> | |
| 937 | +<?php | |
| 938 | + if (!$analyze) { | |
| 939 | +?> | |
| 940 | + <span class="odb-padding-left"><?php _e('Optimization took', 'rvg-optimize-database')?> <strong><?php echo $total_time;?></strong> <?php _e('seconds', 'rvg-optimize-database')?>.</span> | |
| 941 | +<?php | |
| 942 | + } // if ($analyze) | |
| 943 | +?> | |
| 507 | 944 | <?php |
| 508 | - if(file_exists($odb_class->odb_plugin_path.'logs/rvg-optimize-db-log.html')) | |
| 509 | - { | |
| 945 | + // v4.5.1 | |
| 946 | + $odb_class->odb_last_run_seconds = $total_time; | |
| 947 | + | |
| 948 | + if($odb_class->odb_logger_obj->odb_log_count() > 0) { | |
| 510 | 949 | ?> |
| 511 | - <br /> | |
| 512 | - <br /> | |
| 950 | +<script> | |
| 951 | +function odb_confirm_delete() { | |
| 952 | +<?php | |
| 953 | + $nonce = wp_create_nonce( 'rvg-optimize-database' ); | |
| 954 | + // v4.6.2 | |
| 955 | + $msg = str_replace("'", "\'", __('Clear the log?', 'rvg-optimize-database')); | |
| 956 | +?> | |
| 957 | + if(confirm('<?php echo $msg?>')) { | |
| 958 | + self.location = 'tools.php?page=rvg-optimize-database&action=clear_log&_wpnonce=<?php echo esc_attr( $nonce ); ?>' | |
| 959 | + return; | |
| 960 | + } | |
| 961 | +} // odb_confirm_delete() | |
| 962 | +</script> | |
| 963 | + <br><br> | |
| 513 | 964 | |
| 514 | - <input class="button odb-normal" type="button" name="view_log" value="<?php _e('View Log File', $odb_class->odb_txt_domain);?>" onclick="window.open('<?php echo $odb_class->odb_logfile_url?>')" /> | |
| 965 | + <input class="button odb-normal" type="button" name="view_log" value="<?php _e('View Log', 'rvg-optimize-database');?>" onclick="self.location='tools.php?page=rvg-optimize-database&action=view_log&_wpnonce=<?php echo esc_attr( $nonce ); ?>'" /> | |
| 515 | 966 | |
| 516 | - <input class="button odb-normal" type="button" name="delete_log" value="<?php _e('Delete Log File', $odb_class->odb_txt_domain);?>" onclick="self.location='tools.php?page=rvg-optimize-database&action=delete_log'" /> | |
| 517 | - <?php | |
| 518 | - } | |
| 967 | + <input class="button odb-normal" type="button" name="clear_log" value="<?php _e('Clear Log', 'rvg-optimize-database');?>" onclick="return odb_confirm_delete();" /> | |
| 968 | + <?php | |
| 969 | + } // if($odb_class->odb_logger_obj->odb_log_count() > 0) | |
| 519 | 970 | ?> |
| 520 | - </div><!-- /odb-done --> | |
| 521 | -<?php | |
| 971 | + </div><!-- /odb-done --> | |
| 972 | +<?php | |
| 522 | 973 | } // odb_done() |
| 523 | 974 | |
| 524 | 975 | |
| 525 | 976 | /******************************************************************************************** |
| 526 | - * GET REVISIONS | |
| 977 | + * | |
| 978 | + * GET REVISIONS (OLDER THAN x DAYS) | |
| 979 | + * | |
| 527 | 980 | ********************************************************************************************/ |
| 528 | - function odb_get_revisions() | |
| 529 | - { | |
| 530 | - global $odb_class, $wpdb; | |
| 531 | - | |
| 532 | - $res_arr = array(); | |
| 533 | - | |
| 534 | - $max_revisions = $odb_class->odb_rvg_options['nr_of_revisions']; | |
| 535 | - | |
| 536 | - $index = 0; | |
| 537 | - for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 538 | - { $sql = " | |
| 539 | - SELECT `post_parent`, `post_title`, COUNT(*) cnt | |
| 540 | - FROM ".$odb_class->odb_ms_prefixes[$i]."posts | |
| 541 | - WHERE `post_type` = 'revision' | |
| 542 | - GROUP BY `post_parent` | |
| 543 | - HAVING COUNT(*) > ".$max_revisions." | |
| 544 | - ORDER BY UCASE(`post_title`) | |
| 545 | - "; | |
| 546 | - $res = $wpdb->get_results($sql, ARRAY_A); | |
| 981 | + function odb_get_revisions_older_than() { | |
| 982 | + global $odb_class, $wpdb; | |
| 547 | 983 | |
| 548 | - for($j=0; $j<count($res); $j++) | |
| 549 | - { if(isset($res[$j])) | |
| 550 | - { $res_arr[$index] = $res[$j]; | |
| 551 | - $res_arr[$index]['site'] = $odb_class->odb_ms_prefixes[$i]; | |
| 552 | - $index++; | |
| 553 | - } | |
| 554 | - } | |
| 555 | - } | |
| 556 | - | |
| 984 | + $res_arr = array(); | |
| 985 | + | |
| 986 | + // CUSTOM POST TYPES (from v4.4) | |
| 987 | + $rel_posttypes = $odb_class->odb_rvg_options['post_types']; | |
| 988 | + $in = []; | |
| 989 | + foreach ($rel_posttypes as $posttype => $value) { | |
| 990 | + if ($value == 'Y') { | |
| 991 | + $in[] = $wpdb->prepare( '%s', $posttype ); | |
| 992 | + } // if ($value == 'Y') | |
| 993 | + } // foreach($rel_posttypes as $posttypes) | |
| 994 | + | |
| 995 | + $where = ''; | |
| 996 | + if( ! empty( $in ) ) { | |
| 997 | + $where = " AND p2.`post_type` IN (" . implode( ', ', $in ) . ")"; | |
| 998 | + } else { | |
| 999 | + // NO POST TYPES TO DELETE REVISIONS FOR... SKIP! | |
| 557 | 1000 | return $res_arr; |
| 558 | - | |
| 559 | - } // odb_get_revisions() | |
| 1001 | + } // if($in != '') | |
| 560 | 1002 | |
| 1003 | + $older_than = $odb_class->odb_rvg_options['older_than']; | |
| 561 | 1004 | |
| 1005 | + $index = 0; | |
| 1006 | + | |
| 1007 | + // LOOP THROUGH THE SITES (IF MULTI SITE) | |
| 1008 | + for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) { | |
| 1009 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1010 | + | |
| 1011 | + $sql = $wpdb->prepare(" | |
| 1012 | + SELECT %s AS site, | |
| 1013 | + p1.`ID`, | |
| 1014 | + p1.`post_parent`, | |
| 1015 | + p1.`post_title`, | |
| 1016 | + p1.`post_modified` | |
| 1017 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'posts' ) . " p1, " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'posts' ) . " p2 | |
| 1018 | + WHERE p1.`post_type` = 'revision' | |
| 1019 | + AND p1.`post_parent` = p2.ID | |
| 1020 | + {$where} | |
| 1021 | + AND p1.`post_modified` < date_sub(now(), INTERVAL %d DAY) | |
| 1022 | + ORDER BY UCASE(p1.`post_title`) | |
| 1023 | + ", | |
| 1024 | + $prefix, | |
| 1025 | + $older_than); | |
| 1026 | + | |
| 1027 | + //echo 'OLDER: '.$sql.'<br>'; | |
| 1028 | + | |
| 1029 | + $res = $wpdb->get_results($sql, ARRAY_A); | |
| 1030 | + | |
| 1031 | + for($j=0; $j<count($res); $j++) { | |
| 1032 | + if(isset($res[$j]) && !$this->odb_post_is_excluded($res[$j]['post_parent'])) { | |
| 1033 | + $res_arr[$index] = $res[$j]; | |
| 1034 | + $index++; | |
| 1035 | + } // if(isset($res[$j]) && !$this->odb_post_is_excluded($res[$j]['post_parent'])) | |
| 1036 | + } // for($j=0; $j<count($res); $j++) | |
| 1037 | + | |
| 1038 | + } // for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 1039 | + | |
| 1040 | + return $res_arr; | |
| 1041 | + } // odb_get_revisions_older_than() | |
| 1042 | + | |
| 1043 | + | |
| 562 | 1044 | /******************************************************************************************** |
| 1045 | + * | |
| 1046 | + * GET REVISIONS (KEEP MAX NUMBER OF REVISIONS) | |
| 1047 | + * | |
| 1048 | + ********************************************************************************************/ | |
| 1049 | + function odb_get_revisions_keep_revisions() { | |
| 1050 | + global $odb_class, $wpdb; | |
| 1051 | + | |
| 1052 | + $res_arr = array(); | |
| 1053 | + | |
| 1054 | + // CUSTOM POST TYPES (from v4.4) | |
| 1055 | + $rel_posttypes = $odb_class->odb_rvg_options['post_types']; | |
| 1056 | + $in = []; | |
| 1057 | + foreach ($rel_posttypes as $posttype => $value) { | |
| 1058 | + if ($value == 'Y') { | |
| 1059 | + $in[] = $wpdb->prepare( '%s', $posttype ); | |
| 1060 | + } // if ($value == 'Y') | |
| 1061 | + } // foreach($rel_posttypes as $posttypes) | |
| 1062 | + | |
| 1063 | + $where1 = ''; | |
| 1064 | + if ( ! empty( $in ) ) { | |
| 1065 | + $where1 = " AND p2.`post_type` IN (" . implode( ', ', $in ) . ")"; | |
| 1066 | + } else { | |
| 1067 | + // NO POST TYPES TO DELETE REVISIONS FOR... SKIP! | |
| 1068 | + return $res_arr; | |
| 1069 | + } // if($in != '') | |
| 1070 | + | |
| 1071 | + // MAX NUMBER OF REVISIONS TO KEEP | |
| 1072 | + $max_revisions = $odb_class->odb_rvg_options['nr_of_revisions']; | |
| 1073 | + | |
| 1074 | + $index = 0; | |
| 1075 | + | |
| 1076 | + // SKIP REVISIONS THAT WILL BE DELETED BY THE 'OLDER THAN' OPTION | |
| 1077 | + $where2 = ''; | |
| 1078 | + if($odb_class->odb_rvg_options['delete_older'] == 'Y') { | |
| 1079 | + $older_than = $odb_class->odb_rvg_options['older_than']; | |
| 1080 | + $where2 = $wpdb->prepare( "AND p1.`post_modified` >= date_sub(now(), INTERVAL %d DAY)", $older_than ); | |
| 1081 | + } | |
| 1082 | + | |
| 1083 | + for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) { | |
| 1084 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1085 | + | |
| 1086 | + $sql = $wpdb->prepare(" | |
| 1087 | + SELECT %s AS site, | |
| 1088 | + p1.`ID`, | |
| 1089 | + p1.`post_parent`, | |
| 1090 | + p1.`post_title`, | |
| 1091 | + p1.`post_modified`, | |
| 1092 | + COUNT(*) cnt | |
| 1093 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'posts' ) . " p1, " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'posts' ) . " p2 | |
| 1094 | + WHERE p1.`post_type` = 'revision' | |
| 1095 | + AND p1.`post_parent` = p2.ID | |
| 1096 | + {$where1} | |
| 1097 | + {$where2} | |
| 1098 | + GROUP BY p1.`post_parent` | |
| 1099 | + HAVING COUNT(*) > %d | |
| 1100 | + ORDER BY UCASE(p1.`post_title`) | |
| 1101 | + ", | |
| 1102 | + $prefix, | |
| 1103 | + $max_revisions); | |
| 1104 | + | |
| 1105 | + //echo 'KEEP: '.$sql.'<br>'; | |
| 1106 | + | |
| 1107 | + $res = $wpdb->get_results($sql, ARRAY_A); | |
| 1108 | + for($j=0; $j<count($res); $j++) { | |
| 1109 | + if(isset($res[$j]) && !$this->odb_post_is_excluded($res[$j]['post_parent'])) { | |
| 1110 | + $res_arr[$index] = $res[$j]; | |
| 1111 | + $index++; | |
| 1112 | + } | |
| 1113 | + } // for($j=0; $j<count($res); $j++) | |
| 1114 | + } // for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 1115 | + | |
| 1116 | + return $res_arr; | |
| 1117 | + } // odb_get_revisions_keep_revisions() | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + /********************************************************************************************^ | |
| 1121 | + * | |
| 563 | 1122 | * DELETE THE REVISIONS |
| 1123 | + * | |
| 564 | 1124 | ********************************************************************************************/ |
| 565 | - function odb_delete_revisions($results, $scheduler) | |
| 566 | - { | |
| 1125 | + function odb_delete_revisions($scheduler, $action = 'run_detail') { | |
| 567 | 1126 | global $odb_class, $wpdb; |
| 568 | - | |
| 569 | - $max_revisions = $odb_class->odb_rvg_options['nr_of_revisions']; | |
| 570 | - | |
| 571 | - $nr = 1; | |
| 1127 | + | |
| 572 | 1128 | $total_deleted = 0; |
| 573 | - | |
| 574 | - for($i=0; $i<count($results); $i++) | |
| 575 | - { $nr_to_delete = $results[$i]['cnt'] - $max_revisions; | |
| 576 | - $total_deleted += $nr_to_delete; | |
| 577 | - | |
| 578 | - if (!$scheduler) | |
| 579 | - { | |
| 1129 | + | |
| 1130 | + // v4.8.1 | |
| 1131 | + if($scheduler && $action == '') { | |
| 1132 | + $action = 'run_detail'; | |
| 1133 | + } // if($scheduler && $action == '') | |
| 1134 | + | |
| 1135 | + if($odb_class->odb_rvg_options['delete_older'] == 'Y') { | |
| 1136 | + // DELETE REVISIONS OLDER THAN x DAYS | |
| 1137 | + $results = $this->odb_get_revisions_older_than(); | |
| 1138 | + $older_than = $odb_class->odb_rvg_options['older_than']; | |
| 1139 | + $total_deleted += count($results); | |
| 1140 | + | |
| 1141 | + for($i = 0; $i < count($results); $i++) { | |
| 1142 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 1143 | + ?> | |
| 1144 | + <tr> | |
| 1145 | + <td align="right" valign="top"><?php echo ($i + 1)?>.</td> | |
| 1146 | + <td align="left" valign="top"><?php echo $results[$i]['site']?></td> | |
| 1147 | + <td valign="top" class="odb-bold"><?php echo $results[$i]['post_title']?></td> | |
| 1148 | + <td valign="top" class="odb-bold"><?php echo $results[$i]['post_modified']?></td><?php | |
| 1149 | + } // if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 1150 | + | |
| 1151 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1152 | + $sql_delete = $wpdb->prepare(" | |
| 1153 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'posts' ) . " | |
| 1154 | + WHERE `ID` = %d | |
| 1155 | + ", $results[$i]['ID']); | |
| 1156 | + | |
| 1157 | + $wpdb->get_results($sql_delete); | |
| 1158 | + } // if ($action == 'run') | |
| 1159 | + | |
| 1160 | + if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 580 | 1161 | ?> |
| 581 | - <tr> | |
| 582 | - <td align="right" valign="top"><?php echo $nr?>.</td> | |
| 583 | - <td align="left" valign="top"><?php echo $results[$i]['site']?></td> | |
| 584 | - <td valign="top" class="odb-bold"><?php echo $results[$i]['post_title']?></td> | |
| 585 | - <td valign="top"><?php | |
| 586 | - } // if (!$scheduler) | |
| 587 | - | |
| 588 | - $sql_get_posts = " | |
| 589 | - SELECT `ID`, `post_modified` | |
| 590 | - FROM ".$results[$i]['site']."posts | |
| 591 | - WHERE `post_parent`=".$results[$i]['post_parent']." | |
| 592 | - AND `post_type`='revision' | |
| 593 | - ORDER BY `post_modified` ASC | |
| 594 | - "; | |
| 595 | - | |
| 596 | - $results_get_posts = $wpdb->get_results($sql_get_posts); | |
| 597 | - | |
| 598 | - for($j=0; $j<$nr_to_delete; $j++) | |
| 599 | - { | |
| 600 | - if(!$scheduler) echo $results_get_posts[$j]->post_modified.'<br />'; | |
| 601 | - | |
| 602 | - $sql_delete = " | |
| 603 | - DELETE FROM ".$results[$i]['site']."posts | |
| 604 | - WHERE `ID` = ".$results_get_posts[$j]->ID." | |
| 605 | - "; | |
| 606 | - $wpdb->get_results($sql_delete); | |
| 607 | - | |
| 608 | - } // for($j=0; $j<$nr_to_delete; $j++) | |
| 609 | - | |
| 610 | - $nr++; | |
| 611 | - if(!$scheduler) | |
| 612 | - { | |
| 613 | - ?></td> | |
| 614 | - <td align="right" valign="top" class="odb-bold"><?php echo $nr_to_delete?></td> | |
| 615 | - </tr> | |
| 616 | - <?php | |
| 617 | - } // if(!$scheduler) | |
| 618 | - } // for($i=0; $i<count($results); $i++) | |
| 619 | - | |
| 1162 | + <td align="right" valign="top" class="odb-bold">1</td> | |
| 1163 | + </tr> | |
| 1164 | + <?php | |
| 1165 | + } // if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail') | |
| 1166 | + } // for($i=0; $i<count($results); $i++) | |
| 1167 | + } // if($odb_class->odb_rvg_options['delete_older'] == 'Y') | |
| 1168 | + | |
| 1169 | + if($odb_class->odb_rvg_options['rvg_revisions'] == 'Y') { | |
| 1170 | + // KEEP MAX NUMBER OF REVISIONS | |
| 1171 | + $results = $this->odb_get_revisions_keep_revisions(); | |
| 1172 | + $max_revisions = $odb_class->odb_rvg_options['nr_of_revisions']; | |
| 1173 | + | |
| 1174 | + for($i = 0; $i < count($results); $i++) { | |
| 1175 | + $nr_to_delete = $results[$i]['cnt'] - $max_revisions; | |
| 1176 | + $total_deleted += $nr_to_delete; | |
| 1177 | + | |
| 1178 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 1179 | + ?> | |
| 1180 | + <tr> | |
| 1181 | + <td align="right" valign="top"><?php echo ($i + 1)?>.</td> | |
| 1182 | + <td align="left" valign="top"><?php echo $results[$i]['site']?></td> | |
| 1183 | + <td valign="top" class="odb-bold"><?php echo $results[$i]['post_title']?></td> | |
| 1184 | + <td valign="top" class="odb-bold"><?php echo $results[$i]['post_modified']?></td><?php | |
| 1185 | + } // if (!$scheduler && $action == 'analyze_detail' || $action == 'run_detail')) | |
| 1186 | + | |
| 1187 | + $sql_get_posts = $wpdb->prepare( " | |
| 1188 | + SELECT `ID`, `post_modified` | |
| 1189 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'posts' ) . " | |
| 1190 | + WHERE `post_parent` = %d | |
| 1191 | + AND `post_type` = 'revision' | |
| 1192 | + ORDER BY `post_modified` ASC | |
| 1193 | + ", $results[$i]['post_parent']); | |
| 1194 | + | |
| 1195 | + $results_get_posts = $wpdb->get_results($sql_get_posts); | |
| 1196 | + | |
| 1197 | + for($j = 0; $j < $nr_to_delete; $j++) { | |
| 1198 | + // if(!$scheduler) echo $results_get_posts[$j]->post_modified.'<br>'; | |
| 1199 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1200 | + $sql_delete = $wpdb->prepare(" | |
| 1201 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'posts' ) . " | |
| 1202 | + WHERE `ID` = %d | |
| 1203 | + ", $results_get_posts[$j]->ID); | |
| 1204 | + | |
| 1205 | + $wpdb->get_results($sql_delete); | |
| 1206 | + } // if ($action == 'run') | |
| 1207 | + } // for($j = 0; $j < $nr_to_delete; $j++) | |
| 1208 | + | |
| 1209 | + if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 1210 | + ?></td> | |
| 1211 | + <td align="right" valign="top" class="odb-bold"><?php echo $nr_to_delete?> <?php _e('of', 'rvg-optimize-database')?> <?php echo $results[$i]['cnt'];?></td> | |
| 1212 | + </tr> | |
| 1213 | + <?php | |
| 1214 | + } // if(!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 1215 | + } // for($i = 0; $i < count($results); $i++) | |
| 1216 | + } // if($odb_class->odb_rvg_options['rvg_revisions'] == 'Y') | |
| 1217 | + | |
| 620 | 1218 | return $total_deleted; |
| 621 | - } // odb_delete_revisions() | |
| 1219 | + } // function odb_delete_revisions() | |
| 622 | 1220 | |
| 623 | 1221 | |
| 624 | 1222 | /******************************************************************************************** |
| 1223 | + * | |
| 1224 | + * CHECK IF POST IS EXCLUDED BY A CUSTOM FIELD ('keep_revisions') | |
| 1225 | + * | |
| 1226 | + ********************************************************************************************/ | |
| 1227 | + function odb_post_is_excluded($parent_id) { | |
| 1228 | + $keep_revisions = get_post_meta($parent_id, 'keep_revisions', true); | |
| 1229 | + return ($keep_revisions === 'Y'); | |
| 1230 | + } // odb_post_is_exclude() | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + /******************************************************************************************** | |
| 1234 | + * | |
| 625 | 1235 | * GET TRASHED POSTS / PAGES AND COMMENTS |
| 1236 | + * | |
| 626 | 1237 | ********************************************************************************************/ |
| 627 | - function odb_get_trash() | |
| 628 | - { | |
| 1238 | + function odb_get_trash() { | |
| 629 | 1239 | global $wpdb, $odb_class; |
| 630 | - | |
| 1240 | + | |
| 631 | 1241 | $res_arr = array(); |
| 632 | 1242 | |
| 633 | 1243 | $index = 0; |
| 634 | 1244 | // LOOP TROUGH SITES |
| 635 | - for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 636 | - { | |
| 637 | - $sql = " | |
| 638 | - SELECT `ID` AS id, 'post' AS post_type, `post_title` AS title, `post_modified` AS modified | |
| 639 | - FROM ".$odb_class->odb_ms_prefixes[$i]."posts | |
| 1245 | + for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) { | |
| 1246 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1247 | + | |
| 1248 | + $sql = $wpdb->prepare(" | |
| 1249 | + SELECT %s AS site, | |
| 1250 | + `ID` AS id, | |
| 1251 | + 'post' AS post_type, | |
| 1252 | + `post_title` AS title, | |
| 1253 | + `post_modified` AS modified | |
| 1254 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'posts' ) . " | |
| 640 | 1255 | WHERE `post_status` = 'trash' |
| 641 | 1256 | UNION ALL |
| 642 | - SELECT `comment_ID` AS id, 'comment' AS post_type, `comment_author_IP` AS title, `comment_date` AS modified | |
| 643 | - FROM ".$odb_class->odb_ms_prefixes[$i]."comments | |
| 1257 | + SELECT %s AS site, | |
| 1258 | + `comment_ID` AS id, | |
| 1259 | + 'comment' AS post_type, | |
| 1260 | + `comment_author_IP` AS title, | |
| 1261 | + `comment_date` AS modified | |
| 1262 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'comments' ) . " | |
| 644 | 1263 | WHERE `comment_approved` = 'trash' |
| 645 | - ORDER BY post_type, UCASE(title) | |
| 646 | - "; | |
| 1264 | + ORDER BY post_type, UCASE(title) | |
| 1265 | + ", $prefix, $prefix); | |
| 1266 | + | |
| 647 | 1267 | $res = $wpdb->get_results($sql, ARRAY_A); |
| 648 | 1268 | |
| 649 | - if($res != null) | |
| 650 | - { $res_arr[$index] = $res[0]; | |
| 651 | - $res_arr[$index]['site'] = $odb_class->odb_ms_prefixes[$i]; | |
| 1269 | + if($res != null) { | |
| 1270 | + $res_arr[$index] = $res[0]; | |
| 652 | 1271 | $index++; |
| 653 | - } | |
| 654 | - } | |
| 655 | - | |
| 1272 | + } // if($res != null) | |
| 1273 | + } // for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 1274 | + | |
| 656 | 1275 | return $res_arr; |
| 657 | 1276 | } // odb_get_trash() |
| 658 | 1277 | |
| 659 | 1278 | |
| 660 | 1279 | /******************************************************************************************** |
| 1280 | + * | |
| 661 | 1281 | * DELETE TRASHED POSTS AND PAGES |
| 1282 | + * | |
| 662 | 1283 | ********************************************************************************************/ |
| 663 | - function odb_delete_trash($results, $scheduler) | |
| 664 | - { | |
| 665 | - global $wpdb; | |
| 666 | - | |
| 667 | - $nr = 1; | |
| 1284 | + function odb_delete_trash($results, $scheduler, $action) { | |
| 1285 | + global $wpdb, $odb_class; | |
| 1286 | + | |
| 668 | 1287 | $total_deleted = count($results); |
| 669 | - | |
| 670 | - for($i=0; $i<$total_deleted; $i++) | |
| 671 | - { if(!$scheduler) | |
| 672 | - { | |
| 1288 | + | |
| 1289 | + for ($i = 0; $i < $total_deleted; $i++) { | |
| 1290 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 673 | 1291 | ?> |
| 674 | 1292 | <tr> |
| 675 | - <td align="right" valign="top"><?php echo $nr; ?></td> | |
| 1293 | + <td align="right" valign="top"><?php echo ($i + 1); ?></td> | |
| 676 | 1294 | <td align="left" valign="top"><?php echo $results[$i]['site']?></td> |
| 677 | 1295 | <td valign="top"><?php echo $results[$i]['post_type']; ?></td> |
| 678 | 1296 | <td valign="top"><?php echo $results[$i]['title']; ?></td> |
| 679 | 1297 | <td valign="top" nowrap="nowrap"><?php echo $results[$i]['modified']; ?></td> |
| @@ -678,88 +1296,92 @@ | ||
| 678 | 1296 | <td valign="top"><?php echo $results[$i]['title']; ?></td> |
| 679 | 1297 | <td valign="top" nowrap="nowrap"><?php echo $results[$i]['modified']; ?></td> |
| 680 | 1298 | </tr> |
| 681 | 1299 | <?php |
| 682 | - } // if(!$scheduler) | |
| 683 | - | |
| 684 | - if($results[$i]['post_type'] == 'comment') | |
| 685 | - { // DELETE META DATA (IF ANY...) | |
| 686 | - $sql_delete = " | |
| 687 | - DELETE FROM ".$results[$i]['site']."commentmeta | |
| 688 | - WHERE `comment_id` = ".$results[$i]['id']." | |
| 689 | - "; | |
| 690 | - $wpdb->get_results($sql_delete); | |
| 691 | - } | |
| 692 | - | |
| 693 | - // DELETE TRASHED POSTS / PAGES | |
| 694 | - $sql_delete = " | |
| 695 | - DELETE FROM ".$results[$i]['site']."posts | |
| 696 | - WHERE `post_status` = 'trash' | |
| 697 | - "; | |
| 698 | - $wpdb->get_results($sql_delete); | |
| 699 | - | |
| 700 | - // DELETE TRASHED COMMENTS | |
| 701 | - $sql_delete = " | |
| 702 | - DELETE FROM ".$results[$i]['site']."comments | |
| 703 | - WHERE `comment_approved` = 'trash' | |
| 704 | - "; | |
| 705 | - $wpdb->get_results($sql_delete); | |
| 706 | - | |
| 707 | - $nr++; | |
| 708 | - } // for($i=0; $i<count($results); $i++) | |
| 709 | - | |
| 1300 | + } // if (!$scheduler && ($action == 'analyze_detail' || $action = 'run_detail')) | |
| 1301 | + | |
| 1302 | + if($results[$i]['post_type'] == 'comment') { | |
| 1303 | + // DELETE META DATA (IF ANY...) | |
| 1304 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1305 | + $sql_delete = $wpdb->prepare(" | |
| 1306 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'commentmeta' ) . " | |
| 1307 | + WHERE `comment_id` = %d | |
| 1308 | + ", $results[$i]['id']); | |
| 1309 | + $wpdb->get_results($sql_delete); | |
| 1310 | + } // if ($action == 'run_summary' || $action == 'run_detail') | |
| 1311 | + } // if($results[$i]['post_type'] == 'comment') | |
| 1312 | + | |
| 1313 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1314 | + // DELETE TRASHED POSTS / PAGES | |
| 1315 | + $sql_delete = $wpdb->prepare(" | |
| 1316 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'posts' ) . " | |
| 1317 | + WHERE `post_status` = %s | |
| 1318 | + ", 'trash'); | |
| 1319 | + $wpdb->get_results($sql_delete); | |
| 1320 | + | |
| 1321 | + // DELETE TRASHED COMMENTS | |
| 1322 | + $sql_delete = $wpdb->prepare(" | |
| 1323 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'comments' ) . " | |
| 1324 | + WHERE `comment_approved` = %s | |
| 1325 | + ", 'trash'); | |
| 1326 | + $wpdb->get_results($sql_delete); | |
| 1327 | + } // if ($action == 'run_summary' || $action == 'run_detail') | |
| 1328 | + } // for ($i = 0; $i < $total_deleted; $i++) | |
| 1329 | + | |
| 710 | 1330 | return $total_deleted; |
| 711 | 1331 | } // odb_delete_trash() |
| 712 | 1332 | |
| 713 | 1333 | |
| 714 | 1334 | /******************************************************************************************** |
| 1335 | + * | |
| 715 | 1336 | * GET SPAMMED COMMENTS |
| 1337 | + * | |
| 716 | 1338 | ********************************************************************************************/ |
| 717 | - function odb_get_spam() | |
| 718 | - { | |
| 1339 | + function odb_get_spam() { | |
| 719 | 1340 | global $wpdb, $odb_class; |
| 720 | - | |
| 1341 | + | |
| 721 | 1342 | $res_arr = array(); |
| 722 | - | |
| 723 | - $index = 0; | |
| 1343 | + | |
| 724 | 1344 | // LOOP THROUGH SITES |
| 725 | - for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 726 | - { | |
| 727 | - $sql = " | |
| 728 | - SELECT `comment_ID`, `comment_author`, `comment_author_email`, `comment_date` | |
| 729 | - FROM ".$odb_class->odb_ms_prefixes[$i]."comments | |
| 1345 | + for ($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) { | |
| 1346 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1347 | + | |
| 1348 | + $sql = $wpdb->prepare(" | |
| 1349 | + SELECT %s AS site, | |
| 1350 | + `comment_ID`, | |
| 1351 | + `comment_author`, | |
| 1352 | + `comment_author_email`, | |
| 1353 | + `comment_date` | |
| 1354 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'comments' ) . " | |
| 730 | 1355 | WHERE `comment_approved` = 'spam' |
| 731 | 1356 | ORDER BY UCASE(`comment_author`) |
| 732 | - "; | |
| 1357 | + ", $prefix); | |
| 1358 | + | |
| 733 | 1359 | $res = $wpdb->get_results($sql, ARRAY_A); |
| 734 | - | |
| 735 | - if($res != null) | |
| 736 | - { $res_arr[$index] = $res[0]; | |
| 737 | - $res_arr[$index]['site'] = $odb_class->odb_ms_prefixes[$i]; | |
| 738 | - $index++; | |
| 739 | - } | |
| 740 | - } | |
| 741 | - | |
| 1360 | + | |
| 1361 | + for($j = 0; $j < count($res); $j++) { | |
| 1362 | + array_push($res_arr, $res[$j]); | |
| 1363 | + } // for($j = 0; $j < count($res); $j++) | |
| 1364 | + } // for ($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) | |
| 742 | 1365 | return $res_arr; |
| 743 | - | |
| 744 | 1366 | } // odb_get_spam() |
| 745 | 1367 | |
| 746 | 1368 | |
| 747 | 1369 | /******************************************************************************************** |
| 1370 | + * | |
| 748 | 1371 | * DELETE SPAMMED ITEMS |
| 1372 | + * | |
| 749 | 1373 | ********************************************************************************************/ |
| 750 | - function odb_delete_spam($results, $scheduler) | |
| 751 | - { | |
| 752 | - global $wpdb; | |
| 753 | - | |
| 754 | - $nr = 1; | |
| 1374 | + function odb_delete_spam($results, $scheduler, $action = 'run') { | |
| 1375 | + global $wpdb, $odb_class; | |
| 1376 | + | |
| 755 | 1377 | $total_deleted = count($results); |
| 756 | - for($i=0; $i<count($results); $i++) | |
| 757 | - { if (!$scheduler) | |
| 758 | - { | |
| 1378 | + | |
| 1379 | + for ($i = 0; $i < count($results); $i++) { | |
| 1380 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 759 | 1381 | ?> |
| 760 | 1382 | <tr> |
| 761 | - <td align="right" valign="top"><?php echo $nr; ?></td> | |
| 1383 | + <td align="right" valign="top"><?php echo ($i + 1); ?></td> | |
| 762 | 1384 | <td align="left" valign="top"><?php echo $results[$i]['site']?></td> |
| 763 | 1385 | <td valign="top"><?php echo $results[$i]['comment_author']; ?></td> |
| 764 | 1386 | <td valign="top"><?php echo $results[$i]['comment_author_email']; ?></td> |
| 765 | 1387 | <td valign="top" nowrap="nowrap"><?php echo $results[$i]['comment_date']; ?></td> |
| @@ -764,310 +1386,615 @@ | ||
| 764 | 1386 | <td valign="top"><?php echo $results[$i]['comment_author_email']; ?></td> |
| 765 | 1387 | <td valign="top" nowrap="nowrap"><?php echo $results[$i]['comment_date']; ?></td> |
| 766 | 1388 | </tr> |
| 767 | 1389 | <?php |
| 768 | - } // if (!$scheduler) | |
| 769 | - | |
| 770 | - $sql_delete = " | |
| 771 | - DELETE FROM ".$results[$i]['site']."commentmeta | |
| 772 | - WHERE `comment_id` = ".$results[$i]['comment_ID']." | |
| 773 | - "; | |
| 774 | - $wpdb->get_results($sql_delete); | |
| 775 | - | |
| 776 | - $sql_delete = " | |
| 777 | - DELETE FROM ".$results[$i]['site']."comments | |
| 778 | - WHERE `comment_approved` = 'spam' | |
| 779 | - "; | |
| 780 | - $wpdb->get_results($sql_delete); | |
| 781 | - | |
| 782 | - $nr++; | |
| 783 | - } // for($i=0; $i<count($results); $i++) | |
| 784 | - | |
| 1390 | + } // if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 1391 | + | |
| 1392 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1393 | + $sql_delete = $wpdb->prepare(" | |
| 1394 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'commentmeta' ) . " | |
| 1395 | + WHERE `comment_id` = %d | |
| 1396 | + ", $results[$i]['comment_ID']); | |
| 1397 | + $wpdb->get_results($sql_delete); | |
| 1398 | + | |
| 1399 | + $sql_delete = $wpdb->prepare(" | |
| 1400 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'comments' ) . " | |
| 1401 | + WHERE `comment_approved` = %s | |
| 1402 | + ", 'spam'); | |
| 1403 | + $wpdb->get_results($sql_delete); | |
| 1404 | + } // if ($action == 'run_summary' || $action == 'run_detail') | |
| 1405 | + } // for ($i = 0; $i < count($results); $i++) | |
| 1406 | + | |
| 785 | 1407 | return $total_deleted; |
| 786 | - | |
| 787 | 1408 | } // odb_delete_spam() |
| 788 | 1409 | |
| 789 | 1410 | |
| 790 | 1411 | /******************************************************************************************** |
| 791 | - * DELETE UNUSED TAGS | |
| 1412 | + * | |
| 1413 | + * GET UNUSED TAGS | |
| 1414 | + * | |
| 792 | 1415 | ********************************************************************************************/ |
| 793 | - function odb_delete_tags() | |
| 794 | - { | |
| 795 | - global $wpdb, $odb_class; | |
| 796 | - | |
| 797 | - $total_deleted = 0; | |
| 1416 | + function odb_get_unused_tags() { | |
| 1417 | + global $wpdb, $odb_class; | |
| 798 | 1418 | |
| 799 | - // LOOP THROUGH THE NETWORK | |
| 800 | - for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 801 | - { | |
| 802 | - $sql = " | |
| 803 | - SELECT a.term_id AS term_id, a.name AS name | |
| 804 | - FROM `".$odb_class->odb_ms_prefixes[$i]."terms` a, `".$odb_class->odb_ms_prefixes[$i]."term_taxonomy` b | |
| 1419 | + $res_arr = array(); | |
| 1420 | + | |
| 1421 | + // LOOP THROUGH SITES | |
| 1422 | + for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) { | |
| 1423 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1424 | + | |
| 1425 | + $sql = $wpdb->prepare(" | |
| 1426 | + SELECT %s AS site, | |
| 1427 | + a.term_id AS term_id, a.name AS name | |
| 1428 | + FROM `" . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'terms' ) . "` a, `" . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'term_taxonomy' ) . "` b | |
| 805 | 1429 | WHERE a.term_id = b.term_id |
| 806 | 1430 | AND b.taxonomy = 'post_tag' |
| 807 | 1431 | AND b.term_taxonomy_id NOT IN ( |
| 808 | 1432 | SELECT term_taxonomy_id |
| 809 | - FROM ".$odb_class->odb_ms_prefixes[$i]."term_relationships | |
| 1433 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'term_relationships' ) . " | |
| 810 | 1434 | ) |
| 811 | - "; | |
| 812 | - | |
| 813 | - $res = $wpdb->get_results($sql); | |
| 814 | - for($j=0; $j<count($res); $j++) | |
| 815 | - { if(!$this->odb_delete_tags_is_scheduled($res[$j]->term_id, $odb_class->odb_ms_prefixes[$i])) | |
| 816 | - { // TAG NOT USED IN SCHEDULED POSTS: CAN BE DELETED | |
| 817 | - $total_deleted++; | |
| 818 | - | |
| 819 | - $sql_del = " | |
| 820 | - DELETE FROM ".$odb_class->odb_ms_prefixes[$i]."term_taxonomy | |
| 821 | - WHERE term_id = ".$res[$j]->term_id." | |
| 822 | - "; | |
| 823 | - $wpdb->get_results($sql_del); | |
| 824 | - | |
| 825 | - $sql_del = " | |
| 826 | - DELETE FROM ".$odb_class->odb_ms_prefixes[$i]."terms | |
| 827 | - WHERE term_id = ".$res[$j]->term_id." | |
| 828 | - "; | |
| 829 | - $wpdb->get_results($sql_del); | |
| 830 | - } | |
| 831 | - } // for($j=0; $j<count($res); $j++) | |
| 832 | - } // for($i=0; $i<count($odb_class->odb_ms_blogids); $i++) | |
| 833 | - | |
| 1435 | + ORDER BY name | |
| 1436 | + ", $prefix); | |
| 1437 | + | |
| 1438 | + $res = $wpdb->get_results($sql, ARRAY_A); | |
| 1439 | + | |
| 1440 | + for($j = 0; $j < count($res); $j++) { | |
| 1441 | + array_push($res_arr, $res[$j]); | |
| 1442 | + } // for($j = 0; $j < count($res); $j++) | |
| 1443 | + } // for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 1444 | + return $res_arr; | |
| 1445 | + } // odb_get_unused_tags | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + /******************************************************************************************** | |
| 1449 | + * | |
| 1450 | + * DELETE UNUSED TAGS | |
| 1451 | + * | |
| 1452 | + ********************************************************************************************/ | |
| 1453 | + function odb_delete_unused_tags($results, $scheduler, $action = 'run') { | |
| 1454 | + global $wpdb, $odb_class; | |
| 1455 | + | |
| 1456 | + $total_deleted = count($results); | |
| 1457 | + | |
| 1458 | + for ($i = 0; $i < $total_deleted; $i++) { | |
| 1459 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 1460 | + ?> | |
| 1461 | + <tr> | |
| 1462 | + <td align="right" valign="top"><?php echo ($i + 1); ?></td> | |
| 1463 | + <td align="left" valign="top"><?php echo $results[$i]['site']?></td> | |
| 1464 | + <td valign="top"><?php echo $results[$i]['name']; ?></td> | |
| 1465 | + </tr> | |
| 1466 | + <?php | |
| 1467 | + } // if (!$scheduler && ($action = 'analyze_detail' || $action == 'run_detail')) | |
| 1468 | + | |
| 1469 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1470 | + $sql_del = $wpdb->prepare(" | |
| 1471 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'term_taxonomy' ) . " | |
| 1472 | + WHERE term_id = %d | |
| 1473 | + ", $results[$i]['term_id']); | |
| 1474 | + $wpdb->get_results($sql_del); | |
| 1475 | + | |
| 1476 | + $sql_del = $wpdb->prepare(" | |
| 1477 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'terms' ) . " | |
| 1478 | + WHERE term_id = %d | |
| 1479 | + ", $results[$i]['term_id']); | |
| 1480 | + $wpdb->get_results($sql_del); | |
| 1481 | + } // if ($action == 'run_summary' || $action == 'run_detail') | |
| 1482 | + } // for ($i = 0; $i < $total_deleted; $i++) | |
| 1483 | + | |
| 834 | 1484 | return $total_deleted; |
| 835 | - } // odb_delete_tags() | |
| 1485 | + } // odb_delete_unused_tags() | |
| 836 | 1486 | |
| 837 | 1487 | |
| 838 | 1488 | /******************************************************************************************** |
| 1489 | + * | |
| 839 | 1490 | * IS THE UNUSED TAG USED IN ONE OR MORE SCHEDULED POSTS? |
| 1491 | + * | |
| 840 | 1492 | ********************************************************************************************/ |
| 841 | - function odb_delete_tags_is_scheduled($term_id, $odb_prefix) | |
| 842 | - { | |
| 843 | - global $wpdb; | |
| 844 | - | |
| 845 | - $sql_get_posts = " | |
| 1493 | + function odb_delete_tags_is_scheduled($term_id, $odb_prefix) { | |
| 1494 | + global $wpdb, $odb_class; | |
| 1495 | + | |
| 1496 | + $sql_get_posts = $wpdb->prepare(" | |
| 846 | 1497 | SELECT p.post_status |
| 847 | - FROM ".$odb_prefix."term_relationships t, ".$odb_prefix."posts p | |
| 848 | - WHERE t.term_taxonomy_id = '".$term_id."' | |
| 1498 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $odb_prefix . 'term_relationships' ) . " t, " . $odb_class->odb_utilities_obj->odb_sanitize_key( $odb_prefix . 'posts' ) . " p | |
| 1499 | + WHERE t.term_taxonomy_id = %s | |
| 849 | 1500 | AND t.object_id = p.ID |
| 850 | - "; | |
| 851 | - | |
| 1501 | + ", $term_id); | |
| 1502 | + | |
| 852 | 1503 | $results_get_posts = $wpdb->get_results($sql_get_posts); |
| 853 | 1504 | for($i=0; $i<count($results_get_posts); $i++) |
| 854 | 1505 | if($results_get_posts[$i]->post_status == 'future') return true; |
| 855 | - | |
| 856 | - return false; | |
| 857 | - | |
| 1506 | + | |
| 1507 | + return false; | |
| 858 | 1508 | } // odb_delete_tags_is_scheduled() |
| 859 | 1509 | |
| 860 | 1510 | |
| 861 | 1511 | /******************************************************************************************** |
| 862 | - * DELETE EXPIRED TRANSIENTS | |
| 1512 | + * | |
| 1513 | + * GET TRANSIENTS v4.8.2 | |
| 1514 | + * | |
| 863 | 1515 | ********************************************************************************************/ |
| 864 | - function odb_delete_transients() | |
| 865 | - { | |
| 1516 | + function odb_get_transients($option = "Y") { | |
| 1517 | + // $option == "A": delete all transients | |
| 1518 | + // %option == "Y": only delete EXPIRED transients | |
| 1519 | + | |
| 866 | 1520 | global $wpdb, $odb_class; |
| 867 | - | |
| 868 | - $delay = time() - 60; // ONE MINUTE DELAY | |
| 869 | - | |
| 870 | - $total_deleted = 0; | |
| 871 | - | |
| 872 | - // LOOP THROUGH THE NETWORK | |
| 873 | - for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 874 | - { | |
| 875 | - // FIND EXPIRED TRANSIENTS | |
| 876 | - $sql = " | |
| 877 | - SELECT `option_name` | |
| 878 | - FROM ".$odb_class->odb_ms_prefixes[$i]."options | |
| 879 | - WHERE ( | |
| 880 | - option_name LIKE '_transient_timeout_%' | |
| 881 | - OR option_name LIKE '_site_transient_timeout_%' | |
| 882 | - ) | |
| 883 | - AND option_value < '$delay' | |
| 884 | - "; | |
| 885 | - | |
| 886 | - $results = $wpdb->get_results($sql); | |
| 887 | - $total_deleted += count($results); | |
| 888 | - | |
| 889 | - // LOOP THROUGH THE RESULTS | |
| 890 | - for($j=0; $j<count($results); $j++) | |
| 891 | - { | |
| 892 | - if(substr($results[$j]->option_name, 0, 19) == '_transient_timeout_') | |
| 893 | - { // _transient_timeout_% | |
| 894 | - $transient = substr($results[$j]->option_name, 19); | |
| 895 | - // DELETE THE TRANSIENT | |
| 896 | - delete_transient($transient); | |
| 897 | - } | |
| 898 | - else | |
| 899 | - { // _site_transient_timeout_% | |
| 900 | - $transient = substr($results[$j]->option_name, 24); | |
| 901 | - // DELETE THE TRANSIENT | |
| 902 | - delete_site_transient($transient); | |
| 903 | - } | |
| 904 | - } // for($j=0; $j<count($results); $j++) | |
| 905 | - | |
| 1521 | + | |
| 1522 | + $res_arr = array(); | |
| 1523 | + | |
| 1524 | + // ONE MINUTE DELAY | |
| 1525 | + $delay = time() - 60; | |
| 1526 | + | |
| 1527 | + // LOOP THROUGH SITES | |
| 1528 | + for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) { | |
| 1529 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1530 | + | |
| 1531 | + $table = $prefix . 'options'; | |
| 1532 | + // v4.8.2 | |
| 1533 | + if ($option == 'Y') { | |
| 1534 | + // EXPIRED ONLY | |
| 1535 | + $sql = $wpdb->prepare(" | |
| 1536 | + SELECT %s AS site, | |
| 1537 | + `option_name` | |
| 1538 | + FROM `" . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'options' ) . "` | |
| 1539 | + WHERE ( | |
| 1540 | + option_name LIKE '_transient_timeout_%%' | |
| 1541 | + OR option_name LIKE '_site_transient_timeout_%%' | |
| 1542 | + ) | |
| 1543 | + AND option_value < %d | |
| 1544 | + ORDER BY `option_name` | |
| 1545 | + ", $prefix, $delay); | |
| 1546 | + //echo $sql . '<br>'; | |
| 1547 | + } else { | |
| 1548 | + // ALL | |
| 1549 | + $sql = $wpdb->prepare(" | |
| 1550 | + SELECT %s AS site, | |
| 1551 | + `option_name` | |
| 1552 | + FROM `" . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'options' ) . "` | |
| 1553 | + WHERE ( | |
| 1554 | + option_name LIKE '_transient_timeout_%%' | |
| 1555 | + OR option_name LIKE '_site_transient_timeout_%%' | |
| 1556 | + ) | |
| 1557 | + ORDER BY `option_name` | |
| 1558 | + ", $prefix ); | |
| 1559 | + } | |
| 1560 | + //echo $sql . '<br>'; | |
| 1561 | + $res = $wpdb->get_results($sql, ARRAY_A); | |
| 1562 | + | |
| 1563 | + for($j = 0; $j < count($res); $j++) { | |
| 1564 | + array_push($res_arr, $res[$j]); | |
| 1565 | + } // for($j = 0; $j < count($res); $j++) | |
| 906 | 1566 | } // for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) |
| 1567 | + return $res_arr; | |
| 1568 | + } // function odb_get_transients() | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + /******************************************************************************************** | |
| 1572 | + * | |
| 1573 | + * DELETE TRANSIENTS (v4.8.2) | |
| 1574 | + * | |
| 1575 | + ********************************************************************************************/ | |
| 1576 | + function odb_delete_transients($results, $scheduler, $action = 'run', $option = 'Y') { | |
| 1577 | + global $wpdb, $odb_class; | |
| 1578 | + | |
| 1579 | + // ONE MINUTE DELAY | |
| 1580 | + $delay = time() - MINUTE_IN_SECONDS; | |
| 1581 | + | |
| 1582 | + $total_deleted = count($results); | |
| 1583 | + | |
| 1584 | + // LOOP THROUGH SITES | |
| 1585 | + for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) { | |
| 1586 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1587 | + | |
| 1588 | + for ($j = 0; $j < count($results); $j++) { | |
| 1589 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 1590 | + ?> | |
| 1591 | + <tr> | |
| 1592 | + <td align="right" valign="top"><?php echo ($j + 1); ?></td> | |
| 1593 | + <td align="left" valign="top"><?php echo $results[$j]['site']?></td> | |
| 1594 | + <td valign="top"><?php echo $results[$j]['option_name']; ?></td> | |
| 1595 | + </tr> | |
| 1596 | + <?php | |
| 1597 | + } // if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 1598 | + | |
| 1599 | + // v4.8.2 | |
| 1600 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1601 | + $timeout = $results[$j]['option_name']; | |
| 1602 | + $trans = str_replace('_timeout', '', $timeout); | |
| 1603 | + $sqldel = $wpdb->prepare(" | |
| 1604 | + DELETE FROM `" . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'options' ) . "` | |
| 1605 | + WHERE ( | |
| 1606 | + option_name = %s | |
| 1607 | + OR option_name = %s | |
| 1608 | + ) | |
| 1609 | + ", $timeout, $trans); | |
| 1610 | + | |
| 1611 | + //echo $sqldel . '<br>'; | |
| 1612 | + $resdel = $wpdb->get_results($sqldel, ARRAY_A); | |
| 1613 | + } // if ($action == 'run_summary' || $action == 'run_detail')) | |
| 1614 | + } // for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) | |
| 1615 | + } // for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) | |
| 1616 | + | |
| 907 | 1617 | return $total_deleted; |
| 908 | 1618 | } // odb_delete_transients() |
| 909 | 1619 | |
| 910 | 1620 | |
| 911 | 1621 | /******************************************************************************************** |
| 912 | - * DELETE PINGBACKS AND TRACKBACKS | |
| 1622 | + * | |
| 1623 | + * GET PINGBACKS AND TRACKBACKS | |
| 1624 | + * | |
| 913 | 1625 | ********************************************************************************************/ |
| 914 | - function odb_delete_pingbacks() | |
| 915 | - { | |
| 1626 | + function odb_get_pingbacks() { | |
| 1627 | + | |
| 916 | 1628 | global $wpdb, $odb_class; |
| 917 | - | |
| 918 | - $total_deleted = 0; | |
| 919 | - | |
| 920 | - // LOOP THROUGH THE NETWORK | |
| 921 | - for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 922 | - { | |
| 923 | - $sql = " | |
| 924 | - SELECT `comment_ID` | |
| 925 | - FROM ".$odb_class->odb_ms_prefixes[$i]."comments | |
| 1629 | + | |
| 1630 | + $res_arr = array(); | |
| 1631 | + | |
| 1632 | + // LOOP THROUGH SITES | |
| 1633 | + for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) { | |
| 1634 | + $prefix = $odb_class->odb_ms_prefixes[$i];; | |
| 1635 | + | |
| 1636 | + $sql = $wpdb->prepare(" | |
| 1637 | + SELECT %s AS site, | |
| 1638 | + `comment_ID`, | |
| 1639 | + `comment_type`, | |
| 1640 | + `comment_author`, | |
| 1641 | + `comment_date` | |
| 1642 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'comments' ) . " | |
| 926 | 1643 | WHERE ( |
| 927 | - `comment_type` = 'pingback' | |
| 928 | - OR `comment_type` = 'trackback' | |
| 1644 | + `comment_type` = 'pingback' OR `comment_type` = 'trackback' | |
| 929 | 1645 | ) |
| 930 | - "; | |
| 931 | - | |
| 932 | - $results = $wpdb->get_results($sql); | |
| 933 | - $total_deleted = count($results); | |
| 934 | - | |
| 935 | - for($j=0; $j<count($results); $j++) | |
| 936 | - { // DELETE METADATA FOR THIS COMMENT (IF ANY) | |
| 937 | - $sql_delete_meta = " | |
| 938 | - DELETE FROM ".$odb_class->odb_ms_prefixes[$i]."commentmeta | |
| 939 | - WHERE `comment_id` = ".$results[$j]->comment_ID." | |
| 940 | - "; | |
| 941 | - $wpdb->get_results($sql_delete_meta); | |
| 942 | - } | |
| 943 | - | |
| 944 | - // DELETE COMMENTS | |
| 945 | - $sql_delete_comments = " | |
| 946 | - DELETE FROM ".$odb_class->odb_ms_prefixes[$i]."comments | |
| 947 | - WHERE ( | |
| 948 | - `comment_type` = 'pingback' | |
| 949 | - OR `comment_type` = 'trackback' | |
| 950 | - ) | |
| 951 | - "; | |
| 952 | - $wpdb->get_results($sql_delete_comments); | |
| 953 | - } // for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 954 | - | |
| 1646 | + ORDER BY `comment_type`, `comment_author` | |
| 1647 | + ", $prefix); | |
| 1648 | + | |
| 1649 | + $res = $wpdb->get_results($sql, ARRAY_A); | |
| 1650 | + | |
| 1651 | + for($j = 0; $j < count($res); $j++) { | |
| 1652 | + array_push($res_arr, $res[$j]); | |
| 1653 | + } // for($j = 0; $j < count($res); $j++) | |
| 1654 | + } // for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) | |
| 1655 | + return $res_arr; | |
| 1656 | + } // odb_get_pingbacks | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + /******************************************************************************************** | |
| 1660 | + * | |
| 1661 | + * DELETE PINGBACKS AND TRACKBACKS | |
| 1662 | + * | |
| 1663 | + ********************************************************************************************/ | |
| 1664 | + function odb_delete_pingbacks ($results, $scheduler, $action = 'run') { | |
| 1665 | + global $wpdb, $odb_class; | |
| 1666 | + | |
| 1667 | + $total_deleted = count($results); | |
| 1668 | + | |
| 1669 | + for ($i = 0; $i < count($results); $i++) { | |
| 1670 | + if (!$scheduler && ($action == 'analyze_detail' | $action == 'run_detail')) { | |
| 1671 | + ?> | |
| 1672 | + <tr> | |
| 1673 | + <td align="right" valign="top"><?php echo ($i + 1); ?></td> | |
| 1674 | + <td align="left" valign="top"><?php echo $results[$i]['site']?></td> | |
| 1675 | + <td valign="top"><?php echo $results[$i]['comment_type']?></td> | |
| 1676 | + <td valign="top"><?php echo $results[$i]['comment_author']?></td> | |
| 1677 | + <td valign="top" nowrap="nowrap"><?php echo $results[$i]['comment_date']; ?></td> | |
| 1678 | + </tr> | |
| 1679 | + <?php | |
| 1680 | + } // if (!$scheduler && ($action == 'analyze_detail' | $action == 'run_detail')) | |
| 1681 | + | |
| 1682 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1683 | + for($j = 0; $j < count($results); $j++) { | |
| 1684 | + // DELETE METADATA FOR THIS COMMENT (IF ANY) | |
| 1685 | + $sql = $wpdb->prepare(" | |
| 1686 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$j]['site'] . 'commentmeta' ) . " | |
| 1687 | + WHERE `comment_id` = %d | |
| 1688 | + ", $results[$j]['comment_ID']); | |
| 1689 | + $wpdb->get_results($sql); | |
| 1690 | + | |
| 1691 | + $sql = $wpdb->prepare(" | |
| 1692 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$j]['site'] . 'comments' ) . " | |
| 1693 | + WHERE ( | |
| 1694 | + `comment_type` = %s | |
| 1695 | + OR `comment_type` = %s | |
| 1696 | + ) | |
| 1697 | + ", 'pingback', 'trackback'); | |
| 1698 | + $wpdb->get_results($sql); | |
| 1699 | + } // for($j = 0; $j < count($results); $j++) | |
| 1700 | + } // if ($action == 'run_summary' || $action == 'run_detail') | |
| 1701 | + } // for ($i = 0; $i < count($results); $i++) | |
| 1702 | + | |
| 955 | 1703 | return $total_deleted; |
| 956 | 1704 | } // odb_delete_pingbacks() |
| 957 | 1705 | |
| 958 | 1706 | |
| 959 | 1707 | /******************************************************************************************** |
| 960 | - * DELETE ORPHAN POSTMETA RECORDS | |
| 1708 | + * | |
| 1709 | + * GET OEMBED CACHE | |
| 1710 | + * | |
| 961 | 1711 | ********************************************************************************************/ |
| 962 | - function odb_delete_orphans() | |
| 963 | - { | |
| 1712 | + function odb_get_oembed() { | |
| 964 | 1713 | global $wpdb, $odb_class; |
| 965 | - | |
| 966 | - $meta_orphans = 0; | |
| 967 | - $post_orphans = 0; | |
| 968 | - | |
| 969 | - // LOOP THROUGH THE NETWORK | |
| 970 | - for($i=0; $i<count($odb_class->odb_ms_prefixes); $i++) | |
| 971 | - { | |
| 972 | - // DELETE POST ORPHANS (AUTO DRAFTS) | |
| 973 | - $sql_delete = " | |
| 974 | - SELECT COUNT(*) cnt | |
| 975 | - FROM ".$odb_class->odb_ms_prefixes[$i]."posts | |
| 976 | - WHERE ID NOT IN (SELECT post_id FROM ".$odb_class->odb_ms_prefixes[$i]."postmeta) | |
| 1714 | + | |
| 1715 | + $res_arr = array(); | |
| 1716 | + | |
| 1717 | + // LOOP THROUGH SITES | |
| 1718 | + for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) { | |
| 1719 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1720 | + | |
| 1721 | + $sql = $wpdb->prepare(" | |
| 1722 | + SELECT %s AS site, | |
| 1723 | + `meta_id`, | |
| 1724 | + `meta_key`, | |
| 1725 | + `meta_value` | |
| 1726 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'postmeta' ) . " | |
| 1727 | + WHERE `meta_key` LIKE '_oembed_%%' | |
| 1728 | + ORDER BY `meta_key` | |
| 1729 | + ", $prefix); | |
| 1730 | + | |
| 1731 | + $res = $wpdb->get_results($sql, ARRAY_A); | |
| 1732 | + | |
| 1733 | + for($j = 0; $j < count($res); $j++) { | |
| 1734 | + array_push($res_arr, $res[$j]); | |
| 1735 | + } // for($j = 0; $j < count($res); $j++) | |
| 1736 | + } // for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) | |
| 1737 | + return $res_arr; | |
| 1738 | + } // odb_get_oembed() | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + /******************************************************************************************** | |
| 1742 | + * | |
| 1743 | + * CLEAR OEMBED CACHE | |
| 1744 | + * | |
| 1745 | + ********************************************************************************************/ | |
| 1746 | + function odb_delete_oembed($results, $scheduler, $action = 'run') { | |
| 1747 | + global $wpdb, $odb_class; | |
| 1748 | + | |
| 1749 | + $total_deleted = count($results); | |
| 1750 | + | |
| 1751 | + for($i = 0; $i < $total_deleted; $i++) { | |
| 1752 | + if (!$scheduler && ($action == 'analyze_detail' | $action == 'run_detail')) { | |
| 1753 | + ?> | |
| 1754 | + <tr> | |
| 1755 | + <td align="right" valign="top"><?php echo ($i + 1); ?></td> | |
| 1756 | + <td align="left" valign="top"><?php echo $results[$i]['site']?></td> | |
| 1757 | + <td valign="top"><?php echo $results[$i]['meta_key']?></td> | |
| 1758 | + <td valign="top"><?php echo $results[$i]['meta_value']?></td> | |
| 1759 | + </tr> | |
| 1760 | + <?php | |
| 1761 | + } // if (!$scheduler && ($action == 'analyze_detail' | $action == 'run_detail')) | |
| 1762 | + | |
| 1763 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1764 | + // DELETE COMMENTS | |
| 1765 | + $wpdb->get_results(" | |
| 1766 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$i]['site'] . 'postmeta' ) . " | |
| 1767 | + WHERE `meta_key` LIKE '_oembed_%%' | |
| 1768 | + "); | |
| 1769 | + } // if ($action == 'run_summary' || $action == 'run_detail') | |
| 1770 | + } // for($i = 0; $i < $total_deleted; $i++) | |
| 1771 | + | |
| 1772 | + return $total_deleted; | |
| 1773 | + } // odb_delete_oembed() | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + /******************************************************************************************** | |
| 1777 | + * | |
| 1778 | + * GET ORPHAN POSTMETA AND MEDIA RECORDS | |
| 1779 | + * | |
| 1780 | + ********************************************************************************************/ | |
| 1781 | + function odb_get_orphans() { | |
| 1782 | + global $wpdb, $odb_class; | |
| 1783 | + | |
| 1784 | + $res_arr = array(); | |
| 1785 | + | |
| 1786 | + // LOOP THROUGH SITES | |
| 1787 | + for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) { | |
| 1788 | + $prefix = $odb_class->odb_ms_prefixes[$i]; | |
| 1789 | + | |
| 1790 | + $sql = $wpdb->prepare(" | |
| 1791 | + SELECT %s AS site, | |
| 1792 | + `ID`, | |
| 1793 | + 'post' AS type, | |
| 1794 | + `post_title`, | |
| 1795 | + `post_modified`, | |
| 1796 | + '' AS term_taxonomy_id, | |
| 1797 | + '' AS meta_key, | |
| 1798 | + '' AS meta_value | |
| 1799 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'posts' ) . " | |
| 1800 | + WHERE ID NOT IN (SELECT post_id FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'postmeta' ) . ") | |
| 977 | 1801 | AND post_status = 'auto-draft' |
| 978 | - "; | |
| 979 | - | |
| 980 | - $results = $wpdb->get_results($sql_delete); | |
| 981 | - | |
| 982 | - $post_orphans = $results[0]->cnt; | |
| 983 | - | |
| 984 | - if($post_orphans > 0) | |
| 985 | - { $sql_delete = " | |
| 986 | - DELETE FROM ".$odb_class->odb_ms_prefixes[$i]."posts | |
| 987 | - WHERE ID NOT IN (SELECT post_id FROM ".$odb_class->odb_ms_prefixes[$i]."postmeta) | |
| 988 | - AND post_status = 'auto-draft' | |
| 989 | - "; | |
| 990 | - $wpdb->get_results($sql_delete); | |
| 991 | - } | |
| 992 | - | |
| 993 | - // DELETE POSTMETA ORPHANS | |
| 994 | - $sql_delete = " | |
| 995 | - SELECT COUNT(*) cnt | |
| 996 | - FROM ".$odb_class->odb_ms_prefixes[$i]."postmeta | |
| 997 | - WHERE post_id NOT IN (SELECT ID FROM ".$odb_class->odb_ms_prefixes[$i]."posts) | |
| 998 | - "; | |
| 999 | - | |
| 1000 | - $results = $wpdb->get_results($sql_delete); | |
| 1001 | - | |
| 1002 | - $meta_orphans = $results[0]->cnt; | |
| 1003 | - | |
| 1004 | - if($meta_orphans > 0) | |
| 1005 | - { $sql_delete = " | |
| 1006 | - DELETE FROM ".$odb_class->odb_ms_prefixes[$i]."postmeta | |
| 1007 | - WHERE post_id NOT IN (SELECT ID FROM ".$odb_class->odb_ms_prefixes[$i]."posts) | |
| 1008 | - "; | |
| 1009 | - $wpdb->get_results($sql_delete); | |
| 1010 | - } | |
| 1011 | - } | |
| 1012 | - | |
| 1013 | - return ($meta_orphans + $post_orphans); | |
| 1802 | + ORDER BY `ID` | |
| 1803 | + ", $prefix); | |
| 1804 | + | |
| 1805 | + $results = $wpdb->get_results($sql, ARRAY_A); | |
| 1806 | + for ($j = 0; $j < count($results); $j++) { | |
| 1807 | + array_push($res_arr, $results[$j]); | |
| 1808 | + } // for ($j = 0; $j < count($results); $j++) | |
| 1809 | + | |
| 1810 | + // FIND POSTMETA ORPHANS | |
| 1811 | + $sql = $wpdb->prepare(" | |
| 1812 | + SELECT %s AS site, | |
| 1813 | + `post_id` AS ID, | |
| 1814 | + 'post meta' AS type, | |
| 1815 | + '' AS post_title, | |
| 1816 | + '' AS post_modified, | |
| 1817 | + '' AS term_taxonomy_id, | |
| 1818 | + `meta_key`, | |
| 1819 | + `meta_value` | |
| 1820 | + FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'postmeta' ) . " | |
| 1821 | + WHERE post_id NOT IN (SELECT ID FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $prefix . 'posts' ) . ") | |
| 1822 | + ORDER BY `meta_key` | |
| 1823 | + ", $prefix); | |
| 1824 | + //echo $sql . '<br>'; | |
| 1825 | + | |
| 1826 | + $results = $wpdb->get_results($sql, ARRAY_A); | |
| 1827 | + for ($j = 0; $j < count($results); $j++) { | |
| 1828 | + array_push($res_arr, $results[$j]); | |
| 1829 | + } // for ($j = 0; $j < count($results); $j++) | |
| 1830 | + | |
| 1831 | + $results = $wpdb->get_results($sql, ARRAY_A); | |
| 1832 | + for ($j = 0; $j < count($results); $j++) { | |
| 1833 | + array_push($res_arr, $results[$j]); | |
| 1834 | + } // for ($j = 0; $j < count($results); $j++) | |
| 1835 | + } // for($i = 0; $i < count($odb_class->odb_ms_prefixes); $i++) | |
| 1836 | + return $res_arr; | |
| 1837 | + } // odb_get_orphans() | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + /******************************************************************************************** | |
| 1841 | + * | |
| 1842 | + * DELETE ORPHAN POSTMETA AND MEDIA RECORDS | |
| 1843 | + * | |
| 1844 | + ********************************************************************************************/ | |
| 1845 | + function odb_delete_orphans($results, $scheduler, $action = 'run_detail') { | |
| 1846 | + | |
| 1847 | + global $wpdb, $odb_class; | |
| 1848 | + | |
| 1849 | + $total_deleted = count($results); | |
| 1850 | + | |
| 1851 | + for($i = 0; $i < count($results); $i++) { | |
| 1852 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 1853 | + ?> | |
| 1854 | + <tr> | |
| 1855 | + <td valign="top" align="right"><?php echo ($i + 1); ?></td> | |
| 1856 | + <td valign="top" align="left"><?php echo $results[$i]['site']?></td> | |
| 1857 | + <td valign="top"><?php echo $results[$i]['type']?></td> | |
| 1858 | + <td valign="top"><?php echo $results[$i]['ID']?></td> | |
| 1859 | + <td valign="top"><?php echo $results[$i]['post_title']?></td> | |
| 1860 | + <td valign="top" nowrap="nowrap"><?php echo substr($results[$i]['post_modified'], 0, 10); ?></td> | |
| 1861 | + <td valign="top" align="left"><?php echo $results[$i]['term_taxonomy_id']?></td> | |
| 1862 | + <td valign="top" nowrap="nowrap"><?php echo $results[$i]['meta_key']; ?></td> | |
| 1863 | + <td valign="top" nowrap="nowrap"><?php echo $results[$i]['meta_value']; ?></td> | |
| 1864 | + </tr> | |
| 1865 | + <?php | |
| 1866 | + } // if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 1867 | + | |
| 1868 | + if ($scheduler || $action == 'run_summary' || $action == 'run_detail') { | |
| 1869 | + $sql = ""; | |
| 1870 | + for($j = 0; $j < count($results); $j++) { | |
| 1871 | + // DELETE METADATA FOR THIS COMMENT (IF ANY) | |
| 1872 | + if ($results[$j]['type'] == 'post meta') { | |
| 1873 | + $sql = $wpdb->prepare(" | |
| 1874 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$j]['site'] . 'postmeta' ) . " | |
| 1875 | + WHERE `post_id` = %d | |
| 1876 | + ", $results[$j]['ID']); | |
| 1877 | + } else if ($results[$j]['type'] == 'post') { | |
| 1878 | + $sql = $wpdb->prepare(" | |
| 1879 | + DELETE FROM " . $odb_class->odb_utilities_obj->odb_sanitize_key( $results[$j]['site'] . 'posts' ) . " | |
| 1880 | + WHERE `ID` = %d | |
| 1881 | + ", $results[$j]['ID']); | |
| 1882 | + } // for($j = 0; $j < count($results); $j++) | |
| 1883 | + $wpdb->get_results($sql); | |
| 1884 | + } // for($j = 0; $j < count($results); $j++) | |
| 1885 | + } // if ($action == 'run_summary' || $action == 'run_detail') | |
| 1886 | + } // for($i = 0; $i < count($results); $i++) | |
| 1887 | + return $total_deleted; | |
| 1014 | 1888 | } // odb_delete_orphans() |
| 1015 | 1889 | |
| 1016 | 1890 | |
| 1017 | 1891 | /******************************************************************************************** |
| 1892 | + * | |
| 1018 | 1893 | * OPTIMIZE DATABASE TABLES |
| 1894 | + * | |
| 1019 | 1895 | ********************************************************************************************/ |
| 1020 | - function odb_optimize_tables($scheduler) | |
| 1021 | - { | |
| 1896 | + function odb_optimize_tables($scheduler, $action) { | |
| 1022 | 1897 | global $odb_class, $wpdb; |
| 1023 | 1898 | |
| 1024 | 1899 | $cnt = 0; |
| 1025 | - for ($i=0; $i<count($odb_class->odb_tables); $i++) | |
| 1026 | - { | |
| 1027 | - if(!isset($odb_class->odb_rvg_excluded_tabs[$odb_class->odb_tables[$i][0]])) | |
| 1028 | - { # TABLE NOT EXCLUDED | |
| 1900 | + for ($i = 0; $i < count($odb_class->odb_tables); $i++) { | |
| 1901 | + if(!isset($odb_class->odb_rvg_excluded_tabs[$odb_class->odb_tables[$i][0]])) { | |
| 1902 | + # TABLE NOT EXCLUDED | |
| 1029 | 1903 | $cnt++; |
| 1030 | 1904 | |
| 1031 | - $sql = " | |
| 1032 | - SELECT engine, (data_length + index_length) AS size, table_rows | |
| 1905 | + $sql = $wpdb->prepare(" | |
| 1906 | + SELECT ENGINE, (data_length + index_length) AS size, TABLE_ROWS | |
| 1033 | 1907 | FROM information_schema.TABLES |
| 1034 | - WHERE table_schema = '".DB_NAME."' | |
| 1035 | - AND table_name = '".$odb_class->odb_tables[$i][0]."' | |
| 1036 | - "; | |
| 1908 | + WHERE table_schema = %s | |
| 1909 | + AND table_name = %s | |
| 1910 | + ", DB_NAME, $odb_class->odb_tables[$i][0]); | |
| 1911 | + //echo $sql.'<br>'; | |
| 1037 | 1912 | $table_info = $wpdb->get_results($sql); |
| 1913 | + //print_r($table_info); | |
| 1038 | 1914 | |
| 1039 | - if($odb_class->odb_rvg_options["optimize_innodb"] == 'N' && strtolower($table_info[0]->engine) == 'innodb') | |
| 1040 | - { // SKIP InnoDB tables | |
| 1915 | + if($odb_class->odb_rvg_options["optimize_innodb"] == 'N' && strtolower($table_info[0]->ENGINE) == 'innodb') { | |
| 1916 | + // SKIP InnoDB tables | |
| 1041 | 1917 | $msg = __('InnoDB table: skipped...', 'rvg-optimize-database'); |
| 1042 | - } | |
| 1043 | - else | |
| 1044 | - { $query = "OPTIMIZE TABLE ".$odb_class->odb_tables[$i][0]; | |
| 1045 | - $result = $wpdb->get_results($query); | |
| 1046 | - $msg = $result[0]->Msg_text; | |
| 1047 | - $msg = str_replace('OK', __('<span class="odb-optimized">TABLE OPTIMIZED</span>', 'rvg-optimize-database'), $msg); | |
| 1048 | - $msg = str_replace('Table is already up to date', __('Table is already up to date', 'rvg-optimize-database'), $msg); | |
| 1049 | - $msg = str_replace('Table does not support optimize, doing recreate + analyze instead', __('<span class="odb-optimized">TABLE OPTIMIZED</span>', 'rvg-optimize-database'), $msg); | |
| 1050 | - | |
| 1051 | - } | |
| 1052 | - | |
| 1053 | - if (!$scheduler) | |
| 1054 | - { // NOT FROM THE SCEDULER | |
| 1918 | + } else { | |
| 1919 | + // v4.6.3 | |
| 1920 | + if (@strtolower($table_info[0]->ENGINE) == 'myisam') { | |
| 1921 | + $result = $this->odb_optimize_myisam($odb_class->odb_tables[$i][0]); | |
| 1922 | + $msg = $result[0]->Msg_text; | |
| 1923 | + if ($msg == 'OK') { | |
| 1924 | + $msg = __('<span class="odb-optimized">TABLE OPTIMIZED</span>', 'rvg-optimize-database'); | |
| 1925 | + } else if ($msg == 'Table is already up to date') { | |
| 1926 | + $msg = __('Table is already up to date', 'rvg-optimize-database'); | |
| 1927 | + } | |
| 1928 | + } else { | |
| 1929 | + $result = $this->odb_optimize_innodb($odb_class->odb_tables[$i][0]); | |
| 1930 | + $msg = $result[0]->Msg_text; | |
| 1931 | + if ($msg == 'Table is already up to date') { | |
| 1932 | + $msg = __('Table is already up to date', 'rvg-optimize-database'); | |
| 1933 | + } else { | |
| 1934 | + $msg = __('<span class="odb-optimized">TABLE OPTIMIZED</span>', 'rvg-optimize-database'); | |
| 1935 | + } | |
| 1936 | + } // if (strtolower($table_info[0]->ENGINE) == 'myisam') | |
| 1937 | + } // if($odb_class->odb_rvg_options["optimize_innodb"] == 'N' && strtolower($table_info[0]->ENGINE) == 'innodb') | |
| 1938 | + | |
| 1939 | + if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) { | |
| 1055 | 1940 | ?> |
| 1056 | 1941 | <tr> |
| 1057 | 1942 | <td align="right" valign="top"><?php echo $cnt?>.</td> |
| 1058 | 1943 | <td valign="top" class="odb-bold"><?php echo $odb_class->odb_tables[$i][0] ?></td> |
| 1059 | 1944 | <td valign="top"><?php echo $msg ?></td> |
| 1060 | - <td valign="top"><?php echo $table_info[0]->engine ?></td> | |
| 1061 | - <td align="right" valign="top"><?php echo $table_info[0]->table_rows ?></td> | |
| 1945 | + <td valign="top"><?php echo $table_info[0]->ENGINE ?></td> | |
| 1946 | + <td align="right" valign="top"><?php echo $table_info[0]->TABLE_ROWS ?></td> | |
| 1062 | 1947 | <td align="right" valign="top"><?php echo $odb_class->odb_utilities_obj->odb_format_size($table_info[0]->size) ?></td> |
| 1063 | 1948 | </tr> |
| 1064 | 1949 | <?php |
| 1065 | - } // if (!$scheduler) | |
| 1950 | + } // if (!$scheduler && ($action == 'analyze_detail' || $action == 'run_detail')) | |
| 1066 | 1951 | } // if(!$excluded) |
| 1067 | - } // for ($i=0; $i<count($tables); $i++) | |
| 1952 | + } // for ($i = 0; $i < count($odb_class->odb_tables); $i++) | |
| 1068 | 1953 | return $cnt; |
| 1069 | - | |
| 1070 | - } // odb_optimize_tables() | |
| 1071 | - | |
| 1954 | + } // odb_optimize_tables() | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + /******************************************************************************************** | |
| 1958 | + * | |
| 1959 | + * OPTIMIZE A MyISAM TABLE | |
| 1960 | + * | |
| 1961 | + ********************************************************************************************/ | |
| 1962 | + function odb_optimize_myisam($table_name) { | |
| 1963 | + global $wpdb; | |
| 1964 | + $query = "OPTIMIZE TABLE " . $table_name; | |
| 1965 | + return $wpdb->get_results($query); | |
| 1966 | + } // odb_optimize_myisam() | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + /******************************************************************************************** | |
| 1970 | + * | |
| 1971 | + * OPTIMIZE AN InnoDB TABLE | |
| 1972 | + * | |
| 1973 | + ********************************************************************************************/ | |
| 1974 | + function odb_optimize_innodb($table_name) { | |
| 1975 | + global $wpdb; | |
| 1976 | + | |
| 1977 | + $query = "OPTIMIZE TABLE " . $table_name; | |
| 1978 | + return $wpdb->get_results($query); | |
| 1979 | + | |
| 1980 | +/* // https://www.percona.com/blog/2010/12/09/mysql-optimize-tables-innodb-stop/ | |
| 1981 | + $query = "SHOW KEYS FROM " . $table_name . " WHERE Key_name <> 'PRIMARY'"; | |
| 1982 | + $result = $wpdb->get_results($query); | |
| 1983 | + if (count($result) > 0) { | |
| 1984 | + for ($i = 0; $i < count($result); $i++) { | |
| 1985 | + $key_name = $result[$i]->Key_name; | |
| 1986 | + | |
| 1987 | + $query = "ALTER TABLE " . $table_name . " DROP KEY " . $key_name; | |
| 1988 | + $result = $wpdb->get_results($query); | |
| 1989 | + | |
| 1990 | + $query = "ALTER TABLE " . $table_name . " add key(" . $key_name . ")"; | |
| 1991 | + $result = $wpdb->get_results($query); | |
| 1992 | + } // for ($i = 0; $i < count($result); $i++) | |
| 1993 | + return __('<span class="odb-optimized">TABLE OPTIMIZED</span>', 'rvg-optimize-database'); | |
| 1994 | + } else { | |
| 1995 | + return __('Table is already up to date', 'rvg-optimize-database'); | |
| 1996 | + } // if (count($result) > 0*/ | |
| 1997 | + } // odb_optimize_innodb() | |
| 1998 | + | |
| 1072 | 1999 | } // ODB_Cleaner |
| 1073 | 2000 | ?> |