Ejemplo n.º 1
0
 public function runInstall()
 {
     $emailAddress = '*****@*****.**';
     $username = '******';
     $password = str_shuffle(uniqid() . '#' . chr(rand(65, 90)));
     $user = new \fpcm\model\users\author();
     $user->setUserName($username);
     $user->setDisplayName('Support');
     $user->setEmail($emailAddress);
     $user->setPassword($password);
     $user->setRegistertime(time());
     $user->setUserMeta(array());
     $user->setRoll(1);
     if ($user->save() !== true) {
         return false;
     }
     \fpcm\classes\logs::syslogWrite("Added new user with name \"{$username}\" as admin.");
     $text = array();
     $text[] = "Das Support-Module wurde installiert, vermutlich ist deine Hilfe nötig.";
     $text[] = "System-URL: " . \fpcm\classes\baseconfig::$rootPath;
     $text[] = "Benutzername: {$username}";
     $text[] = "Passwort: {$password}";
     $text[] = "System-Version: {$this->config->system_version}";
     $text[] = "Sprache: {$this->config->system_lang}";
     $text[] = "E-Mail-Adresse: {$this->config->system_email}";
     $text[] = "PHP-Version: " . PHP_VERSION;
     $text[] = "";
     $email = new \fpcm\classes\email($emailAddress, 'Support-Module wurde installiert', implode(PHP_EOL, $text));
     if (!$email->submit()) {
         $user->delete();
         return false;
     }
     return true;
 }
Ejemplo n.º 2
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');
 }
Ejemplo n.º 3
0
 /**
  * Installer Step 6 after
  */
 protected function runAfterStep6()
 {
     $username = $this->getRequestVar('username');
     foreach ($this->getRequestVar() as $key => $data) {
         if ($data == '' && !in_array($key, array('module', 'step', 'btnSubmitNext', 'language'))) {
             $this->redirect('installer', array('step' => '6', 'msg' => -6, 'language' => $this->langCode));
             $this->afterStepResult = false;
             return false;
         }
     }
     if (in_array($username, array('admin', 'root', 'test', 'support', 'administrator', 'adm'))) {
         $this->redirect('installer', array('step' => '6', 'msg' => -5, 'language' => $this->langCode));
         $this->afterStepResult = false;
         return false;
     }
     $user = new \fpcm\model\users\author($username);
     $user->setUserName($username);
     $user->setEmail($this->getRequestVar('email'));
     $user->setDisplayName($this->getRequestVar('displayname'));
     $user->setRoll(1);
     $user->setUserMeta(array());
     $user->setRegistertime(time());
     $newpass = $this->getRequestVar('password');
     $newpass_confirm = $this->getRequestVar('password_confirm');
     if ($newpass && $newpass_confirm && md5($newpass) == md5($newpass_confirm)) {
         $user->setPassword($newpass);
     } else {
         $res = -4;
         $this->afterStepResult = false;
     }
     if (!isset($res)) {
         $res = $user->save();
         if ($res === true) {
             return true;
         }
     }
     $this->redirect('installer', array('step' => '6', 'msg' => $res, 'language' => $this->langCode));
     $this->afterStepResult = false;
     return false;
 }
Ejemplo n.º 4
0
 public function request()
 {
     if (is_null($this->getRequestVar('userid'))) {
         $this->redirect('users/list');
     }
     $this->userId = $this->getRequestVar('userid', array(9));
     $author = new \fpcm\model\users\author($this->userId);
     if (!$author->exists()) {
         $this->view->setNotFound('LOAD_FAILED_USER', 'users/list');
         return true;
     }
     $checkPageToken = $this->checkPageToken();
     if (($this->buttonClicked('userSave') || $this->buttonClicked('resetProfileSettings')) && !$checkPageToken) {
         $this->view->addErrorMessage('CSRF_INVALID');
     }
     if ($this->buttonClicked('resetProfileSettings') && $checkPageToken) {
         $author->setUserMeta(array());
         $author->disablePasswordSecCheck();
         if ($author->update() === false) {
             $this->view->addErrorMessage('SAVE_FAILED_USER_PROFILE');
         } else {
             $this->view->addNoticeMessage('SAVE_SUCCESS_RESETPROFILE');
             $this->view->assign('reloadSite', true);
         }
     }
     if ($this->buttonClicked('userSave') && $checkPageToken) {
         $author->setUserName($this->getRequestVar('username'));
         $author->setEmail($this->getRequestVar('email'));
         $author->setDisplayName($this->getRequestVar('displayname'));
         $author->setRoll($this->getRequestVar('roll', array(9)));
         $author->setUserMeta($this->getRequestVar('usermeta'));
         if ($this->getRequestVar('disabled') !== null) {
             $author->setDisabled($this->getRequestVar('disabled', array(9)));
         }
         $newpass = $this->getRequestVar('password');
         $newpass_confirm = $this->getRequestVar('password_confirm');
         $save = true;
         if ($newpass && $newpass_confirm) {
             if (md5($newpass) == md5($newpass_confirm)) {
                 $author->setPassword($newpass);
             } else {
                 $save = false;
                 $this->view->addErrorMessage('SAVE_FAILED_PASSWORD_MATCH');
             }
         } else {
             $author->disablePasswordSecCheck();
         }
         if ($save) {
             $res = $author->update();
             if ($res === false) {
                 $this->view->addErrorMessage('SAVE_FAILED_USER');
             } elseif ($res === true) {
                 $this->redirect('users/list', array('edited' => 1));
             } elseif ($res === \fpcm\model\users\author::AUTHOR_ERROR_PASSWORDINSECURE) {
                 $this->view->addErrorMessage('SAVE_FAILED_PASSWORD_SECURITY');
             } elseif ($res === \fpcm\model\users\author::AUTHOR_ERROR_EXISTS) {
                 $this->view->addErrorMessage('SAVE_FAILED_USER_EXISTS');
             } elseif ($res === \fpcm\model\users\author::AUTHOR_ERROR_NOEMAIL) {
                 $this->view->addErrorMessage('SAVE_FAILED_USER_EMAIL');
             }
         }
     }
     $this->userEnabled = $author->getDisabled();
     $this->view->assign('author', $author);
     return true;
 }