You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: inc/admin/advanced-settings.php
+28-18Lines changed: 28 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,9 @@ function adminAdvancedSettings()
23
23
$bouncer = newBouncer($configs);
24
24
$bouncer->clearCache();
25
25
$refresh = $bouncer->refreshBlocklistCache();
26
-
$result = $refresh['new']??0;
27
-
$message = __('As the stream mode is enabled, the cache has just been refreshed, '.($result > 1 ? 'there are now '.$result.' decisions' : 'there is now '.$result.' decision').' in cache.');
26
+
$new = $refresh['new']??0;
27
+
$deleted = $refresh['deleted']??0;
28
+
$message = __('As the stream mode is enabled, the cache has just been refreshed. New decision(s): '.$new.'. Deleted decision(s): '. $deleted);
28
29
AdminNotice::displaySuccess($message);
29
30
scheduleBlocklistRefresh();
30
31
}, function () {
@@ -54,11 +55,9 @@ function adminAdvancedSettings()
54
55
$bouncer = newBouncer($configs);
55
56
$bouncer->clearCache();
56
57
$refresh = $bouncer->refreshBlocklistCache();
57
-
$result = $refresh['new']??0;
58
-
$message = __('As the stream mode refresh duration changed, the cache has just been refreshed, ' .
59
-
($result > 1 ? 'there are now '.$result.' decisions' : 'there is now '.$result.' decision')
60
-
. ' in cache.'
61
-
);
58
+
$new = $refresh['new']??0;
59
+
$deleted = $refresh['deleted']??0;
60
+
$message = __('As the stream mode refresh duration changed, the cache has just been refreshed. New decision(s): '.$new.'. Deleted decision(s): '. $deleted);
62
61
AdminNotice::displaySuccess($message);
63
62
scheduleBlocklistRefresh();
64
63
}
@@ -170,8 +169,9 @@ function adminAdvancedSettings()
170
169
// system
171
170
$bouncer->clearCache();
172
171
$result = $bouncer->refreshBlocklistCache();
173
-
$count = $result['new'];
174
-
$message .= __('As the stream mode is enabled, the cache has just been refreshed, '.($count > 1 ? 'there are now '.$count.' decisions' : 'there is now '.$count.' decision').' in cache.');
172
+
$new = $result['new']??0;
173
+
$deleted = $result['deleted']??0;
174
+
$message = __('As the stream mode is enabled, the cache has just been refreshed. New decision(s): '.$new.'. Deleted decision(s): '. $deleted);
175
175
AdminNotice::displaySuccess($message);
176
176
scheduleBlocklistRefresh();
177
177
}
@@ -190,24 +190,34 @@ function adminAdvancedSettings()
}, ' seconds. <p>The duration between re-asking Local API about an already checked clean IP.<br>Minimum 1 second.<br> Note that this setting can not be apply in stream mode.', '...', 'width: 115px;', 'number', (bool) get_option('crowdsec_stream_mode'));
201
206
202
207
// Field "crowdsec_bad_ip_cache_duration"
203
208
addFieldString('crowdsec_bad_ip_cache_duration', 'Recheck bad IPs each<br>(live mode only)', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_cache', function ($input) {
204
-
if (!get_option('crowdsec_stream_mode') && (int) $input <= 0) {
205
-
add_settings_error('Recheck bad IPs each', 'crowdsec_error', 'Recheck bad IPs each: Minimum is 1 second.');
209
+
if(!empty($input)) {
210
+
if (!get_option('crowdsec_stream_mode') && !empty($input) && (int)$input <= 0) {
211
+
add_settings_error('Recheck bad IPs each', 'crowdsec_error', 'Recheck bad IPs each: Minimum is 1 second.');
}, ' seconds. <p>The duration between re-asking Local API about an already checked bad IP.<br>Minimum 1 second.<br> Note that this setting can not be apply in stream mode.', '...', 'width: 115px;', 'number', (bool) get_option('crowdsec_stream_mode'));
212
222
213
223
// Field "crowdsec_captcha_cache_duration"
@@ -350,7 +360,7 @@ function convertInlineIpRangesToComparableIpBounds(string $inlineIpRanges): arra
Copy file name to clipboardExpand all lines: inc/admin/init.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -45,8 +45,9 @@ function clearBouncerCacheInAdminPage()
45
45
// In stream mode, immediatelly warm the cache up.
46
46
if (get_option('crowdsec_stream_mode')) {
47
47
$refresh = $bouncer->refreshBlocklistCache();
48
-
$result = $refresh['new']??0;
49
-
$message .= __(' As the stream mode is enabled, the cache has just been refreshed, '.($result > 1 ? 'there are now '.$result.' decisions' : 'there is now '.$result.' decision').' in cache.');
48
+
$new = $refresh['new']??0;
49
+
$deleted = $refresh['deleted']??0;
50
+
$message .= __(' As the stream mode is enabled, the cache has just been refreshed. New decision(s): '.$new.'. Deleted decision(s): '. $deleted);
50
51
}
51
52
52
53
AdminNotice::displaySuccess($message);
@@ -77,7 +78,10 @@ function refreshBouncerCacheInAdminPage()
77
78
$configs = getDatabaseConfigs();
78
79
$bouncer = newBouncer($configs);
79
80
$result = $bouncer->refreshBlocklistCache();
80
-
AdminNotice::displaySuccess(__(' The cache has just been refreshed ('.($result['new'] > 0 ? $result['new'].' new decisions' : $result['new'].' new decision').', '.$result['deleted'].' deleted).'));
81
+
$new = $result['new']??0;
82
+
$deleted = $result['deleted']??0;
83
+
$message = __('The cache has just been refreshed. New decision(s): '.$new.'. Deleted decision(s): '. $deleted);
0 commit comments