+
+if ( 'moderation.php' == $pagenow ) {
+ function akismet_recheck_button( $page ) {
+ global $submenu;
+ if ( isset( $submenu['edit-comments.php'] ) )
+ $link = 'edit-comments.php';
+ else
+ $link = 'edit.php';
+ $button = "<a href='$link?page=akismet-admin&recheckqueue=true&noheader=true' style='display: block; width: 100px; position: absolute; right: 7%; padding: 5px; font-size: 14px; text-decoration: underline; background: #fff; border: 1px solid #ccc;'>" . __('Recheck Queue for Spam') . "</a>";
+ $page = str_replace( '<div class="wrap">', '<div class="wrap">' . $button, $page );
+ return $page;
+ }
+
+ if ( $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ) )
+ ob_start( 'akismet_recheck_button' );
+}
+
+function akismet_recheck_queue() {
+ global $wpdb, $akismet_api_host, $akismet_api_port;
+
+ if ( !isset( $_GET['recheckqueue'] ) )
+ return;
+
+ $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A );
+ foreach ( $moderation as $c ) {
+ $c['user_ip'] = $c['comment_author_IP'];
+ $c['user_agent'] = $c['comment_agent'];
+ $c['referrer'] = '';
+ $c['blog'] = get_option('home');
+ $id = $c['comment_ID'];
+
+ $query_string = '';
+ foreach ( $c as $key => $data )
+ $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
+
+ $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
+ if ( 'true' == $response[1] ) {
+ $wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'spam' WHERE comment_ID = $id" );
+ }
+ }
+ wp_redirect( $_SERVER['HTTP_REFERER'] );
+ exit;
+}
+
+function akismet_check_db_comment( $id ) {
+ global $wpdb, $akismet_api_host, $akismet_api_port;
+
+ $id = (int) $id;
+ $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
+ if ( !$c )
+ return;
+
+ $c['user_ip'] = $c['comment_author_IP'];
+ $c['user_agent'] = $c['comment_agent'];
+ $c['referrer'] = '';
+ $c['blog'] = get_option('home');
+ $id = $c['comment_ID'];
+
+ $query_string = '';
+ foreach ( $c as $key => $data )
+ $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
+
+ $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
+ return $response[1];
+}
+
+// This option causes tons of FPs, was removed in 2.1
+function akismet_kill_proxy_check( $option ) { return 0; }
+add_filter('option_open_proxy_check', 'akismet_kill_proxy_check');
+
+// Widget stuff
+function widget_akismet_register() {
+ if ( function_exists('register_sidebar_widget') ) :
+ function widget_akismet($args) {
+ extract($args);
+ $options = get_option('widget_akismet');
+ $count = number_format(get_option('akismet_spam_count'));
+ $text = __('%d spam comments have been blocked by <a href="http://akismet.com">Akismet</a>.');
+ ?>
+ <?php echo $before_widget; ?>
+ <?php echo $before_title . $options['title'] . $after_title; ?>
+ <div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( __( '%1$s %2$sspam comments%3$s %4$sblocked by%5$s<br />%6$sAkismet%7$s' ), '<div id="akismet1"><span id="akismetcount">' . $count . '</span>', '<span id="akismetsc">', '</span></div>', '<div id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></div>' ); ?></a></div></div>
+ <?php echo $after_widget; ?>
+ <?php
+ }
+
+ function widget_akismet_style() {
+ ?>
+<style type="text/css">
+#aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
+#aka:hover{border:none;text-decoration:none}
+#aka:hover #akismet1{display:none}
+#aka:hover #akismet2,#akismet1{display:block}
+#akismet2{display:none;padding-top:2px}
+#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
+#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
+#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'); ?>/wp-content/plugins/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
+</style>
+ <?php
+ }
+
+ function widget_akismet_control() {
+ $options = $newoptions = get_option('widget_akismet');
+ if ( $_POST["akismet-submit"] ) {
+ $newoptions['title'] = strip_tags(stripslashes($_POST["akismet-title"]));
+ if ( empty($newoptions['title']) ) $newoptions['title'] = 'Spam Blocked';
+ }
+ if ( $options != $newoptions ) {
+ $options = $newoptions;
+ update_option('widget_akismet', $options);
+ }
+ $title = htmlspecialchars($options['title'], ENT_QUOTES);
+ ?>
+ <p><label for="akismet-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="akismet-title" name="akismet-title" type="text" value="<?php echo $title; ?>" /></label></p>
+ <input type="hidden" id="akismet-submit" name="akismet-submit" value="1" />
+ <?php
+ }
+
+ register_sidebar_widget('Akismet', 'widget_akismet', null, 'akismet');
+ register_widget_control('Akismet', 'widget_akismet_control', 300, 75, 'akismet');
+ if ( is_active_widget('widget_akismet') )
+ add_action('wp_head', 'widget_akismet_style');
+ endif;
+}
+
+add_action('init', 'widget_akismet_register');
+
+// Counter for non-widget users
+function akismet_counter() {
+?>
+<style type="text/css">
+#akismetwrap #aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
+#aka:hover{border:none;text-decoration:none}
+#aka:hover #akismet1{display:none}
+#aka:hover #akismet2,#akismet1{display:block}
+#akismet2{display:none;padding-top:2px}
+#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
+#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
+#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'); ?>/wp-content/plugins/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
+</style>
+<?php
+$count = number_format(get_option('akismet_spam_count'));
+?>
+<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount"><?php echo $count; ?></span> <span id="akismetsc"><?php _e('spam comments') ?></span></div> <div id="akismet2"><span id="akismetbb"><?php _e('blocked by') ?></span><br /><span id="akismeta">Akismet</span></div></a></div></div>
+<?php
+}
+