Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2004, 05:34 PM
AaronJH AaronJH is offline
 
Join Date: Apr 2003
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 08-14-2004, 06:00 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 08-14-2004, 06:09 PM
Aaron Freed's Avatar
Aaron Freed Aaron Freed is offline
 
Join Date: Oct 2002
Location: Florida
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I applaud your taste in replacements.
Reply With Quote
  #4  
Old 08-14-2004, 06:13 PM
Tigga's Avatar
Tigga Tigga is offline
 
Join Date: Dec 2001
Location: Atlanta
Posts: 1,061
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a reason why you can't just add those as replacement variables?
Reply With Quote
  #5  
Old 08-14-2004, 06:17 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 08-15-2004, 01:19 AM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 08-15-2004, 02:52 AM
AN-net's Avatar
AN-net AN-net is offline
 
Join Date: Dec 2003
Location: AnimationTalk.com
Posts: 2,367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well he could modify the censor text function to change those certain words to a desired word
Reply With Quote
  #8  
Old 08-15-2004, 05:27 AM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 08-15-2004, 12:30 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 08-17-2004, 01:09 AM
AaronJH AaronJH is offline
 
Join Date: Apr 2003
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the hack!
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 06:07 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04089 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete