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

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

use preg_match, usually faster

File size: 802 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  $blacklist = array_map(create_function('$w', 'return " ".preg_quote($w)." ";'), $blacklist);
15  $blacklist = implode('|', $blacklist);
16
17  $content = str_replace(array("\r\n","\n"), ' ', $comm['content']);
18 
19  if ( preg_match('#('.$blacklist.')#i', ' '.$comm['author'].' ') or preg_match('#('.$blacklist.')#i', ' '.$content.' ') )
20  {
21    return $conf['comments_blacklist']['action'];
22  }
23 
24  return $comment_action;
25}
26
27?>
Note: See TracBrowser for help on using the repository browser.