Created
July 6, 2014 01:33
-
-
Save ariscop/4744a3da2fa93a055798 to your computer and use it in GitHub Desktop.
Apply blocklist.de to shorewall, intended for use as a cron script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://api.blocklist.de/getlast.php?time='; | |
$cachefile = '/tmp/blocklist.de.cache'; | |
$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