mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 10:37:30 -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
|
@ -1606,36 +1606,6 @@ function bb_preg_quote($str, $delimiter)
|
|||
return $text;
|
||||
}
|
||||
|
||||
//
|
||||
// Obtain list of naughty words and build preg style replacement arrays for use by the
|
||||
// calling script, note that the vars are passed as references this just makes it easier
|
||||
// to return both sets of arrays
|
||||
//
|
||||
function obtain_word_list(&$orig_word, &$replacement_word)
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
if (!$bb_cfg['use_word_censor']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$sql = CACHE('bb_cache')->get('censored')) {
|
||||
$sql = DB()->fetch_rowset("SELECT word, replacement FROM " . BB_WORDS);
|
||||
if (!$sql) {
|
||||
$sql = [['word' => 1, 'replacement' => 1]];
|
||||
}
|
||||
CACHE('bb_cache')->set('censored', $sql, 7200);
|
||||
}
|
||||
|
||||
foreach ($sql as $row) {
|
||||
//$orig_word[] = '#(?<!\S)(' . str_replace('\*', '\S*?', preg_quote($row['word'], '#')) . ')(?!\S)#iu';
|
||||
$orig_word[] = '#(?<![\p{Nd}\p{L}_])(' . str_replace('\*', '[\p{Nd}\p{L}_]*?', preg_quote($row['word'], '#')) . ')(?![\p{Nd}\p{L}_])#iu';
|
||||
$replacement_word[] = $row['replacement'];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function bb_die($msg_text, $status_code = null)
|
||||
{
|
||||
global $ajax, $bb_cfg, $lang, $template, $theme, $userdata, $user;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue