source: extensions/comments_blacklist/include/functions.inc.php @ 18651

Last change on this file since 18651 was 18651, checked in by mistic100, 12 years ago

handle empty file case, check COA and GuestBook

File size: 870 bytes
Line 
1<?php
2defined('COMM_BLACKLIST_PATH') or die('Hacking attempt!');
3
4function comm_blacklist_user_comment_check($comment_action, $comm)
5{
6  global $conf;
7 
8  if ( $comment_action==$conf['comments_blacklist']['action'] or $comment_action=='reject' )
9  {
10    return $comment_action;
11  }
12 
13  $blacklist = @file(COMM_BLACKLIST_FILE, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
14 
15  if (empty($blacklist))
16  {
17    return $comment_action;
18  }
19 
20  $blacklist = array_map(create_function('$w', 'return " ".preg_quote($w)." ";'), $blacklist);
21  $blacklist = implode('|', $blacklist);
22
23  $content = str_replace(array("\r\n","\n"), ' ', $comm['content']);
24 
25  if ( preg_match('#('.$blacklist.')#i', ' '.$comm['author'].' ') or preg_match('#('.$blacklist.')#i', ' '.$content.' ') )
26  {
27    return $conf['comments_blacklist']['action'];
28  }
29 
30  return $comment_action;
31}
32
33?>
Note: See TracBrowser for help on using the repository browser.