Wildcard for censored words now works correctly

git-svn-id: file:///svn/phpbb/trunk@884 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2001-08-15 16:00:57 +00:00
parent 0f21ea1e90
commit 5f3f466898

View file

@ -345,6 +345,7 @@ if(!$total_posts = $db->sql_numrows($result))
{ {
message_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "There don't appear to be any posts for this topic.", "", __LINE__, __FILE__, $sql);
} }
$postrow = $db->sql_fetchrowset($result);
$sql = "SELECT * $sql = "SELECT *
FROM " . RANKS_TABLE . " FROM " . RANKS_TABLE . "
@ -353,12 +354,10 @@ if(!$ranks_result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Couldn't obtain ranks information.", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Couldn't obtain ranks information.", "", __LINE__, __FILE__, $sql);
} }
$postrow = $db->sql_fetchrowset($result);
$ranksrow = $db->sql_fetchrowset($ranksresult); $ranksrow = $db->sql_fetchrowset($ranksresult);
// //
// Define censored word matches ... this should end // Define censored word matches
// up in functions I think ...
// //
$sql = "SELECT word, replacement $sql = "SELECT word, replacement
FROM " . WORDS_TABLE; FROM " . WORDS_TABLE;
@ -375,10 +374,10 @@ else
for($i = 0; $i < count($word_list); $i++) for($i = 0; $i < count($word_list); $i++)
{ {
$word = str_replace("\*", "[\w]+", preg_quote($word_list[$i]['word'])); $word = str_replace("\*", "\w*?", preg_quote($word_list[$i]['word']));
$orig_word[] = "/(^|[\s\W])(" . $word . ")([\s\W]|$)/si"; $orig_word[] = "/\b(" . $word . ")\b/i";
$replacement_word[] = '\\1' . $word_list[$i]['replacement'] . '\\3'; $replacement_word[] = $word_list[$i]['replacement'];
} }
} }
@ -591,11 +590,6 @@ for($i = 0; $i < $total_posts; $i++)
$message = stripslashes($postrow[$i]['post_text']); $message = stripslashes($postrow[$i]['post_text']);
$post_subject = ($postrow[$i]['post_subject'] != "") ? stripslashes($postrow[$i]['post_subject']) : $topic_title; $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']; $bbcode_uid = $postrow[$i]['bbcode_uid'];
$user_sig = stripslashes($postrow[$i]['user_sig']); $user_sig = stripslashes($postrow[$i]['user_sig']);
@ -638,14 +632,19 @@ for($i = 0; $i < $total_posts; $i++)
$message = make_clickable($message); $message = make_clickable($message);
$message = ($user_sig != "") ? ereg_replace("\[addsig]$", "<br /><br />_________________<br />" . $user_sig, $message) : ereg_replace("\[addsig]$", "", $message); $message = ($user_sig != "") ? ereg_replace("\[addsig]$", "<br /><br />_________________<br />" . $user_sig, $message) : ereg_replace("\[addsig]$", "", $message);
$message = str_replace("\n", "<br />", $message); if( count($orig_word) )
{
$message = preg_replace($orig_word, $replacement_word, $message);
}
if($board_config['allow_smilies'] && $postrow[$i]['enable_smilies']) if($board_config['allow_smilies'] && $postrow[$i]['enable_smilies'])
{ {
$message = smilies_pass($message); $message = smilies_pass($message);
} }
$message = str_replace("\n", "<br />", $message);
// //
// Editing information // Editing information
// //
@ -740,13 +739,13 @@ if($can_watch_topic)
{ {
if($is_watching_topic) if($is_watching_topic)
{ {
$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic\">" . $lang['Stop_watching_topic'] . "</a>"; $s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start\">" . $lang['Stop_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic\"><img src=\"" . $images['Topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\"></a>"; $s_watching_topic_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start\"><img src=\"" . $images['Topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\"></a>";
} }
else else
{ {
$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic\">" . $lang['Start_watching_topic'] . "</a>"; $s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start\">" . $lang['Start_watching_topic'] . "</a>";
$s_watching_topic_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic\"><img src=\"" . $images['Topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" border=\"0\"></a>"; $s_watching_topic_img = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start\"><img src=\"" . $images['Topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" border=\"0\"></a>";
} }
} }
else else