예제 #1
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $data = $db->fetch($db->select('authors', '*'), true);
     $tmp = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingUser);
     $ids = array();
     $rmfile = new \fpcm\model\files\tempfile(\fpcm\modules\nkorg\classicimporter\nkorgclassicimporter::mappingRolls);
     $rollmapping = $rmfile->getContent();
     $rollmapping = json_decode($rollmapping, true);
     if ($rmfile->getFilesize() > 0 && !is_array($rollmapping)) {
         trigger_error('Unable to parse user roll mapping file');
         die('0');
     }
     foreach ($data as $user) {
         $author = new \fpcm\model\users\author();
         $author->disablePasswordSecCheck();
         $author->setUserName(utf8_encode($user->sysusr));
         $author->setDisplayName(utf8_encode($user->name));
         $author->setEmail(utf8_encode($user->email));
         $author->setRegistertime($user->registertime);
         $roll = isset($rollmapping[$user->usrlevel]) ? $rollmapping[$user->usrlevel] : 3;
         $author->setRoll($roll);
         $author->setPassword(utf8_encode($user->sysusr));
         $author->setUserMeta(array());
         $res = $author->save();
         if ($res !== true) {
             if ($res == \fpcm\model\users\author::AUTHOR_ERROR_EXISTS) {
                 trigger_error('User import failed, user already exists: ' . $author->getUsername());
             } else {
                 trigger_error('Unable to import user: '******'Classic Importer: No user ids found, maybe no users imported...');
         die('0');
     }
     $tmp->setContent(json_encode($ids));
     $tmp->save();
     die('1');
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 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;
 }