Version Description
- Removed dependency on PHP's fsockopen function
- Fix spam/ham reports to work when reported outside of the WP dashboard, e.g., from Notifications or the WP app
- Remove jQuery dependency for comment form JavaScript
- Remove unnecessary data from some Akismet comment meta
- Suspended keys will now result in all comments being put in moderation, not spam.
Download this release
Release Info
Developer | cfinke |
Plugin | Akismet Anti-Spam |
Version | 3.0.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.0 to 3.0.1
- .htaccess +11 -0
- _inc/akismet.css +2 -2
- _inc/akismet.js +1 -1
- _inc/form.js +27 -14
- akismet.php +3 -3
- class.akismet-admin.php +89 -192
- class.akismet.php +167 -8
- readme.txt +20 -14
- views/notice.php +1 -1
- wrapper.php +8 -8
.htaccess
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Order Deny,Allow
|
2 |
+
Deny from all
|
3 |
+
|
4 |
+
<FilesMatch "^(form|akismet)\.(css|js)$">
|
5 |
+
Allow from all
|
6 |
+
</FilesMatch>
|
7 |
+
|
8 |
+
#allow access to any image
|
9 |
+
<FilesMatch "^(.+)\.(png|gif)$">
|
10 |
+
Allow from all
|
11 |
+
</FilesMatch>
|
_inc/akismet.css
CHANGED
@@ -75,8 +75,8 @@ h2.ak-header {
|
|
75 |
display: inline-block !important;
|
76 |
}
|
77 |
.checkforspam-spinner {
|
78 |
-
display:
|
79 |
-
margin-top:
|
80 |
}
|
81 |
|
82 |
.config-wrap {
|
75 |
display: inline-block !important;
|
76 |
}
|
77 |
.checkforspam-spinner {
|
78 |
+
display: inline-block;
|
79 |
+
margin-top: 7px;
|
80 |
}
|
81 |
|
82 |
.config-wrap {
|
_inc/akismet.js
CHANGED
@@ -125,7 +125,7 @@ jQuery( function ( $ ) {
|
|
125 |
});
|
126 |
$('.checkforspam:not(.button-disabled)').click( function(e) {
|
127 |
$('.checkforspam:not(.button-disabled)').addClass('button-disabled');
|
128 |
-
$('.checkforspam-spinner').
|
129 |
akismet_check_for_spam(0, 100);
|
130 |
e.preventDefault();
|
131 |
});
|
125 |
});
|
126 |
$('.checkforspam:not(.button-disabled)').click( function(e) {
|
127 |
$('.checkforspam:not(.button-disabled)').addClass('button-disabled');
|
128 |
+
$('.checkforspam-spinner').addClass( 'spinner' );
|
129 |
akismet_check_for_spam(0, 100);
|
130 |
e.preventDefault();
|
131 |
});
|
_inc/form.js
CHANGED
@@ -1,17 +1,30 @@
|
|
1 |
-
|
2 |
-
var ak_js = $( '#ak_js' );
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var ak_js = document.getElementById( "ak_js" );
|
|
|
2 |
|
3 |
+
if ( ! ak_js ) {
|
4 |
+
ak_js = document.createElement( 'input' );
|
5 |
+
ak_js.setAttribute( 'id', 'ak_js' );
|
6 |
+
ak_js.setAttribute( 'name', 'ak_js' );
|
7 |
+
ak_js.setAttribute( 'type', 'hidden' );
|
8 |
+
}
|
9 |
+
else {
|
10 |
+
ak_js.parentNode.removeChild( ak_js );
|
11 |
+
}
|
12 |
+
|
13 |
+
ak_js.setAttribute( 'value', ( new Date() ).getTime() );
|
14 |
|
15 |
+
var commentForm = document.getElementById( 'commentform' );
|
16 |
|
17 |
+
if ( commentForm ) {
|
18 |
+
commentForm.appendChild( ak_js );
|
19 |
+
}
|
20 |
+
else {
|
21 |
+
var replyRowContainer = document.getElementById( 'replyrow' );
|
22 |
+
|
23 |
+
if ( replyRowContainer ) {
|
24 |
+
var children = replyRowContainer.getElementsByTagName( 'td' );
|
25 |
+
|
26 |
+
if ( children.length > 0 ) {
|
27 |
+
children[0].appendChild( ak_js );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
akismet.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
Plugin Name: Akismet
|
7 |
Plugin URI: http://akismet.com/
|
8 |
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
|
9 |
-
Version: 3.0.
|
10 |
Author: Automattic
|
11 |
Author URI: http://automattic.com/wordpress-plugins/
|
12 |
License: GPLv2 or later
|
@@ -35,8 +35,8 @@ if ( !function_exists( 'add_action' ) ) {
|
|
35 |
exit;
|
36 |
}
|
37 |
|
38 |
-
define( 'AKISMET_VERSION', '3.0.
|
39 |
-
define( 'AKISMET__MINIMUM_WP_VERSION', '3.
|
40 |
define( 'AKISMET__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
41 |
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
42 |
define( 'AKISMET_DELETE_LIMIT', 100000 );
|
6 |
Plugin Name: Akismet
|
7 |
Plugin URI: http://akismet.com/
|
8 |
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
|
9 |
+
Version: 3.0.1
|
10 |
Author: Automattic
|
11 |
Author URI: http://automattic.com/wordpress-plugins/
|
12 |
License: GPLv2 or later
|
35 |
exit;
|
36 |
}
|
37 |
|
38 |
+
define( 'AKISMET_VERSION', '3.0.1' );
|
39 |
+
define( 'AKISMET__MINIMUM_WP_VERSION', '3.1' );
|
40 |
define( 'AKISMET__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
41 |
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
42 |
define( 'AKISMET_DELETE_LIMIT', 100000 );
|
class.akismet-admin.php
CHANGED
@@ -33,7 +33,6 @@ class Akismet_Admin {
|
|
33 |
add_action( 'activity_box_end', array( 'Akismet_Admin', 'dashboard_stats' ) );
|
34 |
add_action( 'rightnow_end', array( 'Akismet_Admin', 'rightnow_stats' ) );
|
35 |
add_action( 'manage_comments_nav', array( 'Akismet_Admin', 'check_for_spam_button' ) );
|
36 |
-
add_action( 'transition_comment_status', array( 'Akismet_Admin', 'transition_comment_status' ), 10, 3 );
|
37 |
add_action( 'admin_action_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
38 |
add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
39 |
add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) );
|
@@ -44,6 +43,8 @@ class Akismet_Admin {
|
|
44 |
add_filter( 'comment_text', array( 'Akismet_Admin', 'text_add_link_class' ) );
|
45 |
|
46 |
add_filter( 'plugin_action_links_'.plugin_basename( plugin_dir_path( __FILE__ ) . 'akismet.php'), array( 'Akismet_Admin', 'admin_plugin_settings_link' ) );
|
|
|
|
|
47 |
}
|
48 |
|
49 |
public static function admin_init() {
|
@@ -64,7 +65,7 @@ class Akismet_Admin {
|
|
64 |
}
|
65 |
|
66 |
public static function admin_plugin_settings_link( $links ) {
|
67 |
-
$settings_link = '<a href="'.self::get_page_url().'">'.__('Settings', 'akismet').'</a>';
|
68 |
array_unshift( $links, $settings_link );
|
69 |
return $links;
|
70 |
}
|
@@ -331,51 +332,7 @@ class Akismet_Admin {
|
|
331 |
else
|
332 |
$link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
|
333 |
|
334 |
-
echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . esc_url( $link ) . '">' . esc_html__('Check for Spam', 'akismet') . '</a>';
|
335 |
-
echo '<img src="' . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . '" class="checkforspam-spinner" />';
|
336 |
-
}
|
337 |
-
|
338 |
-
public static function transition_comment_status( $new_status, $old_status, $comment ) {
|
339 |
-
if ( $new_status == $old_status )
|
340 |
-
return;
|
341 |
-
|
342 |
-
# we don't need to record a history item for deleted comments
|
343 |
-
if ( $new_status == 'delete' )
|
344 |
-
return;
|
345 |
-
|
346 |
-
if ( !is_admin() )
|
347 |
-
return;
|
348 |
-
|
349 |
-
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
|
350 |
-
return;
|
351 |
-
|
352 |
-
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
|
353 |
-
return;
|
354 |
-
|
355 |
-
// if this is present, it means the status has been changed by a re-check, not an explicit user action
|
356 |
-
if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
|
357 |
-
return;
|
358 |
-
|
359 |
-
global $current_user;
|
360 |
-
$reporter = '';
|
361 |
-
if ( is_object( $current_user ) )
|
362 |
-
$reporter = $current_user->user_login;
|
363 |
-
|
364 |
-
// Assumption alert:
|
365 |
-
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
|
366 |
-
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
|
367 |
-
// determine why the transition_comment_status action was triggered. And there are several different ways by which
|
368 |
-
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
|
369 |
-
// We'll assume that this is an explicit user action if POST or GET has an 'action' key.
|
370 |
-
if ( isset($_POST['action']) || isset($_GET['action']) ) {
|
371 |
-
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
|
372 |
-
return self::submit_spam_comment( $comment->comment_ID );
|
373 |
-
} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
|
374 |
-
return self::submit_nonspam_comment( $comment->comment_ID );
|
375 |
-
}
|
376 |
-
}
|
377 |
-
|
378 |
-
Akismet::update_comment_history( $comment->comment_ID, sprintf( __('%1$s changed the comment status to %2$s', 'akismet'), $reporter, $new_status ), 'status-' . $new_status );
|
379 |
}
|
380 |
|
381 |
public static function recheck_queue() {
|
@@ -410,7 +367,7 @@ class Akismet_Admin {
|
|
410 |
|
411 |
add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
|
412 |
|
413 |
-
$response = Akismet::http_post(
|
414 |
if ( 'true' == $response[1] ) {
|
415 |
wp_set_comment_status( $c['comment_ID'], 'spam' );
|
416 |
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
|
@@ -514,7 +471,10 @@ class Akismet_Admin {
|
|
514 |
if ( $desc )
|
515 |
echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' , 'akismet') . '">'.esc_html( $desc ).'</a></span>';
|
516 |
|
517 |
-
|
|
|
|
|
|
|
518 |
$comment_count = Akismet::get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
|
519 |
$comment_count = intval( $comment_count );
|
520 |
echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'. sprintf( esc_html( _n( '%s approved', '%s approved', $comment_count , 'akismet') ), number_format_i18n( $comment_count ) ) . '</span></span>';
|
@@ -557,102 +517,6 @@ class Akismet_Admin {
|
|
557 |
return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', array( 'Akismet_Admin', 'text_add_link_callback' ), $comment_text );
|
558 |
}
|
559 |
|
560 |
-
public static function submit_spam_comment( $comment_id ) {
|
561 |
-
global $wpdb, $current_user, $current_site;
|
562 |
-
|
563 |
-
$comment_id = (int) $comment_id;
|
564 |
-
|
565 |
-
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
566 |
-
|
567 |
-
if ( !$comment ) // it was deleted
|
568 |
-
return;
|
569 |
-
|
570 |
-
if ( 'spam' != $comment->comment_approved )
|
571 |
-
return;
|
572 |
-
|
573 |
-
// use the original version stored in comment_meta if available
|
574 |
-
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
575 |
-
|
576 |
-
if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) )
|
577 |
-
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
578 |
-
|
579 |
-
$comment->blog = get_bloginfo('url');
|
580 |
-
$comment->blog_lang = get_locale();
|
581 |
-
$comment->blog_charset = get_option('blog_charset');
|
582 |
-
$comment->permalink = get_permalink($comment->comment_post_ID);
|
583 |
-
|
584 |
-
if ( is_object($current_user) )
|
585 |
-
$comment->reporter = $current_user->user_login;
|
586 |
-
|
587 |
-
if ( is_object($current_site) )
|
588 |
-
$comment->site_domain = $current_site->domain;
|
589 |
-
|
590 |
-
$comment->user_role = '';
|
591 |
-
if ( isset( $comment->user_ID ) )
|
592 |
-
$comment->user_role = Akismet::get_user_roles( $comment->user_ID );
|
593 |
-
|
594 |
-
if ( Akismet::is_test_mode() )
|
595 |
-
$comment->is_test = 'true';
|
596 |
-
|
597 |
-
$post = get_post( $comment->comment_post_ID );
|
598 |
-
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
599 |
-
|
600 |
-
$response = Akismet::http_post( http_build_query( $comment ), 'submit-spam' );
|
601 |
-
if ( $comment->reporter ) {
|
602 |
-
Akismet::update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam', 'akismet'), $comment->reporter ), 'report-spam' );
|
603 |
-
update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
|
604 |
-
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
605 |
-
}
|
606 |
-
|
607 |
-
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
|
608 |
-
}
|
609 |
-
|
610 |
-
public static function submit_nonspam_comment( $comment_id ) {
|
611 |
-
global $wpdb, $current_user, $current_site;
|
612 |
-
|
613 |
-
$comment_id = (int) $comment_id;
|
614 |
-
|
615 |
-
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
616 |
-
if ( !$comment ) // it was deleted
|
617 |
-
return;
|
618 |
-
|
619 |
-
// use the original version stored in comment_meta if available
|
620 |
-
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
621 |
-
|
622 |
-
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) )
|
623 |
-
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
624 |
-
|
625 |
-
$comment->blog = get_bloginfo('url');
|
626 |
-
$comment->blog_lang = get_locale();
|
627 |
-
$comment->blog_charset = get_option('blog_charset');
|
628 |
-
$comment->permalink = get_permalink( $comment->comment_post_ID );
|
629 |
-
$comment->user_role = '';
|
630 |
-
|
631 |
-
if ( is_object($current_user) )
|
632 |
-
$comment->reporter = $current_user->user_login;
|
633 |
-
|
634 |
-
if ( is_object($current_site) )
|
635 |
-
$comment->site_domain = $current_site->domain;
|
636 |
-
|
637 |
-
if ( isset( $comment->user_ID ) )
|
638 |
-
$comment->user_role = Akismet::get_user_roles($comment->user_ID);
|
639 |
-
|
640 |
-
if ( Akismet::is_test_mode() )
|
641 |
-
$comment->is_test = 'true';
|
642 |
-
|
643 |
-
$post = get_post( $comment->comment_post_ID );
|
644 |
-
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
645 |
-
|
646 |
-
$response = Akismet::http_post( http_build_query( $comment ), 'submit-ham' );
|
647 |
-
if ( $comment->reporter ) {
|
648 |
-
Akismet::update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam', 'akismet'), $comment->reporter ), 'report-ham' );
|
649 |
-
update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
|
650 |
-
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
651 |
-
}
|
652 |
-
|
653 |
-
do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
|
654 |
-
}
|
655 |
-
|
656 |
// Total spam in queue
|
657 |
// get_option( 'akismet_spam_count' ) is the total caught ever
|
658 |
public static function get_spam_count( $type = false ) {
|
@@ -672,53 +536,73 @@ class Akismet_Admin {
|
|
672 |
return $count;
|
673 |
} elseif ( 'comments' == $type || 'comment' == $type ) { // comments
|
674 |
$type = '';
|
675 |
-
} else { // pingback, trackback, ...
|
676 |
-
$type = $wpdb->escape( $type );
|
677 |
}
|
678 |
|
679 |
-
return (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam' AND comment_type=
|
680 |
}
|
681 |
|
682 |
// Check connectivity between the WordPress blog and Akismet's servers.
|
683 |
// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
|
684 |
-
public static function
|
685 |
-
|
686 |
-
|
687 |
-
// Some web hosts may disable one or both functions
|
688 |
-
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
|
689 |
-
return array();
|
690 |
-
|
691 |
-
$ips = gethostbynamel( $test_host );
|
692 |
-
if ( !$ips || !is_array($ips) || !count($ips) )
|
693 |
-
return array();
|
694 |
-
|
695 |
-
$api_key = Akismet::get_api_key();
|
696 |
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
if ( $
|
702 |
-
$
|
703 |
-
|
704 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
705 |
}
|
|
|
706 |
return $servers;
|
707 |
}
|
708 |
-
|
709 |
-
//
|
710 |
-
|
711 |
-
|
712 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
713 |
$servers = get_option('akismet_available_servers');
|
714 |
-
if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false )
|
715 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
716 |
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
update_option('akismet_connectivity_time', time());
|
721 |
-
return $servers;
|
722 |
}
|
723 |
|
724 |
public static function get_number_spam_waiting() {
|
@@ -741,7 +625,7 @@ class Akismet_Admin {
|
|
741 |
}
|
742 |
|
743 |
public static function get_akismet_user( $api_key ) {
|
744 |
-
$akismet_user = Akismet::http_post(
|
745 |
|
746 |
if ( ! empty( $akismet_user[1] ) )
|
747 |
$akismet_user = json_decode( $akismet_user[1] );
|
@@ -755,7 +639,7 @@ class Akismet_Admin {
|
|
755 |
$stat_totals = array();
|
756 |
|
757 |
foreach( array( '6-months', 'all' ) as $interval ) {
|
758 |
-
$response = Akismet::http_post(
|
759 |
|
760 |
if ( ! empty( $response[1] ) ) {
|
761 |
$stat_totals[$interval] = json_decode( $response[1] );
|
@@ -765,7 +649,7 @@ class Akismet_Admin {
|
|
765 |
}
|
766 |
|
767 |
public static function verify_wpcom_key( $api_key, $user_id, $token = '' ) {
|
768 |
-
$akismet_account = Akismet::http_post(
|
769 |
'user_id' => $user_id,
|
770 |
'api_key' => $api_key,
|
771 |
'token' => $token,
|
@@ -790,9 +674,11 @@ class Akismet_Admin {
|
|
790 |
|
791 |
public static function display_spam_check_warning() {
|
792 |
Akismet::fix_scheduled_recheck();
|
|
|
|
|
793 |
|
794 |
if ( self::get_number_spam_waiting() > 0 && wp_next_scheduled('akismet_schedule_cron_recheck') > time() )
|
795 |
-
Akismet::view( 'notice', array( 'type' => 'spam-check' ) );
|
796 |
}
|
797 |
|
798 |
public static function display_invalid_version() {
|
@@ -869,7 +755,7 @@ class Akismet_Admin {
|
|
869 |
|
870 |
if ( empty( self::$notices ) ) {
|
871 |
//show status
|
872 |
-
if ( $akismet_user->status == 'active' && $akismet_user->account_type == 'free-api-key' ) {
|
873 |
|
874 |
$time_saved = false;
|
875 |
|
@@ -920,16 +806,11 @@ class Akismet_Admin {
|
|
920 |
}
|
921 |
|
922 |
public static function display_status() {
|
923 |
-
$
|
924 |
-
$fail_count = count( $servers ) - count( array_filter( $servers ) );
|
925 |
-
$type = '';
|
926 |
|
927 |
-
if (
|
928 |
$type = 'servers-be-down';
|
929 |
|
930 |
-
if ( !function_exists('fsockopen') || !function_exists('gethostbynamel') )
|
931 |
-
$type = 'missing-functions';
|
932 |
-
|
933 |
if ( !empty( $type ) )
|
934 |
Akismet::view( 'notice', compact( 'type' ) );
|
935 |
elseif ( !empty( self::$notices ) ) {
|
@@ -961,4 +842,20 @@ class Akismet_Admin {
|
|
961 |
}
|
962 |
return false;
|
963 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
964 |
}
|
33 |
add_action( 'activity_box_end', array( 'Akismet_Admin', 'dashboard_stats' ) );
|
34 |
add_action( 'rightnow_end', array( 'Akismet_Admin', 'rightnow_stats' ) );
|
35 |
add_action( 'manage_comments_nav', array( 'Akismet_Admin', 'check_for_spam_button' ) );
|
|
|
36 |
add_action( 'admin_action_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
37 |
add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) );
|
38 |
add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) );
|
43 |
add_filter( 'comment_text', array( 'Akismet_Admin', 'text_add_link_class' ) );
|
44 |
|
45 |
add_filter( 'plugin_action_links_'.plugin_basename( plugin_dir_path( __FILE__ ) . 'akismet.php'), array( 'Akismet_Admin', 'admin_plugin_settings_link' ) );
|
46 |
+
|
47 |
+
add_filter( 'wxr_export_skip_commentmeta', array( 'Akismet_Admin', 'exclude_commentmeta_from_export' ), 10, 3 );
|
48 |
}
|
49 |
|
50 |
public static function admin_init() {
|
65 |
}
|
66 |
|
67 |
public static function admin_plugin_settings_link( $links ) {
|
68 |
+
$settings_link = '<a href="'.esc_url( self::get_page_url() ).'">'.__('Settings', 'akismet').'</a>';
|
69 |
array_unshift( $links, $settings_link );
|
70 |
return $links;
|
71 |
}
|
332 |
else
|
333 |
$link = add_query_arg( array( 'page' => 'akismet-admin', 'recheckqueue' => 'true', 'noheader' => 'true' ), admin_url( 'edit-comments.php' ) );
|
334 |
|
335 |
+
echo '</div><div class="alignleft"><a class="button-secondary checkforspam" href="' . esc_url( $link ) . '">' . esc_html__('Check for Spam', 'akismet') . '</a><span class="checkforspam-spinner"></span>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
}
|
337 |
|
338 |
public static function recheck_queue() {
|
367 |
|
368 |
add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
|
369 |
|
370 |
+
$response = Akismet::http_post( build_query( $c ), 'comment-check' );
|
371 |
if ( 'true' == $response[1] ) {
|
372 |
wp_set_comment_status( $c['comment_ID'], 'spam' );
|
373 |
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
|
471 |
if ( $desc )
|
472 |
echo '<span class="akismet-status" commentid="'.$comment->comment_ID.'"><a href="comment.php?action=editcomment&c='.$comment->comment_ID.'#akismet-status" title="' . esc_attr__( 'View comment history' , 'akismet') . '">'.esc_html( $desc ).'</a></span>';
|
473 |
|
474 |
+
$show_user_comments = apply_filters( 'akismet_show_user_comments_approved', get_option('akismet_show_user_comments_approved') );
|
475 |
+
$show_user_comments = $show_user_comments === 'false' ? false : $show_user_comments; //option used to be saved as 'false' / 'true'
|
476 |
+
|
477 |
+
if ( $show_user_comments ) {
|
478 |
$comment_count = Akismet::get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url );
|
479 |
$comment_count = intval( $comment_count );
|
480 |
echo '<span class="akismet-user-comment-count" commentid="'.$comment->comment_ID.'" style="display:none;"><br><span class="akismet-user-comment-counts">'. sprintf( esc_html( _n( '%s approved', '%s approved', $comment_count , 'akismet') ), number_format_i18n( $comment_count ) ) . '</span></span>';
|
517 |
return preg_replace_callback( '#<a ([^>]*)href="([^"]+)"([^>]*)>(.*?)</a>#i', array( 'Akismet_Admin', 'text_add_link_callback' ), $comment_text );
|
518 |
}
|
519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
// Total spam in queue
|
521 |
// get_option( 'akismet_spam_count' ) is the total caught ever
|
522 |
public static function get_spam_count( $type = false ) {
|
536 |
return $count;
|
537 |
} elseif ( 'comments' == $type || 'comment' == $type ) { // comments
|
538 |
$type = '';
|
|
|
|
|
539 |
}
|
540 |
|
541 |
+
return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam' AND comment_type = %s", $type ) );
|
542 |
}
|
543 |
|
544 |
// Check connectivity between the WordPress blog and Akismet's servers.
|
545 |
// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect).
|
546 |
+
public static function check_server_ip_connectivity() {
|
547 |
+
|
548 |
+
$servers = $ips = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
|
550 |
+
// Some web hosts may disable this function
|
551 |
+
if ( function_exists('gethostbynamel') ) {
|
552 |
+
|
553 |
+
$ips = gethostbynamel( 'rest.akismet.com' );
|
554 |
+
if ( $ips && is_array($ips) && count($ips) ) {
|
555 |
+
$api_key = Akismet::get_api_key();
|
556 |
+
|
557 |
+
foreach ( $ips as $ip ) {
|
558 |
+
$response = Akismet::verify_key( $api_key, $ip );
|
559 |
+
// even if the key is invalid, at least we know we have connectivity
|
560 |
+
if ( $response == 'valid' || $response == 'invalid' )
|
561 |
+
$servers[$ip] = 'connected';
|
562 |
+
else
|
563 |
+
$servers[$ip] = $response ? $response : 'unable to connect';
|
564 |
+
}
|
565 |
+
}
|
566 |
}
|
567 |
+
|
568 |
return $servers;
|
569 |
}
|
570 |
+
|
571 |
+
// Simpler connectivity check
|
572 |
+
public static function check_server_connectivity($cache_timeout = 86400) {
|
573 |
+
|
574 |
+
$debug = array();
|
575 |
+
$debug[ 'PHP_VERSION' ] = PHP_VERSION;
|
576 |
+
$debug[ 'WORDPRESS_VERSION' ] = $GLOBALS['wp_version'];
|
577 |
+
$debug[ 'AKISMET_VERSION' ] = AKISMET_VERSION;
|
578 |
+
$debug[ 'AKISMET__PLUGIN_DIR' ] = AKISMET__PLUGIN_DIR;
|
579 |
+
$debug[ 'SITE_URL' ] = site_url();
|
580 |
+
$debug[ 'HOME_URL' ] = home_url();
|
581 |
+
|
582 |
$servers = get_option('akismet_available_servers');
|
583 |
+
if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false ) {
|
584 |
+
$servers = self::check_server_ip_connectivity();
|
585 |
+
update_option('akismet_available_servers', $servers);
|
586 |
+
update_option('akismet_connectivity_time', time());
|
587 |
+
}
|
588 |
+
|
589 |
+
$response = wp_remote_get( 'http://rest.akismet.com/1.1/test' );
|
590 |
+
|
591 |
+
$debug[ 'gethostbynamel' ] = function_exists('gethostbynamel') ? 'exists' : 'not here';
|
592 |
+
$debug[ 'Servers' ] = $servers;
|
593 |
+
$debug[ 'Test Connection' ] = $response;
|
594 |
+
|
595 |
+
Akismet::log( $debug );
|
596 |
+
|
597 |
+
if ( $response && 'connected' == wp_remote_retrieve_body( $response ) )
|
598 |
+
return true;
|
599 |
+
|
600 |
+
return false;
|
601 |
+
}
|
602 |
|
603 |
+
// Check the server connectivity and store the available servers in an option.
|
604 |
+
public static function get_server_connectivity($cache_timeout = 86400) {
|
605 |
+
return self::check_server_connectivity( $cache_timeout );
|
|
|
|
|
606 |
}
|
607 |
|
608 |
public static function get_number_spam_waiting() {
|
625 |
}
|
626 |
|
627 |
public static function get_akismet_user( $api_key ) {
|
628 |
+
$akismet_user = Akismet::http_post( build_query( array( 'key' => $api_key ) ), 'get-subscription' );
|
629 |
|
630 |
if ( ! empty( $akismet_user[1] ) )
|
631 |
$akismet_user = json_decode( $akismet_user[1] );
|
639 |
$stat_totals = array();
|
640 |
|
641 |
foreach( array( '6-months', 'all' ) as $interval ) {
|
642 |
+
$response = Akismet::http_post( build_query( array( 'blog' => urlencode( get_bloginfo('url') ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
|
643 |
|
644 |
if ( ! empty( $response[1] ) ) {
|
645 |
$stat_totals[$interval] = json_decode( $response[1] );
|
649 |
}
|
650 |
|
651 |
public static function verify_wpcom_key( $api_key, $user_id, $token = '' ) {
|
652 |
+
$akismet_account = Akismet::http_post( build_query( array(
|
653 |
'user_id' => $user_id,
|
654 |
'api_key' => $api_key,
|
655 |
'token' => $token,
|
674 |
|
675 |
public static function display_spam_check_warning() {
|
676 |
Akismet::fix_scheduled_recheck();
|
677 |
+
|
678 |
+
$link_text = apply_filters( 'akismet_spam_check_warning_link_text', sprintf( __( 'Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.', 'akismet'), esc_url( self::get_page_url() ) ) );
|
679 |
|
680 |
if ( self::get_number_spam_waiting() > 0 && wp_next_scheduled('akismet_schedule_cron_recheck') > time() )
|
681 |
+
Akismet::view( 'notice', array( 'type' => 'spam-check', 'link_text' => $link_text ) );
|
682 |
}
|
683 |
|
684 |
public static function display_invalid_version() {
|
755 |
|
756 |
if ( empty( self::$notices ) ) {
|
757 |
//show status
|
758 |
+
if ( ! empty( $stat_totals['all'] ) && isset( $stat_totals['all']->time_saved ) && $akismet_user->status == 'active' && $akismet_user->account_type == 'free-api-key' ) {
|
759 |
|
760 |
$time_saved = false;
|
761 |
|
806 |
}
|
807 |
|
808 |
public static function display_status() {
|
809 |
+
$type = '';
|
|
|
|
|
810 |
|
811 |
+
if ( !self::get_server_connectivity() )
|
812 |
$type = 'servers-be-down';
|
813 |
|
|
|
|
|
|
|
814 |
if ( !empty( $type ) )
|
815 |
Akismet::view( 'notice', compact( 'type' ) );
|
816 |
elseif ( !empty( self::$notices ) ) {
|
842 |
}
|
843 |
return false;
|
844 |
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
* Some commentmeta isn't useful in an export file. Suppress it (when supported).
|
848 |
+
*
|
849 |
+
* @param bool $exclude
|
850 |
+
* @param string $key The meta key
|
851 |
+
* @param object $meta The meta object
|
852 |
+
* @return bool Whether to exclude this meta entry from the export.
|
853 |
+
*/
|
854 |
+
public static function exclude_commentmeta_from_export( $exclude, $key, $meta ) {
|
855 |
+
if ( in_array( $key, array( 'akismet_as_submitted', 'akismet_rechecking', 'akismet_delayed_moderation_email' ) ) ) {
|
856 |
+
return true;
|
857 |
+
}
|
858 |
+
|
859 |
+
return $exclude;
|
860 |
+
}
|
861 |
}
|
class.akismet.php
CHANGED
@@ -33,12 +33,14 @@ class Akismet {
|
|
33 |
if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
|
34 |
add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
|
35 |
|
36 |
-
add_action( '
|
37 |
add_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
|
38 |
add_action( 'comment_form', array( 'Akismet', 'inject_ak_js' ) );
|
39 |
|
40 |
add_filter( 'comment_moderation_recipients', array( 'Akismet', 'disable_moderation_emails_if_unreachable' ), 1000, 2 );
|
41 |
add_filter( 'pre_comment_approved', array( 'Akismet', 'last_comment_status' ), 10, 2 );
|
|
|
|
|
42 |
|
43 |
if ( '3.0.5' == $GLOBALS['wp_version'] ) {
|
44 |
remove_filter( 'comment_text', 'wp_kses_data' );
|
@@ -48,11 +50,11 @@ class Akismet {
|
|
48 |
}
|
49 |
|
50 |
public static function get_api_key() {
|
51 |
-
return defined('WPCOM_API_KEY') ? constant('WPCOM_API_KEY') : get_option('wordpress_api_key');
|
52 |
}
|
53 |
|
54 |
public static function check_key_status( $key, $ip = null ) {
|
55 |
-
return self::http_post(
|
56 |
}
|
57 |
|
58 |
public static function verify_key( $key, $ip = null ) {
|
@@ -115,19 +117,24 @@ class Akismet {
|
|
115 |
$post = get_post( $comment['comment_post_ID'] );
|
116 |
$comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
|
117 |
|
118 |
-
$response = self::http_post(
|
119 |
|
120 |
do_action( 'akismet_comment_check_response', $response );
|
121 |
|
122 |
self::update_alert( $response );
|
123 |
|
124 |
-
$commentdata['comment_as_submitted'] = $comment;
|
125 |
$commentdata['akismet_result'] = $response[1];
|
126 |
|
127 |
if ( isset( $response[0]['x-akismet-pro-tip'] ) )
|
128 |
$commentdata['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
|
129 |
|
130 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
131 |
// akismet_spam_count will be incremented later by comment_is_spam()
|
132 |
self::$last_comment_result = 'spam';
|
133 |
|
@@ -363,10 +370,155 @@ class Akismet {
|
|
363 |
if ( self::is_test_mode() )
|
364 |
$c['is_test'] = 'true';
|
365 |
|
366 |
-
$response = self::http_post(
|
367 |
|
368 |
return ( is_array( $response ) && ! empty( $response[1] ) ) ? $response[1] : false;
|
369 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
|
371 |
public static function cron_recheck() {
|
372 |
global $wpdb;
|
@@ -670,7 +822,14 @@ class Akismet {
|
|
670 |
}
|
671 |
|
672 |
public static function load_form_js() {
|
673 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
wp_print_scripts( 'akismet-form' );
|
675 |
}
|
676 |
|
33 |
if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
|
34 |
add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
|
35 |
|
36 |
+
add_action( 'admin_head-edit-comments.php', array( 'Akismet', 'load_form_js' ) );
|
37 |
add_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
|
38 |
add_action( 'comment_form', array( 'Akismet', 'inject_ak_js' ) );
|
39 |
|
40 |
add_filter( 'comment_moderation_recipients', array( 'Akismet', 'disable_moderation_emails_if_unreachable' ), 1000, 2 );
|
41 |
add_filter( 'pre_comment_approved', array( 'Akismet', 'last_comment_status' ), 10, 2 );
|
42 |
+
|
43 |
+
add_action( 'transition_comment_status', array( 'Akismet', 'transition_comment_status' ), 10, 3 );
|
44 |
|
45 |
if ( '3.0.5' == $GLOBALS['wp_version'] ) {
|
46 |
remove_filter( 'comment_text', 'wp_kses_data' );
|
50 |
}
|
51 |
|
52 |
public static function get_api_key() {
|
53 |
+
return apply_filters( 'akismet_get_api_key', defined('WPCOM_API_KEY') ? constant('WPCOM_API_KEY') : get_option('wordpress_api_key') );
|
54 |
}
|
55 |
|
56 |
public static function check_key_status( $key, $ip = null ) {
|
57 |
+
return self::http_post( build_query( array( 'key' => $key, 'blog' => get_option('home') ) ), 'verify-key', $ip );
|
58 |
}
|
59 |
|
60 |
public static function verify_key( $key, $ip = null ) {
|
117 |
$post = get_post( $comment['comment_post_ID'] );
|
118 |
$comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
|
119 |
|
120 |
+
$response = self::http_post( build_query( $comment ), 'comment-check' );
|
121 |
|
122 |
do_action( 'akismet_comment_check_response', $response );
|
123 |
|
124 |
self::update_alert( $response );
|
125 |
|
126 |
+
$commentdata['comment_as_submitted'] = array_intersect_key( $comment, array( 'blog' => '', 'blog_charset' => '', 'blog_lang' => '', 'blog_ua' => '', 'comment_agent' => '', 'comment_author' => '', 'comment_author_IP' => '', 'comment_author_email' => '', 'comment_author_url' => '', 'comment_content' => '', 'comment_date_gmt' => '', 'comment_tags' => '', 'comment_type' => '', 'guid' => '', 'is_test' => '', 'permalink' => '', 'reporter' => '', 'site_domain' => '', 'submit_referer' => '', 'submit_uri' => '', 'user_ID' => '', 'user_agent' => '', 'user_id' => '', 'user_ip' => '' ) );
|
127 |
$commentdata['akismet_result'] = $response[1];
|
128 |
|
129 |
if ( isset( $response[0]['x-akismet-pro-tip'] ) )
|
130 |
$commentdata['akismet_pro_tip'] = $response[0]['x-akismet-pro-tip'];
|
131 |
|
132 |
+
if ( isset( $response[0]['x-akismet-error'] ) ) {
|
133 |
+
// An error occurred that we anticipated (like a suspended key) and want the user to act on.
|
134 |
+
// Send to moderation.
|
135 |
+
self::$last_comment_result = '0';
|
136 |
+
}
|
137 |
+
else if ( 'true' == $response[1] ) {
|
138 |
// akismet_spam_count will be incremented later by comment_is_spam()
|
139 |
self::$last_comment_result = 'spam';
|
140 |
|
370 |
if ( self::is_test_mode() )
|
371 |
$c['is_test'] = 'true';
|
372 |
|
373 |
+
$response = self::http_post( build_query( $c ), 'comment-check' );
|
374 |
|
375 |
return ( is_array( $response ) && ! empty( $response[1] ) ) ? $response[1] : false;
|
376 |
}
|
377 |
+
|
378 |
+
|
379 |
+
|
380 |
+
public static function transition_comment_status( $new_status, $old_status, $comment ) {
|
381 |
+
|
382 |
+
if ( $new_status == $old_status )
|
383 |
+
return;
|
384 |
+
|
385 |
+
# we don't need to record a history item for deleted comments
|
386 |
+
if ( $new_status == 'delete' )
|
387 |
+
return;
|
388 |
+
|
389 |
+
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
|
390 |
+
return;
|
391 |
+
|
392 |
+
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
|
393 |
+
return;
|
394 |
+
|
395 |
+
// if this is present, it means the status has been changed by a re-check, not an explicit user action
|
396 |
+
if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
|
397 |
+
return;
|
398 |
+
|
399 |
+
global $current_user;
|
400 |
+
$reporter = '';
|
401 |
+
if ( is_object( $current_user ) )
|
402 |
+
$reporter = $current_user->user_login;
|
403 |
+
|
404 |
+
// Assumption alert:
|
405 |
+
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
|
406 |
+
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
|
407 |
+
// determine why the transition_comment_status action was triggered. And there are several different ways by which
|
408 |
+
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
|
409 |
+
// We'll assume that this is an explicit user action if certain POST/GET variables exist.
|
410 |
+
if ( ( isset( $_POST['status'] ) && in_array( $_POST['status'], array( 'spam', 'unspam' ) ) ) ||
|
411 |
+
( isset( $_POST['spam'] ) && (int) $_POST['spam'] == 1 ) ||
|
412 |
+
( isset( $_POST['unspam'] ) && (int) $_POST['unspam'] == 1 ) ||
|
413 |
+
( isset( $_POST['comment_status'] ) && in_array( $_POST['comment_status'], array( 'spam', 'unspam' ) ) ) ||
|
414 |
+
( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'spam', 'unspam' ) ) ) ||
|
415 |
+
( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'editedcomment' ) ) )
|
416 |
+
) {
|
417 |
+
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
|
418 |
+
return self::submit_spam_comment( $comment->comment_ID );
|
419 |
+
} elseif ( $old_status == 'spam' && ( $new_status == 'approved' || $new_status == 'unapproved' ) ) {
|
420 |
+
return self::submit_nonspam_comment( $comment->comment_ID );
|
421 |
+
}
|
422 |
+
}
|
423 |
+
|
424 |
+
self::update_comment_history( $comment->comment_ID, sprintf( __('%1$s changed the comment status to %2$s', 'akismet'), $reporter, $new_status ), 'status-' . $new_status );
|
425 |
+
}
|
426 |
+
|
427 |
+
public static function submit_spam_comment( $comment_id ) {
|
428 |
+
global $wpdb, $current_user, $current_site;
|
429 |
+
|
430 |
+
$comment_id = (int) $comment_id;
|
431 |
+
|
432 |
+
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
433 |
+
|
434 |
+
if ( !$comment ) // it was deleted
|
435 |
+
return;
|
436 |
+
|
437 |
+
if ( 'spam' != $comment->comment_approved )
|
438 |
+
return;
|
439 |
+
|
440 |
+
// use the original version stored in comment_meta if available
|
441 |
+
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
442 |
+
|
443 |
+
if ( $as_submitted && is_array( $as_submitted ) && isset( $as_submitted['comment_content'] ) )
|
444 |
+
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
445 |
+
|
446 |
+
$comment->blog = get_bloginfo('url');
|
447 |
+
$comment->blog_lang = get_locale();
|
448 |
+
$comment->blog_charset = get_option('blog_charset');
|
449 |
+
$comment->permalink = get_permalink($comment->comment_post_ID);
|
450 |
+
|
451 |
+
if ( is_object($current_user) )
|
452 |
+
$comment->reporter = $current_user->user_login;
|
453 |
+
|
454 |
+
if ( is_object($current_site) )
|
455 |
+
$comment->site_domain = $current_site->domain;
|
456 |
+
|
457 |
+
$comment->user_role = '';
|
458 |
+
if ( isset( $comment->user_ID ) )
|
459 |
+
$comment->user_role = Akismet::get_user_roles( $comment->user_ID );
|
460 |
+
|
461 |
+
if ( self::is_test_mode() )
|
462 |
+
$comment->is_test = 'true';
|
463 |
+
|
464 |
+
$post = get_post( $comment->comment_post_ID );
|
465 |
+
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
466 |
+
|
467 |
+
$response = Akismet::http_post( build_query( $comment ), 'submit-spam' );
|
468 |
+
if ( $comment->reporter ) {
|
469 |
+
self::update_comment_history( $comment_id, sprintf( __('%s reported this comment as spam', 'akismet'), $comment->reporter ), 'report-spam' );
|
470 |
+
update_comment_meta( $comment_id, 'akismet_user_result', 'true' );
|
471 |
+
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
472 |
+
}
|
473 |
+
|
474 |
+
do_action('akismet_submit_spam_comment', $comment_id, $response[1]);
|
475 |
+
}
|
476 |
+
|
477 |
+
public static function submit_nonspam_comment( $comment_id ) {
|
478 |
+
global $wpdb, $current_user, $current_site;
|
479 |
+
|
480 |
+
$comment_id = (int) $comment_id;
|
481 |
+
|
482 |
+
$comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_ID = %d", $comment_id ) );
|
483 |
+
if ( !$comment ) // it was deleted
|
484 |
+
return;
|
485 |
+
|
486 |
+
// use the original version stored in comment_meta if available
|
487 |
+
$as_submitted = get_comment_meta( $comment_id, 'akismet_as_submitted', true);
|
488 |
+
|
489 |
+
if ( $as_submitted && is_array($as_submitted) && isset($as_submitted['comment_content']) )
|
490 |
+
$comment = (object) array_merge( (array)$comment, $as_submitted );
|
491 |
+
|
492 |
+
$comment->blog = get_bloginfo('url');
|
493 |
+
$comment->blog_lang = get_locale();
|
494 |
+
$comment->blog_charset = get_option('blog_charset');
|
495 |
+
$comment->permalink = get_permalink( $comment->comment_post_ID );
|
496 |
+
$comment->user_role = '';
|
497 |
+
|
498 |
+
if ( is_object($current_user) )
|
499 |
+
$comment->reporter = $current_user->user_login;
|
500 |
+
|
501 |
+
if ( is_object($current_site) )
|
502 |
+
$comment->site_domain = $current_site->domain;
|
503 |
+
|
504 |
+
if ( isset( $comment->user_ID ) )
|
505 |
+
$comment->user_role = Akismet::get_user_roles($comment->user_ID);
|
506 |
+
|
507 |
+
if ( Akismet::is_test_mode() )
|
508 |
+
$comment->is_test = 'true';
|
509 |
+
|
510 |
+
$post = get_post( $comment->comment_post_ID );
|
511 |
+
$comment->comment_post_modified_gmt = $post->post_modified_gmt;
|
512 |
+
|
513 |
+
$response = self::http_post( build_query( $comment ), 'submit-ham' );
|
514 |
+
if ( $comment->reporter ) {
|
515 |
+
self::update_comment_history( $comment_id, sprintf( __('%s reported this comment as not spam', 'akismet'), $comment->reporter ), 'report-ham' );
|
516 |
+
update_comment_meta( $comment_id, 'akismet_user_result', 'false' );
|
517 |
+
update_comment_meta( $comment_id, 'akismet_user', $comment->reporter );
|
518 |
+
}
|
519 |
+
|
520 |
+
do_action('akismet_submit_nonspam_comment', $comment_id, $response[1]);
|
521 |
+
}
|
522 |
|
523 |
public static function cron_recheck() {
|
524 |
global $wpdb;
|
822 |
}
|
823 |
|
824 |
public static function load_form_js() {
|
825 |
+
// WP < 3.3 can't enqueue a script this late in the game and still have it appear in the footer.
|
826 |
+
// Once we drop support for everything pre-3.3, this can change back to a single enqueue call.
|
827 |
+
wp_register_script( 'akismet-form', AKISMET__PLUGIN_URL . '_inc/form.js', array(), AKISMET_VERSION, true );
|
828 |
+
add_action( 'wp_footer', array( 'Akismet', 'print_form_js' ) );
|
829 |
+
add_action( 'admin_footer', array( 'Akismet', 'print_form_js' ) );
|
830 |
+
}
|
831 |
+
|
832 |
+
public static function print_form_js() {
|
833 |
wp_print_scripts( 'akismet-form' );
|
834 |
}
|
835 |
|
readme.txt
CHANGED
@@ -1,27 +1,26 @@
|
|
1 |
=== Akismet ===
|
2 |
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic
|
3 |
Tags: akismet, comments, spam
|
4 |
-
Requires at least: 3.
|
5 |
-
Tested up to: 3.9
|
6 |
-
Stable tag: 3.0.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
-
Akismet checks your comments against the Akismet
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Akismet checks your comments against the Akismet
|
14 |
-
review the spam it catches under your blog's "Comments" admin screen.
|
15 |
|
16 |
-
Major
|
17 |
|
18 |
-
*
|
19 |
-
*
|
20 |
-
*
|
21 |
-
* Moderators can see the number of approved comments for each user
|
22 |
-
*
|
23 |
|
24 |
-
PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs
|
25 |
|
26 |
== Installation ==
|
27 |
|
@@ -31,6 +30,13 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
31 |
|
32 |
== Changelog ==
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
= 3.0.0 =
|
35 |
* Move Akismet to Settings menu
|
36 |
* Drop Akismet Stats menu
|
@@ -38,7 +44,7 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
|
|
38 |
* Add Akismet subscription details and status to Akismet settings
|
39 |
* Add contextual help for each page
|
40 |
* Improve Akismet setup to use Jetpack to automate plugin setup
|
41 |
-
* Fix
|
42 |
* Fix Akismet settings page to be responsive
|
43 |
* Drop legacy code
|
44 |
* Tidy up CSS and Javascript
|
1 |
=== Akismet ===
|
2 |
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic
|
3 |
Tags: akismet, comments, spam
|
4 |
+
Requires at least: 3.1
|
5 |
+
Tested up to: 3.9.1
|
6 |
+
Stable tag: 3.0.1
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
+
Akismet checks your comments against the Akismet Web service to see if they look like spam or not.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
Akismet checks your comments against the Akismet Web service to see if they look like spam or not and lets you review the spam it catches under your blog's "Comments" admin screen.
|
|
|
14 |
|
15 |
+
Major features in Akismet include:
|
16 |
|
17 |
+
* Automatically checks all comments and filters out the ones that look like spam.
|
18 |
+
* Each comment has a status history, so you can easily see which comments were caught or cleared by Akismet and which were spammed or unspammed by a moderator.
|
19 |
+
* URLs are shown in the comment body to reveal hidden or misleading links.
|
20 |
+
* Moderators can see the number of approved comments for each user.
|
21 |
+
* A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site.
|
22 |
|
23 |
+
PS: You'll need an [Akismet.com API key](http://akismet.com/get/) to use it. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites.
|
24 |
|
25 |
== Installation ==
|
26 |
|
30 |
|
31 |
== Changelog ==
|
32 |
|
33 |
+
= 3.0.1 =
|
34 |
+
* Removed dependency on PHP's fsockopen function
|
35 |
+
* Fix spam/ham reports to work when reported outside of the WP dashboard, e.g., from Notifications or the WP app
|
36 |
+
* Remove jQuery dependency for comment form JavaScript
|
37 |
+
* Remove unnecessary data from some Akismet comment meta
|
38 |
+
* Suspended keys will now result in all comments being put in moderation, not spam.
|
39 |
+
|
40 |
= 3.0.0 =
|
41 |
* Move Akismet to Settings menu
|
42 |
* Drop Akismet Stats menu
|
44 |
* Add Akismet subscription details and status to Akismet settings
|
45 |
* Add contextual help for each page
|
46 |
* Improve Akismet setup to use Jetpack to automate plugin setup
|
47 |
+
* Fix "Check for Spam" to use AJAX to avoid page timing out
|
48 |
* Fix Akismet settings page to be responsive
|
49 |
* Drop legacy code
|
50 |
* Tidy up CSS and Javascript
|
views/notice.php
CHANGED
@@ -34,7 +34,7 @@
|
|
34 |
<?php elseif ( $type == 'missing-functions' ) :?>
|
35 |
<div class="wrap alert critical">
|
36 |
<h3 class="key-status failed"><?php esc_html_e('Network functions are disabled.', 'akismet'); ?></h3>
|
37 |
-
<p class="description"><?php printf( __('Your web host or server administrator has disabled PHP’s <code>
|
38 |
</div>
|
39 |
<?php elseif ( $type == 'servers-be-down' ) :?>
|
40 |
<div class="wrap alert critical">
|
34 |
<?php elseif ( $type == 'missing-functions' ) :?>
|
35 |
<div class="wrap alert critical">
|
36 |
<h3 class="key-status failed"><?php esc_html_e('Network functions are disabled.', 'akismet'); ?></h3>
|
37 |
+
<p class="description"><?php printf( __('Your web host or server administrator has disabled PHP’s <code>gethostbynamel</code> functions. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet’s system requirements</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
|
38 |
</div>
|
39 |
<?php elseif ( $type == 'servers-be-down' ) :?>
|
40 |
<div class="wrap alert critical">
|
wrapper.php
CHANGED
@@ -15,7 +15,7 @@ function akismet_test_mode() {
|
|
15 |
function akismet_http_post( $request, $host, $path, $port = 80, $ip = null ) {
|
16 |
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::http_post()' );
|
17 |
|
18 |
-
$path =
|
19 |
|
20 |
return Akismet::http_post( $request, $path, $ip );
|
21 |
}
|
@@ -120,19 +120,19 @@ function akismet_check_for_spam_button( $comment_status ) {
|
|
120 |
return Akismet_Admin::check_for_spam_button( $comment_status );
|
121 |
}
|
122 |
function akismet_submit_nonspam_comment( $comment_id ) {
|
123 |
-
_deprecated_function( __FUNCTION__, '3.0', '
|
124 |
|
125 |
-
return
|
126 |
}
|
127 |
function akismet_submit_spam_comment( $comment_id ) {
|
128 |
-
_deprecated_function( __FUNCTION__, '3.0', '
|
129 |
|
130 |
-
return
|
131 |
}
|
132 |
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
|
133 |
-
_deprecated_function( __FUNCTION__, '3.0', '
|
134 |
|
135 |
-
return
|
136 |
}
|
137 |
function akismet_spam_count( $type = false ) {
|
138 |
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::get_spam_count()' );
|
@@ -290,4 +290,4 @@ function akismet_kill_proxy_check( $option ) {
|
|
290 |
_deprecated_function( __FUNCTION__, '3.0' );
|
291 |
|
292 |
return 0;
|
293 |
-
}
|
15 |
function akismet_http_post( $request, $host, $path, $port = 80, $ip = null ) {
|
16 |
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::http_post()' );
|
17 |
|
18 |
+
$path = str_replace( '/1.1/', '', $path );
|
19 |
|
20 |
return Akismet::http_post( $request, $path, $ip );
|
21 |
}
|
120 |
return Akismet_Admin::check_for_spam_button( $comment_status );
|
121 |
}
|
122 |
function akismet_submit_nonspam_comment( $comment_id ) {
|
123 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::submit_nonspam_comment()' );
|
124 |
|
125 |
+
return Akismet::submit_nonspam_comment( $comment_id );
|
126 |
}
|
127 |
function akismet_submit_spam_comment( $comment_id ) {
|
128 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::submit_spam_comment()' );
|
129 |
|
130 |
+
return Akismet::submit_spam_comment( $comment_id );
|
131 |
}
|
132 |
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
|
133 |
+
_deprecated_function( __FUNCTION__, '3.0', 'Akismet::transition_comment_status()' );
|
134 |
|
135 |
+
return Akismet::transition_comment_status( $new_status, $old_status, $comment );
|
136 |
}
|
137 |
function akismet_spam_count( $type = false ) {
|
138 |
_deprecated_function( __FUNCTION__, '3.0', 'Akismet_Admin::get_spam_count()' );
|
290 |
_deprecated_function( __FUNCTION__, '3.0' );
|
291 |
|
292 |
return 0;
|
293 |
+
}
|