Anti-spam - Version 1.5

Version Description

  • 2013-04-15 =
  • disable trackbacks because of spam (pingbacks are enabled)
Download this release

Release Info

Developer webvitaly
Plugin Icon 128x128 Anti-spam
Version 1.5
Comparing to
See all releases

Code changes from version 1.4 to 1.5

Files changed (2) hide show
  1. anti-spam.php +67 -32
  2. readme.txt +13 -1
anti-spam.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Anti-spam
4
  Plugin URI: http://wordpress.org/extend/plugins/anti-spam/
5
  Description: No spam in comments. No captcha.
6
- Version: 1.4
7
  Author: webvitaly
8
  Author URI: http://web-profile.com.ua/wordpress/plugins/
9
  License: GPLv2 or later
@@ -11,7 +11,11 @@ License: GPLv2 or later
11
 
12
  $antispam_send_spam_comment_to_admin = false; // if true, than rejected spam comments will be sent to admin email
13
 
14
- $antispam_version = '1.4';
 
 
 
 
15
 
16
 
17
  if ( ! function_exists( 'antispam_scripts_styles_init' ) ) :
@@ -51,11 +55,47 @@ endif; // end of antispam_form_part()
51
 
52
  if ( ! function_exists( 'antispam_check_comment' ) ) :
53
  function antispam_check_comment( $commentdata ) {
54
- global $antispam_send_spam_comment_to_admin;
55
  extract( $commentdata );
56
 
57
  $antispam_pre_error_message = '<strong><a href="javascript:window.history.back()">Go back</a></strong> and try again.';
58
  $antispam_error_message = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  if ( ! is_user_logged_in() && $comment_type != 'pingback' && $comment_type != 'trackback' ) { // logged in user is not a spammer
60
  $spam_flag = false;
61
 
@@ -73,35 +113,15 @@ function antispam_check_comment( $commentdata ) {
73
  }
74
  if ( $spam_flag ) { // if we have spam
75
  if ( $antispam_send_spam_comment_to_admin ) { // if sending email to admin is enabled
76
- $post = get_post( $comment->comment_post_ID );
77
 
78
- $antispam_admin_email = get_option('admin_email'); // admin email
79
- $antispam_subject = 'Spam comment on site "'.get_bloginfo( 'name' ).'" '; // email subject
80
- $antispam_message = 'Spam comment on "'.$post->post_title.'"' . "\r\n";
81
- $antispam_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
82
-
83
- $antispam_message .= 'IP : ' . $_SERVER['REMOTE_ADDR'] . "\r\n";
84
- $antispam_message .= 'User agent : ' . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
85
- $antispam_message .= 'Referer : ' . $_SERVER['HTTP_REFERER'] . "\r\n\r\n";
86
 
87
  $antispam_message .= 'Errors: ' . $antispam_error_message . "\r\n\r\n";
88
 
89
- $antispam_message .= 'Post vars:'."\r\n"; // lets see what post vars spammers try to submit
90
- foreach ( $_POST as $key => $value ) {
91
- $antispam_message .= '$_POST['.$key. '] = '.$value."\r\n"; // .chr(13).chr(10)
92
- }
93
- $antispam_message .= "\r\n\r\n";
94
-
95
- $antispam_message .= 'Cookie vars:'."\r\n"; // lets see what cookie vars spammers try to submit
96
- foreach ( $_COOKIE as $key => $value ) {
97
- $antispam_message .= '$_COOKIE['.$key. '] = '.$value."\r\n"; // .chr(13).chr(10)
98
- }
99
- $antispam_message .= "\r\n\r\n";
100
 
101
- $antispam_message .= '-----------------------------'."\r\n";
102
- $antispam_message .= 'This is spam comment rejected by Anti-spam plugin. wordpress.org/extend/plugins/anti-spam/' . "\r\n";
103
- $antispam_message .= 'You may edit "anti-spam.php" file and disable this notification.' . "\r\n";
104
- $antispam_message .= 'You should find "$antispam_send_spam_comment_to_admin" and make it equal to "false".' . "\r\n";
105
 
106
  @wp_mail( $antispam_admin_email, $antispam_subject, $antispam_message ); // send spam comment to admin email
107
  }
@@ -109,12 +129,27 @@ function antispam_check_comment( $commentdata ) {
109
  }
110
  }
111
 
112
- //if ( $comment_type == 'trackback' || $comment_type == 'pingback' ) { // check spam in trackbacks - http://web-profile.com.ua/web/trackback-vs-pingback/
113
- // $debug_message = print_r( $commentdata, true );
114
- // @wp_mail( 'vitalymylo@gmail.com', 'antispam trackback debug info', $debug_message ); // debug info
115
- //}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
- return $commentdata;
118
  }
119
 
120
  if( ! is_admin() ) {
3
  Plugin Name: Anti-spam
4
  Plugin URI: http://wordpress.org/extend/plugins/anti-spam/
5
  Description: No spam in comments. No captcha.
6
+ Version: 1.5
7
  Author: webvitaly
8
  Author URI: http://web-profile.com.ua/wordpress/plugins/
9
  License: GPLv2 or later
11
 
12
  $antispam_send_spam_comment_to_admin = false; // if true, than rejected spam comments will be sent to admin email
13
 
14
+ $antispam_allow_trackbacks = false; // if true, than trackbacks will be allowed
15
+ // trackbacks almost not used by users, but mostly used by spammers; pingbacks are always enabled
16
+ // more about the difference between trackback and pingback - http://web-profile.com.ua/web/trackback-vs-pingback/
17
+
18
+ $antispam_version = '1.5';
19
 
20
 
21
  if ( ! function_exists( 'antispam_scripts_styles_init' ) ) :
55
 
56
  if ( ! function_exists( 'antispam_check_comment' ) ) :
57
  function antispam_check_comment( $commentdata ) {
58
+ global $antispam_send_spam_comment_to_admin, $antispam_allow_trackbacks;
59
  extract( $commentdata );
60
 
61
  $antispam_pre_error_message = '<strong><a href="javascript:window.history.back()">Go back</a></strong> and try again.';
62
  $antispam_error_message = '';
63
+
64
+ if ( $antispam_send_spam_comment_to_admin ) { // if sending email to admin is enabled
65
+ $antispam_admin_email = get_option('admin_email'); // admin email
66
+
67
+ $post = get_post( $comment->comment_post_ID );
68
+ $antispam_message_spam_info = 'Spam for post: "'.$post->post_title.'"' . "\r\n";
69
+ $antispam_message_spam_info .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
70
+
71
+ $antispam_message_spam_info .= 'IP : ' . $_SERVER['REMOTE_ADDR'] . "\r\n";
72
+ $antispam_message_spam_info .= 'User agent : ' . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
73
+ $antispam_message_spam_info .= 'Referer : ' . $_SERVER['HTTP_REFERER'] . "\r\n\r\n";
74
+
75
+ $antispam_message_spam_info .= 'Comment data:'."\r\n"; // lets see what comment data spammers try to submit
76
+ foreach ( $commentdata as $key => $value ) {
77
+ $antispam_message_spam_info .= '$commentdata['.$key. '] = '.$value."\r\n"; // .chr(13).chr(10)
78
+ }
79
+ $antispam_message_spam_info .= "\r\n\r\n";
80
+
81
+ $antispam_message_spam_info .= 'Post vars:'."\r\n"; // lets see what post vars spammers try to submit
82
+ foreach ( $_POST as $key => $value ) {
83
+ $antispam_message_spam_info .= '$_POST['.$key. '] = '.$value."\r\n"; // .chr(13).chr(10)
84
+ }
85
+ $antispam_message_spam_info .= "\r\n\r\n";
86
+
87
+ $antispam_message_spam_info .= 'Cookie vars:'."\r\n"; // lets see what cookie vars spammers try to submit
88
+ foreach ( $_COOKIE as $key => $value ) {
89
+ $antispam_message_spam_info .= '$_COOKIE['.$key. '] = '.$value."\r\n"; // .chr(13).chr(10)
90
+ }
91
+ $antispam_message_spam_info .= "\r\n\r\n";
92
+
93
+ $antispam_message_append = '-----------------------------'."\r\n";
94
+ $antispam_message_append .= 'This is spam comment rejected by Anti-spam plugin. wordpress.org/extend/plugins/anti-spam/' . "\r\n";
95
+ $antispam_message_append .= 'You may edit "anti-spam.php" file and disable this notification.' . "\r\n";
96
+ $antispam_message_append .= 'You should find "$antispam_send_spam_comment_to_admin" and make it equal to "false".' . "\r\n";
97
+ }
98
+
99
  if ( ! is_user_logged_in() && $comment_type != 'pingback' && $comment_type != 'trackback' ) { // logged in user is not a spammer
100
  $spam_flag = false;
101
 
113
  }
114
  if ( $spam_flag ) { // if we have spam
115
  if ( $antispam_send_spam_comment_to_admin ) { // if sending email to admin is enabled
 
116
 
117
+ $antispam_subject = 'Spam comment on site ['.get_bloginfo( 'name' ).']'; // email subject
118
+ $antispam_message = '';
 
 
 
 
 
 
119
 
120
  $antispam_message .= 'Errors: ' . $antispam_error_message . "\r\n\r\n";
121
 
122
+ $antispam_message .= $antispam_message_spam_info; // spam comment, post, cookie and other data
 
 
 
 
 
 
 
 
 
 
123
 
124
+ $antispam_message .= $antispam_message_append;
 
 
 
125
 
126
  @wp_mail( $antispam_admin_email, $antispam_subject, $antispam_message ); // send spam comment to admin email
127
  }
129
  }
130
  }
131
 
132
+ if( ! $antispam_allow_trackbacks ) { // if trackbacks are blocked (pingbacks are alowed)
133
+ if ( $comment_type == 'trackback' ) { // if trackbacks ( || $comment_type == 'pingback' )
134
+ $antispam_error_message .= '<br> Error: trackbacks are disabled. ';
135
+ if ( $antispam_send_spam_comment_to_admin ) { // if sending email to admin is enabled
136
+ $antispam_subject = 'Spam trackback on site ['.get_bloginfo( 'name' ).']'; // email subject
137
+
138
+ $antispam_message = '';
139
+
140
+ $antispam_message .= 'Errors: ' . $antispam_error_message . "\r\n\r\n";
141
+
142
+ $antispam_message .= $antispam_message_spam_info; // spam comment, post, cookie and other data
143
+
144
+ $antispam_message .= $antispam_message_append;
145
+
146
+ @wp_mail( $antispam_admin_email, $antispam_subject, $antispam_message ); // send trackback comment to admin email
147
+ }
148
+ wp_die( $antispam_pre_error_message . $antispam_error_message ); // die - do not send trackback
149
+ }
150
+ }
151
 
152
+ return $commentdata; // if comment does not looks like spam
153
  }
154
 
155
  if( ! is_admin() ) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://web-profile.com.ua/donate/
4
  Tags: spam, spammer, spammers, comment, comments, antispam, anti-spam, block-spam, spamfree, spam-free, spambot, spam-bot, bot
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
- Stable tag: 1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -52,6 +52,14 @@ You should edit "anti-spam.php" file and find "$antispam_send_spam_comment_to_ad
52
  Anti-spam plugin blocks about 99.9% of automatic spam messages (sent by spam-bots via post requests).
53
  But Anti-spam plugin will pass the messages which were submitted by spammers manually via browser. But such messages happens very rarely.
54
 
 
 
 
 
 
 
 
 
55
  = Not enough information about the plugin? =
56
 
57
  You may check out the [source code of the plugin](http://plugins.trac.wordpress.org/browser/anti-spam/trunk/anti-spam.php).
@@ -59,12 +67,16 @@ The plugin has about 100 lines of code and pretty easy to read. I was trying my
59
  Plugin is small but it makes all the dirty work against spam pretty good. You may give it a try.
60
 
61
  = How to reduce the amount of spam? =
 
62
  Do not order spam-newsletters because people hate spam and people will not like products received from spam.
63
  Do not order products from spam. If spam will be less effective than spammers will stop sending it.
64
 
65
 
66
  == Changelog ==
67
 
 
 
 
68
  = 1.4 - 2013-04-13 =
69
  * code refactor
70
  * renaming empty field to "*-email-url" to trap more spam
4
  Tags: spam, spammer, spammers, comment, comments, antispam, anti-spam, block-spam, spamfree, spam-free, spambot, spam-bot, bot
5
  Requires at least: 3.0
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
52
  Anti-spam plugin blocks about 99.9% of automatic spam messages (sent by spam-bots via post requests).
53
  But Anti-spam plugin will pass the messages which were submitted by spammers manually via browser. But such messages happens very rarely.
54
 
55
+ = What about trackback spam? =
56
+
57
+ Users rarely use trackbacks because it is manual and requires extra input. Spammers uses trackbacks because it is easy to cheat here.
58
+ Users use pingbacks very often because they work automatically. Spammers does not use pingbacks because backlinks are checked.
59
+ So trackbacks are blocked by default but pingbacks are enabled. You may enable trackbacks if you use it.
60
+ Just edit "anti-spam.php" file and find "$antispam_allow_trackbacks" and make it "true".
61
+ You may read more about the [difference between trackbacks and pingbacks](http://web-profile.com.ua/web/trackback-vs-pingback/).
62
+
63
  = Not enough information about the plugin? =
64
 
65
  You may check out the [source code of the plugin](http://plugins.trac.wordpress.org/browser/anti-spam/trunk/anti-spam.php).
67
  Plugin is small but it makes all the dirty work against spam pretty good. You may give it a try.
68
 
69
  = How to reduce the amount of spam? =
70
+
71
  Do not order spam-newsletters because people hate spam and people will not like products received from spam.
72
  Do not order products from spam. If spam will be less effective than spammers will stop sending it.
73
 
74
 
75
  == Changelog ==
76
 
77
+ = 1.5 - 2013-04-15 =
78
+ * disable trackbacks because of spam (pingbacks are enabled)
79
+
80
  = 1.4 - 2013-04-13 =
81
  * code refactor
82
  * renaming empty field to "*-email-url" to trap more spam