Use HTML in Word Censor
Posted October 6th 2012, 8:20pm
I have shown members how to modify phpBB3 to use HTML in ranks and forum rules/descriptions. Now it's time to show how to modify phpBB3 to use HTML in the word censor!

Again, for some unknown reason, the phpBB developers chose to disable HTML in the word censor. Since one must have ACP access to the word censor module in order to add/modify/delete censored words, there is no security risk to allow HTML. So here is how to allow HTML:

First, open the includes/acp/acp_words.php file, and find this line (roughly line 75):

					'REPLACEMENT'		=> (isset($word_info['replacement'])) ? $word_info['replacement'] : '',

change it to:

					'REPLACEMENT'		=> (isset($word_info['replacement'])) ? htmlspecialchars($word_info['replacement']) : '',

Now fine this line (roughly line 105):

					'replacement'	=> $replacement

change it to:

					'replacement'	=> htmlspecialchars_decode($replacement)

And finally, find this line: (roughly line 185):

				'REPLACEMENT'	=> $row['replacement'],

and change it to:

				'REPLACEMENT'	=> htmlspecialchars($row['replacement']),

Once you save the modified file, go to your ACP and create a test censored word that includes HTML tags, or modify a current censored word to include HTML tags. Then look at a post which contains the censored word. You will like what you see. :)

Enjoy!
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Use HTML in Word Censor
Posted August 21st 2016, 9:17am
I've installed this on my forum and it works great! My only issue is that it seems to be truncated after a certain amount of characters (I'm trying to get it to display a few images instead of a word). Is there a way to alter the field or modify it further so that it can display more HTML? If so, how would you go about doing that?
φ
Posts: 2
Joined: August 21st 2016, 6:12am
Likes Given: 1
Use HTML in Word Censor
Posted August 21st 2016, 1:28pm
You would need to change the structure of the (prefix)_words table in your database, where (prefix) is the table prefix vaue in your config.php file.

My suggestion would be to change the replacement column from VARCHAR(255) to TEXT. If for some reason you require a default value, use VARCHAR(1024) instead of TEXT.

Use of VARCHAR(1024) requires MySQL 5.0.5 or later. Use of TEXT will work with all database types and versions.
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Use HTML in Word Censor
Posted August 21st 2016, 10:13pm
I was able to change the replacement field to mediumtext (that's what the php_posts field used) but it still truncates at 255 characters. Do I need to make any adjustments to the code you posted above or should this db alteration be able to do the trick?
φ
Posts: 2
Joined: August 21st 2016, 6:12am
Likes Given: 1
1
#5
Use HTML in Word Censor
Posted August 22nd 2016, 12:32am
You'll need to change the adm/style/acp_words.html template. In it you'll find two maxlength="255" attributes in INPUT tags. Remove the one for the replacement text, and you'll be able to add more than a million characters of replacement text. :)
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357

Who is online

Users browsing this forum: No registered users and 1 guest