/**
 * Test CF7 message for spam
 */
function ct_wpcf7_spam($param)
{
    global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_cf7, $ct_cf7_comment, $ct_options, $ct_data;
    $ct_options = ct_get_options();
    $ct_data = ct_get_data();
    if (WPCF7_VERSION >= '3.0.0') {
        if ($param === true) {
            return $param;
        }
    } else {
        if ($param == false) {
            return $param;
        }
    }
    if ($ct_options['contact_forms_test'] == 0) {
        return $param;
    }
    $checkjs = js_test('ct_checkjs', $_COOKIE, true);
    if ($checkjs != 1) {
        $checkjs = js_test($ct_checkjs_cf7, $_POST, true);
    }
    $post_info['comment_type'] = 'feedback';
    $post_info = json_encode($post_info);
    if ($post_info === false) {
        $post_info = '';
    }
    $sender_email = null;
    $sender_nickname = null;
    $message = '';
    $subject = '';
    foreach ($_POST as $k => $v) {
        if ($sender_email === null && preg_match("/^\\S+@\\S+\\.\\S+\$/", $v)) {
            $sender_email = $v;
        } else {
            if ($sender_nickname === null && preg_match("/-name\$/", $k)) {
                $sender_nickname = $v;
            } else {
                if ($subject === '' && ct_get_data_from_submit($k, 'subject')) {
                    $subject = $v;
                } else {
                    if (preg_match("/(\\-message|\\w*message\\w*|contact|comment|contact\\-)\$/", $k)) {
                        $message .= $v . "\n";
                    }
                }
            }
        }
    }
    if ($subject != '') {
        if ($message != '') {
            $message = "\n\n" . $message;
        }
        $message = sprintf("%s%s", $subject, $message);
    }
    $ct_base_call_result = ct_base_call(array('message' => $message, 'example' => null, 'sender_email' => $sender_email, 'sender_nickname' => $sender_nickname, 'post_info' => $post_info, 'checkjs' => $checkjs));
    $ct = $ct_base_call_result['ct'];
    $ct_result = $ct_base_call_result['ct_result'];
    if ($ct_result->spam == 1) {
        if (WPCF7_VERSION >= '3.0.0') {
            $param = true;
        } else {
            $param = false;
        }
        $ct_cf7_comment = $ct_result->comment;
        add_filter('wpcf7_display_message', 'ct_wpcf7_display_message', 10, 2);
    }
    return $param;
}
function ct_get_fields_any(&$email, &$message, &$nickname, &$subject, &$contact, $arr)
{
    $skip_params = array('ipn_track_id', 'txn_type', 'payment_status');
    foreach ($skip_params as $key => $value) {
        if (@array_key_exists($value, $_GET) || @array_key_exists($value, $_POST)) {
            $contact = false;
        }
    }
    foreach ($arr as $key => $value) {
        if (!is_array($value) && !is_object($value) && @get_class($value) != 'WP_User') {
            if (in_array($key, $skip_params) || preg_match("/^ct_checkjs/", $key)) {
                $contact = false;
            }
            if ($email === '' && @preg_match("/^\\S+@\\S+\\.\\S+\$/", $value)) {
                $email = $value;
            } else {
                if ($nickname === '' && ct_get_data_from_submit($value, 'name')) {
                    $nickname = $value;
                } else {
                    if ($subject === '' && ct_get_data_from_submit($value, 'subject')) {
                        $subject = $value;
                    } else {
                        @($message .= "{$value}\n");
                    }
                }
            }
        } else {
            if (!is_object($value) && @get_class($value) != 'WP_User') {
                ct_get_fields_any($email, $message, $nickname, $subject, $contact, $value);
            }
        }
    }
}