Announcement

#1 2019-04-10 18:23:30

wbeddoe
Member
2018-12-26
4

Reject Comments with URL

Hi Support!

I'm getting flooded with comments containing URLs in various cases (Http, HTTP, hTtP, etc)

The Link check is not working, I have the config set to allow "0" links

Can your preg_match_all check for case-insensitive URLs?

// we do here only BASIC spam check (plugins can do more)
  if ( !is_a_guest() )
    return $action;

  $link_count = preg_match_all( '/https?:\/\//',
    $comment['content'], $matches);

  if ( strpos($comment['author'], 'http://')!==false )
  {
    $link_count++;
  }



Piwigo 2.9.5
Operating system: Linux
PHP: 7.1.27 (Show info) [2019-04-10 12:20:17]
MySQL: 5.5.60-0+deb7u1-log [2019-04-10 12:20:17]
Graphics Library: External ImageMagick 6.8.9-9
Piwigo URL: http://www.popasmoke.com/visions

Offline

 

#2 2019-04-10 22:39:45

executive
Member
2017-08-16
1099

Re: Reject Comments with URL

You could do a 'strtoupper' fucntion on the comment URL, and then match it to "HTTP".

But I think you would be better off using a dedicated plugin.

Offline

 

#3 2019-04-11 11:39:45

eliz82
Member
Romania
2016-04-27
281

Re: Reject Comments with URL

open an issue to github https://github.com/Piwigo/Piwigo/issues

until then try this code to see if it works, i made it case insensitive and switched author to regex to detect also 'https'

Code:

  
$link_count = preg_match_all( '/https?:\/\//i', $comment['content'], $matches);

if (preg_match('/https?:\/\//i', $comment['author'])) {
  $link_count++;
}

Last edited by eliz82 (2019-04-11 11:46:24)

Offline

 

#4 2019-04-11 12:14:59

wbeddoe
Member
2018-12-26
4

Re: Reject Comments with URL

Thanks, that seems to work! Much appreciated.

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact