Using censor bad words function externaly?

Posted by Stuart 
Using censor bad words function externaly?
September 22, 2008 10:25AM
Hi,

I'm currently building a site and have integrated Phorum's user login/registration features. I've got to say Phorum and it's api rocks, so thanks guys!

What I'm hoping to do is use Phorum's censor/bad words filter outside of the forum, in order to filter user generated content across the site. While I could code my own functions and use Phorum's word table, I would like to use the tried and tested functions already written by the Phorum team. No sense trying to re-invent the wheel!

Has anyone done this or got any ideas?

Cheers!
Re: Using censor bad words function externaly?
September 22, 2008 10:35AM
Thanks for your compliments and welcome to the happy Phorum user bunch!

On your question: you could use Phorum's format function, which includes censor list formatting. But mind that you will get all other Phorum formatting as well. If you don't want that, then you might have to do something like assigning an empty array to $PHORUM['hooks'] before calling the formatting function.

Some basic code for including the Phorum code and using its formatting (beware of undefined index warnings; I didn't test the code and the $fake_messages elements might need some more fields):

[code="php"]
$body = 'your text that has to be censored';

chdir('/your/phorum/install/dir');
include('common.php');
require_once('include/format_functions.php');

$fake_messages = array( 1 => array( 'body' => $body, 'subject' => '' ) );
$formatted_messages = phorum_format_messages($fake_messages);
$formatted_body = $formatted_messages[1]['body'];
[/code]

I hope this helps.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Using censor bad words function externaly?
September 22, 2008 11:08AM
Hi Maurice,

Thanks for pointing me in the right direction.

I'll get it working and post the code here.

Thanks again!
Your IP address, domain or ISP has been blocked. Please contact the forum administrators.
Sorry, only registered users may post in this forum.

Click here to login