Skip to content

Commit

Permalink
Added word censor in some cases (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
belomaxorka committed Apr 1, 2023
1 parent 584cf67 commit c3a320f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
14 changes: 10 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'])),
));
Expand Down Expand Up @@ -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']),
));
Expand All @@ -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']),
));
Expand Down
10 changes: 8 additions & 2 deletions library/includes/ucp/topic_watch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
8 changes: 7 additions & 1 deletion tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));

Expand Down Expand Up @@ -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') .' <b>&middot;</b> '. delta_time($tor['topic_time']),
'POST_ID' => $tor['post_id'],
'POSTER_ID' => $poster_id,
Expand Down
2 changes: 1 addition & 1 deletion viewforum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit c3a320f

Please sign in to comment.