mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 22:33:55 -07:00
misc: Minor improvements
This commit is contained in:
parent
36d399220e
commit
0d58bb12ea
3 changed files with 10 additions and 19 deletions
|
@ -2154,10 +2154,7 @@ function getBanInfo(?int $userId = null): ?array
|
||||||
global $datastore;
|
global $datastore;
|
||||||
|
|
||||||
// Get bans info from datastore
|
// Get bans info from datastore
|
||||||
if (!$bans = $datastore->get('ban_list')) {
|
$bans = $datastore->get('ban_list');
|
||||||
$datastore->update('ban_list');
|
|
||||||
$bans = $datastore->get('ban_list');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($userId)) {
|
if (!isset($userId)) {
|
||||||
return $bans;
|
return $bans;
|
||||||
|
|
|
@ -41,10 +41,7 @@ class Censor
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get censored words
|
// Get censored words
|
||||||
if (!$censoredWords = $datastore->get('censor')) {
|
$censoredWords = $datastore->get('censor');
|
||||||
$datastore->update('censor');
|
|
||||||
$censoredWords = $datastore->get('censor');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($censoredWords as $word) {
|
foreach ($censoredWords as $word) {
|
||||||
$this->words[] = '#(?<![\p{Nd}\p{L}_])(' . str_replace('\*', '[\p{Nd}\p{L}_]*?', preg_quote($word['word'], '#')) . ')(?![\p{Nd}\p{L}_])#iu';
|
$this->words[] = '#(?<![\p{Nd}\p{L}_])(' . str_replace('\*', '[\p{Nd}\p{L}_]*?', preg_quote($word['word'], '#')) . ')(?![\p{Nd}\p{L}_])#iu';
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BBCode
|
||||||
public array $tpl = [];
|
public array $tpl = [];
|
||||||
|
|
||||||
/** @var array $smilies Replacements for smilies */
|
/** @var array $smilies Replacements for smilies */
|
||||||
public array $smilies;
|
public array $smilies = [];
|
||||||
|
|
||||||
/** @var array $tidy_cfg Tidy preprocessor configuration */
|
/** @var array $tidy_cfg Tidy preprocessor configuration */
|
||||||
public array $tidy_cfg = [
|
public array $tidy_cfg = [
|
||||||
|
@ -336,19 +336,16 @@ class BBCode
|
||||||
{
|
{
|
||||||
global $datastore;
|
global $datastore;
|
||||||
|
|
||||||
if (!$this->smilies = $datastore->get('smile_replacements')) {
|
$this->smilies = $datastore->get('smile_replacements');
|
||||||
$datastore->update('smile_replacements');
|
|
||||||
$this->smilies = $datastore->get('smile_replacements');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined('IN_ADMIN')) {
|
if (!empty($this->smilies)) {
|
||||||
foreach ($this->smilies['repl'] as &$smile) {
|
if (defined('IN_ADMIN')) {
|
||||||
$smile = preg_replace('/src="([^"]+)"/', 'src="./../$1"', $smile);
|
foreach ($this->smilies['repl'] as &$smile) {
|
||||||
|
$smile = preg_replace('/src="([^"]+)"/', 'src="./../$1"', $smile);
|
||||||
|
}
|
||||||
|
unset($smile);
|
||||||
}
|
}
|
||||||
unset($smile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->smilies) {
|
|
||||||
/** @noinspection NestedPositiveIfStatementsInspection */
|
/** @noinspection NestedPositiveIfStatementsInspection */
|
||||||
if ($parsed_text = preg_replace($this->smilies['orig'], $this->smilies['repl'], $text)) {
|
if ($parsed_text = preg_replace($this->smilies['orig'], $this->smilies['repl'], $text)) {
|
||||||
return $parsed_text;
|
return $parsed_text;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue