Changeset 3053310
- Timestamp:
- 03/18/2024 10:04:23 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ip-guard/tags/v1.23.1/ip-guard.php
r3052132 r3053310 56 56 57 57 function ip_addresses_similar($ip_addresses) { 58 $subnet_mask = ip2long('255.255.0.0'); 59 60 $first_ip = reset($ip_addresses); 58 $ip_groups = []; 61 59 foreach ($ip_addresses as $ip) { 62 if (!subnet_match($first_ip, $ip, $subnet_mask)) { 60 $first_octet = explode('.', $ip)[0]; 61 $ip_groups[$first_octet][] = $ip; 62 } 63 64 foreach ($ip_groups as $group) { 65 if (!all_ip_addresses_similar_in_group($group)) { 63 66 return false; 64 67 } 65 68 } 69 66 70 return true; 67 71 } 68 72 69 function subnet_match($ip1, $ip2, $subnet_mask) { 70 $ip1_long = ip2long($ip1); 71 $ip2_long = ip2long($ip2); 72 $network1 = $ip1_long & $subnet_mask; 73 $network2 = $ip2_long & $subnet_mask; 74 return ($network1 === $network2); 73 function all_ip_addresses_similar_in_group($ip_group) { 74 $first_ip_octets = explode('.', reset($ip_group)); 75 76 foreach ($ip_group as $ip) { 77 $current_ip_octets = explode('.', $ip); 78 79 if (count($first_ip_octets) !== count($current_ip_octets)) { 80 return false; 81 } 82 83 for ($i = 1; $i < count($first_ip_octets); $i++) { 84 if ($first_ip_octets[$i] !== $current_ip_octets[$i]) { 85 return false; 86 } 87 } 88 } 89 90 return true; 75 91 } 76 92 … … 257 273 add_submenu_page( 258 274 'ip_guard_admin_page', 259 __('Donat ion', 'ip-guard'),260 __('Donat ion', 'ip-guard'),275 __('Donate', 'ip-guard'), 276 __('Donate', 'ip-guard'), 261 277 'manage_options', 262 278 'ip_guard_donation_page',
Note: See TracChangeset
for help on using the changeset viewer.