mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Improved word censor 🤐 (#1393)
* Improved default word censor * Updated * Updated * Updated * Update Censor.php * Update CHANGELOG.md * Updated
This commit is contained in:
parent
800cd714ef
commit
d5390132ec
15 changed files with 116 additions and 168 deletions
|
@ -365,14 +365,8 @@ if (!$ranks = $datastore->get('ranks')) {
|
|||
$ranks = $datastore->get('ranks');
|
||||
}
|
||||
|
||||
// Define censored word matches
|
||||
$orig_word = $replacement_word = [];
|
||||
obtain_word_list($orig_word, $replacement_word);
|
||||
|
||||
// Censor topic title
|
||||
if (count($orig_word)) {
|
||||
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
|
||||
}
|
||||
$topic_title = $wordCensor->censorString($topic_title);
|
||||
|
||||
// Post, reply and other URL generation for templating vars
|
||||
$new_topic_url = POSTING_URL . "?mode=newtopic&f=" . $forum_id;
|
||||
|
@ -627,28 +621,26 @@ for ($i = 0; $i < $total_posts; $i++) {
|
|||
}
|
||||
|
||||
// Replace naughty words
|
||||
if (count($orig_word)) {
|
||||
if ($user_sig) {
|
||||
$user_sig = str_replace(
|
||||
'\"', '"',
|
||||
substr(
|
||||
preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function ($matches) use ($orig_word, $replacement_word) {
|
||||
return preg_replace($orig_word, $replacement_word, reset($matches));
|
||||
}, '>' . $user_sig . '<'), 1, -1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$message = str_replace(
|
||||
if ($user_sig) {
|
||||
$user_sig = str_replace(
|
||||
'\"', '"',
|
||||
substr(
|
||||
preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function ($matches) use ($orig_word, $replacement_word) {
|
||||
return preg_replace($orig_word, $replacement_word, reset($matches));
|
||||
}, '>' . $message . '<'), 1, -1
|
||||
preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function ($matches) use ($wordCensor) {
|
||||
return $wordCensor->censorString(reset($matches));
|
||||
}, '>' . $user_sig . '<'), 1, -1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$message = str_replace(
|
||||
'\"', '"',
|
||||
substr(
|
||||
preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function ($matches) use ($wordCensor) {
|
||||
return $wordCensor->censorString(reset($matches));
|
||||
}, '>' . $message . '<'), 1, -1
|
||||
)
|
||||
);
|
||||
|
||||
// Replace newlines (we use this rather than nl2br because till recently it wasn't XHTML compliant)
|
||||
if ($user_sig) {
|
||||
$user_sig = $bb_cfg['user_signature_start'] . $user_sig . $bb_cfg['user_signature_end'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue