vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   User-optional Replacements-based Censorship (https://vborg.vbsupport.ru/showthread.php?t=63875)

tjdrico 04-13-2004 10:00 PM

User-optional Replacements-based Censorship
 
User-optional Replacements-based Censorship Hack
================================================

Rationale:
----------

Some of my forum members wanted a swear filter for use at work, but others didn't. I searched for a hack that could do that and I saw a similar hack ( https://vborg.vbsupport.ru/showthread.php?t=53640 ) by 006 but that's for vB 2.2.* and I have vB 3.0.0. I started to look at the hack to install it but it looked significantly different from the code I had for vB, so I thought it'd be simpler to write a new version for vB 3 from scratch. This is it.

Description:
------------

The "bad words" censorship filter built in to vBulletin has at least three drawbacks:

1. It's all or nothing - all users are subject to the censorship whether they choose to be or not.

2. Censored words are replaced by asterisks and are not recoverable, even if the censorship is subsequently removed.

3. There is only a single list possible, where a forum administrator may wish different censorship lists within different styles (if they relate to different fora, for example).

This hack is a solution.

Based upon the built-in Replacement Variables system, this hack enables individual users to specify whether they want to view censored posts or not. Even if the Administrator chooses not to censor his forum, individual members sometimes prefer some words to be censored because they view in an office environment and Web proxies log certain words, or because minors may be present and read the screen.

Using his own "Edit Options" page, a member of your forum can turn his censorhip on or off unilaterally, and because of the way the replacements system works this is an entirely reversible operation. He can view censored posts at work, then log in at home and turn the censorship off again to view the posts as intended.

Also because of the way the replacements system works, censorship should take place in thread titles as well as posts.

If there are words that simply must be censored for all users, the built-in global censorship system can deal with that.

Caveats:
--------

Using the Replacement Variables system in this manner may preclude its use from any other function.

I have no useful information relating to how much additional load this will put in your server. I would imagine it would be minimal if the list of words is short or most users have censorship turned off.

Hack Information:
-----------------

Queries to run: 1
Files to modify: 2
Templates to modify: 1
Phrases to add: 4

Estimated time to install hack: 5 minutes

As ever, please take sensible precautions before installing this hack; back up your database and files beforehand. I have tested this hack on my own forum and my test forum and found it to be fine, but I am not responsible for the application of any hack I don't do myself.

For support, please use this thread or email me if you don't get a response. Thanks.

Daren "Rico" Chandisingh
rico[at]justice-department.org.uk
http://www.respawned.co.uk/forums/

???`S?LV?R???` 04-14-2004 09:13 PM

nice idea, I think I might use it for my board

Red Blaze 04-14-2004 09:27 PM

I'm definatly using this for my board. Will install later today. :) Finally, some php editing to do. XD

BarryA 04-14-2004 09:59 PM

Quote:

Originally Posted by Sonikku
I'm definatly using this for my board. Will install later today. :) Finally, some php editing to do. XD

This could also be used as an advertising hack.

Say you have a webhost running a banner on your website, now you could charge him to have every instance of the word webhosting replaced with a link to his site. Maybe you could charge a few $$$ per key word... :)

Great hack BTW...

Koutaru 04-14-2004 10:11 PM

Definately will try this out :-D

alkatraz 04-14-2004 11:07 PM

fantastic idea, thank you!

Suggestion: If a user types a censored word with bbcode in the middle of it (ie: sh[anybbcode]it) vbulletin will display the word uncensored. Any way you could incorporate a fix for this into your hack?

Red Blaze 04-15-2004 02:19 AM

I tried to install it but dunno why it af fected it, but my background image disappeared. 'Twas odd. I uninstalled it. Oh well, nice hack though. :)

tjdrico 04-15-2004 06:02 AM

Quote:

Originally Posted by alkatraz
fantastic idea, thank you!


Suggestion: If a user types a censored word with bbcode in the middle of it (ie: sh[anybbcode]it) vbulletin will display the word uncensored. Any way you could incorporate a fix for this into your hack?

Really the hope is that since the censorship is optional and not forced, users won't resort to such tricks to be able to "swear".

Oblivion Knight 04-15-2004 08:46 AM

I really like the idea behind this hack.. :)
I'll take a look at it later today and hopefully it won't increase the server load too much.

Thanks for sharing.!

colicab-d 04-15-2004 10:32 AM

just the other day I had a thread started on my board about this, the older members wanted to see this and it looks like i,ll be able to do it thnx :D

ptbyjason 04-15-2004 03:29 PM

Oh thank you so much! I have been wanting to do this but I had no idea how. Now everyone will be happy. THANK YOU! :)

tjdrico 04-15-2004 08:31 PM

Quote:

Originally Posted by Sonikku
I tried to install it but dunno why it af fected it, but my background image disappeared. 'Twas odd. I uninstalled it. Oh well, nice hack though. :)

I can't imagine why that would be, unless you were already using the replacement variables for something else, or added a word that modified your display template somehow. The replacement variables don't just get operated upon post contents, but entire templates, so it's quite possible that something like that happened. If you try re-installing the hack, check that it doesn't affect your forum display before adding any words. If it only happens with some words, then change those words, or change the part of the template that's being altered (such as the image name or URL). I can't think why else it would be happening.

Cyricx 04-18-2004 03:09 PM

Very awesome! Thank you TONS :)

Gio Takahashi 04-19-2004 01:16 AM

this is interesting however, I want to make it so that it is censored from Guests. Is it possible?

tjdrico 04-19-2004 08:04 AM

Quote:

Originally Posted by Gio Takahashi
this is interesting however, I want to make it so that it is censored from Guests. Is it possible?

Yes, it's a simple change.

Open ./includes/functions.php and replace this:

PHP Code:

    // USER OPTIONAL REPLACEMENTS AS WORD CENSOR HACK
    // Use replacements as an optional display-time swear filter.
    
if (== $bbuserinfo['usereplacementscensor'])
    {
        
// this user doesn't want censoring
        // so just return the text as given
        
return $newtext;
    } 

with this:

PHP Code:

    // USER OPTIONAL REPLACEMENTS AS WORD CENSOR HACK
    // Use replacements as an optional display-time swear filter.
    
if ( (== $bbuserinfo['usereplacementscensor']) && (!= $bbuserinfo['userid']) )
    {
        
// this user doesn't want censoring
        // so just return the text as given
        
return $newtext;
    } 

Save and close the file. That should be that, and guests will be subject to censorship. I'll update the main instructions with this information.

Oblivion Knight 04-20-2004 10:54 AM

The zip file has disappeared.. ;)
I was just going to install this, and now I can't.!

tjdrico 04-20-2004 11:26 AM

Quote:

Originally Posted by Oblivion Knight
The zip file has disappeared.. ;)
I was just going to install this, and now I can't.!

Oddness! Hehe, I think I screwed up when I was updating the instructions. Should be back now - sorry about that. =)

Oblivion Knight 04-20-2004 12:24 PM

It doesn't appear to be working for me.. :(

I'm using 3.0.1.. The Microstats hack also touches the same area of code in includes/functions.php, but I don't think that's the cause of it. The censor is disabled in the Admin CP, and tested on my account to enable the censor option - and the words are still visible uncensored..

Any ideas?

007 04-20-2004 01:06 PM

Good work tjdrico. I don't have VB3 yet (plan to upgrade in the next week or so) so it will be nice not to have to rehack this one. Thanks for giving me credit for the idea. Looks like you have managed to take yours a step further and get it to work with titles as well. Looks good. I will install for sure when I upgrade.

tjdrico 04-20-2004 04:13 PM

