Trackback Validator and Spam entries in your WordPress Table comments. Version: 1.5 Author: Frank Bueltge Author URI: http://bueltge.de */ // How many files you will see? $paginationCount = 10000; // include language-file if(function_exists('load_plugin_textdomain')) load_plugin_textdomain('spamviewer','wp-content/plugins'); $fbtbv_link = $_SERVER['REQUEST_URI']; $fbtbv_link = str_replace("\\", "/", $fbtbv_link); // pagination if ($spam_count > $paginationCount) { $paginationMsg = $paginationCount . ' ' . __('from', 'spamviewer') . ' ' . $spam_count; } else { $paginationView = $spam_count; $paginationMsg = ''; } // Counter for spam entries in comments if (! function_exists('fbtbv_get_count')) { function fbtbv_get_count() { global $wpdb, $comments; $comments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam'"); return $comments; } } // Counter for entries with type SPAM in db-table if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$wpdb->prefix . 'tb_data'."'") ) == 1) { if (! function_exists('fbtbv_get_spam_count')) { function fbtbv_get_spam_count() { global $wpdb, $comments; $comments = $wpdb->get_var("SELECT COUNT(tb_ID) FROM " . $wpdb->prefix . 'tb_data' . " WHERE tb_type = 'spam'"); return $comments; } } } // variable for comment-counter if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$wpdb->comments."'") ) == 1) { $count = fbtbv_get_count(); } else { $count = 0; } // variable for tb_data-counter if(mysql_num_rows(mysql_query("SHOW TABLES LIKE '".$wpdb->prefix . 'tb_data'."'") ) == 1) { $spam_count = fbtbv_get_spam_count(); } else { $spam_count = 0; } // Add page in WordPress-admin-panel if (! function_exists('fbtbv_delete_add_manage_page')) { function fbtbv_delete_add_manage_page() { global $wpdb, $count, $spam_count, $paginationCount, $paginationMsg; $viewcount = $spam_count + $count; // ask for wp-version if (function_exists('add_options_page')) if (get_bloginfo('version') <= '2.0.99') { add_management_page("Spam Viewer", 'SpamV ('.$viewcount.')', 8, __FILE__); // It's Wordpress 1.5.2 or 2.x. since it has been loaded successfully } else { add_submenu_page('edit-comments.php', 'Spam Viewer', 'SpamV ('.$viewcount.')', 8, __FILE__); // In Wordpress 2.1, a new file name is being used } } } // Delete entries in comment-table if (is_plugin_page()) { global $wpdb, $count, $spam_count; if ( ($_POST['action'] == 'comment_killed') ) { $killed = $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' LIMIT $paginationCount"); if (isset($killed)){ echo '

'; if ($killed) { echo __('Spam comments destroyed!', 'spamviewer'); } echo "

"; } $count = fbtbv_get_count(); } // Delete entries in db_data-table if (function_exists('fbtbv_get_spam_count')) { if ( ($_POST['action'] == 'tb_killed') ) { $killed = $wpdb->query("DELETE FROM " . $wpdb->prefix . 'tb_data' . " LIMIT $paginationCount"); if (isset($killed)){ echo '

'; if ($killed) { echo __('Trackback-Spamentries destroyed!', 'spamviewer'); } echo "

"; } $spam_count = fbtbv_get_spam_count(); } } if ( (isset($_POST['submit'])) && ($_POST['action'] == 'unspam') ) { if ($_POST['not_tbspam'] == 0) { echo '

' . __('No comments selected.', 'spamviewer') . "

"; } else { $i = 0; foreach ($_POST['not_tbspam'] as $comment) : $comment = (int) $comment; $wpdb->query("UPDATE $wpdb->comments SET comment_approved = '0' WHERE comment_ID = '$comment'"); if (function_exists('fbtbv_get_spam_count')) { $wpdb->query("DELETE FROM " . $wpdb->prefix . 'tb_data' . " WHERE tb_comments_ID = '$comment'"); } ++$i; endforeach; if ($i == 1) { echo '

' . sprintf(__('%s entry unspam.', 'spamviewer'), $i) . "

"; } else { echo '

' . sprintf(__('%s entries unspam.', 'spamviewer'), $i) . "

"; } } } // Page in WP-admin-panel ?>

'; _e('The Spam Viewer allows you to delete or rescue any comments marked as Spam out of your database.
', 'spamviewer'); _e('Warning: Once started, deletion cannot be cancelled.
', 'spamviewer'); _e('All comments marked as Spam in the WordPress table comments is listed below', 'spamviewer'); if (function_exists('fbtbv_get_spam_count')) { _e(' and from the plugin Trackback Validator in the table wp_data', 'spamviewer'); } echo '.

'."\n"; if ( ($spam_count == 0) && ($count == 0) ) { echo '

'; _e('Congratulations, you are free of Spam!', 'spamviewer'); echo '

'."\n"; } else { ?>

get_results("SELECT * FROM " . $wpdb->prefix . 'tb_data' . " GROUP BY tb_comments_ID ORDER BY tb_date DESC LIMIT $paginationCount ") or die ('

In Table tb_data there are no data!

' . mysql_error()); foreach ($results as $result) { $tb_author = substr($result->tb_author, 0, 15); $tb_author_url = substr($result->tb_author_url, 7, 20).' ...'; $class = (' class="alternate"' == $class) ? '' : ' class="alternate"'; $iplink_title = __('More Informations over IP:', 'spamviewer'); if ($result->tb_type == 'ham') { $checkbox_ask = "tb_comments_ID\" />"; } else { $checkbox_ask = ''; }; $tb_content = stripslashes(strip_tags($result->tb_content)); if ($tb_content == '') { $tb_content = '...'; } $tb_content = substr($tb_content, 0, 50); $tb_content_if = strpos($tb_content, '[...]'); if ($tb_content_if === false) { $tb_content_if = ''; } else { $tb_content_if = ' style="background: #ffdfdf;"'; } if ($result->tb_author_IP == '') { $result->tb_author_IP = '...'; } if ($result->comment_author_email == '') { $tb_author_email = '...'; } else { $tb_author_email = $result->comment_author_email; } if ($result->tb_author_IP == '') { $tb_author_IP = '...'; } else { $tb_author_IP = $result->tb_author_IP; } echo " \n"; } // End foreach tb_data ?>
$checkbox_ask $result->tb_comments_ID $result->tb_ID $tb_author tb_author_url\" title=\"$result->tb_author_url\">$tb_author_url $tb_content tb_author_IP\" title=\"$iplink_title $result->tb_author_IP\">$tb_author_IP

Pingback
Trackback

get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' GROUP BY comment_ID, comment_author_IP ORDER BY comment_type DESC, comment_date DESC LIMIT $paginationCount ") or die ('

The table comments is empty!

' . mysql_error()); foreach ($results as $result) { $comment_author = substr($result->comment_author, 0, 15); $comment_author_url = substr($result->comment_author_url, 7, 20).' ...'; $class = (' class="alternate"' == $class) ? '' : ' class="alternate"'; $iplink_title = __('More Informations over IP:', 'spamviewer'); if ($result->comment_approved == 'spam') { $checkbox_ask = "comment_ID\" />"; } else { $checkbox_ask = ''; }; $comment_content = stripslashes(strip_tags($result->comment_content)); if ($comment_content == '') { $comment_content = '...'; } $comment_content = substr($comment_content, 0, 50); $comment_content_if = strpos($comment_content, '[...]'); if ($comment_content_if === false) { $comment_content_if = ''; } else { $comment_content_if = ' style="background: #ffdfdf;"'; } if ($result->comment_author_email == '') { $comment_author_email = '...'; } else { $comment_author_email = $result->comment_author_email; } if ($result->comment_author_IP == '') { $comment_author_IP = '...'; } else { $comment_author_IP = $result->comment_author_IP; } if ($result->comment_type == 'pingback') { $is_pingback = 'background:#ffffb0;'; } else { $is_pingback = ''; } if ($result->comment_type == 'trackback') { $is_pingback = 'background:#d7fdb5;'; } else { $is_pingback = ''; } echo " \n"; } // End foreach comment ?>
$checkbox_ask $result->comment_ID $result->comment_post_ID $comment_author comment_author_url\" title=\"$result->comment_author_url\">$comment_author_url $comment_content comment_author_IP\" title=\"$iplink_title $result->comment_author_IP\">$comment_author_IP




plugin\'s homepage.', 'spamviewer'); ?>
© Copyright 2006 - 2007 Frank Bültge | wishlist.', 'spamviewer'); ?>