diff options
author | Hugues Hiegel <root@paranoid> | 2014-08-05 16:46:22 +0200 |
---|---|---|
committer | Hugues Hiegel <root@paranoid> | 2014-08-05 16:46:22 +0200 |
commit | 59478e06c25303a790a0840ab2ac30662c4ef781 (patch) | |
tree | 8d5e964a8f94adaef41efebb0597629f11495c42 /plugins/fail2ban/fail2ban.php | |
parent | 7c494b677f9e470ee0d32e62cfa8dc709f39e748 (diff) |
c'est la merde..working
Diffstat (limited to 'plugins/fail2ban/fail2ban.php')
-rw-r--r-- | plugins/fail2ban/fail2ban.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/plugins/fail2ban/fail2ban.php b/plugins/fail2ban/fail2ban.php new file mode 100644 index 000000000..c877e5c98 --- /dev/null +++ b/plugins/fail2ban/fail2ban.php @@ -0,0 +1,33 @@ +<?php +/** + * RoundCube Fail2Ban Plugin + * + * @version 1.1 + * @author Matt Rude [m@mattrude.com] + * @url http://mattrude.com/plugins/roundcube-fail2ban-plugin/ + * @license GPLv3 + */ +class fail2ban extends rcube_plugin +{ + function init() + { + $this->add_hook('login_failed', array($this, 'log')); + } + + function log($args) + { + $log_entry = 'FAILED login for ' .$args['user']. ' from ' .getenv('REMOTE_ADDR'); + $log_config = rcmail::get_instance()->config->get('log_driver'); + + if ($log_config == 'syslog'){ + syslog(LOG_WARNING, $log_entry); + } elseif ($log_config == 'file'){ + error_log('['.date('d-M-Y H:i:s O')."]: ".$log_entry."\n", 3, "logs/userlogins"); + } else { + echo 'WARNING!! The RoundCube Fail2Ban Plugin was unable to retrieve the log driver from the config, please check your config file for log_driver.'; + } + } + +} + +?> |