This is an old file that I had sitting around on my laptop, and it dates from my time as a developer at the BBC.
I didn’t write it… I think it was passed down over the generations from a list drawn up by editorial types long ago, and it was used whenever someone did anything that would be shown publically… if they commented or set a displayname for themselves.
I think this line speaks for itself:
$_shitlist = $this->_getProfanities();
Enjoy :-)
<?php
/**
* BBC_Idapp_Validation_Contains_NoProfanity
*/
class BBC_Idapp_Validation_Contains_NoProfanity extends BBC_Idapp_Validation{
const NAME = 'contains_noprofanity';
const ERROR_LEVEL = BBC_Idapp_Validation::ERROR_LEVEL_WARNING;
protected $_locale = null;
public function setLocale( $loc ) {
$this->_locale = $loc;
}
private function _getProfanities(){
$data = <<<EOT
{
"profanities":{
"cy-GB":{
"pwp": [],
"cnych": [],
"tân": ["bwletîn", "cantîn", "gilotîn"],
"goc": ["goctel", "gocsen", "gocŵn", "gorffil", "goch", "goctêl", "gocos", "gicatw", "gocyn"],
"wanc": ["gwanc", "wancus"],
"tin": ["bwletin", "meitin", "tindro", "owtin", "ystinos", "tinsel", "gwylltineb", "retina", "tinwen", "ffestiniog", "tincer", "platinwm", "tinc", "setin", "ceratin"],
"bonc": ["boncath", "sbonc", "boncyff"],
"haliwr": ["cynhaliwr", "gynhaliwr"],
"cotsan": [],
"cwiar": [],
"chont": ["chontract"],
"gont": ["gontract", "segontiwm"],
"ffani": ["alffaniwmerig"],
"cnwch": ["dycnwch"],
"badans": [],
"cont": ["contract"],
"ffwrch": [],
"twrd": [],
"shelffo": [],
"pwsi": [],
"nigar": [],
"budrogen": [],
"cach": ["pwysicach", "tebycach", "dicach", "bwysicach", "debycach"],
"alimentiwr": [],
"halio": ["cynhaliol", "gynhaliol"],
"gach": ["llosgach", "ehangach", "llegach"],
"basdad": [],
"ffwc": [],
"biji": [],
"hŵr": [],
"ffyc": [],
"fflanj": [],
"shelffad": [],
"coc": ["cocyn", "coctel", "cocatw", "cocŵn", "coch", "cocsen", "cocos", "corffil", "coctêl"],
"gotsan": []
},
"en-GB":{
"sodomy":[],
"blowjob":[],
"ballsack":[],
"asshole":[],
"bullshit":[],
"felch":[],
"furbox":[],
"sodomite":[],
"shagstress":[],
"fellate":[],
"queef":[],
"feltch":[],
"fuck":[],
"penis":[],
"pussy":["pussyfoots","pussycat","pussyfooted","pussycats","pussyfooting","pussyfoot"],
"shagbucket":[],
"bollock":[],
"queve":[],
"asswipe":[],
"shithead":[],
"furburger":[],
"cunt":["scunthorpe"],
"nigger":["sniggeringly","sniggering","sniggers","sniggered","snigger"],
"dickhead":[],
"hairymuff":[],
"bastard":[],
"blow-job":[],
"faggot":[],
"twat":["derwentwater","cutwater","wristwatches","twattle","heartwater","atwater","witwatersrand","saltwater","wristwatch","meltwater"],
"bunghole":[],
"pussies":[],
"bitch":[],
"cojones":[]
}
}
}
EOT;
$data = Zend_Json::decode($data);
return $data;
}
public function evaluate($value){
$_shitlist = $this->_getProfanities();
$profanities = array(
'en-GB' => $_shitlist['profanities']['en-GB']
);
// add any extra locale if it's passed
if($this->_locale !== null && array_key_exists( $this->_locale, $_shitlist['profanities'] )){
$profanities[$this->_locale] = $_shitlist['profanities'][$this->_locale];
}
foreach($profanities as $thisLocale => $swears){
foreach($swears as $swear => $exceptions){
if(stripos($value, $swear)!==false){
if(count($exceptions)){
$butcheredValue = $value;
foreach($exceptions as $exception){
$butcheredValue = str_replace($exception, '', $butcheredValue);
}
if(stripos($butcheredValue, $swear)!==false){
return false;
}
}
else{
return false;
}
}
}
}
return true;
}
}