Example #1
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handleSettingsPostAction(function () use($formData) {
         $this->adminFormValidation->validate($formData);
         $data = ['feed_image' => $this->secureHelper->strEncode($formData['feed_image']), 'feed_type' => $formData['feed_type']];
         return $this->config->saveSettings($data, Feeds\Installer\Schema::MODULE_NAME);
     });
 }
Example #2
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handleSettingsPostAction(function () use($formData) {
         $this->adminSettingsFormValidation->validate($formData);
         $data = ['mail' => $formData['mail'], 'mailsig' => $this->secureHelper->strEncode($formData['mailsig'], true), 'html' => (int) $formData['html']];
         return $this->config->saveSettings($data, Newsletter\Installer\Schema::MODULE_NAME);
     });
 }
Example #3
0
 /**
  * Erzeugt das Captchafeld für das Template
  *
  * @param integer $captchaLength
  * @param string  $formFieldId
  * @param bool    $inputOnly
  * @param string  $path
  *
  * @return string
  */
 public function captcha($captchaLength = self::CAPTCHA_DEFAULT_LENGTH, $formFieldId = self::CAPTCHA_DEFAULT_INPUT_ID, $inputOnly = false, $path = '')
 {
     if ($this->user->isAuthenticated() === false) {
         $path = sha1($this->router->route(empty($path) === true ? $this->request->getQuery() : $path));
         $this->sessionHandler->set('captcha_' . $path, $this->secureHelper->salt($captchaLength));
         $this->view->assign('captcha', ['width' => $captchaLength * 25, 'id' => $formFieldId, 'height' => 30, 'input_only' => $inputOnly, 'path' => $path]);
         return $this->view->fetchTemplate('Captcha/Partials/captcha.tpl');
     }
     return '';
 }
Example #4
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handleCreatePostAction(function () use($formData) {
         $this->adminFormValidation->validate($formData);
         $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
         $formData = array_merge($formData, ['pwd' => $this->secureHelper->generateSaltedPassword($salt, $formData['pwd'], 'sha512'), 'pwd_salt' => $salt, 'time_zone' => $formData['date_time_zone'], 'registration_date' => 'now']);
         $lastId = $this->usersModel->save($formData);
         $this->permissionsHelpers->updateUserRoles($formData['roles'], $lastId);
         return $lastId;
     });
 }
Example #5
0
 /**
  * Erzeugt eine neue Kategorie und gibt ihre ID zurück
  *
  * @param string $title
  * @param string $module
  *
  * @return integer
  */
 public function categoriesCreate($title, $module)
 {
     $moduleInfo = $this->modules->getModuleInfo($module);
     if ($this->categoryRepository->resultIsDuplicate($title, $moduleInfo['id'], '') === false) {
         $insertValues = ['id' => '', 'title' => $this->secureHelper->strEncode($title), 'picture' => '', 'description' => '', 'module_id' => $moduleInfo['id']];
         $result = $this->categoryRepository->insert($insertValues);
         $this->categoriesCache->saveCache($module);
         return $result;
     }
     return $this->categoryRepository->getOneByTitleAndModule($title, $module)['id'];
 }
Example #6
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handleSettingsPostAction(function () use($formData) {
         $this->adminSettingsFormValidation->validate($formData);
         $data = ['address' => $this->secureHelper->strEncode($formData['address'], true), 'ceo' => $this->secureHelper->strEncode($formData['ceo']), 'disclaimer' => $this->secureHelper->strEncode($formData['disclaimer'], true), 'fax' => $this->secureHelper->strEncode($formData['fax']), 'mail' => $formData['mail'], 'mobile_phone' => $this->secureHelper->strEncode($formData['mobile_phone']), 'picture_credits' => $this->secureHelper->strEncode($formData['picture_credits'], true), 'telephone' => $this->secureHelper->strEncode($formData['telephone']), 'vat_id' => $this->secureHelper->strEncode($formData['vat_id'])];
         return $this->config->saveSettings($data, Contact\Installer\Schema::MODULE_NAME);
     });
 }
Example #7
0
 /**
  * Meldet eine E-Mail-Adresse beim Newsletter an
  *
  * @param string $emailAddress
  * @param int $salutation
  * @param string $firstName
  * @param string $lastName
  *
  * @return bool
  */
 public function subscribeToNewsletter($emailAddress, $salutation = 0, $firstName = '', $lastName = '')
 {
     $hash = $this->secureHelper->generateSaltedPassword('', mt_rand(0, microtime(true)), 'sha512');
     $mailSent = $this->sendDoubleOptInEmail($emailAddress, $hash);
     $result = $this->addNewsletterAccount($emailAddress, $salutation, $firstName, $lastName, $hash);
     return $mailSent === true && $result !== false;
 }
Example #8
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handlePostAction(function () use($formData) {
         $this->accountForgotPasswordFormValidation->validate($formData);
         $newPassword = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
         $user = $this->fetchUserByFormFieldValue($formData['nick_mail']);
         $mailIsSent = $this->sendPasswordChangeEmail($user, $newPassword);
         // Das Passwort des Benutzers nur abändern, wenn die E-Mail erfolgreich versendet werden konnte
         if ($mailIsSent === true) {
             $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
             $updateValues = ['pwd' => $this->secureHelper->generateSaltedPassword($salt, $newPassword, 'sha512'), 'pwd_salt' => $salt, 'login_errors' => 0];
             $bool = $this->userRepository->update($updateValues, $user['id']);
         }
         $this->setTemplate($this->get('core.helpers.alerts')->confirmBox($this->translator->t('users', $mailIsSent === true && isset($bool) && $bool !== false ? 'forgot_pwd_success' : 'forgot_pwd_error'), $this->appPath->getWebRoot()));
     }, $this->request->getFullPath());
 }
