diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index d073f2f5ee..b4ed444875 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -356,10 +356,37 @@ if(!$ranks_result = $db->sql_query($sql))
$postrow = $db->sql_fetchrowset($result);
$ranksrow = $db->sql_fetchrowset($ranksresult);
+//
+// Define censored word matches ... this should end
+// up in functions I think ...
+//
+$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[] = "/(^|[\s\W])(" . $word . ")([\s\W]|$)/si";
+ $replacement_word[] = '\\1' . $word_list[$i]['replacement'] . '\\3';
+ }
+}
+
//
// Dump out the page header and load viewtopic body template
//
setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
+
$page_title = $lang['View_topic'] ." - $topic_title";
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
@@ -554,44 +581,21 @@ 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 = "
";
$delpost_img = "
";
}
-
+
+ $message = stripslashes($postrow[$i]['post_text']);
$post_subject = ($postrow[$i]['post_subject'] != "") ? stripslashes($postrow[$i]['post_subject']) : $topic_title;
+ if( count($orig_word) )
+ {
+ $message = preg_replace($orig_word, $replacement_word, $message);
+ }
+
$bbcode_uid = $postrow[$i]['bbcode_uid'];
$user_sig = stripslashes($postrow[$i]['user_sig']);
@@ -774,4 +778,4 @@ $template->pparse("body");
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
-?>
+?>
\ No newline at end of file