Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Apply to shorewall, intended for use as a cron script
$url = '';
$cachefile = '/tmp/';
$cachetime = 0 + @filemtime($cachefile);
$url = $url . $cachetime;
$result = file_get_contents($url);
if (is_string($result)) {
file_put_contents($cachefile, $result, FILE_APPEND);
$arr = explode("\n", $result);
foreach ($arr as $ip) {
if(strlen($ip)) {
echo "Blocking ${ip}\n";
shell_exec("shorewall drop ".escapeshellarg($ip));
} else {
echo "Failed to update blocklist";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment