PostNuke Help

Previous
pnUserValidateVar

Home
up

Next
pnVarCleanFromInput


pnVarCensor

remove censored words from variable

Synopsis

mixed pnVarCensor(var, ...);

Description

pnVarCensor() takes a variable number of var arguments and for each one examines it for words which are deemed offensive or otherwise not allowed to be displayed. These words are replaced with asterix marks to show that words have been removed.

pnVarCensor() tries to be intelligent in its attempt to remove censored words whilst not censoring words on the censor list that happen to be embedded in a larger word.

Return Values

If pnVarCensor() is only passed a single var argument then it returns the corresponding censored variable. If pnVarCensor() is passed multiple arguments then it returns an array of corresponding censored variables. This function returns void if an exception was raised.

Exceptions

This function doesn't raise exceptions but throws back exceptions raised from other functions.

Notes

pnVarCensor() uses the information provided in the configuration setting 'CensorList' as the basis of the words that it censors. It also looks for commonly derivations of the words used to try to avoid censoring. The system is also case-insensitive.

It is possible to censor information either before it is stored in the database or before it is displayed on-screen. The choice of which one to do is up to the developer, but the implications of the two different approaches should be considered. By censoring information before putting it in to the database it is stored internally with censored marks, and it is possible that part of the meaning might be lost due to a bad choice of words in the censor list. By censoring information before it is displayed the ability to add items to the censor list and have them take effect retrospectively is possible, but there is an overhead involved each time that the information is displayed, and the uncensored text will be stored in the database.

Care should be taken to consider the effect of censorship, and if it should be applied to all information that is passed in by the user or if it should only be used in specific cases. It is also up to the developer to decide whether to accept the censored version of text or to return it to the user for editing.

Examples

// Obtain user comment and censor it
$comment = pnVarCleanFromInput('comment');
$comment = pnVarCensor($comment);
// See if user input contains censored words
$userinput = pnVarCleanFromInput('info');
if ($userinput != pnVarCensor($userinput)) {
        // Contains censored words
}
       

Previous
pnUserValidateVar

Home
up

Next
pnVarCleanFromInput