Created
July 29, 2013 23:55
-
-
Save joshcanhelp/6108952 to your computer and use it in GitHub Desktop.
Get and parse blocked IPs
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
$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