From e873818d0884598cb869b5d2186b84f8fb73d92e Mon Sep 17 00:00:00 2001 From: ozh Date: Wed, 11 Dec 2013 18:33:58 +0100 Subject: [PATCH] Check first (with most frequent check first), then compute --- includes/functions.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 5c704e4..8a1f8d9 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1272,8 +1272,12 @@ function yourls_check_IP_flood( $ip = '' ) { ) return true; - $ip = ( $ip ? yourls_sanitize_ip( $ip ) : yourls_get_IP() ); - + // Don't throttle logged in users + if( yourls_is_private() ) { + if( yourls_is_valid_user() === true ) + return true; + } + // Don't throttle whitelist IPs if( defined( 'YOURLS_FLOOD_IP_WHITELIST' ) && YOURLS_FLOOD_IP_WHITELIST ) { $whitelist_ips = explode( ',', YOURLS_FLOOD_IP_WHITELIST ); @@ -1284,12 +1288,8 @@ function yourls_check_IP_flood( $ip = '' ) { } } - // Don't throttle logged in users - if( yourls_is_private() ) { - if( yourls_is_valid_user() === true ) - return true; - } - + $ip = ( $ip ? yourls_sanitize_ip( $ip ) : yourls_get_IP() ); + yourls_do_action( 'check_ip_flood', $ip ); global $ydb; -- 2.45.0