내 웹 사이트에서이 코드를 사용해보십시오. 여기서 변수라는 모든 변수를 변수로 바꿉니다. 비속어가 포함 된 CSV 파일이 필요합니다. 이 코드는 맹세 한 단어와 예를 들어 Scunthorpe와 같은 맹목적 인 단어가 포함 된 구별 된 단어를 구별 할 수 있습니다. 또한 단어를 적절한 수의 별으로 대체하고 모든 공통 접미사를 인식합니다. 실행하는 데 시간이 오래 걸리지 만 가양 성의 위험을 크게 줄일 수 있습니다.
//inport profanities csv and list suffixes
$profanities=explode(",", file_get_contents('NAME OF YOUR CSV FILE GOES HERE'));
$suffixes=array('','s','es','e','ed','ing','ted','ting','y','ty','d','head','bag','hole','wit','tard','er','ter','en','ten','est','test','able','ible','ful','full');
//get text input
$sanitize_text=$YOUR VARIABLE HERE;
//combine profanities and sufixes
foreach($profanities as $profanity)
{
foreach($suffixes as $suffix)
{
$sanitize_terms=$profanity;
$sanitize_terms.=$suffix;
$word=$sanitize_terms;
$match_count=preg_match_all('/'.$word.'/i', $YOUR VARIABLE HERE, $matches);
for($i=0; $i<$match_count; $i++)
{
$bwstr=trim($matches[0][$i]);
$sanitize_text=preg_replace('/\b'.$bwstr.'\b/', str_repeat("*", strlen($bwstr)), $sanitize_text);
}
}
}
$YOUR VARIABLE HERE=$sanitize_text;
올바르게 수행하는 것은 매우 어려운 작업입니다. 좋은 읽을 거리 : http://www.codinghorror.com/blog/2008/10/obscenity-filters-bad-ide-or-incredibly-intercoursing-bad-idea.html –
시도해 본 적이 있으면 코드가 있으면 솔루션에 가까울 수 있습니다. – greg0ire
"몇 번 시도했지만 실패했습니다!"... 실패한 이유는 무엇입니까? 배열 생성? 잠재적 인 모욕적 인 단어를 귀하의 배열과 비교 하시겠습니까? – chahuistle