4 * Sample plugin to try out some hooks.
5 * This performs an automatic login if accessed from localhost
7 class autologon extends rcube_plugin
9 public $task = 'login';
13 $this->add_hook('startup', array($this, 'startup'));
14 $this->add_hook('authenticate', array($this, 'authenticate'));
17 function startup($args)
19 $rcmail = rcmail::get_instance();
21 // change action to login
22 if (empty($_SESSION['user_id']) && !empty($_GET['_autologin']) && $this->is_localhost())
23 $args['action'] = 'login';
28 function authenticate($args)
30 if (!empty($_GET['_autologin']) && $this->is_localhost()) {
32 $args['pass'] = '******';
33 $args['host'] = 'localhost';
39 function is_localhost()
41 return $_SERVER['REMOTE_ADDR'] == '::1' || $_SERVER['REMOTE_ADDR'] == '127.0.0.1';