Skip to content

Instantly share code, notes, and snippets.

@schplurtz
Created April 27, 2013 20:47
Show Gist options
  • Save schplurtz/55d6d712514a70562990 to your computer and use it in GitHub Desktop.
Save schplurtz/55d6d712514a70562990 to your computer and use it in GitHub Desktop.
patch to fix can't save array issue
From 22838985637b71a1a5fffa8f29bc6e8fa5911923 Mon Sep 17 00:00:00 2001
From: Schplurtz le déboulonné <Schplurtz@laposte.net>
Date: Sat, 27 Apr 2013 22:21:35 +0200
Subject: [PATCH] fix can't save array bug
---
action.php | 2 +-
conf/default.php | 2 +-
lang/en/settings.php | 12 ++++++++++++
lang/fr/settings.php | 12 ++++++++++++
4 files changed, 26 insertions(+), 2 deletions(-)
create mode 100644 lang/en/settings.php
create mode 100644 lang/fr/settings.php
diff --git a/action.php b/action.php
index 7ecaaab..e4aa2fb 100644
--- a/action.php
+++ b/action.php
@@ -86,7 +86,7 @@ class action_plugin_tokenbucketauth extends DokuWiki_Action_Plugin
$time = time();
/* If the user come from a whitelisted address */
- if(in_array($ip, $this->getConf('tba_whitelist')))
+ if(in_array($ip, preg_split( '/[\s,]+/', $this->getConf('tba_whitelist'), 0, PREG_SPLIT_NO_EMPTY )))
{
$this->unlock();
return;
diff --git a/conf/default.php b/conf/default.php
index 8a56097..2f75910 100644
--- a/conf/default.php
+++ b/conf/default.php
@@ -3,7 +3,7 @@
$conf['tba_block_time'] = 600; // Block a user 10 minutes
$conf['tba_nb_attempt'] = 5; // If he failed 5 attempts to login
$conf['tba_mean_time'] = 120; // Within 2 minutes
-$conf['tba_whitelist'] = array('127.0.0.1'); // And is not on the white list
+$conf['tba_whitelist'] = '127.0.0.1'; // And is not on the white list
$conf['tba_iptime_file'] = DOKU_PLUGIN.'tokenbucketauth/files/users.pbf'; // Log users attempts into this file
$conf['tba_block_file'] = DOKU_PLUGIN.'tokenbucketauth/files/block.pbf'; // Log blocked users into this one
diff --git a/lang/en/settings.php b/lang/en/settings.php
new file mode 100644
index 0000000..e9281c5
--- /dev/null
+++ b/lang/en/settings.php
@@ -0,0 +1,12 @@
+<?php
+$lang['tba_block_time'] = 'Block an IP address this amount of seconds';
+$lang['tba_nb_attempt'] = 'If the user failed a certain amount of attempts to login';
+$lang['tba_mean_time'] = 'Within a certain amount of seconds';
+$lang['tba_whitelist'] = 'And is not on the white list (comma or blank separated)';
+
+$lang['tba_iptime_file'] = 'Log users attempts into this file';
+$lang['tba_block_file'] = 'Log blocked users into this one';
+$lang['tba_lockfile'] = 'Lock file to know when we can put content into the two others';
+
+$lang['tba_send_mail'] = 'Define whom to send email when a user has been banned';
+
diff --git a/lang/fr/settings.php b/lang/fr/settings.php
new file mode 100644
index 0000000..86e4970
--- /dev/null
+++ b/lang/fr/settings.php
@@ -0,0 +1,12 @@
+<?php
+$lang['tba_block_time'] = 'Durée du blocage en secondes';
+$lang['tba_nb_attempt'] = 'Nombre de tentatives maximum d\'affilé avant blocage.';
+$lang['tba_mean_time'] = 'Temps maximum (en secondes) englobant l\'ensemble des tentatives infructueuses.';
+$lang['tba_whitelist'] = 'Liste d\'adresses IP séparées par une virgule ou un espace qui ne seront jamais bloquées.';
+
+$lang['tba_iptime_file'] = 'Fichier de comptage des tentatives de connexions.';
+$lang['tba_block_file'] = 'Fichier d\'enregistrement des utilisateurs bloqués.';
+$lang['tba_lockfile'] = 'Fichier verrou nécessaire à la gestion des autres fichiers.';
+
+$lang['tba_send_mail'] = 'Adresse de courriel où expédier les notifications de blocage.';
+
--
1.7.9.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment