aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewforum.php
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-08-15 22:53:57 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-08-15 22:53:57 +0000
commit88d259a6c2eeb2dac4a0d5b433fe07415f82ce84 (patch)
tree485fe238c41dedc9d41444acd962e67397836791 /phpBB/viewforum.php
parentd4ca9eb8096f811737f7a094e3ff2571889676b0 (diff)
downloadforums-88d259a6c2eeb2dac4a0d5b433fe07415f82ce84.tar
forums-88d259a6c2eeb2dac4a0d5b433fe07415f82ce84.tar.gz
forums-88d259a6c2eeb2dac4a0d5b433fe07415f82ce84.tar.bz2
forums-88d259a6c2eeb2dac4a0d5b433fe07415f82ce84.tar.xz
forums-88d259a6c2eeb2dac4a0d5b433fe07415f82ce84.zip
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
Diffstat (limited to 'phpBB/viewforum.php')
-rw-r--r--phpBB/viewforum.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index b511b2eb13..5236a2e9f1 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -265,6 +265,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
//
$template->assign_vars(array(
@@ -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'];