1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?php
add_filter( 'wpcf7_spam', 'wpcf7_disallowed_list', 10, 2 );
function wpcf7_disallowed_list( $spam, $submission ) { if ( $spam ) { return $spam; }
$target = wpcf7_array_flatten( $submission->get_posted_data() ); $target[] = $submission->get_meta( 'remote_ip' ); $target[] = $submission->get_meta( 'user_agent' ); $target = implode( "\n", $target );
$word = wpcf7_check_disallowed_list( $target );
$word = wpcf7_apply_filters_deprecated( 'wpcf7_submission_is_blacklisted', array( $word, $submission ), '5.3', 'wpcf7_submission_has_disallowed_words' );
$word = apply_filters( 'wpcf7_submission_has_disallowed_words', $word, $submission );
if ( $word ) { if ( is_bool( $word ) ) { $reason = __( "Disallowed words are used.", 'contact-form-7' ); } else { $reason = sprintf( __( "Disallowed words (%s) are used.", 'contact-form-7' ), implode( ', ', (array) $word ) ); }
$submission->add_spam_log( array( 'agent' => 'disallowed_list', 'reason' => $reason, ) ); }
$spam = (bool) $word;
return $spam; }
function wpcf7_check_disallowed_list( $target ) { $mod_keys = trim( get_option( 'blacklist_keys' ) );
if ( '' === $mod_keys ) { return false; }
foreach ( explode( "\n", $mod_keys ) as $word ) { $word = trim( $word ); $length = strlen( $word );
if ( $length < 2 or 256 < $length ) { continue; }
$pattern = sprintf( '#%s#i', preg_quote( $word, '#' ) );
if ( preg_match( $pattern, $target ) ) { return $word; } }
return false; }
function wpcf7_blacklist_check( $target ) { wpcf7_deprecated_function( __FUNCTION__, '5.3', 'wpcf7_check_disallowed_list' );
return wpcf7_check_disallowed_list( $target ); }
|