From 88d259a6c2eeb2dac4a0d5b433fe07415f82ce84 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Wed, 15 Aug 2001 22:53:57 +0000 Subject: [PATCH] Another file that shouldve commited ages ago, adds word censor to topic titles git-svn-id: file:///svn/phpbb/trunk@887 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/viewforum.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index b511b2eb13..5236a2e9f1 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -264,6 +264,31 @@ if(!$ta_result = $db->sql_query($sql)) } $total_announcements = $db->sql_numrows($ta_result); +// +// Define censored word matches +// +$sql = "SELECT word, replacement + 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 +{ + $word_list = $db->sql_fetchrowset($words_result); + + $orig_word = array(); + $replacement_word = array(); + + for($i = 0; $i < count($word_list); $i++) + { + $word = str_replace("\*", "\w*?", preg_quote($word_list[$i]['word'])); + + $orig_word[] = "/\b(" . $word . ")\b/i"; + $replacement_word[] = $word_list[$i]['replacement']; + } +} + // // Post URL generation for templating vars // @@ -368,7 +393,10 @@ if($total_topics || $total_announcements) for($i = 0; $i < $total_topics; $i++) { - $topic_title = stripslashes($topic_rowset[$i]['topic_title']); + if( count($orig_word) ) + { + $topic_title = preg_replace($orig_word, $replacement_word, stripslashes($topic_rowset[$i]['topic_title'])); + } $topic_type = $topic_rowset[$i]['topic_type'];