/** * Execute the 'login' command. * * @param string $command command name * * @param array $options option_name => value * * @param array $params list of additional parameters * * @return bool TRUE on success, FALSE for unknown commands, or * a PEAR error on failure * * @access public */ function doLogin($command, $options, $params) { $server = $this->config->get('master_server'); $remote = new PEAR_Remote($this->config); $username = $this->config->get('username'); if (empty($username)) { $username = @$_ENV['USER']; } $this->ui->outputData("Logging in to {$server}.", $command); list($username, $password) = $this->ui->userDialog($command, array('Username', 'Password'), array('text', 'password'), array($username, '')); $username = trim($username); $password = trim($password); $this->config->set('username', $username); $this->config->set('password', $password); $remote->expectError(401); $ok = $remote->call('logintest'); $remote->popExpect(); if ($ok === true) { $this->ui->outputData("Logged in.", $command); $this->config->store(); } else { return $this->raiseError("Login failed!"); } }