From b2034fdfec040a67988e543a911208ef2491ce7a Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Sun, 22 Feb 2015 12:58:46 +0100 Subject: New RoundCube Plugins Git folder --- autologon/autologon.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 autologon/autologon.php (limited to 'autologon/autologon.php') diff --git a/autologon/autologon.php b/autologon/autologon.php new file mode 100644 index 0000000..9c7d5b6 --- /dev/null +++ b/autologon/autologon.php @@ -0,0 +1,48 @@ +add_hook('startup', array($this, 'startup')); + $this->add_hook('authenticate', array($this, 'authenticate')); + } + + function startup($args) + { + // change action to login + if (empty($_SESSION['user_id']) && !empty($_GET['_autologin']) && $this->is_localhost()) + $args['action'] = 'login'; + + return $args; + } + + function authenticate($args) + { + if (!empty($_GET['_autologin']) && $this->is_localhost()) { + $args['user'] = 'me'; + $args['pass'] = '******'; + $args['host'] = 'localhost'; + $args['cookiecheck'] = false; + $args['valid'] = true; + } + + return $args; + } + + function is_localhost() + { + return $_SERVER['REMOTE_ADDR'] == '::1' || $_SERVER['REMOTE_ADDR'] == '127.0.0.1'; + } + +} + -- cgit v1.2.3