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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 10 years ago akismet.php 11 years ago checkbox.php 10 years ago count.php 11 years ago date.php 10 years ago file.php 10 years ago flamingo.php 10 years ago jetpack.php 10 years ago listo.php 12 years ago number.php 10 years ago quiz.php 10 years ago really-simple-captcha.php 10 years ago recaptcha.php 10 years ago response.php 11 years ago select.php 10 years ago submit.php 10 years ago text.php 10 years ago textarea.php 10 years ago
akismet.php
143 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
14 if ( ! wpcf7_akismet_is_available() ) {
15 return false;
16 }
17
18 if ( ! $params = wpcf7_akismet_submitted_params() ) {
19 return false;
20 }
21
22 $c = array();
23
24 $c['comment_author'] = $params['author'];
25 $c['comment_author_email'] = $params['author_email'];
26 $c['comment_author_url'] = $params['author_url'];
27 $c['comment_content'] = $params['content'];
28
29 $c['blog'] = get_option( 'home' );
30 $c['blog_lang'] = get_locale();
31 $c['blog_charset'] = get_option( 'blog_charset' );
32 $c['user_ip'] = $_SERVER['REMOTE_ADDR'];
33 $c['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
34 $c['referrer'] = $_SERVER['HTTP_REFERER'];
35
36 // http://blog.akismet.com/2012/06/19/pro-tip-tell-us-your-comment_type/
37 $c['comment_type'] = 'contact-form';
38
39 if ( $permalink = get_permalink() ) {
40 $c['permalink'] = $permalink;
41 }
42
43 $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
44
45 foreach ( $_SERVER as $key => $value ) {
46 if ( ! in_array( $key, (array) $ignore ) )
47 $c["$key"] = $value;
48 }
49
50 return wpcf7_akismet_comment_check( $c );
51 }
52
53 function wpcf7_akismet_is_available() {
54 if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+
55 return (bool) Akismet::get_api_key();
56 }
57
58 if ( function_exists( 'akismet_get_key' ) ) {
59 return (bool) akismet_get_key();
60 }
61
62 return false;
63 }
64
65 function wpcf7_akismet_submitted_params() {
66 $params = array(
67 'author' => '',
68 'author_email' => '',
69 'author_url' => '',
70 'content' => '' );
71
72 $has_akismet_option = false;
73
74 foreach ( (array) $_POST as $key => $val ) {
75 if ( '_wpcf7' == substr( $key, 0, 6 ) || '_wpnonce' == $key ) {
76 continue;
77 }
78
79 if ( is_array( $val ) ) {
80 $val = implode( ', ', wpcf7_array_flatten( $val ) );
81 }
82
83 $val = trim( $val );
84
85 if ( 0 == strlen( $val ) ) {
86 continue;
87 }
88
89 if ( $tags = wpcf7_scan_shortcode( array( 'name' => $key ) ) ) {
90 $tag = $tags[0];
91 $tag = new WPCF7_Shortcode( $tag );
92
93 $akismet = $tag->get_option( 'akismet',
94 '(author|author_email|author_url)', true );
95
96 if ( $akismet ) {
97 $has_akismet_option = true;
98
99 if ( 'author' == $akismet ) {
100 $params[$akismet] = trim( $params[$akismet] . ' ' . $val );
101 } elseif ( '' == $params[$akismet] ) {
102 $params[$akismet] = $val;
103 }
104 }
105 }
106
107 $params['content'] .= "\n\n" . $val;
108 }
109
110 if ( ! $has_akismet_option ) {
111 return false;
112 }
113
114 $params['content'] = trim( $params['content'] );
115
116 return $params;
117 }
118
119 function wpcf7_akismet_comment_check( $comment ) {
120 global $akismet_api_host, $akismet_api_port;
121
122 $spam = false;
123 $query_string = wpcf7_build_query( $comment );
124
125 if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+
126 $response = Akismet::http_post( $query_string, 'comment-check' );
127 } else {
128 $response = akismet_http_post( $query_string, $akismet_api_host,
129 '/1.1/comment-check', $akismet_api_port );
130 }
131
132 if ( 'true' == $response[1] ) {
133 $spam = true;
134 }
135
136 if ( $submission = WPCF7_Submission::get_instance() ) {
137 $submission->akismet = array( 'comment' => $comment, 'spam' => $spam );
138 }
139
140 return apply_filters( 'wpcf7_akismet_comment_check', $spam, $comment );
141 }
142
143 ?>