Skip to content

Instantly share code, notes, and snippets.

@RyanHarijanto
Last active October 3, 2015 09:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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