View Full Version : Enable HTML but get rid of certain tags??
Does anyone know where VB does this? I can't for the life of me find it! I added a little thing in the control panel options called "HTML Censoring" where you can stick in tags that you don't want displayed. For instance, on our HTML enabled forums someone discovered that you can embed sounds < bgsound > into posts and that really trashed everything. So, we had to turn HTML off, and people really like it (create tables, colors and such), and so I want to turn HTML back on, but just create a list of "bad" tags that will *not* be turned into HTML... So you could do something like:
<B>This is bold</B>
<table> <tr> <td> etc </td> </tr> </table> This is ok too.
<bgsound = "http://www.bob.com/a_Really_annoying_wav.wav" loop="forever">
--
BAD! Will be either deleted or turned into the <g; whatever tags so it will just appear on the board instead of being turned into HTML.
I'm looking in showthread.php and I see
$htmlcodeon=iif($foruminfo[allowhtml]==1,$ontext,$offtext);
but further searches for this variable in the file result in nothing! Also, it doesn't appear in global.php either. How does VB know to replace < > with the HTML equivalents?
Thanks,
Never mind, I found it.. Sheesh, I am tired or something, and it's only Sunday afternoon! Ok, if anyone wants this hack I'll post it, otherwise this thread can die. :)
please share, sounds nice.
Ok, a couple of easy things to do:
Edit /admin/options.php:
On or about line 68 you'll see
<li><a href=\"#styles\">Styles Options</a></li>
Add the following line to the bottom of the big list of options. Really, it doesn't matter where it goes, just somewhere in the list is fine.
<li><a href=\"#html\">HTML Censoring Options</a></li>
Ok. Further on down in options.php (around line 610) you will see
</table>
<div align=\"center\"><center><table border=\"0\">
<tr>
<td><p><p align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Submit\"></p></p></td>
<td><p><p align=\"center\"><input type=\"reset\" name=\"reset\" value=\"Reset\"></p></p></td>
</tr>
</table>
</center></div>
</form>";
That is the end of the table. Place the following code anywhere above that:
<!--/// Start HTML Censoring -->
<tr><td colspan=2><hr></td></tr>
<tr><td><a name=\"html\"></a><b>HTML </b></td></tr>
<tr>
<td><p><b>enable html censoring</b></p></td>
<td><p>Yes<input type=\"radio\" name=\"newoption[censorhtml]\" ".iif($censorhtml==1,"checked","")." value=\"1\"> No <input type=\"radio\" name=\"newoption[censorhtml]\" ".iif($censorhtml==0,"checked","")." value=\"0\"></p></td>
</tr>
<tr>
<td><p><b>HTML censor text</b></p></td>
<td><p><input type=\"text\" size=\"35\" name=\"newoption[htmlcensortext]\" value=\"$htmlcensortext\"></p></td></tr>
<!--/// End HTML Censoring -->
Ok. Save, close, and upload the file to your server.
Now open /global.php (not the one in /admin). Find (around line 421) the line that reads:
$bbcode=censortext($bbcode);
Add this right after that:
if( $dohtml == 1 ) {
$bbcode = censorhtml( $bbcode );
} // end if
Ok. That is the call to the censorhtml function.. Now all you have to do is add the function anywhere inside of global.php. I placed mine directly after the censortext( ) function (near line 457).
Here is the function:
// ###################### Start censorhtml #######################
function censorhtml( $text ) {
global $censorhtml, $htmlcensortext;
if( $censorhtml == 1 ) {
$censorword = explode( " ", $htmlcensortext );
while( list( $key, $val ) = each( $censorword ) ) {
if( $val != "" ) {
$clean_val = substr( $val, 1 );
$text = str_replace( $val, "<" . $clean_val, $text );
} // end if
} // end while
} // end if
return $text;
} // end function censorhtml
That's it! Then save, close, and upload global.php to the server.
Now you can play around in the options control panel to make changes. You have to dot the "Enable Censoring" thing in the HTML Censoring section or otherwise it will skip censoring the HTML. Also, you enter in your censor tags like this:
<bgsound <sometag <someothertag
Should be straightforward. Works ok on our server / boards.
Of course, you need to "enable HTML" on the forum in which you post to in order to make the code active.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.