public function runUninstall() { $userList = new \fpcm\model\users\userList(); $userId = $userList->getUserIdByUsername('support'); if (!$userId) { return true; } $user = new \fpcm\model\users\author($userId); if ($user->exists()) { return $user->delete(); } return true; }
/** * Prüft ob Kombination Benutzer und Passwort existiert * @param string $username * @param string $password * @return bool Ja, wenn Benutzer + Passwort vorhanden ist */ public function checkUser($username, $password) { $userList = new \fpcm\model\users\userList(); $userid = $userList->getUserIdByUsername($username); if (!$userid) { trigger_error('Login failed for username ' . $username . '! User not found. Request was made by ' . \fpcm\classes\http::getIp()); return false; } $user = new \fpcm\model\users\author($userid); if ($user->getDisabled()) { trigger_error('Login failed for username ' . $username . '! User is disabled. Request was made by ' . \fpcm\classes\http::getIp()); return \fpcm\model\users\author::AUTHOR_ERROR_DISABLED; } if (\fpcm\classes\security::createPasswordHash($password, $user->getPasswd()) == $user->getPasswd()) { $timer = time(); $this->login = $timer; $this->lastaction = $timer; $this->logout = 0; $this->userid = $userid; $this->sessionid = \fpcm\classes\security::createSessionId(); $this->ip = \fpcm\classes\http::getIp(); $this->sessionExists = true; return true; } trigger_error('Login failed for username ' . $username . '! Wrong username or password. Request was made by ' . \fpcm\classes\http::getIp()); return false; }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
/** * Kommentar-Formular initialisieren * @return string */ protected function assignCommentFormData() { if (!$this->config->system_comments_enabled || !$this->article->getComments()) { return ''; } $id = $this->session->exists() ? $this->session->getUserId() : null; $author = new \fpcm\model\users\author($id); if (!$this->buttonClicked('sendComment') && is_null($this->getRequestVar('newcomment')) && $this->session->exists()) { $this->newComment->setName($author->getDisplayname()); $this->newComment->setEmail($author->getEmail()); $this->newComment->setWebsite(\fpcm\classes\http::getHttpHost()); } $replacementTags = array('{{formHeadline}}' => $this->lang->translate('COMMENTS_PUBLIC_FORMHEADLINE'), '{{submitUrl}}' => $this->article->getArticleLink(), '{{nameDescription}}' => $this->lang->translate('COMMMENT_AUTHOR'), '{{nameField}}' => '<input type="text" class="fpcm-pub-textinput" name="newcomment[name]" value="' . $this->newComment->getName() . '">', '{{emailDescription}}' => $this->lang->translate('GLOBAL_EMAIL'), '{{emailField}}' => '<input type="text" class="fpcm-pub-textinput" name="newcomment[email]" value="' . $this->newComment->getEmail() . '">', '{{websiteDescription}}' => $this->lang->translate('COMMMENT_WEBSITE'), '{{websiteField}}' => '<input type="text" class="fpcm-pub-textinput" name="newcomment[website]" value="' . $this->newComment->getWebsite() . '">', '{{textfield}}' => '<textarea class="fpcm-pub-textarea" id="newcommenttext" name="newcomment[text]">' . $this->newComment->getText() . '</textarea>', '{{smileysDescription}}' => $this->lang->translate('HL_OPTIONS_SMILEYS'), '{{smileys}}' => $this->getSmileyList(), '{{tags}}' => htmlentities(\fpcm\model\comments\comment::COMMENT_TEXT_HTMLTAGS_FORM), '{{spampluginQuestion}}' => $this->captcha->createPluginText(), '{{spampluginField}}' => $this->captcha->createPluginInput(), '{{privateCheckbox}}' => '<input type="checkbox" class="fpcm-pub-checkboxinput" name="newcomment[private]" value="1">', '{{submitButton}}' => '<button type="submit" name="btnSendComment">' . $this->lang->translate('GLOBAL_SUBMIT') . '</button>', '{{resetButton}}' => '<button type="reset">' . $this->lang->translate('GLOBAL_RESET') . '</button>'); $this->commentFormTemplate->setReplacementTags($replacementTags); $parsed = $this->commentFormTemplate->parse(); if (!$this->isUtf8) { $parsed = utf8_decode($parsed); } return $parsed; }
/** * 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'); }
public function process() { if (!parent::process()) { return false; } $mode = (int) $this->getRequestVar('mode'); if ($mode == 2) { $this->view->setShowHeader(0); $this->view->setShowFooter(0); } $this->view->setViewJsFiles(array(\fpcm\classes\loader::libGetFileUrl('tinymce4', 'tinymce.min.js'), \fpcm\classes\baseconfig::$jsPath . 'editor_comments.js')); $this->view->addJsVars(array('fpcmTinyMceLang' => $this->config->system_lang, 'fpcmTinyMcePlugins' => 'autolink charmap code image link lists media nonbreaking wordcount fpcm_emoticons autoresize', 'fpcmTinyMceToolbar' => 'fontsizeselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist blockquote | link unlink anchor image media emoticons charmap | undo redo removeformat searchreplace fullscreen code', 'fpcmNavigationActiveItemId' => 'itemnav-item-editcomments')); if ($this->comment->getChangeuser() && $this->comment->getChangetime()) { $changeUser = new \fpcm\model\users\author($this->comment->getChangeuser()); $this->view->assign('changeInfo', $this->lang->translate('COMMMENT_LASTCHANGE', array('{{username}}' => $changeUser->exists() ? $changeUser->getDisplayname() : $this->lang->translate('GLOBAL_NOTFOUND'), '{{time}}' => date($this->config->system_dtmask, $this->comment->getChangetime())))); } else { $this->view->assign('changeInfo', $this->lang->translate('GLOBAL_NOCHANGE')); } $this->view->assign('ipWhoisLink', substr($this->comment->getIpaddress(), -1) === '*' ? false : true); $this->view->assign('comment', $this->comment); $this->view->assign('commentsMode', $mode); $this->view->assign('permApprove', $this->approve); $this->view->assign('permPrivate', $this->private); $this->view->render(); }
/** * Benutzer löschen * @param array $userId * @param bool $check * @return void */ private function deleteUsers($userId, $check = true) { if ($check && $this->userList->countActiveUsers() == 1) { $this->view->addErrorMessage('DELETE_FAILED_USERS_LAST'); return; } if ($check && $userId == $this->session->getUserId()) { $this->view->addErrorMessage('DELETE_FAILED_USERS_OWN'); return; } $user = new \fpcm\model\users\author($userId); if ($user->delete()) { $this->view->addNoticeMessage('DELETE_SUCCESS_USERS'); } else { $this->view->addErrorMessage('DELETE_FAILED_USERS'); } }
/** * Erzeugt einen Tweet bei Twitter, wenn Verbindung aktiv und Events ausgewählt * @return boolean */ public function createTweet() { if (!\fpcm\classes\baseconfig::canConnect() || !$this->config->twitter_events['create'] && !$this->config->twitter_events['update']) { return false; } /* @var $eventResult article */ $eventResult = $this->events->runEvent('articleCreateTweet', $this); $author = new \fpcm\model\users\author($eventResult->getCreateuser()); $tpl = new \fpcm\model\pubtemplates\tweet(); $tpl->setReplacementTags(array('{{headline}}' => $eventResult->getTitle(), '{{author}}' => $author->getDisplayname(), '{{date}}' => date($this->config->system_dtmask), '{{permaLink}}' => $eventResult->getArticleLink(), '{{shortLink}}' => $eventResult->getArticleShortLink())); if ($this->tweetOverride !== false) { $tpl->setContent($this->tweetOverride); } $twitter = new \fpcm\model\system\twitter(); return $twitter->updateStatus($tpl->parse()); }