function acf_cf_akismet($content)
{
    // innocent until proven guilty
    $isSpam = FALSE;
    $content = (array) $content;
    if (function_exists('akismet_init')) {
        $wpcom_api_key = get_option('wordpress_api_key');
        if (!empty($wpcom_api_key)) {
            global $akismet_api_host, $akismet_api_port;
            // set remaining required values for akismet api
            $content['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
            $content['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
            $content['referrer'] = $_SERVER['HTTP_REFERER'];
            $content['blog'] = get_option('home');
            if (empty($content['referrer'])) {
                $content['referrer'] = get_permalink();
            }
            $queryString = '';
            foreach ($content as $key => $data) {
                if (!empty($data)) {
                    $queryString .= $key . '=' . urlencode(stripslashes($data)) . '&';
                }
            }
            $response = akismet_http_post($queryString, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
            if ($response[1] == 'true') {
                update_option('akismet_spam_count', get_option('akismet_spam_count') + 1);
                $isSpam = TRUE;
            }
        }
    }
    return $isSpam;
}
Example #2
0
 public static function mark_akismet_spam($esu_post_vars, $is_spam)
 {
     global $akismet_api_host, $akismet_api_port;
     $fields = self::esu_get_akismet_fields($esu_post_vars);
     $as = $is_spam ? "spam" : "ham";
     //Submitting info do Akismet
     akismet_http_post($fields, $akismet_api_host, '/1.1/submit-' . $as, $akismet_api_port);
 }
Example #3
0
function recheck_config_page()
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    if (isset($_POST['recheck_update'])) {
        /* do import */
        $comments = $wpdb->get_results("SELECT comment_ID FROM {$wpdb->comments}\tWHERE comment_approved = '1'", ARRAY_A);
        $spam_found = 0;
        $comments_processed = 0;
        foreach ($comments as $c) {
            $i = $c['comment_ID'];
            $comment = $wpdb->get_row("SELECT * FROM {$wpdb->comments} WHERE comment_id = {$i}", ARRAY_A);
            $comment['user_ip'] = $comment['comment_author_IP'];
            $comment['user_agent'] = $comment['comment_agent'];
            $comment['referrer'] = '';
            $comment['blog'] = get_option('home');
            $id = (int) $comment['comment_ID'];
            $query_string = '';
            foreach ($comment 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 ($response[1] == 'true') {
                //echo '<p>comment #' . $comment['comment_ID'] . ' is SPAM!!!</p>';
                $wpdb->query("UPDATE {$wpdb->comments} SET comment_approved = '0' WHERE comment_ID = {$id}");
                $spam_found++;
            }
            $comments_processed++;
        }
        echo '<p>total spam found: ' . $spam_found . '</p>';
        echo '<p>total comments processed: ' . $comments_processed . '</p>';
        ?>
		<div id="message" class="updated fade">
			<p>Victory!</p>
		</div>
	<?php 
    }
    ?>

<div class="wrap">
	<h2>Spam Recheck</h2>
	<form method="post" action="">
		<div style="width:100%; horizontal-align:right">
			<input type="submit" name="recheck_update" value="Check &raquo;"  style="float:right;" />
			<hr style="clear:both; visibility: hidden" />
		</div>
	</form>
</div>
<?php 
}
Example #4
0
function flamingo_akismet_submit($comment, $as = 'spam')
{
    global $akismet_api_host, $akismet_api_port;
    if (!flamingo_akismet_is_active()) {
        return false;
    }
    if (!in_array($as, array('spam', 'ham'))) {
        return false;
    }
    $query_string = '';
    foreach ((array) $comment as $key => $data) {
        $query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
    }
    if (is_callable(array('Akismet', 'http_post'))) {
        // Akismet v3.0+
        $response = Akismet::http_post($query_string, 'submit-' . $as);
    } else {
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/submit-' . $as, $akismet_api_port);
    }
    return (bool) $response[1];
}
function clean_contact_akismet($body, $subject, $email, $name)
{
    if (!function_exists('akismet_http_post')) {
        return true;
    }
    global $akismet_api_host, $akismet_api_port;
    $comment['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
    $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    $comment['referrer'] = $_SERVER['HTTP_REFERER'];
    $comment['blog'] = get_option('home');
    $comment['comment_author_email'] = $email;
    $comment['comment_author'] = clean_contact_scrub($name);
    $comment['comment_content'] = clean_contact_scrub($body);
    $query_string = '';
    foreach ($comment 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]) {
        return true;
    }
}
Example #6
0
function sharing_email_check_for_spam_via_akismet($data)
{
    if (!function_exists('akismet_http_post') && !method_exists('Akismet', 'http_post')) {
        return $data;
    }
    // Prepare the body_request for akismet
    $body_request = array('blog' => get_option('home'), 'permalink' => get_permalink($data['post']->ID), 'comment_type' => 'share', 'comment_author' => $data['name'], 'comment_author_email' => $data['source'], 'comment_content' => sharing_email_send_post_content($data), 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
    if (method_exists('Akismet', 'http_post')) {
        $body_request['user_ip'] = Akismet::get_ip_address();
        $response = Akismet::http_post(build_query($body_request), 'comment-check');
    } else {
        global $akismet_api_host, $akismet_api_port;
        $body_request['user_ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
        $response = akismet_http_post(build_query($body_request), $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    }
    // The Response is spam lets not send the email.
    if (!empty($response) && isset($response[1]) && 'true' == trim($response[1])) {
        // 'true' is spam
        return false;
        // don't send the email
    }
    return $data;
}
 public static function api_check($params)
 {
     global $akismet_api_host, $akismet_api_port;
     /* bail if no content to check against akismet */
     if (!isset($params['comment_content'])) {
         return;
     }
     $spam = false;
     $query_string = '';
     foreach ($params as $key => $data) {
         $query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
     }
     if (is_callable(array('Akismet', 'http_post'))) {
         // Akismet v3.0+
         $response = Akismet::http_post($query_string, 'comment-check');
     } else {
         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
     }
     /* returns true if spam else return false */
     if ('true' == $response[1]) {
         return true;
     }
     return false;
 }
Example #8
0
 function akismet($values)
 {
     $content = FrmEntriesHelper::entry_array_to_string($values);
     if (empty($content)) {
         return false;
     }
     $datas = array();
     $datas['blog'] = FrmAppHelper::site_url();
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $datas['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false;
     $datas['comment_type'] = 'formidable';
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     $datas['comment_content'] = $content;
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
             $datas["{$key}"] = $value;
         } else {
             $datas["{$key}"] = '';
         }
         unset($key, $value);
     }
     $query_string = '';
     foreach ($datas as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
         unset($key, $data);
     }
     if (is_callable('Akismet::http_post')) {
         $response = Akismet::http_post($query_string, 'comment-check');
     } else {
         global $akismet_api_host, $akismet_api_port;
         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
     }
     return (is_array($response) and $response[1] == 'true') ? true : false;
 }
Example #9
0
 function is_spam($contact)
 {
     if (function_exists('akismet_http_post')) {
         global $akismet_api_host, $akismet_api_port;
         $comment = array('comment_author' => $contact['name'], 'comment_author_email' => $contact['email'], 'comment_author_url' => $contact['email'], 'contact_form_subject' => '', 'comment_content' => $contact['message'], 'user_ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'blog' => get_option('home'));
         foreach ($_SERVER as $key => $value) {
             if ($key != 'HTTP_COOKIE' && is_string($value)) {
                 $comment[$key] = $value;
             }
         }
         $query = '';
         foreach ($comment as $key => $value) {
             $query .= $key . '=' . urlencode($value) . '&';
         }
         $response = akismet_http_post($query, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
         if ('true' == trim($response[1])) {
             return true;
         }
     }
     return false;
 }
 $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
 foreach ($_SERVER as $key => $value) {
     if (!in_array($key, $ignore) && is_string($value)) {
         $c["{$key}"] = $value;
     } else {
         $c["{$key}"] = '';
     }
 }
 $query_string = '';
 foreach ($c as $key => $data) {
     if (is_string($data)) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
     }
 }
 //echo "test $akismet_api_host, $akismet_api_port, $query_string"; exit;
 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
 if ('true' == $response[1]) {
     if ($si_contact_opt['akismet_send_anyway'] == 'false') {
         $this->si_contact_error = 1;
         // Akismet says it is spam.
         $fsc_error_message['message'] = $si_contact_opt['error_input'] != '' ? $si_contact_opt['error_input'] : __('Invalid Input - Spam?', 'si-contact-form');
         if ($user_ID != '' && current_user_can('level_10')) {
             // show administrator a helpful message
             $fsc_error_message['message'] .= '<br />' . __('Akismet determined your message is spam. This can be caused by the message content, your email address, or your IP address being on the Akismet spam system. The administrator can turn off Akismet for the form on the form edit menu.', 'si-contact-form');
         }
     } else {
         // Akismet says it is spam. flag the subject as spam and send anyway.
         $subj = __('Akismet: Spam', 'si-contact-form') . ' - ' . $subj;
         $msg = str_replace(__('Sent from (ip address)', 'si-contact-form'), __('Akismet Spam Check: probably spam', 'si-contact-form') . $php_eol . __('Sent from (ip address)', 'si-contact-form'), $msg);
         $posted_data['akismet'] = __('probably spam', 'si-contact-form');
     }
Example #11
0
function shandora_process_agent_contact()
{
    if (!isset($_POST) || empty($_POST)) {
        $return_data['value'] = __('Cannot send email to destination. No parameter receive form AJAX call.', 'bon');
        die(json_encode($return_data));
    }
    $name = esc_html($_POST['name']);
    if (empty($name)) {
        $return_data['value'] = __('Please enter your name.', 'bon');
        die(json_encode($return_data));
    }
    $email = sanitize_email($_POST['email']);
    if (empty($email)) {
        $return_data['value'] = __('Please enter a valid email address.', 'bon');
        die(json_encode($return_data));
    }
    $phone = isset($_POST['phone']) ? esc_attr($_POST['phone']) : '';
    $subject = esc_html($_POST['subject']);
    $listing_id = absint($_POST['listing_id']);
    $messages = esc_textarea($_POST['messages']);
    if (empty($messages)) {
        $return_data['value'] = 'Please enter your messages.';
        die(json_encode($return_data));
    }
    if (function_exists('akismet_http_post') && trim(get_option('wordpress_api_key')) != '') {
        global $akismet_api_host, $akismet_api_port;
        $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
        $c['blog'] = home_url();
        $c['comment_author'] = $name;
        $c['comment_author_email'] = $email;
        $c['comment_content'] = $messages;
        $query_string = '';
        foreach ($c as $key => $data) {
            if (is_string($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]) {
            // Akismet says it's SPAM
            $return_data['value'] = __('Cheatin Huh?!', 'bon');
            die(json_encode($return_data));
        }
    }
    $receiver = $_POST['receiver'];
    //$body = "You have received a new contact form message via ".get_bloginfo('name')." \n";
    $body = sprintf(__("You have received a new contact form message via %s \n", 'bon'), get_bloginfo('name'));
    /*$body .= 'Name : ' . $name . " \n";
    	$body .= 'Email : ' . $email . " \n";
    	$body .= 'Subject : ' . $subject . " \n";
    	$body .= 'Email Send From: ' . get_permalink( $listing_id ) . " \n";
    	$body .= 'Sender Phone Number :' . $phone . " \n";
    	$body .= 'Message : ' . $messages;
    	*/
    $body .= sprintf(__("Sender Name : %s \n", "bon"), $name);
    $body .= sprintf(__("Sender Email : %s \n", "bon"), $email);
    $body .= sprintf(__("Subject : %s \n", "bon"), $subject);
    $body .= sprintf(__("Sender Phone Number : %s \n", "bon"), $phone);
    $body .= sprintf(__("Email Send From : %s \n", "bon"), get_permalink($listing_id));
    $body .= sprintf(__("Message : %s \n", "bon"), $messages);
    $header = "From: " . $name . " <" . $email . "> \r\n";
    $header .= "Reply-To: " . $email;
    $subject_email = "[" . get_bloginfo('name') . " Contact Form] " . $subject;
    if (wp_mail($receiver, $subject_email, $body, $header)) {
        $return_data['success'] = '1';
        $return_data['value'] = __('Email was sent successfully.', 'bon');
        die(json_encode($return_data));
    } else {
        $return_data['value'] = __('There is an error sending email.', 'bon');
        die(json_encode($return_data));
    }
}
Example #12
0
 function akismet($values)
 {
     global $akismet_api_host, $akismet_api_port, $frm_siteurl;
     $content = '';
     foreach ($values['item_meta'] as $val) {
         if ($content != '') {
             $content .= "\n\n";
         }
         $content .= $val;
     }
     if ($content == '') {
         return false;
     }
     $datas = array();
     $datas['blog'] = $frm_siteurl;
     $datas['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
     $datas['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
     $datas['referrer'] = $_SERVER['HTTP_REFERER'];
     $datas['comment_type'] = 'formidable';
     if ($permalink = get_permalink()) {
         $datas['permalink'] = $permalink;
     }
     $datas['comment_content'] = $content;
     foreach ($_SERVER as $key => $value) {
         if (!in_array($key, array('HTTP_COOKIE', 'argv'))) {
             $datas["{$key}"] = $value;
         }
     }
     $query_string = '';
     foreach ($datas 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] == 'true' ? true : false;
 }
Example #13
0
 static function check_akismet()
 {
     $string = '';
     // Check with Akismet, but only if Akismet is installed, activated, and has a KEY. (Recommended for spam control).
     if (self::$form_options['akismet_disable'] == 'false') {
         // per form disable feature
         // check if akismet is activated, version 2.x or 3.x
         if ((is_callable(array('Akismet', 'http_post')) || function_exists('akismet_http_post')) && get_option('wordpress_api_key')) {
             global $akismet_api_host, $akismet_api_port;
             $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
             $c['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
             $c['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
             $c['blog'] = get_option('home');
             $c['blog_lang'] = get_locale();
             // default 'en_US'
             $c['blog_charset'] = get_option('blog_charset');
             $c['permalink'] = self::$form_action_url;
             $c['comment_type'] = 'contact-form';
             if (!empty(self::$email_fields['from_name'])) {
                 $c['comment_author'] = self::$email_fields['from_name'];
             }
             //$c['is_test']  = "1";  // uncomment this when testing spam detection
             //$c['comment_author']  = "viagra-test-123";  // uncomment this to test spam detection
             // or  You can just put viagra-test-123 as the name when testing the form (no need to edit this php file to test it)
             if (!empty(self::$email_fields['from_email'])) {
                 $c['comment_author_email'] = self::$email_fields['from_email'];
             }
             $c['comment_content'] = self::$email_msg;
             $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
             foreach ($_SERVER as $key => $value) {
                 if (!in_array($key, $ignore) && is_string($value)) {
                     $c["{$key}"] = $value;
                 } else {
                     $c["{$key}"] = '';
                 }
             }
             $query_string = '';
             foreach ($c as $key => $data) {
                 if (is_string($data)) {
                     $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
                 }
             }
             //echo "test $akismet_api_host, $akismet_api_port, $query_string"; exit;
             if (is_callable(array('Akismet', 'http_post'))) {
                 // Akismet v3.0+
                 $response = Akismet::http_post($query_string, 'comment-check');
             } else {
                 // Akismet v2.xx
                 $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
             }
             if ('true' == $response[1]) {
                 if (self::$form_options['akismet_send_anyway'] == 'false') {
                     self::$form_errors['akismet'] = self::$form_options['error_input'] != '' ? self::$form_options['error_input'] : __('Invalid Input - Spam?', 'si-contact-form');
                     global $user_ID;
                     if ($user_ID != '' && current_user_can('manage_options')) {
                         // this error only shown to WP admins
                         // show administrator a helpful message
                         self::$form_errors['akismet'] .= '<br />' . __('Akismet determined your message is spam. This can be caused by the message content, your email address, or your IP address being on the Akismet spam system. The administrator can turn off Akismet for the form on the form edit menu.', 'si-contact-form');
                     }
                 } else {
                     // Akismet says it is spam. flag the subject as spam and send anyway.
                     // XXX someday make these messages editable in settings
                     self::$akismet_spam_subject = __('Akismet: Spam', 'si-contact-form') . ' - ';
                     $string .= __('Akismet Spam Check: probably spam', 'si-contact-form') . self::$php_eol;
                     self::$email_fields['akismet'] = __('probably spam', 'si-contact-form');
                 }
             } else {
                 $string .= __('Akismet Spam Check: passed', 'si-contact-form') . self::$php_eol;
                 self::$email_fields['akismet'] = __('passed', 'si-contact-form');
             }
         }
     }
     return $string;
 }
Example #14
0
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');
    $c['blog_lang'] = get_locale();
    $c['blog_charset'] = get_option('blog_charset');
    $c['permalink'] = get_permalink($c['comment_post_ID']);
    $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];
}
Example #15
0
function akismet_recheck_queue()
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    akismet_fix_scheduled_recheck();
    if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) {
        return;
    }
    $paginate = '';
    if (isset($_POST['limit']) && isset($_POST['offset'])) {
        $paginate = $wpdb->prepare(" LIMIT %d OFFSET %d", array($_POST['limit'], $_POST['offset']));
    }
    $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'{$paginate}", ARRAY_A);
    foreach ((array) $moderation as $c) {
        $c['user_ip'] = $c['comment_author_IP'];
        $c['user_agent'] = $c['comment_agent'];
        $c['referrer'] = '';
        $c['blog'] = get_bloginfo('url');
        $c['blog_lang'] = get_locale();
        $c['blog_charset'] = get_option('blog_charset');
        $c['permalink'] = get_permalink($c['comment_post_ID']);
        $c['user_role'] = '';
        if (isset($c['user_ID'])) {
            $c['user_role'] = akismet_get_user_roles($c['user_ID']);
        }
        if (akismet_test_mode()) {
            $c['is_test'] = 'true';
        }
        $id = (int) $c['comment_ID'];
        $query_string = '';
        foreach ($c as $key => $data) {
            $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
        }
        add_comment_meta($c['comment_ID'], 'akismet_rechecking', true);
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
        if ('true' == $response[1]) {
            wp_set_comment_status($c['comment_ID'], 'spam');
            update_comment_meta($c['comment_ID'], 'akismet_result', 'true');
            delete_comment_meta($c['comment_ID'], 'akismet_error');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam');
        } elseif ('false' == $response[1]) {
            update_comment_meta($c['comment_ID'], 'akismet_result', 'false');
            delete_comment_meta($c['comment_ID'], 'akismet_error');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham');
            // abnormal result: error
        } else {
            update_comment_meta($c['comment_ID'], 'akismet_result', 'error');
            akismet_update_comment_history($c['comment_ID'], sprintf(__('Akismet was unable to re-check this comment (response: %s)'), substr($response[1], 0, 50)), 'check-error');
        }
        delete_comment_meta($c['comment_ID'], 'akismet_rechecking');
    }
    if (defined('DOING_AJAX') && DOING_AJAX) {
        wp_send_json(array('processed' => count((array) $moderation)));
    } else {
        $redirect_to = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : admin_url('edit-comments.php');
        wp_safe_redirect($redirect_to);
        exit;
    }
}
Example #16
0
function wpcf7_akismet_comment_check($comment)
{
    global $akismet_api_host, $akismet_api_port;
    $spam = false;
    $query_string = '';
    foreach ($comment as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes((string) $data)) . '&';
    }
    $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    if ('true' == $response[1]) {
        $spam = true;
    }
    if ($contact_form = wpcf7_get_current_contact_form()) {
        $contact_form->akismet = array('comment' => $comment, 'spam' => $spam);
    }
    return apply_filters('wpcf7_akismet_comment_check', $spam, $comment);
}
Example #17
0
 /**
  * Submit a feedback as either spam or ham
  *
  * @param string $as Either 'spam' or 'ham'.
  * @param array $form the contact-form data
  */
 function akismet_submit($as, $form)
 {
     global $akismet_api_host, $akismet_api_port;
     if (!in_array($as, array('ham', 'spam'))) {
         return false;
     }
     $query_string = http_build_query($form);
     $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-{$as}", $akismet_api_port);
     return trim($response[1]);
 }
 /**
  * Contact Akismet to check if this is spam or ham
  *
  * Props to WordPress core Akismet plugin for alot of this
  *
  * @global string $akismet_api_host
  * @global string $akismet_api_port
  * @param array $activity_data Packet of information to submit to Akismet
  * @param string $check "check" or "submit"
  * @param string $spam "spam" or "ham"
  * @since BuddyPress (1.6)
  */
 public function send_akismet_request($activity_data, $check = 'check', $spam = 'spam')
 {
     global $akismet_api_host, $akismet_api_port;
     // Check that host and port are set, if not, set them
     if (function_exists('akismet_init') && (empty($akismet_api_host) || empty($akismet_api_port))) {
         akismet_init();
     }
     $query_string = $path = $response = '';
     $activity_data['blog'] = bp_get_option('home');
     $activity_data['blog_charset'] = bp_get_option('blog_charset');
     $activity_data['blog_lang'] = get_locale();
     $activity_data['referrer'] = $_SERVER['HTTP_REFERER'];
     $activity_data['user_agent'] = bp_core_current_user_ua();
     $activity_data['user_ip'] = bp_core_current_user_ip();
     if (akismet_test_mode()) {
         $activity_data['is_test'] = 'true';
     }
     // Loop through _POST args and rekey strings
     foreach ($_POST as $key => $value) {
         if (is_string($value) && 'cookie' != $key) {
             $activity_data['POST_' . $key] = $value;
         }
     }
     // Keys to ignore
     $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
     // Loop through _SERVER args and remove whitelisted keys
     foreach ($_SERVER as $key => $value) {
         // Key should not be ignored
         if (!in_array($key, $ignore) && is_string($value)) {
             $activity_data[$key] = $value;
             // Key should be ignored
         } else {
             $activity_data[$key] = '';
         }
     }
     foreach ($activity_data as $key => $data) {
         $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
     }
     if ('check' == $check) {
         $path = '/1.1/comment-check';
     } elseif ('submit' == $check) {
         $path = '/1.1/submit-' . $spam;
     }
     // Send to Akismet
     add_filter('akismet_ua', array($this, 'buddypress_ua'));
     $response = akismet_http_post($query_string, $akismet_api_host, $path, $akismet_api_port);
     remove_filter('akismet_ua', array($this, 'buddypress_ua'));
     // Get the response
     if (!empty($response[1]) && !is_wp_error($response[1])) {
         $activity_data['bp_as_result'] = $response[1];
     } else {
         $activity_data['bp_as_result'] = false;
     }
     // Perform a daily tidy up
     if (!wp_next_scheduled('bp_activity_akismet_delete_old_metadata')) {
         wp_schedule_event(time(), 'daily', 'bp_activity_akismet_delete_old_metadata');
     }
     return $activity_data;
 }
 /**
  * Akismet check for marking an entry as Spam/Not Spam
  *
  * @since 2.1
  * @returns bool|wp_error
  */
 protected function akismet_check($type, $id)
 {
     if (!method_exists('Akismet', 'http_post') || !function_exists('akismet_http_post')) {
         return new WP_Error('missing_akismet', 'Akismet does not appear to be installed and/or active. Entry not marked as spam.');
     }
     global $akismet_api_host, $akismet_api_port, $wpdb;
     $query_string = '';
     $api = 'spam' == $type ? 'submit-spam' : 'submit-ham';
     $akismet_data = maybe_unserialize($wpdb->get_var($wpdb->prepare("SELECT akismet FROM {$this->entries_table_name} WHERE entries_id = %d", $id)));
     foreach (array_keys($akismet_data) as $k) {
         $query_string .= $k . '=' . urlencode($akismet_data[$k]) . '&';
     }
     if (method_exists('Akismet', 'http_post')) {
         $response = Akismet::http_post($query_string, $api);
     } else {
         $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/{$api}", $akismet_api_port);
     }
     // Only return true if a response is available
     if ($response) {
         if ('Thanks for making the web a better place.' == $response[1]) {
             return true;
         }
     } else {
         return new WP_Error('unexpected_response', 'No response returned from Akismet. This could be a connectivity issue or a missing Akismet API key. Entry not marked as spam.');
     }
     return false;
 }
Example #20
0
 /**
  * check
  * @param string $akismet_author
  * @param string $akismet_author_email
  * @param string $akismet_author_url
  * @param MW_WP_Form_Data $Data
  * @return bool
  */
 public function check($akismet_author, $akismet_author_email, $akismet_author_url, $Data)
 {
     global $akismet_api_host, $akismet_api_port;
     if (!$this->is_enable()) {
         return false;
     }
     $doAkismet = false;
     $author = '';
     if ($Data->get_post_value_by_key($akismet_author)) {
         $author = $Data->get_post_value_by_key($akismet_author);
         $doAkismet = true;
     }
     $author_email = '';
     if ($Data->get_post_value_by_key($akismet_author_email)) {
         $author_email = $Data->get_post_value_by_key($akismet_author_email);
         $doAkismet = true;
     }
     $author_url = '';
     if ($Data->get_post_value_by_key($akismet_author_url)) {
         $author_url = $Data->get_post_value_by_key($akismet_author_url);
         $doAkismet = true;
     }
     if ($doAkismet) {
         $content = '';
         foreach ($Data->gets() as $key => $value) {
             $value = $Data->get($key);
             $content .= $value . "\n\n";
         }
         $permalink = get_permalink();
         $akismet = array();
         $akismet['blog'] = home_url();
         $akismet['blog_lang'] = get_locale();
         $akismet['blog_charset'] = get_option('blog_charset');
         $akismet['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
         $akismet['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
         $akismet['referrer'] = $_SERVER['HTTP_REFERER'];
         $akismet['comment_type'] = MWF_Config::NAME;
         if ($permalink) {
             $akismet['permalink'] = $permalink;
         }
         if ($author) {
             $akismet['comment_author'] = $author;
         }
         if ($author_email) {
             $akismet['comment_author_email'] = $author_email;
         }
         if ($author_url) {
             $akismet['comment_author_url'] = $author_url;
         }
         if ($content) {
             $akismet['comment_content'] = $content;
         }
         foreach ($_SERVER as $key => $value) {
             if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'))) {
                 $akismet[$key] = $value;
             }
         }
         $query_string = http_build_query($akismet, null, '&');
         if (is_callable(array('Akismet', 'http_post'))) {
             $response = Akismet::http_post($query_string, 'comment-check');
         } else {
             $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
         }
         $response = apply_filters('mwform_akismet_responce', $response);
         return $response[1] == 'true' ? true : false;
     }
 }
Example #21
0
function mc_spam($event_url = '', $description = '', $post = array())
{
    global $akismet_api_host, $akismet_api_port, $current_user;
    get_currentuserinfo();
    if (current_user_can('mc_manage_events')) {
        // is a privileged user
        return 0;
    }
    $bs = $akismet = false;
    $c = array();
    // check for Akismet
    if (!function_exists('akismet_http_post') || !(get_option('wordpress_api_key') || $wpcom_api_key)) {
        // check for BotSmasher
        $bs = get_option('bs_options');
        if (is_array($bs)) {
            $bskey = $bs['bs_api_key'];
        } else {
            $bskey = '';
        }
        if (!function_exists('bs_checker') || $bskey == '') {
            return 0;
            // if neither exist
        } else {
            $bs = true;
        }
    } else {
        $akismet = true;
    }
    if ($akismet) {
        $c['blog'] = get_option('home');
        $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
        $c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
        $c['referrer'] = $_SERVER['HTTP_REFERER'];
        $c['comment_type'] = 'my_calendar_event';
        if ($permalink = get_permalink()) {
            $c['permalink'] = $permalink;
        }
        if ('' != $event_url) {
            $c['comment_author_url'] = $event_url;
        }
        if ('' != $description) {
            $c['comment_content'] = $description;
        }
        $ignore = array('HTTP_COOKIE');
        foreach ($_SERVER as $key => $value) {
            if (!in_array($key, (array) $ignore)) {
                $c["{$key}"] = $value;
            }
        }
        $query_string = '';
        foreach ($c as $key => $data) {
            $query_string .= $key . '=' . urlencode(stripslashes((string) $data)) . '&';
        }
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
        if ('true' == $response[1]) {
            return 1;
        } else {
            return 0;
        }
    }
    if ($bs) {
        if (is_user_logged_in()) {
            $name = $current_user->user_login;
            $email = $current_user->user_email;
        } else {
            $name = $post['mcs_name'];
            $email = $post['mcs_email'];
        }
        $args = array('ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'email' => $email, 'name' => $name, 'action' => 'check');
        $args['ip'] = "216.152.251.41";
        $response = bs_checker($args);
        if ($response) {
            return 1;
        } else {
            return 0;
        }
    }
    return 0;
}
function formbuilder_check_akismet($allFields = array())
{
    // Code largely taken from Akismet WordPress plugin.
    global $wpdb, $akismet_api_host, $akismet_api_port, $wpcom_api_key;
    if (!function_exists('akismet_http_post') or !$wpcom_api_key) {
        return false;
    }
    $c = array();
    $ignore = array('HTTP_COOKIE');
    foreach ($_SERVER as $key => $value) {
        if (!in_array($key, $ignore)) {
            $c["{$key}"] = $value;
        }
    }
    $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
    $c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    $c['referrer'] = $_SERVER['HTTP_REFERER'];
    $c['permalink'] = get_permalink();
    $c['comment_type'] = 'comment form';
    $c['blog'] = get_option('home');
    $c['blog_lang'] = get_locale();
    $c['blog_charset'] = get_option('blog_charset');
    $c['comment_content'] = '';
    foreach ($allFields as $key => $field) {
        if (!$c['comment_author'] and (strtolower($field['field_name']) == 'name' or $field['required_data'] == "name")) {
            $c['comment_author'] = $field['value'];
        }
        if (!$c['comment_author_email'] and (strtolower($field['field_name']) == 'email' or $field['required_data'] == "email address")) {
            $c['comment_author_email'] = $field['value'];
        }
        if ($field['field_type'] == 'small text area' or $field['field_type'] == 'large text area') {
            $c['comment_content'] .= $field['value'] . "\n";
        }
    }
    $c['comment_content'] = trim($c['comment_content']);
    if (!$c['comment_author'] or !$c['comment_author_email'] or !$c['comment_content']) {
        return false;
    }
    #		echo "<pre>Query Vars: "; print_r($c); echo "<br/></pre>";
    $query_string = '';
    foreach ($c as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
    }
    #		echo "<pre>Query: $query_string<br/>\n</pre>";
    $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    #		echo "<pre>Response: "; print_r($response); echo "<br/></pre>";
    return $response[1];
}
function wpcf7_akismet($spam)
{
    global $akismet_api_host, $akismet_api_port;
    if (!function_exists('akismet_get_key') || !akismet_get_key()) {
        return false;
    }
    $akismet_ready = false;
    $author = $author_email = $author_url = $content = '';
    $fes = wpcf7_scan_shortcode();
    foreach ($fes as $fe) {
        if (!isset($fe['name']) || !is_array($fe['options'])) {
            continue;
        }
        if (preg_grep('%^akismet:author$%', $fe['options'])) {
            $author .= ' ' . $_POST[$fe['name']];
            $author = trim($author);
            $akismet_ready = true;
        }
        if (preg_grep('%^akismet:author_email$%', $fe['options']) && '' == $author_email) {
            $author_email = trim($_POST[$fe['name']]);
            $akismet_ready = true;
        }
        if (preg_grep('%^akismet:author_url$%', $fe['options']) && '' == $author_url) {
            $author_url = trim($_POST[$fe['name']]);
            $akismet_ready = true;
        }
        if ('' != $content) {
            $content .= "\n\n";
        }
        $content .= $_POST[$fe['name']];
    }
    if (!$akismet_ready) {
        return false;
    }
    $c['blog'] = get_option('home');
    $c['blog_lang'] = get_locale();
    $c['blog_charset'] = get_option('blog_charset');
    $c['user_ip'] = preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']);
    $c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
    $c['referrer'] = $_SERVER['HTTP_REFERER'];
    $c['comment_type'] = 'contactform7';
    if ($permalink = get_permalink()) {
        $c['permalink'] = $permalink;
    }
    if ('' != $author) {
        $c['comment_author'] = $author;
    }
    if ('' != $author_email) {
        $c['comment_author_email'] = $author_email;
    }
    if ('' != $author_url) {
        $c['comment_author_url'] = $author_url;
    }
    if ('' != $content) {
        $c['comment_content'] = $content;
    }
    $ignore = array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW');
    foreach ($_SERVER as $key => $value) {
        if (!in_array($key, (array) $ignore)) {
            $c["{$key}"] = $value;
        }
    }
    $query_string = '';
    foreach ($c as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes((string) $data)) . '&';
    }
    $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    if ('true' == $response[1]) {
        $spam = true;
    }
    return $spam;
}
function contact_form_akismet_submit($as, $form)
{
    global $akismet_api_host, $akismet_api_port;
    if (!in_array($as, array('ham', 'spam'))) {
        return false;
    }
    $query_string = '';
    foreach (array_keys($form) as $k) {
        $query_string .= $k . '=' . urlencode($form[$k]) . '&';
    }
    $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/submit-' . $as, $akismet_api_port);
    return trim($response[1]);
}
Example #25
0
function ll_akismet_comment_check($comment)
{
    global $akismet_api_host, $akismet_api_port;
    $spam = false;
    $query_string = http_build_query($comment);
    if (is_callable(array('Akismet', 'http_post'))) {
        // Akismet v3.0+
        $response = Akismet::http_post($query_string, 'comment-check');
    } else {
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    }
    if ('true' == $response[1]) {
        $spam = true;
    }
    if ($submission = WPCF7_Submission::get_instance()) {
        $submission->akismet = array('comment' => $comment, 'spam' => $spam);
    }
    return apply_filters('ll_akismet_comment_check', $spam, $comment);
}
Example #26
0
 public function __actionWPAjaxContactForm()
 {
     if (!isset($this->features['contact-form'])) {
         exit;
     }
     $contact_form = $this->features['contact-form'];
     $options = $this->theme_options->child(array($contact_form['group'], $contact_form['name']));
     $output = function ($result, $message) use($contact_form) {
         echo json_encode(array($contact_form['result_var'] => $result, $contact_form['message_var'] => $message));
         exit;
     };
     $values = array();
     foreach ($options->value('fields') as $field) {
         $value = isset($_POST[$field]) ? trim(strip_tags($_POST[$field])) : '';
         switch ($field) {
             case 'name':
                 if (empty($value)) {
                     $output(false, __('Please enter your name.', $this->domain));
                 }
                 break;
             case 'email':
                 if (!preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)+$/i', $value)) {
                     $output(false, __('Invalid email address.', $this->domain));
                 }
                 break;
             case 'website':
                 if (!empty($value) && !preg_match('|^(https?://)?(www\\.)?([-_a-z0-9]+\\.)+[-_a-z0-9]+$|i', $value)) {
                     $output(false, __('Invalid website address.', $this->domain));
                 }
                 break;
             case 'phone':
                 if (!empty($value) && !preg_match('/^[-_#\\+\\*\\(\\)0-9 ]+$/', $value)) {
                     $output(false, __('Invalid phone number.', $this->domain));
                 }
                 break;
             case 'message':
                 if (strlen($value) < 3) {
                     $output(false, __('Please write your message.', $this->domain));
                 }
                 break;
             case 'captcha':
                 if (function_exists('cptch_check_custom_form') && !cptch_check_custom_form()) {
                     $output(false, __('Please complete the captcha.', $this->domain));
                 }
                 break;
         }
         $values[$field] = $value;
     }
     $to = $options->value('to');
     switch ($options->value('from')) {
         case 'to':
             $from = $to;
             break;
         case 'field':
             $from = $values['email'];
             break;
         default:
             $from = get_option('admin_email');
     }
     $reply_to = $values['email'];
     $author = isset($values['name']) ? $values['name'] : '';
     $subject = $options->value('subject');
     $subject = str_replace(array('%blogname%', '%blogurl%'), array(get_bloginfo('name'), home_url()), $subject);
     $subject = preg_replace_callback('/%([a-z]+)%/i', function ($m) use($values) {
         return isset($values[$m[1]]) ? $values[$m[1]] : '';
     }, $subject);
     $subject = wp_specialchars_decode(trim(str_replace(array("\r", "\n"), ' ', $subject)));
     $message = "{$values['message']}\r\n\r\n---\r\n" . implode("\r\n", array_intersect_key($values, array_flip(array_intersect($options->value('fields'), array('name', 'email', 'website', 'phone')))));
     if ($options->child('settings')->value('akismet') && function_exists('akismet_get_key') && akismet_get_key()) {
         $comment = array('blog' => home_url(), 'blog_lang' => get_locale(), 'blog_charset' => get_option('blog_charset'), 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => 'contactform');
         if (isset($values['name'])) {
             $comment['comment_author'] = $values['name'];
         }
         if (isset($values['email'])) {
             $comment['comment_author_email'] = $values['email'];
         }
         if (isset($values['comment_author_url'])) {
             $comment['comment_author_email'] = $values['website'];
         }
         if (isset($values['message'])) {
             $comment['comment_content'] = $values['message'];
         }
         foreach ($_SERVER as $key => $value) {
             if (!in_array($key, array('HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW')) && is_string($value)) {
                 $comment[$key] = $value;
             } else {
                 $comment[$key] = '';
             }
         }
         $query_string = Func::arraySerialize(array_map('stripslashes', $comment));
         $response = akismet_http_post($query_string, $GLOBALS['akismet_api_host'], '/1.1/comment-check', $GLOBALS['akismet_api_port']);
         if ($response[1] == 'true') {
             $output(false, __('Your message is recognized as spam.', $this->domain));
         }
     }
     $result = @wp_mail($to, $subject, $message, ($options->child('settings')->value('from_header') ? "From: \"{$author}\" <{$from}>\r\n" : '') . "Reply-to: {$reply_to}\r\n" . "Content-type: text/plain; charset=\"" . get_bloginfo('charset') . "\"\r\n");
     if ($result) {
         $output(true, __('Message sent.', $this->domain));
     } else {
         $output(false, __("Error occured. Message couldn't be sent.", $this->domain));
     }
 }
Example #27
0
function akismet_recheck_queue()
{
    global $wpdb, $akismet_api_host, $akismet_api_port;
    if (!(isset($_GET['recheckqueue']) || isset($_REQUEST['action']) && 'akismet_recheck_queue' == $_REQUEST['action'])) {
        return;
    }
    $moderation = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0'", ARRAY_A);
    foreach ((array) $moderation as $c) {
        $c['user_ip'] = $c['comment_author_IP'];
        $c['user_agent'] = $c['comment_agent'];
        $c['referrer'] = '';
        $c['blog'] = get_option('home');
        $c['blog_lang'] = get_locale();
        $c['blog_charset'] = get_option('blog_charset');
        $c['permalink'] = get_permalink($c['comment_post_ID']);
        $c['user_role'] = '';
        if (isset($c['user_ID'])) {
            $c['user_role'] = akismet_get_user_roles($c['user_ID']);
        }
        $id = (int) $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]) {
            wp_set_comment_status($c['comment_ID'], 'spam');
            update_comment_meta($c['comment_ID'], 'akismet_result', 'true');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam');
        } elseif ('false' == $response[1]) {
            update_comment_meta($c['comment_ID'], 'akismet_result', 'false');
            akismet_update_comment_history($c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham');
            // abnormal result: error
        } else {
            update_comment_meta($c['comment_ID'], 'akismet_result', 'error');
            akismet_update_comment_history($c['comment_ID'], sprintf(__('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error');
        }
    }
    wp_redirect($_SERVER['HTTP_REFERER']);
    exit;
}
Example #28
0
function wpcf7_akismet_comment_check($comment)
{
    global $akismet_api_host, $akismet_api_port;
    $spam = false;
    $query_string = '';
    foreach ($comment as $key => $data) {
        $query_string .= $key . '=' . urlencode(wp_unslash((string) $data)) . '&';
    }
    if (is_callable(array('Akismet', 'http_post'))) {
        // Akismet v3.0+
        $response = Akismet::http_post($query_string, 'comment-check');
    } else {
        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
    }
    if ('true' == $response[1]) {
        $spam = true;
    }
    if ($contact_form = wpcf7_get_current_contact_form()) {
        $contact_form->akismet = array('comment' => $comment, 'spam' => $spam);
    }
    return apply_filters('wpcf7_akismet_comment_check', $spam, $comment);
}
 /**
  * Submit a feedback as either spam or ham
  *
  * @param string $as Either 'spam' or 'ham'.
  * @param array $form the contact-form data
  */
 function akismet_submit($as, $form)
 {
     global $akismet_api_host, $akismet_api_port;
     if (!in_array($as, array('ham', 'spam'))) {
         return false;
     }
     $query_string = '';
     if (is_array($form)) {
         $query_string = http_build_query($form);
     }
     if (method_exists('Akismet', 'http_post')) {
         $response = Akismet::http_post($query_string, "submit-{$as}");
     } else {
         $response = akismet_http_post($query_string, $akismet_api_host, "/1.1/submit-{$as}", $akismet_api_port);
     }
     return trim($response[1]);
 }
 public static function mark_akismet_spam($form, $lead, $is_spam)
 {
     global $akismet_api_host, $akismet_api_port;
     $fields = self::get_akismet_fields($form, $lead);
     $as = $is_spam ? 'spam' : 'ham';
     //Submitting info to Akismet
     if (defined('AKISMET_VERSION') && AKISMET_VERSION < 3.0) {
         //Akismet versions before 3.0
         akismet_http_post($fields, $akismet_api_host, '/1.1/submit-' . $as, $akismet_api_port);
     } else {
         Akismet::http_post($fields, 'submit-' . $as);
     }
 }