Version Description
- Added a rejection message for when people trip over the cookie protection.
- Plugin requires WordPress 3.1+ now.
Download this release
Release Info
Developer | donncha |
Plugin | ![]() |
Version | 0.5.4 |
Comparing to | |
See all releases |
Code changes from version 0.5.1 to 0.5.4
- Changelog.txt +198 -0
- blank.gif +0 -0
- cookies-for-comments.php +93 -16
- css.php +12 -0
- readme.txt +25 -6
Changelog.txt
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
2011-07-13 10:35 donncha
|
2 |
+
|
3 |
+
* cookies-for-comments.php, readme.txt: Added a rejection message
|
4 |
+
and bump required version to 3.1 (esc_textarea)
|
5 |
+
|
6 |
+
2010-11-22 16:21 donncha
|
7 |
+
|
8 |
+
* cookies-for-comments.php: Maje sure img and css html loaders
|
9 |
+
validate, props Barýþ Ünver (http://beyn.org/)
|
10 |
+
|
11 |
+
2010-11-05 12:52 donncha
|
12 |
+
|
13 |
+
* Changelog.txt: Updated changelog
|
14 |
+
|
15 |
+
2010-11-05 12:39 donncha
|
16 |
+
|
17 |
+
* cookies-for-comments.php: Doh! If time to post comment is LESS
|
18 |
+
than wait limit then it's spam.
|
19 |
+
|
20 |
+
2010-11-04 13:42 donncha
|
21 |
+
|
22 |
+
* cookies-for-comments.php, readme.txt: Bumped version to 0.5.2 and
|
23 |
+
bumped up tested version
|
24 |
+
|
25 |
+
2010-11-04 13:32 donncha
|
26 |
+
|
27 |
+
* readme.txt: Updated docs explaining delivery options
|
28 |
+
|
29 |
+
2010-11-04 13:22 donncha
|
30 |
+
|
31 |
+
* Changelog.txt: Added changelog
|
32 |
+
|
33 |
+
2010-11-04 13:11 donncha
|
34 |
+
|
35 |
+
* blank.gif, cookies-for-comments.php, css.php: Set the cookie by
|
36 |
+
using an image instead of stylesheet
|
37 |
+
|
38 |
+
2010-11-04 11:38 donncha
|
39 |
+
|
40 |
+
* cookies-for-comments.php: Minor mod to admin page
|
41 |
+
|
42 |
+
2010-11-04 11:35 donncha
|
43 |
+
|
44 |
+
* cookies-for-comments.php: Use plugins_url() for css.php path,
|
45 |
+
props Paul Clark
|
46 |
+
|
47 |
+
2010-11-03 16:05 donncha
|
48 |
+
|
49 |
+
* cookies-for-comments.php: Fixed syntax error.
|
50 |
+
|
51 |
+
2010-11-03 11:40 donncha
|
52 |
+
|
53 |
+
* cookies-for-comments.php: Simplify css key checking significantly
|
54 |
+
so it works now
|
55 |
+
|
56 |
+
2010-11-03 11:14 donncha
|
57 |
+
|
58 |
+
* cookies-for-comments.php: Add "time to post comment" to comment
|
59 |
+
notification emails
|
60 |
+
|
61 |
+
2010-11-03 11:08 donncha
|
62 |
+
|
63 |
+
* cookies-for-comments.php: Check that user already left a comment,
|
64 |
+
*after* they failed the time check.
|
65 |
+
|
66 |
+
2010-11-03 10:29 donncha
|
67 |
+
|
68 |
+
* cookies-for-comments.php, css.php: Serve the css file/cookies
|
69 |
+
from css.php to avoid loading WordPress
|
70 |
+
|
71 |
+
2010-10-29 14:44 donncha
|
72 |
+
|
73 |
+
* cookies-for-comments.php: Better explanation of "speed spammer"
|
74 |
+
function
|
75 |
+
|
76 |
+
2010-10-29 14:24 donncha
|
77 |
+
|
78 |
+
* cookies-for-comments.php: Added "speed spammers" option to catch
|
79 |
+
human spammers
|
80 |
+
|
81 |
+
2010-07-01 15:26 donncha
|
82 |
+
|
83 |
+
* readme.txt: Removed donate link and added automattic as a
|
84 |
+
contributor
|
85 |
+
|
86 |
+
2009-10-23 08:33 donncha
|
87 |
+
|
88 |
+
* readme.txt: Added FAQ on minify
|
89 |
+
|
90 |
+
2009-08-02 09:00 donncha
|
91 |
+
|
92 |
+
* cookies-for-comments.php, readme.txt: Added changelog to
|
93 |
+
readme.txt
|
94 |
+
Bump version to 0.5.1
|
95 |
+
|
96 |
+
2009-08-02 08:46 donncha
|
97 |
+
|
98 |
+
* cookies-for-comments.php, readme.txt: Generate cfc_key all the
|
99 |
+
time if it's missing, not just on serving the css html
|
100 |
+
Added MU signup form mod_rewrite rules to docs and admin page
|
101 |
+
Added Settings page link to plugins page.
|
102 |
+
|
103 |
+
2009-05-19 10:16 donncha
|
104 |
+
|
105 |
+
* cookies-for-comments.php: Add explanation text to css file.
|
106 |
+
Don't let wp-super-cache cache this page.
|
107 |
+
|
108 |
+
2009-05-07 13:03 donncha
|
109 |
+
|
110 |
+
* readme.txt: Add docs on how to use CFC to protect the MU signup
|
111 |
+
form
|
112 |
+
|
113 |
+
2009-04-18 22:05 donncha
|
114 |
+
|
115 |
+
* readme.txt: Updated donation link and tested version number
|
116 |
+
|
117 |
+
2009-02-19 17:24 donncha
|
118 |
+
|
119 |
+
* cookies-for-comments.php: Show htaccess rules on admin page,
|
120 |
+
props freedomblogging
|
121 |
+
|
122 |
+
2009-02-18 20:42 donncha
|
123 |
+
|
124 |
+
* cookies-for-comments.php: Updated changes text.
|
125 |
+
|
126 |
+
2009-02-18 20:39 donncha
|
127 |
+
|
128 |
+
* cookies-for-comments.php: Make sure we return the cfc_key!
|
129 |
+
|
130 |
+
2009-02-18 20:36 donncha
|
131 |
+
|
132 |
+
* cookies-for-comments.php: Store cfc_key in sitemeta for WordPress
|
133 |
+
MU sites
|
134 |
+
|
135 |
+
2008-09-19 15:32 donncha
|
136 |
+
|
137 |
+
* readme.txt: Added mod_rewrite rules to block spam comments before
|
138 |
+
they get to WordPress
|
139 |
+
|
140 |
+
2008-08-23 16:57 donncha
|
141 |
+
|
142 |
+
* cookies-for-comments.php, readme.txt: Bump version to 0.5
|
143 |
+
|
144 |
+
2008-08-23 16:56 donncha
|
145 |
+
|
146 |
+
* cookies-for-comments.php: Add random key to css file
|
147 |
+
|
148 |
+
2008-08-21 11:06 donncha
|
149 |
+
|
150 |
+
* cookies-for-comments.php: Set the cookie for a week
|
151 |
+
|
152 |
+
2008-07-15 19:31 donncha
|
153 |
+
|
154 |
+
* readme.txt: Oops. Fixed name and updated readme
|
155 |
+
|
156 |
+
2008-07-15 11:28 donncha
|
157 |
+
|
158 |
+
* cookies-for-comments.php, readme.txt: Bump version numbers
|
159 |
+
|
160 |
+
2008-07-15 11:26 donncha
|
161 |
+
|
162 |
+
* cookies-for-comments.php: User can delete spam comments now,
|
163 |
+
http://wordpress.org/support/topic/187810?replies=2
|
164 |
+
Check that Akismet functions exist
|
165 |
+
|
166 |
+
2008-07-15 09:50 donncha
|
167 |
+
|
168 |
+
* cookies-for-comments.php, readme.txt: Bump version number
|
169 |
+
|
170 |
+
2008-07-15 09:49 donncha
|
171 |
+
|
172 |
+
* cookies-for-comments.php: Return comment to filter.
|
173 |
+
|
174 |
+
2008-07-07 10:01 donncha
|
175 |
+
|
176 |
+
* cookies-for-comments.php, readme.txt: Bump version numbers
|
177 |
+
|
178 |
+
2008-07-07 09:58 donncha
|
179 |
+
|
180 |
+
* cookies-for-comments.php: Work in sub directories too
|
181 |
+
|
182 |
+
2008-04-07 11:21 donncha
|
183 |
+
|
184 |
+
* cookies-for-comments.php: Mark spam comments with a "Blocked by
|
185 |
+
CFC" message
|
186 |
+
|
187 |
+
2008-03-06 17:09 donncha
|
188 |
+
|
189 |
+
* cookies-for-comments.php: Don't check pingbacks
|
190 |
+
|
191 |
+
2008-03-06 15:38 donncha
|
192 |
+
|
193 |
+
* cookies-for-comments.php, readme.txt: Initial import
|
194 |
+
|
195 |
+
2008-03-06 15:09 plugin-master
|
196 |
+
|
197 |
+
* .: adding cookies-for-comments by donncha
|
198 |
+
|
blank.gif
ADDED
Binary file
|
cookies-for-comments.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Cookies for Comments
|
4 |
Plugin URI: http://ocaoimh.ie/cookies-for-comments/
|
5 |
Description: Sets a cookie that must exist for a comment to be allowed through
|
6 |
-
Version: 0.5.
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
|
@@ -24,9 +24,22 @@ function cfc_stylesheet_html() {
|
|
24 |
if ( $cfc_key == '' )
|
25 |
return false;
|
26 |
|
27 |
-
?><link rel="stylesheet" href="<?php echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
29 |
-
add_action( 'wp_head', 'cfc_stylesheet_html' );
|
30 |
|
31 |
function get_cfc_key() {
|
32 |
if( function_exists( 'get_site_option' ) ) {
|
@@ -55,8 +68,8 @@ function cfc_set_comment_style_cookie() {
|
|
55 |
return;
|
56 |
|
57 |
if( strpos( $_SERVER[ 'REQUEST_URI' ], $cfc_key . '.css' ) ) {
|
58 |
-
if( !isset( $_COOKIE[ $cfc_key ] ) )
|
59 |
-
@setcookie( $cfc_key,
|
60 |
header("Content-type: text/css");
|
61 |
echo "/* Page generated by Cookies for Comments at http://ocaoimh.ie/cookies-for-comments/ */";
|
62 |
define( 'DONOTCACHEPAGE', 1 ); // don't let wp-super-cache cache this page.
|
@@ -74,15 +87,33 @@ function cfc_check_comment_style_cookie( $comment ) {
|
|
74 |
if( !$cfc_key )
|
75 |
return $comment;
|
76 |
|
77 |
-
if(
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
} else {
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
-
if( function_exists( 'akismet_auto_check_comment' ) )
|
84 |
-
remove_filter( 'preprocess_comment', 'akismet_auto_check_comment', 10 ); // remove Akismet, comment is spam!
|
85 |
-
$comment[ 'comment_author' ] = '[Blocked by CFC] ' . $comment[ 'comment_author' ];
|
86 |
}
|
87 |
return $comment;
|
88 |
}
|
@@ -102,19 +133,38 @@ function cfc_conf() {
|
|
102 |
if( $_POST[ 'cfc_spam' ] == 'spam' || $_POST[ 'cfc_spam' ] == 'delete' ) {
|
103 |
update_option( 'cfc_spam', $_POST[ 'cfc_spam' ] );
|
104 |
}
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
if( !get_option( 'cfc_spam' ) )
|
107 |
update_option( 'cfc_spam', 'spam' );
|
|
|
|
|
108 |
|
109 |
-
if ( !empty($_POST ) ) {
|
110 |
-
<div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
|
111 |
-
|
|
|
112 |
<div class="wrap">
|
113 |
<h2><?php _e('Comments for Cookies Configuration'); ?></h2>
|
114 |
<div class="narrow">
|
115 |
<form action="" method="post" id="cfc-conf" style="margin: auto; width: 400px; ">
|
116 |
<?php wp_nonce_field('cfc') ?>
|
117 |
-
<label><h3>What should happen to comments caught by CFC?</h3> <select name='cfc_spam'><option value='delete' <?php echo ( get_option( 'cfc_spam' ) == 'delete' ? 'selected' : '' ); ?> /> Delete <option value='spam' <?php echo ( get_option( 'cfc_spam' ) == 'spam' ? 'selected' : '' ); ?> /> Spam</select></label
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
<input type='submit' name='submit' value='Save Options' />
|
119 |
</form>
|
120 |
<?php
|
@@ -150,4 +200,31 @@ function cfc_plugin_actions( $links, $file ) {
|
|
150 |
return $links;
|
151 |
}
|
152 |
add_filter( 'plugin_action_links', 'cfc_plugin_actions', 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
?>
|
3 |
Plugin Name: Cookies for Comments
|
4 |
Plugin URI: http://ocaoimh.ie/cookies-for-comments/
|
5 |
Description: Sets a cookie that must exist for a comment to be allowed through
|
6 |
+
Version: 0.5.4
|
7 |
Author: Donncha O Caoimh
|
8 |
Author URI: http://ocaoimh.ie/
|
9 |
|
24 |
if ( $cfc_key == '' )
|
25 |
return false;
|
26 |
|
27 |
+
?><link rel="stylesheet" href="<?php echo plugins_url( "css.php?k={$cfc_key}&t=" . mt_rand(), __FILE__ ); ?>" type="text/css" media="screen" /><?php
|
28 |
+
}
|
29 |
+
|
30 |
+
function cfc_img_html() {
|
31 |
+
$cfc_key = get_cfc_key();
|
32 |
+
|
33 |
+
if ( $cfc_key == '' )
|
34 |
+
return false;
|
35 |
+
|
36 |
+
?><img src="<?php echo plugins_url( "css.php?k={$cfc_key}&o=i&t=" . mt_rand(), __FILE__ ); ?>" width='1' height='1' /><?php
|
37 |
+
}
|
38 |
+
if ( get_option( 'cfc_delivery' ) == 'css' ) {
|
39 |
+
add_action( 'wp_head', 'cfc_stylesheet_html' );
|
40 |
+
} else {
|
41 |
+
add_action( 'wp_footer', 'cfc_img_html' );
|
42 |
}
|
|
|
43 |
|
44 |
function get_cfc_key() {
|
45 |
if( function_exists( 'get_site_option' ) ) {
|
68 |
return;
|
69 |
|
70 |
if( strpos( $_SERVER[ 'REQUEST_URI' ], $cfc_key . '.css' ) ) {
|
71 |
+
if ( !isset( $_COOKIE[ $cfc_key ] ) || ( isset( $_COOKIE[ $cfc_key ] ) && $_COOKIE[ $cfc_key ] == 1 ) )
|
72 |
+
@setcookie( $cfc_key, time(), time()+604800, '/' );
|
73 |
header("Content-type: text/css");
|
74 |
echo "/* Page generated by Cookies for Comments at http://ocaoimh.ie/cookies-for-comments/ */";
|
75 |
define( 'DONOTCACHEPAGE', 1 ); // don't let wp-super-cache cache this page.
|
87 |
if( !$cfc_key )
|
88 |
return $comment;
|
89 |
|
90 |
+
if ( is_user_logged_in() )
|
91 |
+
return $comment;
|
92 |
+
if ( $comment[ 'comment_type' ] != 'trackback' && $comment[ 'comment_type' ] != 'pingback' ) {
|
93 |
+
if ( isset( $_COOKIE[ $cfc_key ] ) ) {
|
94 |
+
$spam = 0;
|
95 |
+
$cfc_speed = (int)get_site_option( 'cfc_speed' );
|
96 |
+
if ( $cfc_speed > 0 && $_COOKIE[ $cfc_key ] > 1 && ( time() - $_COOKIE[ $cfc_key ] ) < $cfc_speed && !isset( $_COOKIE[ 'comment_author_' . COOKIEHASH ] ) ) {
|
97 |
+
$spam = 1;
|
98 |
+
}
|
99 |
} else {
|
100 |
+
$spam = 1;
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( $spam == 1 ) {
|
104 |
+
if( get_option( 'cfc_spam' ) == 'delete' ) {
|
105 |
+
$msg = get_option( 'cfc_spam_message' );
|
106 |
+
if ( !$msg ) {
|
107 |
+
$msg = '<p>Sorry, your comment has not been accepted.<p>';
|
108 |
+
}
|
109 |
+
$msg .= "<p>Your comment: <form><input type='text' value='" . esc_attr( $comment[ 'comment_author' ] ) . "' /><br /><input type='text' value='" . esc_attr( $comment[ 'comment_author_email' ] ) . "' /><br /><input type='text' value='" . esc_attr( $comment[ 'comment_author_url' ] ) . "' /><br /><textarea rows=10 cols=40>" . esc_textarea( stripslashes( $comment[ 'comment_content' ] ) ) . "</textarea></form></p>";
|
110 |
+
wp_die( $msg );
|
111 |
+
} else {
|
112 |
+
add_filter('pre_comment_approved', create_function('$a', 'return \'spam\';')); // thanks Akismet
|
113 |
+
}
|
114 |
+
if( function_exists( 'akismet_auto_check_comment' ) )
|
115 |
+
remove_filter( 'preprocess_comment', 'akismet_auto_check_comment', 10 ); // remove Akismet, comment is spam!
|
116 |
}
|
|
|
|
|
|
|
117 |
}
|
118 |
return $comment;
|
119 |
}
|
133 |
if( $_POST[ 'cfc_spam' ] == 'spam' || $_POST[ 'cfc_spam' ] == 'delete' ) {
|
134 |
update_option( 'cfc_spam', $_POST[ 'cfc_spam' ] );
|
135 |
}
|
136 |
+
update_option( 'cfc_speed', (int)$_POST[ 'cfc_speed' ] );
|
137 |
+
update_option( 'cfc_spam_message', stripslashes( $_POST[ 'cfc_spam_message' ] ) );
|
138 |
+
if ( $_POST[ 'cfc_delivery' ] == 'css' || $_POST[ 'cfc_delivery' ] == 'img' )
|
139 |
+
update_option( 'cfc_delivery', $_POST[ 'cfc_delivery' ] );
|
140 |
}
|
141 |
if( !get_option( 'cfc_spam' ) )
|
142 |
update_option( 'cfc_spam', 'spam' );
|
143 |
+
if ( !get_option( 'cfc_delivery' ) )
|
144 |
+
add_option( 'cfc_delivery', 'img' );
|
145 |
|
146 |
+
if ( !empty($_POST ) ) {
|
147 |
+
?> <div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div> <?php
|
148 |
+
}
|
149 |
+
?>
|
150 |
<div class="wrap">
|
151 |
<h2><?php _e('Comments for Cookies Configuration'); ?></h2>
|
152 |
<div class="narrow">
|
153 |
<form action="" method="post" id="cfc-conf" style="margin: auto; width: 400px; ">
|
154 |
<?php wp_nonce_field('cfc') ?>
|
155 |
+
<label><h3>What should happen to comments caught by CFC?</h3> <select name='cfc_spam'><option value='delete' <?php echo ( get_option( 'cfc_spam' ) == 'delete' ? 'selected' : '' ); ?> /> Delete <option value='spam' <?php echo ( get_option( 'cfc_spam' ) == 'spam' ? 'selected' : '' ); ?> /> Spam</select></label><br />
|
156 |
+
<h3>Payload Delivery Mechanism</h3>
|
157 |
+
<input type='radio' name='cfc_delivery' value='css' <?php checked( get_option( 'cfc_delivery' ), 'css' ) ?> /> CSS file.<br />
|
158 |
+
<input type='radio' name='cfc_delivery' value='img' <?php checked( get_option( 'cfc_delivery' ), 'img' ) ?> /> Image file. (recommended)<br />
|
159 |
+
<p>The CSS file loads at the top of the page, possibly slowing down how fast the page renders. The image loads at the end but if your server is very slow someone may have time to enter a comment before the image loads. Unlikely but it might happen.</p>
|
160 |
+
<h3>Speed Spammers</h3>
|
161 |
+
|
162 |
+
<p>Some spammers visit your site, leave a real looking comment and disappear again. They'll do this quickly and then move on to the next target site.<br /> To stop them we check how long they spend on your site before leaving the comment. Any value above 0 will reject those comments but might catch legitimate comments too. Recommended values from 3 to 6 seconds and send comments to the spam folder.</p>
|
163 |
+
<input type='text' name='cfc_speed' size='3' value='<?php echo (int)get_option( 'cfc_speed' ) ?>' /> Seconds</label><br /> <br />
|
164 |
+
|
165 |
+
<h3>Rejection Message</h3>
|
166 |
+
<p>When a comment fails to be posted it's not always a spammer. Add a message here to be shown to those users. Be aware that real spammers will see this message too! The comment they made will be shown below your message.</p>
|
167 |
+
<textarea cols=40 rows=5 name='cfc_spam_message'><?php echo esc_textarea( get_option( 'cfc_spam_message' ) ); ?></textarea><br /><br />
|
168 |
<input type='submit' name='submit' value='Save Options' />
|
169 |
</form>
|
170 |
<?php
|
200 |
return $links;
|
201 |
}
|
202 |
add_filter( 'plugin_action_links', 'cfc_plugin_actions', 10, 2 );
|
203 |
+
|
204 |
+
function cfc_add_referrer_to_notification( $text, $comment_id ) {
|
205 |
+
$cfc_key = get_cfc_key();
|
206 |
+
if( !$cfc_key )
|
207 |
+
return $text;
|
208 |
+
if ( is_user_logged_in() )
|
209 |
+
return $text;
|
210 |
+
|
211 |
+
if ( $_COOKIE[ $cfc_key ] > 1 ) {
|
212 |
+
$ttp = ( time() - $_COOKIE[ $cfc_key ] );
|
213 |
+
$format = "seconds";
|
214 |
+
if ( $ttp > 60 ) {
|
215 |
+
$ttp = $ttp / 60;
|
216 |
+
$format = "minutes";
|
217 |
+
}
|
218 |
+
if ( $ttp > 60 ) {
|
219 |
+
$ttp = $ttp / 60;
|
220 |
+
$format = "hours";
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
$text .= "\r\nTime to post comment: " . number_format( $ttp, 2 ) . " $format\r\n";
|
225 |
+
}
|
226 |
+
return $text;
|
227 |
+
}
|
228 |
+
add_filter( 'comment_notification_text', 'cfc_add_referrer_to_notification', 10, 2 );
|
229 |
+
add_filter( 'comment_moderation_text', 'cfc_add_referrer_to_notification', 10, 2 );
|
230 |
?>
|
css.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( !isset( $_COOKIE[ $_GET[ 'k' ] ] ) || ( isset( $_COOKIE[ $_GET[ 'k' ] ] ) && $_COOKIE[ $_GET[ 'k' ] ] == 1 ) )
|
3 |
+
@setcookie( $_GET[ 'k' ], time(), time()+604800, '/' );
|
4 |
+
if ( isset( $_GET[ 'o' ] ) ) {
|
5 |
+
header("Content-type: image/gif");
|
6 |
+
readfile( './blank.gif' );
|
7 |
+
} else {
|
8 |
+
header("Content-type: text/css");
|
9 |
+
echo "/* Page generated by Cookies for Comments at http://ocaoimh.ie/cookies-for-comments/ */";
|
10 |
+
}
|
11 |
+
die();
|
12 |
+
?>
|
readme.txt
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
=== Cookies for Comments ===
|
2 |
-
Contributors: donncha
|
3 |
Tags: cookies, comments, spam
|
4 |
-
Tested up to:
|
5 |
-
Stable tag: 0.5.
|
6 |
-
|
7 |
|
8 |
Sets a cookie on a random URL that is then checked when a comment is posted. If the cookie is missing the comment is marked as spam. This plugin will reduce your comment spam by at least 90%, probably.
|
9 |
|
10 |
== Description ==
|
11 |
-
This plugin adds a stylesheet to your blog's html source code. When a browser loads that stylesheet a cookie is dropped. If that user then leaves a comment the cookie is checked. If it doesn't exist the comment is marked as spam.
|
|
|
12 |
|
13 |
-
For the adventurous, add these lines to your .htaccess and it will block spam attempts before they ever get to WordPress. Replace the Xs with the cookie that was set in your browser after viewing your blog. Make sure the lines go above the standard WordPress rules.
|
14 |
|
15 |
`RewriteCond %{HTTP_COOKIE} !^.*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.*$`
|
16 |
`RewriteRule ^wp-comments-post.php - [F,L]`
|
@@ -25,6 +26,18 @@ Copy into your plugins folder and activate. If you are using a caching plugin su
|
|
25 |
|
26 |
== Changelog ==
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
= 0.5.1 =
|
29 |
* Generate cfc_key all the time if it's missing, not just on serving the css html
|
30 |
* Added MU signup form mod_rewrite rules to docs and admin page
|
@@ -35,3 +48,9 @@ Copy into your plugins folder and activate. If you are using a caching plugin su
|
|
35 |
* Don't let wp-super-cache cache this page.
|
36 |
* Store cfc_key in sitemeta for WordPress MU sites
|
37 |
* Added mod_rewrite rules to block spam comments before they get to WordPress
|
|
|
|
|
|
|
|
|
|
|
|
1 |
=== Cookies for Comments ===
|
2 |
+
Contributors: donncha, automattic
|
3 |
Tags: cookies, comments, spam
|
4 |
+
Tested up to: 3.5
|
5 |
+
Stable tag: 0.5.4
|
6 |
+
Requires at least: 3.1
|
7 |
|
8 |
Sets a cookie on a random URL that is then checked when a comment is posted. If the cookie is missing the comment is marked as spam. This plugin will reduce your comment spam by at least 90%, probably.
|
9 |
|
10 |
== Description ==
|
11 |
+
This plugin adds a stylesheet or image to your blog's html source code. When a browser loads that stylesheet or image a cookie is dropped. If that user then leaves a comment the cookie is checked. If it doesn't exist the comment is marked as spam.
|
12 |
+
The plugin can also check how long it took a user to enter a comment. If it's too fast it's probably a spam bot. How fast can a legitimate user enter their name, email, web address and enter a well thought out comment?
|
13 |
|
14 |
+
For the adventurous, add these lines to your .htaccess and it will block spam attempts before they ever get to WordPress. Replace the Xs with the cookie that was set in your browser after viewing your blog. You can also find the cookie value by examining the page source code and looking for "css.php?k=XXXXXXXXXXXXXXXXXXX". Make sure the lines go above the standard WordPress rules.
|
15 |
|
16 |
`RewriteCond %{HTTP_COOKIE} !^.*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.*$`
|
17 |
`RewriteRule ^wp-comments-post.php - [F,L]`
|
26 |
|
27 |
== Changelog ==
|
28 |
|
29 |
+
= 0.5.4 =
|
30 |
+
* Added a rejection message for when people trip over the cookie protection.
|
31 |
+
* Plugin requires WordPress 3.1+ now.
|
32 |
+
|
33 |
+
= 0.5.2 =
|
34 |
+
* Use an image to deliver cookie as well as stylesheet.
|
35 |
+
* Don't load WordPress to set the cookie. Makes pageload much faster!
|
36 |
+
* Added "time to post comment" to comment notification emails.
|
37 |
+
* Support for SSL sites.
|
38 |
+
* If user is logged in don't check for cookie.
|
39 |
+
* Speed spammer checks to stop smarter bots and human spammers.
|
40 |
+
|
41 |
= 0.5.1 =
|
42 |
* Generate cfc_key all the time if it's missing, not just on serving the css html
|
43 |
* Added MU signup form mod_rewrite rules to docs and admin page
|
48 |
* Don't let wp-super-cache cache this page.
|
49 |
* Store cfc_key in sitemeta for WordPress MU sites
|
50 |
* Added mod_rewrite rules to block spam comments before they get to WordPress
|
51 |
+
|
52 |
+
== Frequently Asked Questions ==
|
53 |
+
|
54 |
+
= The cookie isn't being set by the plugin. Why? =
|
55 |
+
|
56 |
+
If you use wp-minify make sure you add the Cookies for Comments CSS file to the list of CSS files that shouldn't be minified.
|