Пример #1
0
     foreach ($banned_ips_post as $banned_ip) {
         if ($admin_login == 'admin' && ($banned_ip == ban_get_ip() || is_admin_ip($banned_ip))) {
             $text .= '<p style="color: blue;">' . sprintf(__('This IP \'%s\' Belongs To The Admin And Will Not Be Added To Ban List', 'wp-ban'), $banned_ip) . '</p>';
         } else {
             $banned_ips[] = trim($banned_ip);
         }
     }
 }
 if (!empty($banned_ips_range_post)) {
     $banned_ips_range = array();
     foreach ($banned_ips_range_post as $banned_ip_range) {
         $range = explode('-', $banned_ip_range);
         if (sizeof($range) === 2) {
             $range_start = trim($range[0]);
             $range_end = trim($range[1]);
             if ($admin_login === 'admin' && check_ip_within_range(ban_get_ip(), $range_start, $range_end)) {
                 $text .= '<p style="color: blue;">' . sprintf(__('The Admin\'s IP \'%s\' Fall Within This Range (%s - %s) And Will Not Be Added To Ban List', 'wp-ban'), ban_get_ip(), $range_start, $range_end) . '</p>';
             } else {
                 $banned_ips_range[] = trim($banned_ip_range);
             }
         }
     }
 }
 if (!empty($banned_hosts_post)) {
     $banned_hosts = array();
     foreach ($banned_hosts_post as $banned_host) {
         if ($admin_login == 'admin' && ($banned_host == @gethostbyaddr(ban_get_ip()) || is_admin_hostname($banned_host))) {
             $text .= '<p style="color: blue;">' . sprintf(__('This Hostname \'%s\' Belongs To The Admin And Will Not Be Added To Ban List', 'wp-ban'), $banned_host) . '</p>';
         } else {
             $banned_hosts[] = trim($banned_host);
         }
Пример #2
0
function process_ban_ip_range($banned_ips_range)
{
    if (!empty($banned_ips_range)) {
        foreach ($banned_ips_range as $banned_ip_range) {
            $range = explode('-', $banned_ip_range);
            $range_start = trim($range[0]);
            $range_end = trim($range[1]);
            if (check_ip_within_range(ban_get_ip(), $range_start, $range_end)) {
                print_banned_message();
                break;
            }
        }
    }
}