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

Last change on this file since 26112 was 26112, checked in by mistic100, 10 years ago

use \b delimiter instead of whitespace

File size: 799 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  if (preg_match('#\b('.$blacklist.')\b#i', $comm['author']) or
24      preg_match('#\b('.$blacklist.')\b#i', $comm['content'])
25    )
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.