WordPress.com API key to use this service. Author: Michael Adams Version: 1.0 Author URI: http://blogwaffe.com/ */ // Add filters for the admin area add_action('bb_admin_menu_generator', 'bb_ksd_configuration_page_add'); add_action('bb_admin-header.php', 'bb_ksd_configuration_page_process'); function bb_ksd_configuration_page_add() { bb_admin_add_submenu(__('Akismet Configuration'), 'use_keys', 'bb_ksd_configuration_page'); } function bb_ksd_configuration_page() { ?>
poster_id ); if ( bb_is_trusted_user( $user->ID ) ) return; $_submit = array( 'blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => $bb_post->poster_ip, 'permalink' => get_topic_link( $bb_post->topic_id ), // First page 'comment_type' => 'forum', 'comment_author' => get_user_name( $user->ID ), 'comment_author_email' => bb_get_user_email( $user->ID ), 'comment_author_url' => get_user_link( $user->ID ), 'comment_content' => $bb_post->post_text, 'comment_date_gmt' => $bb_post->post_time ); break; case 'hammer' : case 'spammer' : $path = '/1.1/submit-' . substr($type, 0, -3); $user = bb_get_user( $submit ); if ( !$user ) return; if ( bb_is_trusted_user( $user->ID ) ) return; $_submit = array( 'blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'permalink' => get_user_profile_link( $user->ID ), 'comment_type' => 'profile', 'comment_author' => get_user_name( $user->ID ), 'comment_author_email' => bb_get_user_email( $user->ID ), 'comment_author_url' => get_user_link( $user->ID ), 'comment_content' => $user->occ . ' ' . $user->interests, 'comment_date_gmt' => $user->user_registered ); break; default : if ( bb_is_trusted_user( bb_get_current_user() ) ) return; $path = '/1.1/comment-check'; $_submit = array( 'blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => isset($_POST['topic_id']) ? 'forum' : 'profile', 'comment_author' => bb_get_current_user_info( 'name' ), 'comment_author_email' => bb_get_current_user_info( 'email' ), 'comment_author_url' => bb_get_current_user_info( 'url' ), 'comment_content' => $submit ); if ( isset($_POST['topic_id']) ) $_submit['permalink'] = get_topic_link( $_POST['topic_id'] ); // First page break; endswitch; $query_string = ''; foreach ( $_submit as $key => $data ) $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; return bb_ksd_http_post($query_string, $bb_ksd_api_host, $path, $bb_ksd_api_port); } function bb_ksd_submit_ham( $post_id ) { bb_ksd_submit( $post_id, 'ham' ); } function bb_ksd_submit_spam( $post_id ) { bb_ksd_submit( $post_id, 'spam' ); } function bb_ksd_check_post( $post_text ) { global $bb_current_user, $bb_ksd_pre_post_status; if ( in_array($bb_current_user->roles[0], bb_trusted_roles()) ) // Don't filter content from users with a trusted role return $post_text; $response = bb_ksd_submit( $post_text ); if ( 'true' == $response[1] ) $bb_ksd_pre_post_status = '2'; bb_akismet_delete_old(); return $post_text; } function bb_ksd_check_profile( $user_id ) { global $bb_current_user, $user_obj; $bb_current_id = bb_get_current_user_info( 'id' ); bb_set_current_user( $user_id ); if ( $bb_current_id && $bb_current_id != $user_id ) { if ( $user_obj->data->is_bozo && !$bb_current_user->data->is_bozo ) bb_ksd_submit( $user_id, 'hammer' ); if ( !$user_obj->data->is_bozo && $bb_current_user->data->is_bozo ) bb_ksd_submit( $user_id, 'spammer' ); } else { $response = bb_ksd_submit( $bb_current_user->data->occ . ' ' . $bb_current_user->data->interests ); if ( 'true' == $response[1] && function_exists('bb_bozon') ) bb_bozon( bb_get_current_user_info( 'id' ) ); } bb_set_current_user((int) $bb_current_id); } function bb_ksd_new_post( $post_id ) { global $bb_ksd_pre_post_status; if ( '2' != $bb_ksd_pre_post_status ) return; $bb_post = bb_get_post( $post_id ); $topic = get_topic( $bb_post->topic_id ); if ( 0 == $topic->topic_posts ) bb_delete_topic( $topic->topic_id, 2 ); } function bb_akismet_delete_old() { // Delete old every 20 $n = mt_rand(1, 20); if ( $n % 20 ) return; global $bbdb; $now = bb_current_time('mysql'); $posts = (array) $bbdb->get_col( $bbdb->prepare( "SELECT post_id FROM $bbdb->posts WHERE DATE_SUB(%s, INTERVAL 15 DAY) > post_time AND post_status = '2'", $now ) ); foreach ( $posts as $post ) bb_delete_post( $post, 1 ); } function bb_ksd_pre_post_status( $post_status ) { global $bb_ksd_pre_post_status; if ( '2' == $bb_ksd_pre_post_status ) $post_status = $bb_ksd_pre_post_status; return $post_status; } function bb_ksd_admin_menu() { global $bb_submenu; $bb_submenu['content.php'][] = array(__('Akismet Spam'), 'moderate', 'bb_ksd_admin_page'); } function bb_ksd_delete_post( $post_id, $new_status, $old_status ) { if ( 2 == $new_status && 2 != $old_status ) bb_ksd_submit_spam( $post_id ); else if ( 2 != $new_status && 2 == $old_status ) bb_ksd_submit_ham( $post_id ); } function bb_ksd_admin_page() { global $bb_posts, $page; if ( !bb_akismet_verify_key( bb_get_option( 'akismet_key' ) ) ) : ?>Akismet Key set in Akismet configuration. If you don\'t have an API key yet, you can get one at WordPress.com.'), 'admin-base.php?plugin=bb_ksd_configuration_page', 'http://wordpress.com/api-keys/'); ?>