autoUpdate(COMM_BLACKLIST_VERSION, 'install'); $conf['comments_blacklist'] = unserialize($conf['comments_blacklist']); } /** * admin link */ function comm_blacklist_admin_plugin_menu_links($menu) { $menu[] = array( 'NAME' => 'Comments Blacklist', 'URL' => COMM_BLACKLIST_ADMIN, ); return $menu; } /** * comment check */ function comm_blacklist_user_comment_check($comment_action, $comm) { global $conf; if ($comment_action==$conf['comments_blacklist']['action'] or $comment_action=='reject' or !isset($comm['content']) ) { return $comment_action; } $blacklist = @file(COMM_BLACKLIST_FILE, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if (empty($blacklist)) { return $comment_action; } $blacklist = array_map(create_function('$w', 'return preg_quote($w);'), $blacklist); $blacklist = implode('|', $blacklist); if (preg_match('#\b('.$blacklist.')\b#i', $comm['content']) or (isset($comm['author']) and preg_match('#\b('.$blacklist.')\b#i', $comm['author'])) ) { return $conf['comments_blacklist']['action']; } return $comment_action; }