Thanks 006, but there was absolutely zero extra effort involved in getting it to work with titles as well as thread bodies. The way the replacements system works, the entire page seems to be fed through the filter before it's sent to the browser, so it's always likely to catch everything. I may be wrong there, but it seems that way.

It could present a problem if a forum used a, image URL or something that matches part of the replaced text - users with the censorship turned on would end up with missing images. =)

tjdrico 04-20-2004 04:17 PM

Quote:

Originally Posted by Oblivion Knight
It doesn't appear to be working for me.. :(

I'm using 3.0.1.. The Microstats hack also touches the same area of code in includes/functions.php, but I don't think that's the cause of it. The censor is disabled in the Admin CP, and tested on my account to enable the censor option - and the words are still visible uncensored..

Any ideas?

This hack doesn't use the vBulletin censorship system at all, so that would make no difference at all whether it's on or off. To get words filtered or replaced using this hack you must enter each one into the Replacement Variables system. It's a bit of a pain if you have a long list of words, but it is flexible and means that rather than have just asterisks (as with the vB censorship system) you can replace one word with another. For example, m*therf**ker could be replaced by muddyfunster.

I can't think of a reason why it wouldn't be working for you off the top of my head. I haven't upgraded my forum to 3.0.1 yet, nor do I have Microstats applied. All I can say is it "should work" if you've followed the instructions correctly, to the best of my knowledge.

If anyone else has had problems installing this, I'd be grateful to hear about it.

Oblivion Knight 04-20-2004 04:22 PM

Ahh.. I thought it used the forum's censored words and bypassed the off switch.

My apologies.. I'm not with it at the moment.! ;)


Unfortunately, doing it via replacements censors "ass" in password for example.. Bah, it's a nice idea - but not quite what I wanted.

007 04-21-2004 01:13 PM

I just remembered why I disabled it for titles. The fact that, like Obliviaon Knight said, parts of words are censored, such as "ass." That's the same problem I ran into. No worries though. it's still better than the permanent *** censor. I will install this later tonight when I get home from work. :)

tjdrico 04-21-2004 01:54 PM

Hehe, fair comment. Where I live, "ass" is more likely to mean donkey than buttocks, so I don't even regard it as a candidate for censorship.

However, if it posed a problem, an administrator should be able to get round it by using 3 replacements. For example:

1. ass -> donkey

This has the undesired side-effect of changing password to "pdonkeyword" and "class" to "cldonkey". The abomination of "class" means that a lot of the CSS stuff up. However, if the admin also includes:

2. cldonkey -> class
3. pdonkeyword -> password

Then everything's fine. "ass password" gets rendered as "donkey password", and all the class= definitions in the source are also correct.

Whether an admin can be bothered to add a couple of extra replacements to "correct" any such problems really depends on how important the optional censorship is.

Eternal2u 04-25-2004 07:27 AM

This is a very nice hack, i myself find it EXTREMLY aggrvating that i have to view edited ++++ even though i like to curse myself, therby not really caring if others do as well..

Curll 05-01-2004 11:13 PM

How do I turn on filtering by default to my registered users?

zsmom 05-04-2004 05:11 AM

It doesn't appear to be working for me either and I went back and double, and triple-checked that I followed the instructions correctly. I also have 3.0.1 and Microstats installed, not sure if there's a correlation or not. It just censors words for everyone, regardless of the setting in their control panel.

I'd love to use this, we have a few potty mouths (me included) and a few others quite the opposite and this would be perfect!

tjdrico 05-05-2004 06:46 PM

Quote:

Originally Posted by Curll
How do I turn on filtering by default to my registered users?

You can do this by using the following SQL instead of the line in the instructions:

Code:

ALTER TABLE user ADD usereplacementscensor TINYINT(1) NOT NULL DEFAULT '0' AFTER pmunread;
If you have already added this new column, you can set all the existing users to use the censorship by default using this:

Code:

ALTER TABLE user ALTER COLUMN usereplacementscensor SET DEFAULT '1';

UPDATE user SET usereplacementscensor=1;

