load_config(); $this->debug = $rcmail->config->get('autologon_debug'); $this->autologon_data = $rcmail->config->get('autologon_data'); $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_valid_host()) $args['action'] = 'login'; return $args; } function authenticate($args) { if (!empty($_GET['_autologin']) && $this->is_valid_host()) { $args['user'] = $this->autologon_data[$_SERVER['REMOTE_ADDR']]['user']; $args['pass'] = $this->autologon_data[$_SERVER['REMOTE_ADDR']]['pass']; $args['host'] = ($this->autologon_data[$_SERVER['REMOTE_ADDR']]['host'] ? $this->autologon_data[$_SERVER['REMOTE_ADDR']]['host'] : 'localhost'); $args['cookiecheck'] = false; $args['valid'] = true; } return $args; } function is_valid_host() { if ($this->debug) { ob_start(); print_r($this->autologon_data[$_SERVER['REMOTE_ADDR']]); if ($this->debug) write_log('autologon_ext', 'autologon_data for '.$_SERVER['REMOTE_ADDR'].': '.ob_get_contents()); ob_end_clean(); } return is_array($this->autologon_data[$_SERVER['REMOTE_ADDR']]); } }