vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Replacing certain censored words with other words, rather than *'s (https://vborg.vbsupport.ru/showthread.php?t=68342)

AaronJH 08-14-2004 05:34 PM

Replacing certain censored words with other words, rather than *'s
 
Hello, everyone! I have been having a bit of a problem, but I think somebody will be able to help me out!

At my forum, I want to have the following filters:

liberal = Capulet
liberals = Capulets
conservative = Montague
conservatives = Montagues

First, I put liberal, liberals, conservative, and conservatives in the vB censorship box.

Then I tried to accomplish my goal by putting the following code in functions.php in the censorship code:

$text = strtolower($text);
if ($text == 'liberals')
{ $text = 'Capulets'; }
else if ($text == 'liberal')
{ $text = 'Capulet'; }
else if ($text == 'conservatives')
{ $text = 'Montagues'; }
else if ($text == 'conservative')
{ $text = 'Montague'; }

It works only if the offending word is the ONLY word in the post. If there is anything else, it simply converts the word to asterisks. Anybody have any suggestions?

Zachery 08-14-2004 06:00 PM

Quote:

Originally Posted by AaronJH
Hello, everyone! I have been having a bit of a problem, but I think somebody will be able to help me out!

At my forum, I want to have the following filters:

liberal = Capulet
liberals = Capulets
conservative = Montague
conservatives = Montagues

First, I put liberal, liberals, conservative, and conservatives in the vB censorship box.

Then I tried to accomplish my goal by putting the following code in functions.php in the censorship code:

$text = strtolower($text);
if ($text == 'liberals')
{ $text = 'Capulets'; }
else if ($text == 'liberal')
{ $text = 'Capulet'; }
else if ($text == 'conservatives')
{ $text = 'Montagues'; }
else if ($text == 'conservative')
{ $text = 'Montague'; }

It works only if the offending word is the ONLY word in the post. If there is anything else, it simply converts the word to asterisks. Anybody have any suggestions?

You would need to do a string replace or use a regular expression i think :)

but without getting complicated you can use replacements, but this will effect the whole site.

Aaron Freed 08-14-2004 06:09 PM

I applaud your taste in replacements.

Tigga 08-14-2004 06:13 PM

Is there a reason why you can't just add those as replacement variables?

Zachery 08-14-2004 06:17 PM

Quote:

Originally Posted by Tigga
Is there a reason why you can't just add those as replacement variables?

Because they would replace the words apperance anywhere on the whole site.

CarCdr 08-15-2004 01:19 AM

Modest Proposal For Replacement Text for vBulletin

One approach to offering text replacement in posts, and other user inputs, would be to change the specification for the censored word list in the AdminCP.

Right now, one can specify two types of censored word matching:

foo
matches any occurrence of the 3 characters, words or otherwise

{foo}
matches any occurrence of the word "foo"; anywhere it finds the 3 characters not preceded and followed by a letter. Matches 3 times in this text: Foo is 3foo or _foo

Extending This Implementation (= syntax)

A fairly localized hack could extend this so that AdminCP censored word could include replacement text. An admin could specify these new types in the list of censored words:

{Conservative}=Montague
Replace any occurrence of the first word with the second word.

{/home}=www.mydomain.com
Provides an abbreviation for the word match "/home".

This would be a fairly simple hack, although I would suggest that one would not want to apply the replacer specifications to text inside of [CODE], [PHP], etc.

The other caveat would be that the replacement text may not contain any HTML-special characters.

AN-net 08-15-2004 02:52 AM

well he could modify the censor text function to change those certain words to a desired word:)

CarCdr 08-15-2004 05:27 AM

AaronJH,

Please see: Process post text replacements, abbreviations, fake BBCODE's

To do what you want to do, you can add the following to your AdminCP :: vBulletin Options :: Censorship Options:

{conservative}==montague {liberal}==capulet

The mod (the '==' operator) will take care of matching case for these words, for example, "Conservative" will be translated to "Montague" and "CONSERVATIVE" will be translated to "MONTAGUE".

--------------------------

This post was originally where I posted the mod. I thought it would be better to post it properly, so I removed all the duplicate text here.

BTW, the attached version in the above linked post was modified ever so slightly from the one posted last night. It now allows "=" (equals) in replacement text, which allows one to define fake bbcodes, a la:

{[h1]}=[size=4][color=navy][i]

which would process [h1] bbcodes found in user input and turn them into big, coloured, italicised text.

CarCdr 08-15-2004 12:30 PM

Oh yes, I should have mentioned that this can also be used to remove words or strings rather than replace them with *'s. One would use this syntax to remove a string or a word:

anychars= {word}=

One simply does not specify a replacement -- the '=' is followed by a space.

AaronJH 08-17-2004 01:09 AM

Thanks for the hack! :)


All times are GMT. The time now is 08:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01128 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete