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 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / modules / akismet.php
contact-form-7 / modules Last commit date
acceptance.php 13 years ago akismet.php 13 years ago captcha.php 12 years ago checkbox.php 13 years ago date.php 13 years ago file.php 12 years ago flamingo.php 13 years ago jetpack.php 13 years ago number.php 13 years ago quiz.php 13 years ago response.php 15 years ago select.php 12 years ago special-mail-tags.php 13 years ago submit.php 13 years ago text.php 13 years ago textarea.php 13 years ago
akismet.php
125 lines
1 <?php
2 /**
3 ** Akismet Filter
4 ** Akismet API: http://akismet.com/development/api/
5 **/
6
7 add_filter( 'wpcf7_spam', 'wpcf7_akismet' );
8
9 function wpcf7_akismet( $spam ) {
10 if ( $spam )
11 return $spam;
12
13 if ( ! function_exists( 'akismet_get_key' ) || ! akismet_get_key() )
14 return false;
15
16 if ( ! $params = wpcf7_akismet_submitted_params() )
17 return false;
18
19 $c = array();
20
21 if ( ! empty( $params['author'] ) )
22 $c['comment_author'] = $params['author'];
23
24 if ( ! empty( $params['author_email'] ) )
25 $c['comment_author_email'] = $params['author_email'];
26
27 if ( ! empty( $params['author_url'] ) )
28 $c['comment_author_url'] = $params['author_url'];
29
30 if ( ! empty( $params['content'] ) )
31 $c['comment_content'] = $params['content'];
32
33 $c['blog'] = get_option( 'home' );
34 $c['blog_lang'] = get_locale();
35 $c['blog_charset'] = get_option( 'blog_charset' );
36 $c['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] );
37 $c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
38 $c['referrer'] = $_SERVER['HTTP_REFERER'];
39
40 // http://blog.akismet.com/2012/06/19/pro-tip-tell-us-your-comment_type/
41 $c['comment_type'] = 'contact-form';
42
43 if ( $permalink = get_permalink() )
44 $c['permalink'] = $permalink;
45
46 $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
47
48 foreach ( $_SERVER as $key => $value ) {
49 if ( ! in_array( $key, (array) $ignore ) )
50 $c["$key"] = $value;
51 }
52
53 return wpcf7_akismet_comment_check( $c );
54 }
55
56 function wpcf7_akismet_submitted_params() {
57 $params = array(
58 'author' => '',
59 'author_email' => '',
60 'author_url' => '' );
61
62 $content = '';
63
64 $fes = wpcf7_scan_shortcode();
65
66 foreach ( $fes as $fe ) {
67 if ( ! isset( $fe['name'] ) || ! isset( $_POST[$fe['name']] ) )
68 continue;
69
70 $value = $_POST[$fe['name']];
71
72 if ( is_array( $value ) )
73 $value = implode( ', ', wpcf7_array_flatten( $value ) );
74
75 $value = trim( $value );
76
77 $options = (array) $fe['options'];
78
79 if ( preg_grep( '%^akismet:author$%', $options ) ) {
80 $params['author'] = trim( $params['author'] . ' ' . $value );
81
82 } elseif ( preg_grep( '%^akismet:author_email$%', $options ) ) {
83 if ( '' == $params['author_email'] )
84 $params['author_email'] = $value;
85
86 } elseif ( preg_grep( '%^akismet:author_url$%', $options ) ) {
87 if ( '' == $params['author_url'] )
88 $params['author_url'] = $value;
89 }
90
91 $content = trim( $content . "\n\n" . $value );
92 }
93
94 $params = array_filter( $params );
95
96 if ( ! $params )
97 return false;
98
99 $params['content'] = $content;
100
101 return $params;
102 }
103
104 function wpcf7_akismet_comment_check( $comment ) {
105 global $akismet_api_host, $akismet_api_port;
106
107 $spam = false;
108 $query_string = '';
109
110 foreach ( $comment as $key => $data )
111 $query_string .= $key . '=' . urlencode( stripslashes( (string) $data ) ) . '&';
112
113 $response = akismet_http_post( $query_string,
114 $akismet_api_host, '/1.1/comment-check', $akismet_api_port );
115
116 if ( 'true' == $response[1] )
117 $spam = true;
118
119 if ( $contact_form = wpcf7_get_current_contact_form() )
120 $contact_form->akismet = array( 'comment' => $comment, 'spam' => $spam );
121
122 return apply_filters( 'wpcf7_akismet_comment_check', $spam, $comment );
123 }
124
125 ?>