Skip to content

Instantly share code, notes, and snippets.

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
What would you like to do?
BlockThem PHP Example
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('', ''));
// Example: Cached
// Output: bool(true)
var_dump(isDomainBlocked('', 'blacklist.json'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment