miércoles, 21 de marzo de 2012

BlackMail - Evitar registros fraudulentos con correos temporales

He desarrollado una utilidad para evitar los registros fraudulentos, después de mucho buscar en Internet veo que éste tema está verde, así que me he decidido a hacerlo yo mismo.

Voy a añadir más funciones como obtener el listado en un array para otros usos, la idea es tener una blacklist actualizada.
function bmCheck ( $m ) {
$cUrl = 'http://blackmail.api.l3o.org/'; $q = http_build_query ( array ( 'm' => $m ) );
return file_get_contents ( $cUrl , false , stream_context_create ( array ( 'http' => array ( 'method' => 'POST' , 'header' => "Connection: close\r\nContent-Length: " . strlen ( $q ) . "\r\n" , 'content' => $q ) ) ) );
}


La función trabaja con un correo completo (ej. blackmail@mail.ru) o también se le puede pasar sólo el dominio (ej. yopmail.com), la función devolvera '1' si el dominio no existe en la lista o '0' si existe.

Página:
http://blackmail.api.l3o.org/

Página de prueba:
http://dev.l3o.org/bm/

Código de la página de prueba:
index.php


<?php

 function bmCheck ( $m ) {
  $cUrl = 'http://blackmail.api.l3o.org/'; $q = http_build_query ( array ( 'm' => $m ) );
  return file_get_contents ( $cUrl , false , stream_context_create ( array ( 'http' => array ( 'method' => 'POST' , 'header' => "Connection: close\r\nContent-Length: " . strlen ( $q ) . "\r\n" , 'content' => $q ) ) ) );
    }

 if ( $_POST['mail'] ) {
  $r = (bmCheck ( $_POST['mail'] )) ? 'Correo válido' : 'Correo inválido' ;
  echo $r;
    }

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BlackMail TEST</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="index.php">
  <input type="text" name="mail" id="mail" /><br />
  <input type="submit" name="button" id="button" value="Enviar" />
</form>
</body>
</html>

No hay comentarios:

Publicar un comentario