From bd8652f1869c477b5b7e066eb61b435312c7cd3e Mon Sep 17 00:00:00 2001 From: blackpuma Date: Tue, 14 Aug 2001 17:55:32 +0000 Subject: [PATCH] Word censoring, first part. Does not support wildcards yet but that's coming in the next step. git-svn-id: file:///svn/phpbb/trunk@876 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewtopic.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4f3b34bd0a..d073f2f5ee 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -554,6 +554,35 @@ for($i = 0; $i < $total_posts; $i++) $quote_img = "\"""; + // + // Filtering bad words + // + $message = stripslashes($postrow[$i]['post_text']); + + $sql = "SELECT * FROM " . WORDS_TABLE; + if(!$words_result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't get censored words from database.", "", __LINE__, __FILE__, $sql); + } + else + { // Some performance stuff + if(mysql_num_rows($words_result) != 0) + { + while($current_row = mysql_fetch_array($words_result)) + { + $word = $current_row['word']; + $replacement = $current_row['replacement']; + + $message = preg_replace("/$word/i", " $replacement", $message); + $message = preg_replace("/^$words\s/i", "$replacement ", $message); + $message = preg_replace("/
$word$/i", "
$replacement", $message); + $message = preg_replace("/
$words\s/i", "
$replacement ", $message); + } + } + } + + + if( $is_auth['auth_mod'] ) { $ip_img = "\"""; @@ -566,7 +595,6 @@ for($i = 0; $i < $total_posts; $i++) $bbcode_uid = $postrow[$i]['bbcode_uid']; $user_sig = stripslashes($postrow[$i]['user_sig']); - $message = stripslashes($postrow[$i]['post_text']); if(!$board_config['allow_html'] || !$postrow[$i]['enable_html']) { @@ -746,4 +774,4 @@ $template->pparse("body"); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); -?> \ No newline at end of file +?>