Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion database-run.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
$backup['path'] = $backup_options['path'];


global $wpdb;
$table_prefix = $wpdb->prefix;



### Form Processing
if(!empty($_POST['do'])) {
$text = '';
Expand Down Expand Up @@ -79,7 +84,44 @@
</div>
<table class="form-table">
<tr>
<td align="center"><textarea cols="120" rows="30" name="sql_query" style="width: 99%;" dir="ltr" ></textarea></td>
<label for="quickQueries"><?php _e('Helpful Queries', 'wp-dbmanager'); ?>: </label>
<select id="quickQueries" onChange="quickQuery(this)">
<option value="0"></option>
<option value="1"><?php _e('Close Trackbacks On All Posts', 'wp-dbmanager'); ?></option>
<option value="2"><?php _e('Delete All Spam Comments', 'wp-dbmanager'); ?></option>
<option value="3"><?php _e('Delete All Revisions and Metadata', 'wp-dbmanager'); ?></option>
<option value="4"><?php _e('Remove User Agent from Comments', 'wp-dbmanager'); ?></option>
<option value="5"><?php _e('Empty Trash for ALL POST TYPES', 'wp-dbmanager'); ?></option>
<option value="6"><?php _e('Delete ALL Revisions', 'wp-dbmanager'); ?></option>
<option value="7"><?php _e('Delete All Revisions older than 90 days', 'wp-dbmanager'); ?></option>
<option value="8"><?php _e('Delete All Unapproved Comments', 'wp-dbmanager'); ?></option>
<option value="9"><?php _e('Find and Replace Post Content', 'wp-dbmanager'); ?> <?php _e('*REQUIRES EDITING*', 'wp-dbmanager'); ?></option>
<option value="10"><?php _e('Delete all Pingbacks', 'wp-dbmanager'); ?></option>

</select>
<script type="text/javascript">
const queries = [];
queries[0] = ``;
queries[1] = `UPDATE <?=$table_prefix?>posts SET ping_status = 'closed';`;
queries[2] = `DELETE FROM <?=$table_prefix?>comments WHERE comment_approved = 'spam';`;
queries[3] = `DELETE a,b,c FROM <?=$table_prefix?>posts a WHERE a.post_type = 'revision' LEFT JOIN <?=$table_prefix?>term_relationships b ON (a.ID = b.object_id) LEFT JOIN <?=$table_prefix?>postmeta c ON (a.ID = c.post_id);`;
queries[4] = `update <?=$table_prefix?>comments set comment_agent ='' ;`;
queries[5] = `DELETE FROM <?=$table_prefix?>posts WHERE post_status = 'trash';`;
queries[6] = `DELETE FROM <?=$table_prefix?>posts WHERE post_type = "revision";`;
queries[7] = `DELETE FROM <?=$table_prefix?>posts WHERE post_type = "revision" AND DATEDIFF(NOW(), 'post_date') > 90;`;
queries[8] = `DELETE FROM <?=$table_prefix?>_comments WHERE comment_approved = 0;`;
queries[9] = `UPDATE wp_posts SET 'post_content' = REPLACE ('post_content', 'OLDTEXT', 'NEWTEXT');`;
queries[10] = `DELETE FROM wp_comments WHERE comment_type = 'pingback';`;


function quickQuery(selectObject) {
var value = selectObject.value;
document.getElementById('sql_query').value = queries[value];
}
</script>
</tr>
<tr>
<td align="center"><textarea cols="120" rows="30" id="sql_query" name="sql_query" style="width: 99%;" dir="ltr" ></textarea></td>
</tr>
<tr>
<td align="center"><input type="submit" name="do" value="<?php _e('Run', 'wp-dbmanager'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-dbmanager'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
Expand Down