Example #9
0
 /**
  * @param array $answers
  * @param int $pollId
  *
  * @return bool|int
  */
 public function saveAnswers(array $answers, $pollId)
 {
     $bool = false;
     foreach ($answers as $row) {
         if (empty($row['id'])) {
             if (!empty($row['text']) && !isset($row['delete'])) {
                 $data = ['text' => $this->secure->strEncode($row['text']), 'poll_id' => $pollId];
                 $bool = $this->answerRepository->insert($data);
             }
         } elseif (isset($row['delete'])) {
             $this->answerRepository->delete((int) $row['id']);
         } elseif (!empty($row['text'])) {
             $data = ['text' => $this->secure->strEncode($row['text'])];
             $bool = $this->answerRepository->update($data, (int) $row['id']);
         }
     }
     return $bool;
 }
Example #10
0
 /**
  * @param array $formData
  * @param array $settings
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $settings)
 {
     return $this->actionHelper->handlePostAction(function () use($formData, $settings) {
         $this->registrationFormValidation->validate($formData);
         $systemSettings = $this->config->getSettings(Schema::MODULE_NAME);
         $subject = $this->translator->t('users', 'register_mail_subject', ['{title}' => $systemSettings['site_title'], '{host}' => $this->request->getHost()]);
         $body = $this->translator->t('users', 'register_mail_message', ['{name}' => $formData['nickname'], '{mail}' => $formData['mail'], '{password}' => $formData['pwd'], '{title}' => $systemSettings['site_title'], '{host}' => $this->request->getHost()]);
         $mailIsSent = $this->sendEmail->execute('', $formData['mail'], $settings['mail'], $subject, $body);
         $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
         $insertValues = ['id' => '', 'nickname' => $this->get('core.helpers.secure')->strEncode($formData['nickname']), 'pwd' => $this->secureHelper->generateSaltedPassword($salt, $formData['pwd'], 'sha512'), 'pwd_salt' => $salt, 'mail' => $formData['mail'], 'date_format_long' => $systemSettings['date_format_long'], 'date_format_short' => $systemSettings['date_format_short'], 'time_zone' => $systemSettings['date_time_zone'], 'language' => $systemSettings['lang'], 'registration_date' => $this->date->getCurrentDateTime()];
         $lastId = $this->userRepository->insert($insertValues);
         $bool2 = $this->permissionsHelpers->updateUserRoles([2], $lastId);
         $this->setTemplate($this->get('core.helpers.alerts')->confirmBox($this->translator->t('users', $mailIsSent === true && $lastId !== false && $bool2 !== false ? 'register_success' : 'register_error'), $this->appPath->getWebRoot()));
     }, $this->request->getFullPath());
 }
Example #11
0
 /**
  * @param array $formData
  * @param int $userId
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, $userId)
 {
     return $this->actionHelper->handleEditPostAction(function () use($formData, $userId) {
         $this->adminFormValidation->setUserId($userId)->validate($formData);
         $formData['time_zone'] = $formData['date_time_zone'];
         $this->permissionsHelpers->updateUserRoles($formData['roles'], $userId);
         if (!empty($formData['new_pwd']) && !empty($formData['new_pwd_repeat'])) {
             $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
             $newPassword = $this->secureHelper->generateSaltedPassword($salt, $formData['new_pwd'], 'sha512');
             $formData['pwd'] = $newPassword;
             $formData['pwd_salt'] = $salt;
         }
         $bool = $this->usersModel->save($formData, $userId);
         $this->updateCurrentlyLoggedInUserCookie($userId);
         return $bool;
     });
 }
Example #12
0
 /**
  * @param array $formData
  * @param array $settings
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $settings)
 {
     return $this->actionHelper->handlePostAction(function () use($formData, $settings) {
         $this->accountSettingsFormValidation->setSettings($settings)->validate($formData);
         $formData['time_zone'] = $formData['date_time_zone'];
         if ($settings['language_override'] == 0) {
             unset($formData['language']);
         }
         if (!empty($formData['new_pwd']) && !empty($formData['new_pwd_repeat'])) {
             $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
             $newPassword = $this->secureHelper->generateSaltedPassword($salt, $formData['new_pwd'], 'sha512');
             $formData['pwd'] = $newPassword;
             $formData['pwd_salt'] = $salt;
         }
         $bool = $this->usersModel->save($formData, $this->user->getUserId());
         $user = $this->usersModel->getOneById($this->user->getUserId());
         $cookie = $this->authenticationModel->setRememberMeCookie($this->user->getUserId(), $user['remember_me_token']);
         $this->response->headers->setCookie($cookie);
         return $this->redirectMessages()->setMessage($bool, $this->translator->t('system', $bool !== false ? 'settings_success' : 'settings_error'));
     });
 }
Example #13
0
 /**
  * @param array $formData
  * @param string $phrase
  * @return string
  */
 protected function buildEmailBody(array $formData, $phrase)
 {
     return $this->translator->t('contact', $phrase, ['%name%' => $formData['name'], '%mail%' => $formData['mail'], '%message%' => $this->secure->strEncode($formData['message'], true)]);
 }
Example #14
0
 /**
  * @param string $password
  * @param array $user
  *
  * @return bool
  */
 protected function userHasOldPassword($password, array $user)
 {
     return strlen($user['pwd']) === 40 && $user['pwd'] === $this->secureHelper->generateSaltedPassword($user['pwd_salt'], $password);
 }
Example #15
0
 /**
  * @param mixed $value
  * @return string
  */
 public function doEscape($value)
 {
     return $this->secure->strEncode($value);
 }