aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-08-15 22:54:48 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-08-15 22:54:48 +0000
commitaaf2ec59010a68e1fbfafafb494163456a30939e (patch)
tree3bf7a25fdc01dd27b0aa4b6379dc96d8a69e4f09 /phpBB
parent88d259a6c2eeb2dac4a0d5b433fe07415f82ce84 (diff)
downloadforums-aaf2ec59010a68e1fbfafafb494163456a30939e.tar
forums-aaf2ec59010a68e1fbfafafb494163456a30939e.tar.gz
forums-aaf2ec59010a68e1fbfafafb494163456a30939e.tar.bz2
forums-aaf2ec59010a68e1fbfafafb494163456a30939e.tar.xz
forums-aaf2ec59010a68e1fbfafafb494163456a30939e.zip
Add word censor to preview mode
git-svn-id: file:///svn/phpbb/trunk@888 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/posting.php41
1 files changed, 36 insertions, 5 deletions
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 243cc6d547..7d76095166 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -479,8 +479,8 @@ if( ($mode == "newtopic" || $mode == "reply") && $topic_status == TOPIC_UNLOCKED
{
$topic_notify = ($HTTP_POST_VARS['notify']) ? 1 : 0;
- $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_notify, topic_status, topic_type)
- VALUES ('$subject', " . $userdata['user_id'] . ", " . $topic_time . ", $forum_id, $topic_notify, " . TOPIC_UNLOCKED . ", $topic_type)";
+ $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
+ VALUES ('$subject', " . $userdata['user_id'] . ", " . $topic_time . ", $forum_id, " . TOPIC_UNLOCKED . ", $topic_type)";
if($result = $db->sql_query($sql, BEGIN_TRANSACTION))
{
@@ -1099,7 +1099,7 @@ else if( $mode == "editpost" && $topic_status == TOPIC_UNLOCKED )
{
if( !empty($post_id) )
{
- $sql = "SELECT p.*, pt.post_text, pt.post_subject, u.username, u.user_id, u.user_sig, t.topic_title, t.topic_notify, t.topic_type
+ $sql = "SELECT p.*, pt.post_text, pt.post_subject, u.username, u.user_id, u.user_sig, t.topic_title, t.topic_type
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . TOPICS_TABLE . " t, " . POSTS_TEXT_TABLE . " pt
WHERE p.post_id = $post_id
AND pt.post_id = p.post_id
@@ -1243,6 +1243,31 @@ if($preview && !$error)
break;
}
+ //
+ // 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'];
+ }
+ }
+
if($bbcode_on)
{
$bbcode_uid = make_bbcode_uid();
@@ -1288,6 +1313,12 @@ if($preview && !$error)
$preview_message = preg_replace("/\:[0-9a-z\:]+\]/si", "]", $preview_message);
}
+ if( count($orig_word) )
+ {
+ $preview_subject = preg_replace($orig_word, $replacement_word, stripslashes($subject));
+ $preview_message = preg_replace($orig_word, $replacement_word, $preview_message);
+ }
+
if($smilies_on)
{
$preview_message = smilies_pass($preview_message);
@@ -1305,8 +1336,8 @@ if($preview && !$error)
"preview" => "posting_preview.tpl")
);
$template->assign_vars(array(
- "TOPIC_TITLE" => stripslashes($subject),
- "POST_SUBJECT" => stripslashes($subject),
+ "TOPIC_TITLE" => $preview_subject,
+ "POST_SUBJECT" => $preview_subject,
"POSTER_NAME" => stripslashes($username),
"POST_DATE" => create_date($board_config['default_dateformat'], time(), $board_config['default_timezone']),
"MESSAGE" => $preview_message,