Skip to content

Commit 3f8bdbf

Browse files
Merge pull request #66 from julienloizelet/feature/65-use-json-settings-only-in-standalone
feat(config): Retrieve configurations from database if not standalone
2 parents 83ea792 + bd0b105 commit 3f8bdbf

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

inc/bounce-current-ip.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
use CrowdSecBouncer\Constants;
44

55
require_once __DIR__ . '/Bounce.php';
6+
require_once __DIR__.'/options-config.php';
7+
8+
function getConfigs()
9+
{
10+
$crowdSecWpPluginOptions = getCrowdSecOptionsConfig();
11+
$finalConfigs = [];
12+
foreach ($crowdSecWpPluginOptions as $option) {
13+
$finalConfigs[$option['name']] = get_option($option['name']);
14+
}
15+
16+
return $finalConfigs;
17+
}
18+
619

720
function safelyBounceCurrentIp()
821
{
@@ -13,14 +26,8 @@ function safelyBounceCurrentIp()
1326
if (\PHP_SESSION_NONE === session_status()) {
1427
session_start();
1528
}
16-
if (!file_exists(__DIR__.'/standalone-settings.php')) {
17-
return;
18-
}
19-
require_once __DIR__.'/standalone-settings.php';
20-
$crowdSecConfig = json_decode($crowdSecJsonStandaloneConfig, true);
21-
if (!count($crowdSecConfig)) {
22-
return;
23-
}
29+
30+
$crowdSecConfig = getConfigs();
2431
// Retro compatibility with crowdsec php lib < 0.14.0
2532
if($crowdSecConfig['crowdsec_bouncing_level'] === 'normal_boucing'){
2633
$crowdSecConfig['crowdsec_bouncing_level'] = Constants::BOUNCING_LEVEL_NORMAL;

0 commit comments

Comments
 (0)