From c3a320f4dcd6465e26a5a35dff737091d20e75c8 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 1 Apr 2023 12:43:34 +0700 Subject: [PATCH] Added word censor in some cases (#104) --- index.php | 14 ++++++++++---- library/includes/ucp/topic_watch.php | 10 ++++++++-- search.php | 2 +- tracker.php | 8 +++++++- viewforum.php | 2 +- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index 68f7ba68..2f130c0a 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,12 @@ 'post_icons', ); +// +// Define censored word matches +// +$orig_word = $replacement_word = array(); +obtain_word_list($orig_word, $replacement_word); + $show_last_topic = true; $last_topic_max_len = 28; $show_online_users = true; @@ -269,8 +275,8 @@ { $template->assign_block_vars('c.f.last', array( 'LAST_TOPIC_ID' => $f['last_topic_id'], - 'LAST_TOPIC_TIP' => $f['last_topic_title'], - 'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)), + 'LAST_TOPIC_TIP' => preg_replace($orig_word, $replacement_word, $f['last_topic_title']), + 'LAST_TOPIC_TITLE' => wbr(str_short(preg_replace($orig_word, $replacement_word, $f['last_topic_title']), $last_topic_max_len)), 'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']), 'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])), )); @@ -334,7 +340,7 @@ { $template->assign_block_vars('news', array( 'NEWS_TOPIC_ID' => $news['topic_id'], - 'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']), + 'NEWS_TITLE' => str_short(preg_replace($orig_word, $replacement_word, $news['topic_title']), $bb_cfg['max_news_title']), 'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false), 'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']), )); @@ -358,7 +364,7 @@ { $template->assign_block_vars('net', array( 'NEWS_TOPIC_ID' => $net['topic_id'], - 'NEWS_TITLE' => str_short($net['topic_title'], $bb_cfg['max_net_title']), + 'NEWS_TITLE' => str_short(preg_replace($orig_word, $replacement_word, $net['topic_title']), $bb_cfg['max_net_title']), 'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false), 'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']), )); diff --git a/library/includes/ucp/topic_watch.php b/library/includes/ucp/topic_watch.php index 4fad6c02..d7f33755 100644 --- a/library/includes/ucp/topic_watch.php +++ b/library/includes/ucp/topic_watch.php @@ -5,6 +5,12 @@ bb_die($lang['DISABLED']); } +// +// Define censored word matches +// +$orig_word = $replacement_word = array(); +obtain_word_list($orig_word, $replacement_word); + $page_cfg['use_tablesorter'] = true; $page_cfg['include_bbcode_js'] = true; $tracking_topics = get_tracks('topic'); @@ -66,8 +72,8 @@ 'ROW_CLASS' => ( !($i % 2) ) ? 'row1' : 'row2', 'POST_ID' => $watch[$i]['topic_first_post_id'], 'TOPIC_ID' => $watch[$i]['topic_id'], - 'TOPIC_TITLE' => wbr(str_short($watch[$i]['topic_title'], 70)), - 'FULL_TOPIC_TITLE' => wbr($watch[$i]['topic_title']), + 'TOPIC_TITLE' => wbr(str_short(preg_replace($orig_word, $replacement_word, $watch[$i]['topic_title']), 70)), + 'FULL_TOPIC_TITLE' => wbr(preg_replace($orig_word, $replacement_word, $watch[$i]['topic_title'])), 'U_TOPIC' => TOPIC_URL . $watch[$i]['topic_id'], 'FORUM_TITLE' => wbr($watch[$i]['forum_name']), 'U_FORUM' => FORUM_URL . $watch[$i]['forum_id'], diff --git a/search.php b/search.php index d1e3f67d..556a1870 100644 --- a/search.php +++ b/search.php @@ -811,7 +811,7 @@ 'FORUM_NAME' => $forum_name_html[$forum_id], 'TOPIC_ID' => $topic_id, 'HREF_TOPIC_ID' => ($moved) ? $topic['topic_moved_id'] : $topic['topic_id'], - 'TOPIC_TITLE' => wbr($topic['topic_title']), + 'TOPIC_TITLE' => wbr(preg_replace($orig_word, $replacement_word, $topic['topic_title'])), 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($topic, $is_unread), 'PAGINATION' => ($moved) ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], $bb_cfg['posts_per_page']), diff --git a/tracker.php b/tracker.php index 7af97ce5..08c01e2a 100644 --- a/tracker.php +++ b/tracker.php @@ -16,6 +16,12 @@ 'post_icons', ); +// +// Define censored word matches +// +$orig_word = $replacement_word = array(); +obtain_word_list($orig_word, $replacement_word); + // Session start $user->session_start(array('req_login' => $bb_cfg['bt_tor_browse_only_reg'])); @@ -800,7 +806,7 @@ 'FORUM_ID' => $forum_id, 'FORUM_NAME' => ($forum_id) ? $forum_name_html[$forum_id] : '', 'TOPIC_ID' => $tor['topic_id'], - 'TOPIC_TITLE' => wbr($tor['topic_title']), + 'TOPIC_TITLE' => wbr(preg_replace($orig_word, $replacement_word, $tor['topic_title'])), 'TOPIC_TIME' => bb_date($tor['topic_time'], 'd-M-y') .' · '. delta_time($tor['topic_time']), 'POST_ID' => $tor['post_id'], 'POSTER_ID' => $poster_id, diff --git a/viewforum.php b/viewforum.php index 3cbee859..01344747 100644 --- a/viewforum.php +++ b/viewforum.php @@ -483,7 +483,7 @@ 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'HREF_TOPIC_ID' => ($moved) ? $topic['topic_moved_id'] : $topic['topic_id'], - 'TOPIC_TITLE' => wbr($topic['topic_title']), + 'TOPIC_TITLE' => wbr(preg_replace($orig_word, $replacement_word, $topic['topic_title'])), 'TOPICS_SEPARATOR' => $separator, 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($topic, $is_unread),