Register Members List Search Today's Posts Mark Forums Read

Reply
 
Mod Options
Process post text replacements, abbreviations, fake BBCODE's Details »
Process post text replacements, abbreviations, fake BBCODE's
Mod Version: 1.00, by CarCdr (Member) CarCdr is offline
Developer Last Online: Mar 2007 I like it Show Printable Version Email this Page

This modification is in the archives.
vB Version: 3.0.0 Rating: (0 vote - 0 average) Installs: 16
Released: 15 Aug 2004 Last Update: Never Downloads: 31
Not Supported Is in Beta Stage  

Generalized Word or Text Replacer For User Inputs (Posts, etc.)
Version .2: Replace, remove, define abbreviations, define fake bbcodes.
Requires 1 small mod and adds 1 new function. No queries.


(Please, do not suggest that replacement variables can do this. See below.)

Allows an administrator to define the following sorts of replacements for posts, titles, and all other user input fields:

conservative => montague
Replace. Transform any word match, preserving case in the replacement. as in Conservative=>Montague, CONSERVATIVE=>MONTAGUE.

uglytext =>
Removal. Completely remove any occurrence. Like all others you define, can be specified to match word only or any occurrence.

.us => http://our.domain.com
Abbreviation. If defined as a word match, it would work for " .us " or " .us/subdir", but not for "him.us" or ".use".

