With this snippet you can use html as a kind of word censor in posts
Requested by: Mike3396
Request topic: http://www.phpbb.com/community/viewtopi ... &t=2157114
Instruction
open
includes/functions_content.php
find
- Code: Select all
$vars = array('text', 'uid', 'bitfield', 'flags');
extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars)));
after add
[Fix**]
- Code: Select all
// BNa
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/functions_word_censors.' . $phpEx);
load up a file named
functions_word_censors.php
(utf8 without a bom) with following (test)-content to includes/functions_word_censors.php
- Code: Select all
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
// Here all Word-Censors // Just replace without any masking
$text = @preg_replace('#\bBanana\b#', '<span style="color:red; font-weight: bold;">Banana</span>', $text);
$text = @preg_replace('#\bBanan\b#', '<a href="http://www.google.de">Banan</url>', $text);
$text = @preg_replace('#\Bthinsp\B#', ' ', $text);
?>
Result for "Banana":
Note
Edit
Banana
to any word with any html as replacement like <span style="color:red; font-weight: bold;">Banana</span>
.Leave all other syntax in place. Make as many "new lines" you want.
\b
is for search > solo words > test
(boundarys)\B
is for search > words in words like testthinsptest
(not bounded)