Changeset 13201 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/ui.php
- Timestamp:
- 02/12/2024 06:44:57 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/ui.php
r12208 r13201 198 198 wp_cache_add_global_groups( array( 'registration-limit' ) ); 199 199 200 $expand_to_range = function( $ip ) { 201 $ip = trim( $ip ); 202 $ips = [ $ip ]; 203 if ( str_ends_with( $ip, '.*' ) ) { 204 $ips = []; 205 $ip = substr( $ip, 0, -2 ); 206 foreach ( range( 0, 255 ) as $i ) { 207 $ips[] = $ip . '.' . $i; 208 } 209 } 210 211 return $ips; 212 }; 213 200 214 if ( $ip_allow ) { 201 wp_cache_set( $ip_allow, 'whitelist', 'registration-limit', DAY_IN_SECONDS ); 215 $time_to_allow = wp_unslash( $_POST['ip_allow_time'] ?? DAY_IN_SECONDS ); 216 $ip_allow = $expand_to_range( $ip_allow ); 217 foreach ( $ip_allow as $ip ) { 218 wp_cache_set( $ip, 'whitelist', 'registration-limit', $time_to_allow ); 219 } 220 221 printf( '<div class="notice notice-success"><p>%d IPs added to the allow list.</p></div>', count( $ip_allow ) ); 202 222 } 203 223 if ( $ip_block ) { 204 wp_cache_set( $ip_block, 999, 'registration-limit', DAY_IN_SECONDS ); 224 $time_to_block = wp_unslash( $_POST['ip_block_time'] ?? DAY_IN_SECONDS ); 225 $ip_block = $expand_to_range( $ip_block ); 226 foreach ( $ip_block as $ip ) { 227 wp_cache_set( $ip, 999, 'registration-limit', $time_to_block ); 228 } 229 230 printf( '<div class="notice notice-success"><p>%d IPs blocked from registration.</p></div>', count( $ip_block ) ); 205 231 } 206 232 } … … 253 279 254 280 echo '<tr> 255 <th>IP Block for 24hrs</th>281 <th>IP Block</th> 256 282 <td> 257 <input class="regular-text" type="text" name="ip_block" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" placeholder="xxx.xxx.xxx.xxx"> 258 <p><em>One IP only. IP will be blocked from registrations for 24hrs. </em></p> 283 <input class="regular-text" type="text" name="ip_block" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]|[*])$" placeholder="xxx.xxx.xxx.xxx"> 284 <select name="ip_block_time"> 285 <option value="86400">24hrs</option> 286 <option value="604800">7 days</option> 287 <option value="2592000">30 days</option> 288 </select> 289 <p><em>Single IP, or range specified as <code>1.2.3.*</code>. IP will be blocked from registrations for the selected time period. </em></p> 259 290 </td> 260 291 </tr>'; 261 292 262 293 echo '<tr> 263 <th>IP Allow for 24hrs</th>294 <th>IP Allow</th> 264 295 <td> 265 <input class="regular-text" type="text" name="ip_allow" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$" placeholder="xxx.xxx.xxx.xxx"> 266 <p><em>One IP only. IP will bypass per-IP limits on registrations for 24hrs. Will also bypass Jetpack Protect login limiter.</em></p> 296 <input class="regular-text" type="text" name="ip_allow" minlength="7" maxlength="15" size="15" pattern="^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]|[*])$" placeholder="xxx.xxx.xxx.xxx"> 297 <select name="ip_allow_time"> 298 <option value="86400">24hrs</option> 299 <option value="259200">3 days</option> 300 <option value="604800">7 days</option> 301 </select> 302 <p><em>Single IP, or range specified as <code>1.2.3.*</code>. IP will bypass per-IP limits on registrations for the selected time period. Will also bypass Jetpack Protect login limiter.</em></p> 267 303 </td> 268 304 </tr>';
Note: See TracChangeset
for help on using the changeset viewer.