funcion_spam_coment

Combate el spam de tu Wordpress

29 Enero 2010
Macgrafic
1 comentario
187 VISITAS

Siempre son pocas las barreras que se tienen instaladas para combatir la gran cantidad de spam que recibimos en Wordpress. Necesitamos poner todas las barreras posibles para filtrarlos. Desde ayudawordpres nos amplia una manera más, para combatirlo desde nuestro fichero functions.php en nuestro tema activo.

Añadir este código en el fichero functions.php:


function in_comment_post_like($string, $array) {
	foreach($array as $ref) { if(strstr($string, $ref)) { return true; } }
	return false;
}
function drop_bad_comments() {
	if (!empty($_POST['comment'])) {
		$post_comment_content = $_POST['comment'];
		$lower_case_comment = strtolower($_POST['comment']);
		$bad_comment_content = 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, $bad_comment_content)) {
			$comment_box_text = wordwrap(trim($post_comment_content), 80, "\n  ", true);
			$txtdrop = fopen('/var/log/httpd/wp_post-logger/nullamatix.com-text-area_dropped.txt', 'a');
			fwrite($txtdrop, "  --------------\n  [COMMENT] = " . $post_comment_content . "\n  --------------\n");
			fwrite($txtdrop, "  [SOURCE_IP] = " . $_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.') );
		}
	}
}
add_action('init', 'drop_bad_comments');

En el array $bad_comment_content puedes añadir o quitar palabras y/o espresiones, para personalizar y ajustar tu filtrado de comentarios spam.

Fuente: Ayuda Wordpress

Palabras tags


Comparte esta entrada:

  • del.icio.us
  • Facebook
  • Mixx
  • email
  • LinkedIn
  • NewsVine
  • Reddit
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Buzz

Hay un comentario en “Combate el spam de tu Wordpress”

Escribe un comentario

Insertar número página automaticamente en Indesign CS3 - 16,336 VISITAS Crear gif animado en Photoshop CS3 - 12,643 VISITAS Trípticos y dípticos. Documentos de plantillas para Indesign - 6,274 VISITAS Definir estilos de parrafo y caracter en Indesign CS3 - 5,545 VISITAS 20 increibles videos creados con la Canon 7D - 3,728 VISITAS