Skip to content

Instantly share code, notes, and snippets.

@microdesign
Created September 24, 2016 13:28
Show Gist options
  • Save microdesign/94f20b4d50e4a69fbee8233df92e35c3 to your computer and use it in GitHub Desktop.
Save microdesign/94f20b4d50e4a69fbee8233df92e35c3 to your computer and use it in GitHub Desktop.
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$code = file_get_contents('https://ipapi.co/'.$ip.'/country/');
$bannedCountries = ['IT', 'AU', 'MY', 'HK']; //Replace with your countries
if (in_array($code, $bannedCountries)) {
die('No access');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment