The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
|
#1
|
|||
|
|||
Trouble with a function I am using
Folks, I am having some problems with a function I am using and I would appreciate your help.
Let me explain myself. I have a function which enters a pair of brackets around a censored word, if such a word is found in a post. This function is shown below: Code:
function bracket_censored_text($text) { global $vboptions; static $censorwords; if ($vboptions['enablecensor'] AND !empty($vboptions['censorwords'])) { if (empty($censorwords)) { $vboptions['censorwords'] = preg_quote($vboptions['censorwords'], '#'); $censorwords = preg_split('#\s+#', $vboptions['censorwords'], -1, PREG_SPLIT_NO_EMPTY); } foreach ($censorwords AS $censorword) { $censorword = str_replace('\+', ' ', $censorword); $censorword = str_replace('\\\{','',$censorword); $censorword = str_replace('\\\}','',$censorword); $censorword = str_replace('\\','',$censorword); $text = preg_replace('#(?<=[^a-z]|^)(' . $censorword . ')(?=[^a-z]|$)#si', "[$censorword]", $text); $text = str_replace('[[','[',$text); $text = str_replace(']]',']',$text); $text = str_replace('[[','[',$text); $text = str_replace(']]',']',$text); } } // strip any admin-specified blank ascii chars $text = strip_blank_ascii($text, $vboptions['censorchar']); return $text; } I have the following words (abbreviations) in my censored words list: bs, b.s., BS, B.S. Now if I have a post with the word "best" in it, everything works fine. But if in the same post, there is one of the above abbreviations, then the abbreviation is put in square brackets, but so is the word "best", which is actually replaced by "[b.s.]". So this: Code:
This is the best world. Code:
This is the best world in the B.S. universe. Even though I can work with PHP, I have absolutely no idea how the preg_ functions work, so I am at a loss on how to correct this problem. So if one of you experts can help me out, I would greatly appreciate it. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|