user = $user; $this->errorLogin = false; if (process_user_login($this->user, $password)) { $this->logged = true; $this->hackInjectConfig(); } else { $this->logged = false; } } public static function getInstance() { if (!(self::$instance instanceof self)) { //Check if in the session $system = System::getInstance(); $user = $system->getSession('user', null); if (!empty($user)) { self::$instance = $user; } else { self::$instance = new self; } } return self::$instance; } public function hackInjectConfig() { //hack to compatibility with pandora if ($this->logged) { global $config; $system = System::getInstance(); $config['id_user'] = $this->user; $system->setSessionBase('id_usuario', $this->user); $system->setSession('user', $this); } } public function isLogged() { $system = System::getInstance(); $autologin = $system->getRequest('autologin', false); if ($autologin) { $user = $system->getRequest('user', null); $password = $system->getRequest('password', null); if ($this->checkLogin($user, $password)) { $this->hackInjectConfig(); } } return $this->logged; } public function checkLogin($user = null, $password = null) { $system = System::getInstance(); if (($user == null) && ($password == null)) { $user = $system->getRequest('user', null); $password = $system->getRequest('password', null); } if (!empty($user) && !empty($password)) { if (process_user_login($user, $password) !== false) { $this->logged = true; $this->user = $user; $this->errorLogin = false; } else { $this->logged = false; $this->errorLogin = true; } } if ($this->logged) { $this->hackInjectConfig(); if (! check_acl($system->getConfig('id_user'), 0, "AR")) { db_pandora_audit("ACL Violation", "Trying to access Agent Data view"); require ("../general/noaccess.php"); return; } } return $this->logged; } public function logout() { $this->user = null; $this->logged = false; $this->errorLogin = false; $this->logout_action = true; $system = System::getInstance(); $system->setSession('user', null); } public function showLogin() { global $pandora_version; $ui = Ui::getInstance(); $ui->createPage(); if ($this->errorLogin) { $options['type'] = 'onStart'; $options['title_text'] = __('Login Failed'); $options['content_text'] = __('User not found in database or incorrect password.'); $ui->addDialog($options); } if ($this->logout_action) { $options['type'] = 'onStart'; $options['title_text'] = __('Login out'); $options['content_text'] = __('Your session is over. Please close your browser window to close this Pandora session.'); $ui->addDialog($options); } $ui->createHeader(); $ui->showFooter(false); $ui->beginContent(); $ui->contentAddHtml('