Copiază următorul cod în fişierul functions.php. Comentariile care conţin cuvinte incluse în $cuvinte_rele vor fi respinse automat.
==============================================================================
/**
* SPAM STOP
* Opeste spam din comment-uri automat !
*/
function in_comment_post_like($string, $array) {
foreach($array as $ref) { if(strstr($string, $ref)) { return true; } }
return false;
}
function elimina_comentarii_rele() {
if (!empty($_POST[‘comment’])) {
$post_comment_content = $_POST[‘comment’];
$lower_case_comment = strtolower($_POST[‘comment’]);
$cuvinte_rele = array(
‘viagra’,
‘hydrocodone’,
‘hair loss’,
‘[url=http’,
‘[link=http’,
‘xanax’,
‘tramadol’,
‘russian girls’,
‘russian brides’,
‘lorazepam’,
‘adderall’,
‘dexadrine’,
‘no prescription’,
‘oxycontin’,
‘without a prescription’,
‘sex pics’,
‘family incest’,
‘online casinos’,
‘online dating’,
‘cialis’,
‘best forex’,
‘amoxicillin’
);
if (in_comment_post_like($lower_case_comment, $cuvinte_rele)) {
$comment_box_text = wordwrap(trim($post_comment_content), 80, “\n “, true);
$txtdrop = fopen(‘/domains/4seo.ro/public_html/comm-dropped.txt’, ‘a’);
fwrite($txtdrop, ” ————–\n [COMMENT] = ” . $post_comment_content . “\n ————–\n”);
fwrite($txtdrop, ” [IP Sursa] = ” . $_SERVER[‘REMOTE_ADDR’] . ” @ ” . date(“F j, Y, g:i a”) . “\n”);
fwrite($txtdrop, ” [USERAGENT] = ” . $_SERVER[‘HTTP_USER_AGENT’] . “\n”);
fwrite($txtdrop, ” [REFERER ] = ” . $_SERVER[‘HTTP_REFERER’] . “\n”);
fwrite($txtdrop, ” [FILE_NAME] = ” . $_SERVER[‘SCRIPT_NAME’] . ” – [REQ_URI] = ” . $_SERVER[‘REQUEST_URI’] . “\n”);
fwrite($txtdrop, ‘————–**********——————‘.”\n”);
header(“HTTP/1.1 406 Not Acceptable”);
header(“Status: 406 Not Acceptable”);
header(“Connection: Close”);
wp_die( __(‘bang bang.’) );
}
}
}
==============
Sursa : CWR
pot adauga mai multe cuvinte rele ?
da sigur cate vrei poti adauga !!!