我有以下代码来检查电子邮件是否是一次性的
最新更新:
Captcha
<?PHP
// Adapted for The Art of Web: www.the-art-of-web.com
// Please acknowledge use of this code by including this header.
// initialise image with dimensions of 120 x 30 pixels
$image = @imagecreatetruecolor(120, 30) or die("Cannot Initialize new GD image stream");
// set background to white and allocate drawing colours
$background = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
imagefill($image, 0, 0, $background);
$linecolor = imagecolorallocate($image, 0xCC, 0xCC, 0xCC);
$textcolor = imagecolorallocate($image, 0x33, 0x33, 0x33);
// draw random lines on canvas
for($i=0; $i < 6; $i++) {
imagesetthickness($image, rand(1,3));
imageline($image, 0, rand(0,30), 120, rand(0,30), $linecolor);
}
session_start();
// add random digits to canvas
$digit = '';
for($x = 15; $x <= 95; $x += 20) {
$digit .= ($num = rand(0, 9));
imagechar($image, rand(3, 5), $x, rand(2, 14), $num, $textcolor);
}
// record digits in session variable
$_SESSION['digit'] = $digit;
// display image and clean up
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>
注册的
<html>
<form method="POST" action="validate.php" onsubmit="return checkForm(this);">
Email:<br>
<p><input type="text" size="6" maxlength="10" name="email" value=""><br>
<p><img src="/captcha.php" width="120" height="30" border="1" alt="CAPTCHA"></p>
<p><input type="text" size="6" maxlength="5" name="captcha" value=""><br>
<p><input type="submit" size="6" maxlength="5" name="submit" value="Register"><br>
</form>
</html>
验证
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
if($_POST ) {
if($_POST['captcha'] != $_SESSION['digit'])
{
die("Sorry, the CAPTCHA code entered was incorrect!");
}
else
{
if(disposablecheck($_POST['email'])==0)
{
echo("great");
}
else
{
echo("nope");
}
}
_destroy();
}
else{
echo("yo");
}
function disposablecheck($email) {
$blacklist = array(
"0815.ru0clickemail.com",
"0wnd.net",
"0wnd.org",
"10minutemail.com",
"20minutemail.com",
"2prong.com",
"3d-painting.com",
"4warding.com",
"4warding.net",
"4warding.org",
"9ox.net",
"a-bc.net",
"amilegit.com",
"anonbox.net",
"anonymbox.com",
"antichef.com",
"antichef.net",
"antispam.de",
"baxomale.ht.cx",
"beefmilk.com",
"binkmail.com",
"bio-muesli.net",
"bobmail.info",
"bodhi.lawlita.com",
"bofthew.com",
"brefmail.com",
"bsnow.net",
"bugmenot.com",
"bumpymail.com",
"casualdx.com",
"chogmail.com",
"cool.fr.nf",
"correo.blogos.net",
"cosmorph.com",
"courriel.fr.nf",
"courrieltemporaire.com",
"curryworld.de",
"cust.in",
"dacoolest.com",
"dandikmail.com",
"deadaddress.com",
"despam.it",
"devnullmail.com",
"dfgh.net",
"digitalsanctuary.com",
"discardmail.com",
"discardmail.de",
"disposableaddress.com",
"disposemail.com",
"dispostable.com",
"dm.w3internet.co.uk example.com",
"dodgeit.com",
"dodgit.com",
"dodgit.org",
"dontreg.com",
"dontsendmespam.de",
"dump-email.info",
"dumpyemail.com",
"e4ward.com",
"email60.com",
"emailias.com",
"emailinfive.com",
"emailmiser.com",
"emailtemporario.com.br",
"emailwarden.com",
"ephemail.net",
"explodemail.com",
"fakeinbox.com",
"fakeinformation.com",
"fastacura.com",
"filzmail.com",
"fizmail.com",
"frapmail.com",
"garliclife.com",
"get1mail.com",
"getonemail.com",
"getonemail.net",
"girlsundertheinfluence.com",
"gishpuppy.com",
"great-host.in",
"gsrv.co.uk",
"guerillamail.biz",
"guerillamail.com",
"guerillamail.net",
"guerillamail.org",
"guerrillamail.com",
"guerrillamailblock.com",
"haltospam.com",
"hotpop.com",
"ieatspam.eu",
"ieatspam.info",
"ihateyoualot.info",
"imails.info",
"inboxclean.com",
"inboxclean.org",
"incognitomail.com",
"incognitomail.net",
"ipoo.org",
"irish2me.com",
"jetable.com",
"jetable.fr.nf",
"jetable.net",
"jetable.org",
"junk1e.com",
"kaspop.com",
"kulturbetrieb.info",
"kurzepost.de",
"lifebyfood.com",
"link2mail.net",
"litedrop.com",
"lookugly.com",
"lopl.co.cc",
"lr78.com",
"maboard.com",
"mail.by",
"mail.mezimages.net",
"mail4trash.com",
"mailbidon.com",
"mailcatch.com",
"maileater.com",
"mailexpire.com",
"mailin8r.com",
"mailinator.com",
"mailinator.net",
"mailinator2.com",
"mailincubator.com",
"mailme.lv",
"mailnator.com",
"mailnull.com",
"mailzilla.org",
"mbx.cc",
"mega.zik.dj",
"meltmail.com",
"mierdamail.com",
"mintemail.com",
"moncourrier.fr.nf",
"monemail.fr.nf",
"monmail.fr.nf",
"mt2009.com",
"mx0.wwwnew.eu",
"mycleaninbox.net",
"mytrashmail.com",
"neverbox.com",
"nobulk.com",
"noclickemail.com",
"nogmailspam.info",
"nomail.xl.cx",
"nomail2me.com",
"no-spam.ws",
"nospam.ze.tc",
"nospam4.us",
"nospamfor.us",
"nowmymail.com",
"objectmail.com",
"obobbo.com",
"onewaymail.com",
"ordinaryamerican.net",
"owlpic.com",
"pookmail.com",
"proxymail.eu",
"punkass.com",
"putthisinyourspamdatabase.com",
"quickinbox.com",
"rcpt.at",
"recode.me",
"recursor.net",
"regbypass.comsafe-mail.net",
"safetymail.info",
"sandelf.de",
"saynotospams.com",
"selfdestructingmail.com",
"sendspamhere.com",
"shiftmail.com",
"****mail.me",
"skeefmail.com",
"slopsbox.com",
"smellfear.com",
"snakemail.com",
"sneakemail.com",
"sofort-mail.de",
"sogetthis.com",
"soodonims.com",
"spam.la",
"spamavert.com",
"spambob.net",
"spambob.org",
"spambog.com",
"spambog.de",
"spambog.ru",
"spambox.info",
"spambox.us",
"spamcannon.com",
"spamcannon.net",
"spamcero.com",
"spamcorptastic.com",
"spamcowboy.com",
"spamcowboy.net",
"spamcowboy.org",
"spamday.com",
"spamex.com",
"spamfree24.com",
"spamfree24.de",
"spamfree24.eu",
"spamfree24.info",
"spamfree24.net",
"spamfree24.org",
"spamgourmet.com",
"spamgourmet.net",
"spamgourmet.org",
"spamherelots.com",
"spamhereplease.com",
"spamhole.com",
"spamify.com",
"spaminator.de",
"spamkill.info",
"spaml.com",
"spaml.de",
"spammotel.com",
"spamobox.com",
"spamspot.com",
"spamthis.co.uk",
"spamthisplease.com",
"speed.1s.fr",
"suremail.info",
"tempalias.com",
"tempemail.biz",
"tempemail.com",
"tempe-mail.com",
"tempemail.net",
"tempinbox.co.uk",
"tempinbox.com",
"tempomail.fr",
"temporaryemail.net",
"temporaryinbox.com",
"thankyou2010.com",
"thisisnotmyrealemail.com",
"throwawayemailaddress.com",
"tilien.com",
"tmailinator.com",
"tradermail.info",
"trash2009.com",
"trash-amil.com",
"trashmail.at",
"trash-mail.at",
"trashmail.com",
"trash-mail.com",
"trash-mail.de",
"trashmail.me",
"trashmail.net",
"trashymail.com",
"trashymail.net",
"tyldd.com",
"uggsrock.com",
"wegwerfmail.de",
"wegwerfmail.net",
"wegwerfmail.org",
"wh4f.org",
"whyspam.me",
"willselfdestruct.com",
"winemaven.info",
"wronghead.com",
"wuzupmail.net",
"xoxy.net",
"yogamaven.com",
"yopmail.com",
"yopmail.fr",
"yopmail.net",
"yuurok.com",
"zippymail.info",
"jnxjn.com",
"trashmailer.com",
"klzlk.com",
);
$email_split = explode('@', $email);
$email_domain = $email_split[1];
if (in_array($email_domain, $blacklist)) {
//Return 1, disposable email detected
return 1;
}
else {
//Return 0, no match found
return 0;
}
}
?>
即使我输入了正确的验证码,它也显示无效。
答案 0 :(得分:1)
在 validate.php
中尝试以下代码<?php
if ($_POST) {
session_start();
if ($_POST['captcha'] != $_SESSION['digit']) {
die("Sorry, the CAPTCHA code entered was incorrect!");
} else {
if (disposablecheck($_POST['email'])) {
echo("great");
} else {
echo("nope");
}
}
session_destroy();
} else {
echo("yo");
}
function disposablecheck($email) {
$blacklist = array("0815.ru0clickemail.com", "0wnd.net", "0wnd.org", "10minutemail.com", "20minutemail.com", "2prong.com", "3d-painting.com", "4warding.com", "4warding.net", "4warding.org", "9ox.net", "a-bc.net", "amilegit.com", "anonbox.net", "anonymbox.com", "antichef.com", "antichef.net", "antispam.de", "baxomale.ht.cx", "beefmilk.com", "binkmail.com", "bio-muesli.net", "bobmail.info", "bodhi.lawlita.com", "bofthew.com", "brefmail.com", "bsnow.net", "bugmenot.com", "bumpymail.com", "casualdx.com", "chogmail.com", "cool.fr.nf", "correo.blogos.net", "cosmorph.com", "courriel.fr.nf", "courrieltemporaire.com", "curryworld.de", "cust.in", "dacoolest.com", "dandikmail.com", "deadaddress.com", "despam.it", "devnullmail.com", "dfgh.net", "digitalsanctuary.com", "discardmail.com", "discardmail.de", "disposableaddress.com", "disposemail.com", "dispostable.com", "dm.w3internet.co.uk example.com", "dodgeit.com", "dodgit.com", "dodgit.org", "dontreg.com", "dontsendmespam.de", "dump-email.info", "dumpyemail.com", "e4ward.com", "email60.com", "emailias.com", "emailinfive.com", "emailmiser.com", "emailtemporario.com.br", "emailwarden.com", "ephemail.net", "explodemail.com", "fakeinbox.com", "fakeinformation.com", "fastacura.com", "filzmail.com", "fizmail.com", "frapmail.com", "garliclife.com", "get1mail.com", "getonemail.com", "getonemail.net", "girlsundertheinfluence.com", "gishpuppy.com", "great-host.in", "gsrv.co.uk", "guerillamail.biz", "guerillamail.com", "guerillamail.net", "guerillamail.org", "guerrillamail.com", "guerrillamailblock.com", "haltospam.com", "hotpop.com", "ieatspam.eu", "ieatspam.info", "ihateyoualot.info", "imails.info", "inboxclean.com", "inboxclean.org", "incognitomail.com", "incognitomail.net", "ipoo.org", "irish2me.com", "jetable.com", "jetable.fr.nf", "jetable.net", "jetable.org", "junk1e.com", "kaspop.com", "kulturbetrieb.info", "kurzepost.de", "lifebyfood.com", "link2mail.net", "litedrop.com", "lookugly.com", "lopl.co.cc", "lr78.com", "maboard.com", "mail.by", "mail.mezimages.net", "mail4trash.com", "mailbidon.com", "mailcatch.com", "maileater.com", "mailexpire.com", "mailin8r.com", "mailinator.com", "mailinator.net", "mailinator2.com", "mailincubator.com", "mailme.lv", "mailnator.com", "mailnull.com", "mailzilla.org", "mbx.cc", "mega.zik.dj", "meltmail.com", "mierdamail.com", "mintemail.com", "moncourrier.fr.nf", "monemail.fr.nf", "monmail.fr.nf", "mt2009.com", "mx0.wwwnew.eu", "mycleaninbox.net", "mytrashmail.com", "neverbox.com", "nobulk.com", "noclickemail.com", "nogmailspam.info", "nomail.xl.cx", "nomail2me.com", "no-spam.ws", "nospam.ze.tc", "nospam4.us", "nospamfor.us", "nowmymail.com", "objectmail.com", "obobbo.com", "onewaymail.com", "ordinaryamerican.net", "owlpic.com", "pookmail.com", "proxymail.eu", "punkass.com", "putthisinyourspamdatabase.com", "quickinbox.com", "rcpt.at", "recode.me", "recursor.net", "regbypass.comsafe-mail.net", "safetymail.info", "sandelf.de", "saynotospams.com", "selfdestructingmail.com", "sendspamhere.com", "shiftmail.com", "****mail.me", "skeefmail.com", "slopsbox.com", "smellfear.com", "snakemail.com", "sneakemail.com", "sofort-mail.de", "sogetthis.com", "soodonims.com", "spam.la", "spamavert.com", "spambob.net", "spambob.org", "spambog.com", "spambog.de", "spambog.ru", "spambox.info", "spambox.us", "spamcannon.com", "spamcannon.net", "spamcero.com", "spamcorptastic.com", "spamcowboy.com", "spamcowboy.net", "spamcowboy.org", "spamday.com", "spamex.com", "spamfree24.com", "spamfree24.de", "spamfree24.eu", "spamfree24.info", "spamfree24.net", "spamfree24.org", "spamgourmet.com", "spamgourmet.net", "spamgourmet.org", "spamherelots.com", "spamhereplease.com", "spamhole.com", "spamify.com", "spaminator.de", "spamkill.info", "spaml.com", "spaml.de", "spammotel.com", "spamobox.com", "spamspot.com", "spamthis.co.uk", "spamthisplease.com", "speed.1s.fr", "suremail.info", "tempalias.com", "tempemail.biz", "tempemail.com", "tempe-mail.com", "tempemail.net", "tempinbox.co.uk", "tempinbox.com", "tempomail.fr", "temporaryemail.net", "temporaryinbox.com", "thankyou2010.com", "thisisnotmyrealemail.com", "throwawayemailaddress.com", "tilien.com", "tmailinator.com", "tradermail.info", "trash2009.com", "trash-amil.com", "trashmail.at", "trash-mail.at", "trashmail.com", "trash-mail.com", "trash-mail.de", "trashmail.me", "trashmail.net", "trashymail.com", "trashymail.net", "tyldd.com", "uggsrock.com", "wegwerfmail.de", "wegwerfmail.net", "wegwerfmail.org", "wh4f.org", "whyspam.me", "willselfdestruct.com", "winemaven.info", "wronghead.com", "wuzupmail.net", "xoxy.net", "yogamaven.com", "yopmail.com", "yopmail.fr", "yopmail.net", "yuurok.com", "zippymail.info", "jnxjn.com", "trashmailer.com", "klzlk.com",);
$email_split = explode('@', $email);
if (in_array($email_split[1], $blacklist)) {
return 0;
} else {
return 1;
}
}
在你的HTML中
<html>
<form method="POST" action='validate.php' onsubmit="return checkForm(this);">
<p><img src="../captcha.php" width="120" height="30" border="1" alt="CAPTCHA"></p>
<p><input type="text" size="6" maxlength="5" name="captcha" value=""><br>
<p><input type="text" size="6" name="email" value=""><br>
<p><input type="submit" size="6" maxlength="5" name="submit" value="Register"><br>
</form>
</html>
在您的html代码中删除了电子邮件的最大长度以获取正确的邮件地址。