aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewtopic.php
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-08-15 01:46:27 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-08-15 01:46:27 +0000
commitb471626ab4c1f046af8efa8055c336c312fb2c51 (patch)
treef82a40dad0f8b72572fb7528f240716522944fcc /phpBB/viewtopic.php
parent0bc2d131aaf8b932c582c8e517ba2534d8a29466 (diff)
downloadforums-b471626ab4c1f046af8efa8055c336c312fb2c51.tar
forums-b471626ab4c1f046af8efa8055c336c312fb2c51.tar.gz
forums-b471626ab4c1f046af8efa8055c336c312fb2c51.tar.bz2
forums-b471626ab4c1f046af8efa8055c336c312fb2c51.tar.xz
forums-b471626ab4c1f046af8efa8055c336c312fb2c51.zip
Re-jiggled censored word stuff and added wildcard ... needs testing
git-svn-id: file:///svn/phpbb/trunk@880 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r--phpBB/viewtopic.php66
1 files changed, 35 insertions, 31 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index d073f2f5ee..b4ed444875 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -357,9 +357,36 @@ $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 = "<a href=\"" . append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_quote'] . "\" alt=\"" . $lang['Reply_with_quote'] ."\" border=\"0\" /></a>";
- //
- // 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("/<BR>$word$/i", "<BR>$replacement", $message);
- $message = preg_replace("/<BR>$words\s/i", "<BR>$replacement ", $message);
- }
- }
- }
-
-
-
if( $is_auth['auth_mod'] )
{
$ip_img = "<a href=\"" . append_sid("modcp.$phpEx?mode=viewip&amp;" . POST_POST_URL . "=" . $post_id) . "\"><img src=\"" . $images['icon_ip'] . "\" alt=\"" . $lang['View_IP'] . "\" border=\"0\" /></a>";
$delpost_img = "<a href=\"" . append_sid("topicadmin.$phpEx?mode=delpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']) . "\"><img src=\"" . $images['icon_delpost'] . "\" alt=\"" . $lang['Delete_post'] . "\" border=\"0\" /></a>";
}
-
+
+ $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