Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BlockThem PHP Example
<?php
function isDomainBlocked($domain, $jsonFile) {
$domain = preg_replace('/^http(s?)\:\/\//', '', $domain);
$domain = preg_replace('/^www\./', '', $domain);
$domain = preg_replace('/\/$/', '', $domain);
$list = json_decode(file_get_contents($jsonFile), true);
return in_array($domain, $list);
}
// Example: Live
// Output: bool(false)
var_dump(isDomainBlocked('gmail.com', 'http://api.blockthem.io/v1/blacklist.json'));
// Example: Cached
// Output: bool(true)
var_dump(isDomainBlocked('mailinator.com', 'blacklist.json'));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment