Skip to content

Commit

Permalink
Improve bw_basic_spam_check() #221
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Nov 8, 2023
1 parent 2f65eed commit 27c15b0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions shortcodes/oik-contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,22 @@ function bw_akismet_check( $fields ) {
* If there's any evidence of an attempt to include an URL then treat it as spam.
* The code supports http or https and is case insensitive.
*
* Fields checked now include the author, email and content.
*
* @param array $fields
* @return bool
*/
function bw_basic_spam_check( $fields ) {
//print_r( $fields );
$content = bw_array_get( $fields, "comment_content", null );
$content = strtolower( $content );
if ( false !== strpos( $content, 'http')) {
bw_trace2( "Spam check found http");
return false;

//bw_trace2();
$fields_to_check = [ "comment_author", "comment_author_email", "comment_content" ];
foreach ( $fields_to_check as $field ) {
$content=bw_array_get( $fields, $field, '' );
$content=strtolower( $content );
if ( false !== strpos( $content, 'http' ) ) {
bw_trace2( "Spam check found http" );
return false;
}
}
return true;
}
Expand Down

0 comments on commit 27c15b0

Please sign in to comment.