This will set everyone to be using the censorship filter, and make it the default for all new users. Anyone that had it turned off will have to turn it off again if they want it that way.

tjdrico 05-05-2004 06:48 PM

Quote:

Originally Posted by zsmom
It doesn't appear to be working for me either and I went back and double, and triple-checked that I followed the instructions correctly. I also have 3.0.1 and Microstats installed, not sure if there's a correlation or not. It just censors words for everyone, regardless of the setting in their control panel.

I'd love to use this, we have a few potty mouths (me included) and a few others quite the opposite and this would be perfect!

I'm not sure about this as I don't have Microstats installed. If you give me a link ti the appropriate release thread I'll take a look at installing it and see if I can work out what the problem is.

zetetic 05-08-2004 04:41 PM

I'm interested in this hack, but I'm brand new to vB3 and a bit put off by the caveat that use of the replacements system in this way might preclude its use in other ways. I guess I'm asking what potential I lose by using this, since I'm not really sure what else I would use replacements for.

Thanks!

tjdrico 05-11-2004 11:58 AM

Quote:

Originally Posted by tmhall
I'm interested in this hack, but I'm brand new to vB3 and a bit put off by the caveat that use of the replacements system in this way might preclude its use in other ways. I guess I'm asking what potential I lose by using this, since I'm not really sure what else I would use replacements for.

Thanks!

Well, if you have to ask, you're probably not likely to be affected. =) I haven't yet had any use for replacements, but you could use them to... um... alter the pages in some way. e.g. replacing "<body " with "<body onLoad=..." -- that's something you could do with templates though. Or, say, "someword" with one of those "sponsored links" things. I don't know what else people use the replacements for generally.

I put the caveat in there really as I'm sure some people use the replacements for various purposes, but in general I think most people would be fine using them to implement a censorship hack.

zetetic 05-11-2004 01:19 PM

Excellent. I think I'll give it a shot, then. Thanks. :)

jcr 05-15-2004 03:17 AM

I really like the idea of this hack, but as you mentioned in the instructions, some odd errors may appear. I must frankly say that it is really hard to actually think of all the combinations of ( ass = donkey , password = donkeyword ) swearing / non-swearing words. There must be some way to work this out without having to sit and think of hundreds, maybe thousands of combinations? ( yes... norwegian language has a whole lot of swearing )

moonclamp 05-28-2004 07:16 PM

This is very useful for me as one of my members logs on from work and constantly has pages restricted to her by 'webmarshal' software because of bad language. *installs*

Loon 06-01-2004 05:32 PM

Nice little hack, thanks.

In regards to having part words replaced, you can solve the problem in most cases by using spaces, example:

If you want "ass" replaced with "thingy" for the text to replace put <space>ass<space>

then "password ass glass" would come out as

"password thingy glass" rather than "pthingyword thingy glthingy"

the only time this wouldn't work is if they post the word that's getting replaced as the first word in their post, but it's probally very very rare that would happen.

tjdrico 06-06-2004 03:43 PM

That's handy to know, Loon, thanks.

I noticed that "parse links in text" was coming out as "pdonkey links in text" on my test forum the other day. =)

forumdude 06-09-2004 08:07 PM

AAhhh. Awsome! I'll have to seriously consider this when we install vb3.

I briefly read over this and am wondering if there's still a place where you can have words censored for everyone outside of the optional censorship? We sometimes censor outwar links and other various domain names.

tjdrico 06-09-2004 08:14 PM

You can still use the standard vBulletin censorship system, and those words would be replaced by '**********' as normal.

forumdude 06-09-2004 08:16 PM

great thanks

FASherman 06-10-2004 04:29 PM

One more suggestion, if you don't mind...

Instead of using the forum default for "bad words", why not allow users to specify their own list of words that they personally find offensive?


All times are GMT. The time now is 04:43 PM.

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.01408 seconds
  • Memory Usage 1,842KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete