<?php
/*
Plugin Name: Trackback Validator Spam Cleaner
Plugin URI: http://www.bueltge.de/
Description: Kill eliminates spam trackbacks in your database from the Plugin <a href="http://seclab.cs.rice.edu/proj/trackback/trackback-validator-plugin/">Trackback Validator</a>
Version: 0.1
Author: Frank Bueltge
Author URI: http://bueltge.de
*/
if(function_exists('load_plugin_textdomain'))
load_plugin_textdomain('TBV-Spam-Cleaner','wp-content/plugins/TBValidator');
$wpdb_tb_data = $table_prefix . 'tb_data';
$fbtbv_link = $_SERVER['REQUEST_URI'];
$fbtbv_link = str_replace("\\", "/", $fbtbv_link);
// Counter for entries in db-table
if (! function_exists('fbtbv_get_count')) {
function fbtbv_get_count() {
global $wpdb, $table_prefix, $comments, $wpdb_tb_data;
if (isset($_POST['action']) && ('killed' == $_POST['action'])) {
$comments = 0;
} else {
$comments = $wpdb->get_var("SELECT COUNT(tb_ID) FROM $wpdb_tb_data");
}
return $comments;
}
}
// Counter for entries with type SPAM in db-table
if (! function_exists('fbtbv_get_spam_count')) {
function fbtbv_get_spam_count() {
global $wpdb, $table_prefix, $comments, $wpdb_tb_data;
if (isset($_POST['action']) && ('killed' == $_POST['action'])) {
$comments = 0;
} else {
$comments = $wpdb->get_var("SELECT COUNT(tb_ID) FROM $wpdb_tb_data WHERE tb_type = 'spam'");
}
return $comments;
}
}
// Add page in WordPress-admin-panel
if (! function_exists('fbtbv_delete_add_manage_page')) {
function fbtbv_delete_add_manage_page() {
global $wpdb;
$count = 'TBV-Spam ('.fbtbv_get_count().')';
$spam_count = 'TBV-Spam ('.fbtbv_get_spam_count().')';
if (function_exists('add_options_page'))
add_management_page("Trackback Validator Spam Cleaner", $count, 8, __FILE__);
}
}
// Delete entries in db-table
if (is_plugin_page()) {
global $wpdb, $table_prefix, $fbtbv_link;
if ('killed' == $_POST['action']) {
$killed = $wpdb->query("DELETE FROM $wpdb_tb_data ");
if (isset($killed)){
echo '<div class="updated"><p>';
if ($killed) {
echo __('Die Trackback-Spameinträge sind zerstört!', 'TBV-Spam-Cleaner');
}
echo "</p></div>";
}
}
if ( (isset($_POST['submit'])) && ('delete' == $_POST['action']) ) {
if ($_POST['not_tbspam'] == 0) {
echo '<div class="updated"><p>' . __('Keine Trackback-Einträge zum entspamen gewählt.', 'TBV-Spam-Cleaner') . "</p></div>";
} else {
$i = 0;
foreach ($_POST['not_tbspam'] as $comment) :
$comment = (int) $comment;
$wpdb->query("UPDATE $wpdb->comments SET comment_approved = '1' WHERE comment_ID = '$comment'");
$wpdb->query("DELETE FROM $wpdb_tb_data WHERE $wpdb_tb_data.tb_comments_ID = '$comment' ");
++$i;
endforeach;
if ($i == 1) {
echo '<div class="updated"><p>' . sprintf(__('%s Trackback-Eintrag entspamt.', 'TBV-Spam-Cleaner'), $i) . "</p></div>";
} else {
echo '<div class="updated"><p>' . sprintf(__('%s Trackback-Einträge entspamt.', 'TBV-Spam-Cleaner'), $i) . "</p></div>";
}
}
}
// Page in WP-admin-panel
?>
<div class="wrap">
<h2><?php _e('Trackback Spam Viewer', 'TBV-Spam-Cleaner') ?></h2>
<?php
$count = fbtbv_get_count();
$spam_count = fbtbv_get_spam_count();
if (0 == $spam_count) {
echo '<p align="center">';
_e('<strong>Gratulation</strong>, Sie sind Trackback-Spamfrei!', 'TBV-Spam-Cleaner');
echo '</p>'."\n".'</div>';
} else {
echo '<p>';
_e('Der Trackback Validator Spam Cleaner erlaubt es dir, jeden, als Trackback-Spam deklarierten Eintrag aus deiner Datenbank zu löschen.<br />Sei gewarnt, dies ist nicht rückgängig zu machen! Dabei werden die Einträge gelistet, die vom Plugin <a href=\'http://seclab.cs.rice.edu/proj/trackback/trackback-validator-plugin/\'>Trackback Validator</a> erkannt werden und in einer eigenen Tabelle', 'TBV-Spam-Cleaner');
echo ' ('.$table_prefix.'tb_data) ';
_e('gesichert sind.', 'TBV-Spam-Cleaner');
echo '</p>';
?>
<form method="post" action="<?php echo $fbtbv_link; ?>&action=killed" name="form1">
<input type="hidden" name="action" value="killed" />
<p>
<?php if (1 == $spam_count) {
_e('Derzeit ist', 'TBV-Spam-Cleaner'); ?> <strong><?php echo $spam_count; ?></strong> <?php _e('Trackback als Spam identifiziert.', 'TBV-Spam-Cleaner'); ?> <input type="submit" name="Submit" value="<?php _e('Vernichten, vernichte ihn!', 'TBV-Spam-Cleaner'); ?>" />
<?php } else {
_e('Derzeit sind', 'TBV-Spam-Cleaner'); ?> <strong><?php echo $spam_count.'/'.$count; ?></strong> <?php _e('Trackbacks als Spam identifiziert.', 'TBV-Spam-Cleaner'); ?> <input type="submit" name="Submit" value="<?php _e('Vernichten, vernichte alle!', 'TBV-Spam-Cleaner'); ?>" />
<?php } ?>
</p>
</form>
</div>
<div class="wrap">
<h2><?php _e('Trackback Spam Einträge', 'TBV-Spam-Cleaner'); ?></h2>
<form method="post" action="<?php echo $fbtbv_link; ?>&action=delete" name="form2">
<input type="hidden" name="action" value="delete" />
<table id="fbtbv_trspam" border="0" summary="FB TRSpam" width="100%" cellpadding="3" cellspacing="3">
<tr>
<th style="text-align:center;"><?php _e('Unspam?', 'TBV-Spam-Cleaner'); ?></th>
<th style="text-align:center;"><?php _e('Autor', 'TBV-Spam-Cleaner'); ?></th>
<th><?php _e('URL', 'TBV-Spam-Cleaner'); ?></th>
<th><?php _e('IP', 'TBV-Spam-Cleaner'); ?></th>
<th><?php _e('Gesehen', 'TBV-Spam-Cleaner'); ?></th>
<th><?php _e('ID', 'TBV-Spam-Cleaner'); ?></th>
<th><?php _e('Type', 'TBV-Spam-Cleaner'); ?></th>
</tr>
<?php
global $wpdb, $table_prefix, $wp_query, $siteurl, $tableposts, $wpdb_tb_data;
$results = $wpdb->get_results("SELECT tb_ID, tb_post_link, tb_author, tb_author_url, tb_author_IP, tb_seen, tb_comments_ID, tb_type
FROM $wpdb_tb_data
ORDER BY tb_ID DESC
")
or die ('<div class="wrap"><p style="color:red;"> In Tabelle tb_data sind noch keine Daten vorhanden !</p></div>' . mysql_error());
foreach ($results as $result) {
$tb_author_url = substr($result->tb_author_url, 7, 50).'...';
$class = ('class="alternate"' == $class) ? '' : 'class="alternate"';
$iplink_title = __('More Informations over IP:', 'TBV-Spam-Cleaner');
if ($result->tb_type == 'ham') {
$checkbox_ask = "<input type=\"checkbox\" name=\"not_tbspam[]\" value=\"$result->tb_comments_ID\" />";
} else {
$checkbox_ask = '';
};
echo "
<tr $class>
<td style=\"text-align:center;\">$checkbox_ask</td>
<td>$result->tb_author</td>
<td >$tb_author_url</td>
<td style=\"text-align:center;\"><a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=$result->tb_author_IP\" title=\"$iplink_title $result->tb_author_IP\">$result->tb_author_IP</a></td>
<td style=\"text-align:center;\">$result->tb_seen</td>
<td style=\"text-align:center;\">$result->tb_comments_ID</td>
<td style=\"text-align:center;\">$result->tb_type</td>
</tr>\n";
} // End foreach
?>
</table>
<input type="submit" name="submit" value="<?php _e('Unspam mich!', 'TBV-Spam-Cleaner'); ?>" />
</form>
<hr />
<p><small><?php _e('Das Plugin stammt von <a href=\'http://bueltge.de\' title=\'Zur Website\' >Frank Bueltge</a> und löscht die Spameinträge in der Datenbank, die das Plugin <a href=\'http://seclab.cs.rice.edu/proj/trackback/trackback-validator-plugin/\' title=\'Zur Website\' >Trackback Validator</a> erkennt und in der Datenbank ablegt.', 'TBV-Spam-Cleaner'); ?></small></p>
</div>
<?php
}
}
add_action('admin_menu', 'fbtbv_delete_add_manage_page');
?>You are viewing a mobilized version of this site...
View original page here