diff options
author | Hugues Hiegel <root@paranoid> | 2015-04-21 12:49:44 +0200 |
---|---|---|
committer | Hugues Hiegel <root@paranoid> | 2015-04-21 12:49:44 +0200 |
commit | 733f8e8d0ce6217d906d06dc4fb08e36d48ed794 (patch) | |
tree | cff28366ff63ea6596f8026e1698090bd0b9405c /plugins/autologon/autologon.php | |
parent | ef2e7b3f9d264ec146d4dae257b1e295ab3b462a (diff) | |
parent | a4ba3df54834ee90fb2c9930669f1229dc80261a (diff) |
Conflicts:
composer.json-dist
config/defaults.inc.php
plugins
plugins/acl/acl.js
plugins/acl/acl.php
plugins/acl/skins/classic/templates/table.html
plugins/acl/skins/larry/templates/table.html
plugins/enigma/README
plugins/enigma/config.inc.php.dist
plugins/enigma/enigma.js
plugins/enigma/enigma.php
plugins/enigma/lib/enigma_driver.php
plugins/enigma/lib/enigma_driver_gnupg.php
plugins/enigma/lib/enigma_driver_phpssl.php
plugins/enigma/lib/enigma_engine.php
plugins/enigma/lib/enigma_error.php
plugins/enigma/lib/enigma_key.php
plugins/enigma/lib/enigma_signature.php
plugins/enigma/lib/enigma_subkey.php
plugins/enigma/lib/enigma_ui.php
plugins/enigma/lib/enigma_userid.php
plugins/enigma/localization/en_US.inc
plugins/enigma/localization/ja_JP.inc
plugins/enigma/localization/ru_RU.inc
plugins/enigma/skins/classic/enigma.css
plugins/enigma/skins/classic/templates/keys.html
plugins/help/config.inc.php.dist
plugins/help/help.php
plugins/help/localization/en_US.inc
plugins/jqueryui/jqueryui.php
plugins/managesieve/Changelog
plugins/managesieve/composer.json
plugins/managesieve/config.inc.php.dist
plugins/managesieve/lib/Roundcube/rcube_sieve.php
plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php
plugins/managesieve/localization/en_US.inc
plugins/managesieve/managesieve.js
plugins/managesieve/skins/classic/managesieve.css
plugins/managesieve/skins/larry/managesieve.css
plugins/password/README
plugins/password/config.inc.php.dist
plugins/password/drivers/ldap.php
plugins/password/drivers/poppassd.php
plugins/password/drivers/vpopmaild.php
plugins/vcard_attachments/vcardattach.js
plugins/zipdownload/zipdownload.php
Diffstat (limited to 'plugins/autologon/autologon.php')
-rw-r--r-- | plugins/autologon/autologon.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/autologon/autologon.php b/plugins/autologon/autologon.php new file mode 100644 index 000000000..9c7d5b6fc --- /dev/null +++ b/plugins/autologon/autologon.php @@ -0,0 +1,48 @@ +<?php + +/** + * Sample plugin to try out some hooks. + * This performs an automatic login if accessed from localhost + * + * @license GNU GPLv3+ + * @author Thomas Bruederli + */ +class autologon extends rcube_plugin +{ + public $task = 'login'; + + function init() + { + $this->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'; + } + +} + |