Skip to content

Instantly share code, notes, and snippets.

@joshcanhelp
Created July 29, 2013 23:55
Show Gist options
  • Save joshcanhelp/6108952 to your computer and use it in GitHub Desktop.
Save joshcanhelp/6108952 to your computer and use it in GitHub Desktop.
Get and parse blocked IPs
$blocked = get_option('blacklist_keys');
$blocked = str_replace( "\r", "\n", $blocked );
$blocked_arr = explode( "\n", $blocked );
$blocked_arr = array_map('trim', $blocked_arr);
$final_blocked_arr = array();
foreach ($blocked_arr as $ip) {
$ip = trim($ip);
if ( filter_var( $ip, FILTER_VALIDATE_IP ) ) {
$final_blocked_arr[] = $ip;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment