Akismet Anti-Spam - Version 2.2.7

Version Description

  • Add a new AKISMET_VERSION constant
  • Reduce the possibility of over-counting spam when another spam filter plugin is in use
  • Disable the connectivity check when the API key is hard-coded for WPMU
Download this release

Release Info

Developer tellyworth
Plugin Icon 128x128 Akismet Anti-Spam
Version 2.2.7
Comparing to
See all releases

Code changes from version 2.2.6 to 2.2.7

Files changed (2) hide show
  1. akismet.php +26 -6
  2. readme.txt +8 -2
akismet.php CHANGED
@@ -3,11 +3,13 @@
3
  Plugin Name: Akismet
4
  Plugin URI: http://akismet.com/
5
  Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code>&lt;?php akismet_counter(); ?&gt;</code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>.
6
- Version: 2.2.6
7
  Author: Matt Mullenweg
8
  Author URI: http://ma.tt/
9
  */
10
 
 
 
11
  // If you hardcode a WP.com API key here, all key config screens will be hidden
12
  if ( defined('WPCOM_API_KEY') )
13
  $wpcom_api_key = constant('WPCOM_API_KEY');
@@ -313,6 +315,10 @@ function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
313
 
314
  // Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
315
  function akismet_server_connectivity_ok() {
 
 
 
 
316
  $servers = akismet_get_server_connectivity();
317
  return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
318
  }
@@ -367,12 +373,14 @@ function akismet_get_host($host) {
367
  // Returns array with headers in $response[0] and body in $response[1]
368
  function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
369
  global $wp_version;
 
 
370
 
371
  $http_request = "POST $path HTTP/1.0\r\n";
372
  $http_request .= "Host: $host\r\n";
373
  $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n";
374
  $http_request .= "Content-Length: " . strlen($request) . "\r\n";
375
- $http_request .= "User-Agent: WordPress/$wp_version | Akismet/2.0\r\n";
376
  $http_request .= "\r\n";
377
  $http_request .= $request;
378
 
@@ -396,6 +404,14 @@ function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
396
  return $response;
397
  }
398
 
 
 
 
 
 
 
 
 
399
  function akismet_auto_check_comment( $comment ) {
400
  global $akismet_api_host, $akismet_api_port;
401
 
@@ -419,8 +435,8 @@ function akismet_auto_check_comment( $comment ) {
419
 
420
  $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
421
  if ( 'true' == $response[1] ) {
422
- add_filter('pre_comment_approved', create_function('$a', 'return \'spam\';'));
423
- update_option( 'akismet_spam_count', get_option('akismet_spam_count') + 1 );
424
 
425
  do_action( 'akismet_spam_caught' );
426
 
@@ -428,9 +444,13 @@ function akismet_auto_check_comment( $comment ) {
428
  $last_updated = strtotime( $post->post_modified_gmt );
429
  $diff = time() - $last_updated;
430
  $diff = $diff / 86400;
431
-
432
- if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' )
 
 
 
433
  die;
 
434
  }
435
  akismet_delete_old();
436
  return $comment;
3
  Plugin Name: Akismet
4
  Plugin URI: http://akismet.com/
5
  Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code>&lt;?php akismet_counter(); ?&gt;</code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>.
6
+ Version: 2.2.7
7
  Author: Matt Mullenweg
8
  Author URI: http://ma.tt/
9
  */
10
 
11
+ define('AKISMET_VERSION', '2.2.7');
12
+
13
  // If you hardcode a WP.com API key here, all key config screens will be hidden
14
  if ( defined('WPCOM_API_KEY') )
15
  $wpcom_api_key = constant('WPCOM_API_KEY');
315
 
316
  // Returns true if server connectivity was OK at the last check, false if there was a problem that needs to be fixed.
317
  function akismet_server_connectivity_ok() {
318
+ // skip the check on WPMU because the status page is hidden
319
+ global $wpcom_api_key;
320
+ if ( $wpcom_api_key )
321
+ return true;
322
  $servers = akismet_get_server_connectivity();
323
  return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
324
  }
373
  // Returns array with headers in $response[0] and body in $response[1]
374
  function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
375
  global $wp_version;
376
+
377
+ $akismet_version = constant('AKISMET_VERSION');
378
 
379
  $http_request = "POST $path HTTP/1.0\r\n";
380
  $http_request .= "Host: $host\r\n";
381
  $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n";
382
  $http_request .= "Content-Length: " . strlen($request) . "\r\n";
383
+ $http_request .= "User-Agent: WordPress/$wp_version | Akismet/$akismet_version\r\n";
384
  $http_request .= "\r\n";
385
  $http_request .= $request;
386
 
404
  return $response;
405
  }
406
 
407
+ // filter handler used to return a spam result to pre_comment_approved
408
+ function akismet_result_spam( $approved ) {
409
+ // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
410
+ if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
411
+ update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
412
+ return 'spam';
413
+ }
414
+
415
  function akismet_auto_check_comment( $comment ) {
416
  global $akismet_api_host, $akismet_api_port;
417
 
435
 
436
  $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
437
  if ( 'true' == $response[1] ) {
438
+ // akismet_spam_count will be incremented later by akismet_result_spam()
439
+ add_filter('pre_comment_approved', 'akismet_result_spam');
440
 
441
  do_action( 'akismet_spam_caught' );
442
 
444
  $last_updated = strtotime( $post->post_modified_gmt );
445
  $diff = time() - $last_updated;
446
  $diff = $diff / 86400;
447
+
448
+ if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' ) {
449
+ // akismet_result_spam() won't be called so bump the counter here
450
+ if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
451
+ update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
452
  die;
453
+ }
454
  }
455
  akismet_delete_old();
456
  return $comment;
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Akismet ===
2
- Contributors: matt, ryan, andy, mdawaffe, tellyworth
3
  Tags: akismet, comments, spam
4
  Requires at least: 2.0
5
- Tested up to: 2.8.2
6
 
7
  Akismet checks your comments against the Akismet web service to see if they look like spam or not.
8
 
@@ -25,6 +25,12 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [WordPress.
25
 
26
  == Changelog ==
27
 
 
 
 
 
 
 
28
  = 2.2.6 =
29
 
30
  * Fix a global warning introduced in 2.2.5
1
  === Akismet ===
2
+ Contributors: matt, ryan, andy, mdawaffe, tellyworth, automattic
3
  Tags: akismet, comments, spam
4
  Requires at least: 2.0
5
+ Tested up to: 2.9
6
 
7
  Akismet checks your comments against the Akismet web service to see if they look like spam or not.
8
 
25
 
26
  == Changelog ==
27
 
28
+ = 2.2.7 =
29
+
30
+ * Add a new AKISMET_VERSION constant
31
+ * Reduce the possibility of over-counting spam when another spam filter plugin is in use
32
+ * Disable the connectivity check when the API key is hard-coded for WPMU
33
+
34
  = 2.2.6 =
35
 
36
  * Fix a global warning introduced in 2.2.5