/** * Logfiles auswerten * @return boolean */ public function processUsers() { if (!isset($this->funcParams[1])) { $this->output('Invalid params, no user id set', true); } $userId = (int) $this->funcParams[1]; $user = new \fpcm\model\users\author($userId); if (!$user->exists()) { $this->output('No user foudn give id ' . $userId, true); } switch ($this->funcParams[0]) { case self::FPCMCLI_PARAM_PASSWD: $this->output('Create new password for user ' . $user->getUsername() . '...'); $success = $user->resetPassword(true); if (!$success['updateOk']) { $this->output('Unable to reset password! Check system logs for further details.', true); } $this->output('Password set to ' . $success['password']); break; case self::FPCMCLI_PARAM_ENABLE: $this->output('Enable user ' . $user->getUsername() . '...'); if ($user->enable()) { $this->output('User successfully enabled!'); } else { $this->output('Failed to enable user!'); } break; case self::FPCMCLI_PARAM_DISBALE: $this->output('Disable user ' . $user->getUsername() . '...'); if ($user->disable()) { $this->output('User successfully disabled!'); } else { $this->output('Failed to disable user!'); } break; case self::FPCMCLI_PARAM_REMOVE: $this->output('Delete user ' . $user->getUsername() . '...'); if ($user->delete()) { $this->output('User deleted!'); } else { $this->output('Failed to delete user!'); } break; default: break; } return true; }
/** * Request-Handler * @return boolean */ public function request() { if ($this->session->exists()) { $this->redirect('system/dashboard'); } if (!$this->maintenanceMode(false)) { return false; } $this->pageTokenOk = $this->checkPageToken(); session_start(); $this->loginLocked(); if ($this->buttonClicked('login') && !is_null($this->getRequestVar('login')) && !$this->loginLocked && $this->pageTokenOk) { $data = $this->getRequestVar('login'); $data = $this->events->runEvent('loginBefore', $data); $session = new \fpcm\model\system\session(); $loginRes = $session->checkUser($data['username'], $data['password']); if ($loginRes === \fpcm\model\users\author::AUTHOR_ERROR_DISABLED) { $this->currentAttempts = $this->config->system_loginfailed_locked; $this->view->addErrorMessage('LOGIN_FAILED_DISABLED'); if ($this->currentAttempts == $this->config->system_loginfailed_locked) { $this->loginLocked(); } } elseif ($loginRes === true && $session->save() && $session->setCookie()) { session_destroy(); $this->redirect('system/dashboard'); } else { $this->currentAttempts++; \fpcm\classes\http::setSessionVar('loginAttempts', $this->currentAttempts); $this->view->addErrorMessage('LOGIN_FAILED'); if ($this->currentAttempts == $this->config->system_loginfailed_locked) { $this->loginLocked(); } } } if ($this->buttonClicked('reset') && !is_null($this->getRequestVar('username')) && !is_null($this->getRequestVar('email')) && !$this->loginLocked && $this->pageTokenOk) { $userList = new \fpcm\model\users\userList(); $id = $userList->getUserIdByUsername($this->getRequestVar('username')); if (!$id) { $this->redirect(); } $user = new \fpcm\model\users\author($id); if ($user->getEmail() == $this->getRequestVar('email') && $user->resetPassword()) { $this->view->addNoticeMessage('LOGIN_PASSWORD_RESET'); } else { \fpcm\classes\logs::syslogWrite("Passwort reset for user id {$user->getUsername()} failed."); $this->view->addErrorMessage('LOGIN_PASSWORD_RESET_FAILED'); } } if (!is_null($this->getRequestVar('nologin'))) { $this->view->addErrorMessage('LOGIN_REQUIRED'); } $reset = !is_null($this->getRequestVar('reset')) ? true : false; $this->view->assign('resetPasswort', $reset); $this->view->assign('noFullWrapper', true); return true; }