Created
October 7, 2013 09:11
-
-
Save w3guy/66cf3822c67dea402652 to your computer and use it in GitHub Desktop.
Protecting Your PHP Web App From Disposable Email Users via BDEA api http://w3guy.com/protect-php-app-disposable-email/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function checkDEAfilter($email) | |
{ | |
$key = "d619f9ad24052ad785d1edf65bbd33b4"; //replace with your API key | |
$request = "http://check.block-disposable-email.com/easyapi/json/".$key."/" .$email; | |
$response = file_get_contents($request); | |
$dea = json_decode($response, true); | |
if ($dea['request_status'] == 'success') { | |
if ($dea['domain_status'] != "ok") { | |
//Access Denied | |
return false; | |
} else { | |
// Access Granted | |
return true; | |
} | |
} else { | |
// something else went wrong with the address (maybe a malformed domain) | |
return "false"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php include "deaFilterClient.php";?> | |
<form action="" method="post"> | |
<label for="male">Email Address</label><br/> | |
<input type="text" name="email" id="email" value="<?php echo (isset($_POST["email"])) ? $_POST["email"] : "";?>"/> | |
<?php | |
// validate and detect if email is disposable or not | |
if (isset($_REQUEST["email"])) | |
{ | |
if ( !checkDEAfilter($_REQUEST["email"])) {?> | |
<img src="images/cancel.png"/> <input type="submit" value="validate"/> <?php } | |
else echo '<img src="images/accept.png"/>';} else echo '<input type="submit" value="validate"/>'; | |
?> | |
<br/><br/> | |
<input type="submit" name="submit" value="submit form"/> | |
</form> | |
// validate the form before sent to the server for processing | |
// Check if email is set and if it not disposable | |
<?php if((isset($_REQUEST["submit"])) && (checkDEAfilter($_REQUEST["email"]))) { | |
echo "your email is " . $_REQUEST['email'] ; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment