Hola, les traigo este sistema anti spam, basado en el captcha que esta en la sección de aportes de este Foro(PHP).
Les dejo algunos links utiles..
Descarga:
DESCARGAR
Demo:
DEMO
Bueno comenzamos:
index.php
Código PHP:
<?php
ob_start('ob_gzhandler');
session_start();
include 'form_inc.php';
if (($_POST[x])&&(substr($_SESSION[igif], 17) === $_SESSION['afloat'])){
$x = $_POST[x];
$a = base64_decode($_SESSION['afloat']);
$b = 0 + $a;
$a = explode(" ", $a);
$a = $a[3];
$bb = round($b);
$aa = round($a);
$gc = explode(" ", '0 19 40 60 82 104 79 100 121 142 163 185');
$ac = $aa + 6;
if ($bb <= $aa){ $ac = $bb + 1; }
$mess = "ERROR: Perdon " . $_POST[yname] . " tenes que clikear un el numero correcto";
if (($x >= $gc[$ac-1]) && ($x <= $gc[$ac])){
$to = $owner_email;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Por:<' . $_POST[email] . '>' . $_POST[yname] . "\r\n";
$messages = 'Mensaje: <br>' . $_POST[message] . '<p> Nombre <br>' . $_POST[yname] . '<p> E-mail <br>' . $_POST[email] . '<p> IP:<br>' . $_SERVER[REMOTE_ADDR] . '<p> Host:<br> ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . '<p> Navegador:<br> ' . $_SERVER[HTTP_USER_AGENT] . '<p><br>';
?>
<script>
alert("Gracias <? echo $yname; ?> tu mensaje sera enviado.");
window.location = "<?=$redirect;?>";
</script>
<?
exit; }
?>
<script>
alert("<?=$mess;?>");
window.location = window.location;
</script>
<?
session_unset();
session_destroy();
ob_end_flush();
exit;
}
$afloat = base64_encode(" " . $num1 = rand(0,3) . "." . $num2 = rand(100,999) . "
Float " . $num3 = rand(1,4) . "." . $num4 = rand(100,999) . " ");
$aler = "> 78";
if(round($num1 . "." . $num2) <= round($num3 . "." . $num4)) {$aler = "< 105";}
$_SESSION[igif] = "create_gif.php?a=" . $afloat . "";
$_SESSION['afloat'] = $afloat;
?>
<html>
<head>
<style type="text/css">
.cd {
width: 185px;
height: 15px;
background-image: url(<?=$_SESSION[igif];?>);
background-repeat: no-repeat;
position: relative;
left:<?=rand(-100,100);?>px;
bottom:<?=rand(-5,20);?>px;
z-index: 2;
}
</style>
<script language="JavaScript">
function submitform() {
if (document.xcoords.yname.value == "") {
alert("Por favor introduci tu nombre.");
return false; }
if (document.xcoords.email.value == "" || document.xcoords.email.value.indexOf("@")<1|| document.xcoords.email.value.indexOf(".")<1) {
alert("Por favor pone un email verdadero");
return false;}
if (document.xcoords.message.value == "") {
alert("Por favor introduci algun comentario");
return false; }
if (document.xcoords.x.value <?=$aler;?>) {
document.xcoords.submit();
} else {
alert("Tenes que clickear el numero correcto.");
} }
function xcoord(event) {
image = event.offsetX?(event.offsetX):event.pageX-document.getElementById("coord").offsetLeft;
document.xcoords.x.value = image;
}
</script>
</head>
<body style="background: <?=$backcolor;?>" link="<?=$linkcolor;?>" vlink="<?=$linkcolor;?>" alink="<?=$linkcolor;?>">
<div align="center"> <br><div style="border-right: 1px solid <?=$bordercolor;?>; border-left: 1px solid <?=$bordercolor;?>; background: #F8F8FF; width: 700px; border-top: 1px solid <?=$bordercolor;?>; border-bottom: 2px solid <?=$bordercolor;?>" align="center">
<table summary="" border="0">
<tr>
<td style="font: bold 18px Arial; color: <?=$fontcolor;?>" align="left"><?=$sitename;?> Contacto </td>
</tr>
<form name="xcoords" action="<?=$_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td align="left">
Nombre:
<input type="text" name="yname" size="40" maxlength="256" style="border: 1px solid <?=$bordercolor;?>">
</td>
</tr><tr>
<td align="left">Mail:
<input type="text" name="email" size="40" maxlength="256" style="border: 1px solid <?=$bordercolor;?>"></td></tr>
</table><table summary="" border="0">
<tr>
<td align="center">Mensaje.<br>
<textarea name="message" cols="30" rows="7" style="border: 1px solid <?=$bordercolor;?>; background: #F5F5F5"></textarea>
<input type="hidden" name="x" /> </td>
</tr>
</table><table border="0"><tr>
<td style="font: 11px Arial; color: <?=$bordercolor;?>; border-color: <?=$bordercolor;?>; border-style: solid; border-width: 1px; background: #F8F8FF; height: 30px; width: 189px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; position: relative; font-weight: normal;">Haz click en el numero que le sigue a la palabra 'CLICK' </td>
</tr>
</table></form><p><div id="coord" onClick="submitform(xcoord(event))" class="cd"></div></div><p>
</div>
</body></html><?php ob_end_flush(); ?>
create_gif.php
Código PHP:
<?php
ob_start('ob_gzhandler');
session_start();
$a = $_GET['a'];
if ($a == $_SESSION['afloat']){
$a = base64_decode($a);
$im = imagecreatetruecolor (185, 15);
$myn = array($ooon = rand(81,99), $tooo = rand(61,$ooon-1), $trif = rand(41,$tooo-1),
$foey = rand(21,$trif-1), $flit = rand(11,$foey-1));
$rn = array_rand($myn, 5);
$mynum = " " . $myn[$rn[0]] . " " . $myn[$rn[1]] . " " . $myn[$rn[2]] . " " . $myn[$rn[3]] . " " . $myn[$rn[4]] . "";
$b = 0 + $a;
$a = explode(" ", $a);
$a = $a[3];
$aa = round($a);
$bb = round($b);
$na = 79;
$nb = 185;
$nc = 82;
$nd = 182;
$ims = -1;
$ab = explode(" ", $mynum);
$mystring = "Click $ab[$aa] $mynum";
if ($bb <= $aa){
$aa = $bb + 1;
$mystring = "" . $mynum . " Click $ab[$aa] ";
$na = 0;
$nb = 106;
$nc = 4;
$nd = 104;
$ims = -9;
}
$change = rand(1,9);
$lime = imagecolorallocate($im,0,255,0);
$yellow = imagecolorallocate($im,255,255,0);
$white = imagecolorallocate($im,255,255,255);
$lgray = imagecolorallocate($im,206,206,206);
$gray = imagecolorallocate($im,115,115,115);
$black = imagecolorallocate($im,0,0,0);
$green = imagecolorallocate($im,1,107,0);
$grc = " $lime $yellow $white $lgray $yellow $white $gray $black $green";
$rc = explode(" ", $grc);
$bgc = $rc[$change];
$bc = imagecolorallocate ($im, 0, 0, 0);
$rd = imagecolorallocate ($im, 255, 0, 0);
$wh = imagecolorallocate ($im, 255, 255, 255);
if (($change > 3) && ($change < 7)) { $bc = $rd;}
elseif ($change > 6) { $bc = $wh;}
imagefilledrectangle ($im, 1, 1, 184, 15, $bgc);
imagerectangle ($im, 0, 0, 184, 14, $bc);
for($i=$na;$i<=$nb;$i+=21)
imageline($im,$i,0,$i,15,$bc);
imagestring ($im, 3, $ims, 1, " $mystring", $bc);
header("Content-Type: image/gif");
imagegif($im);
imagedestroy($im);
}
ob_end_flush();
?>
form_inc.php Código PHP:
<?php
$owner_email = "[email protected]";
$redirect = "http://www.tuweb.com";
$sitename = "Simple Sistema de Anti Spam by MaTyS";
$backcolor = "white";
$linkcolor = "maroon";
$bordercolor = "maroon";
$fontcolor = "maroon";
?>
ESPERO QUE LES SEA UTIL :).