[h1] => [ size=4][ color=navy][ i]
[/h1] => [ /i][ /color][ /size]
Abbreviation. New BBCODES :cheeky:: Abbreviation for something more complicated. (Do not add the spaces after the open ['s. I used just to show these codes in this post.) Usage for these is as you'd expect:
[h1]Some Heading[/h1]

Modifications Required
This hack requires 2 changes to one file, functions.php:
* 1 function modification (a few new lines)
* 1 new function

How It Works
The Admin adds replacement definitions using the same field as for censorship: AdminCP>vBulletin Options>Censorship Options. No change is require on the AdminCP side.

On the user code side, the function that now does censorship is modified to support these new replacements. Replacement will take place anywhere that normal censorship takes place.

Replacements should be defined in the AdminCP censorship field BEFORE plain censorship. See small attached image, where the first 5 lines are replacements and the rest of plain censorship.

Defining Replacements
Instead of simple censorship words or strings, rules are added to the censorship field in AdminCP in the same place that you currently add words to be censored. You add rules are of the form:

FIND_SPEC=REPLACEMENT

where REPLACEMENT is optionable.

There are two types of rules:
(1) string match
(2) word match.

his=her
STRING MATCH, CASE INSENSITIVE. Find any occurrence of the characters "his"
and replace it with "her". The case of letters in the replacement ("her")
is used exactly as specified. This would match 3 times in in this fragment:
"His history was this."
{oldword}=newword
WORD MATCH, CASE INSENSITIVE. Replace any occurrences of "oldword" with
"newword", using the replacement exactly as specified (it does not change
the case of any letters).
Preserving Upper Or Lower Case (using "=="):

Either type of match supports the feature of case preservation: matching the
case of the found text in the replacement text. Use "==" instead of "=" to
specify that case should be preserved. Example:

{oldword}==newword
Search is case insensitive, but replacement preserves case. This would match
all occurrences of the word "oldword", regardless of case, but it would attempt to
preserve case in three instances: initial capital, all uppercase, and all
lowercase. Examples translations from the the above rule would be:
Oldword => Newword
OLDWORD => NEWWORD
oldword => newword
A nuance here is that if the found text is not all lowercase, all uppercase,
or a single initial capital (e.g., OldWord), the the replacement text is
used exactly as specified in the rule. For example, the rule "{old}==New"
would use "New" as the replacement if "oLd" were matched.
oldword==newword
Same as above, but matches are string matches rather than word matches.
Removing Words or Text:
If no replacement text is specified, as in "uglychars= ", then the match is simply removed from the user's input. This is an alternative to the censorship replacement by *'s.

Abbreviations:
Another possible use is for abbreviations. For example, one could define the word ".us" as a shorthand for the site url by using the following rule:
{.us}=http://www.our-domain.com
which would match ".us" only as a word, as in ".us/forum" or "go to .us site.", but not "foo.us" or ".use".

Fake BBCODE: You can define an abbreviation that looks like a bbcode. This allows an administrator to define pseudo-bbcode's. You can also use bbcode's in the replacement. As you might expect, "{[red]}=REPLACEMENT" will match [red] as if it were a word and "[red]=REPLACEMENT" will match any occurrence.

Disallowed characters in replacements:
The following characters are not permitted in replacement text:
& ampersand, % percent, < less than, > greater than, ` backquote, \ backslash

Installation Instructions

1. You should include the text of the attached file (a new PHP function) in functions.php, just before the fetch_censored_text would be appropriate.

2. In the function fetch_censored_text in functions.php, find this line:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and add this BEFORE it (just the non-red text):

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Restricting Access/Testing:
You can set "$TEST_USERIDS" in the attached function to your own USERID for testing, so that this mod will not take affect for other users. Then, when you are satisfied and you want to release it, you can set this value back to empty by removing the userid that you added. I have set it to userid "1" (one) in the attachment.

This mod is beta as I have have only tested it on my board, and while I am satisfied with the results, I would not call the testing extensive.

Cautionary Notes

The vB implementation of censored words will match "com" when it is surrounded by any non-letter. Therefore, the censored word input "{com}" will match twice in this phrase, producing the result shown:

Well, 3com is not exactly a .com company.
translates to:
Well, 3*** is not exactly a .*** company.

This same matching implmentation is used by this mod in order to be compatible with vB.

Note that Admin's need to be careful about using translations that will match common words or strings. Remember that translation will take place everywhere that censorship takes place, including of course user profiles and signatures.

Editpost Bug -- Bad Preview

editpost.php does not display previews properly when bbcode abbreviations are used. In editpost.php, censorship is done after bbcode parsing, unlike newthread.php and newreply.php, where previewing works fine for bbcode abbreviations. BTW, the same bug is why URL's are not processed in the preview when you edit a post. I entered vB bugid: 3301.

A note concerning replacement variables
Replacement variables do not have the same flexibility as this mod. Also, I believe they are style specific. More importantly, replacement variables do replacements on ALL output sent to the user, which is often very dangerous. If you defined a replacement variable for "shat", it would replace it everywhere, including in www.shattered.com and HTML and javascript and style sheets... well you get the idea.

Cheers, C.C

Download Now

Only licensed members can download files, Click Here for more information.

Screenshots

Click image for larger version

Name:	admin_box.gif
Views:	304
Size:	3.2 KB
ID:	20211  

Show Your Support

  • To receive notifications regarding updates -> Click to Mark as Installed.
  • This modification may not be copied, reproduced or published elsewhere without author's permission.
  #16  
Old 18 Jul 2005, 16:36
husain's Avatar
husain husain is offline
 
Join Date: Feb 2005
This is exactly what I was looking for. Is it still in beta?
Reply With Quote
  #17  
Old 23 Jul 2006, 18:18
Bison's Avatar
Bison Bison is offline
 
Join Date: Jun 2002
It would be nice is one of you Smart Guys could update this hack to work with vB 3.5
Reply With Quote
  #18  
Old 02 Mar 2007, 22:28
jeepinator jeepinator is offline
 
Join Date: Dec 2004
^ Yes please.
Reply With Quote
  #19  
Old 14 Mar 2007, 02:50
tokosan's Avatar
tokosan tokosan is offline
 
Join Date: Dec 2005
Real name: Paul C Parker
Thumbs up

cool man, thanks for makin this much needed mod.

i'm going to get my friend, who knows what a computer is, to install this when he gets on.
Reply With Quote
  #20  
Old 29 Oct 2007, 05:18
vgevolution vgevolution is offline
 
Join Date: Nov 2006
Real name: Ken
Just applied this hack in 3.6.8. So far, it seems to work fine. It would be nice to be able to replace using spaces as well, but that could be a tough one. Perhaps the built-in filter will be upgraded someday?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Mod Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 07:34.

Layout Options | Width: Wide Color: