Exemplo n.º 1
0
 protected function executeImpl(ArrayAdapter $params)
 {
     $unique = $params->str(DiscussionController::JS_DATA_UNIQUE);
     $upDown = $params->bool(DiscussionController::JS_DATA_UPDOWN);
     $entity = $params->str(DiscussionController::JS_DATA_THREAD);
     $theme = $params->str(self::JS_PARAM_THEME);
     $comment = $params->str(self::JS_PARAM_COMMENT);
     $parentId = $params->int(self::JS_PARAM_PARENT_ID);
     $controller = Handlers::getInstance()->getDiscussionController($unique);
     //Валидируем тему
     if (!$parentId && $controller->getDiscussionSettings()->isThemed()) {
         if (!$theme) {
             return 'Введите тему';
         }
         $error = UserInputValidator::validateShortText($theme);
         if ($error) {
             return $error;
         }
         $theme = UserInputTools::safeShortText($theme);
     }
     //Валидируем комментарий
     if (!$comment) {
         return 'Введите комментарий';
     }
     $error = UserInputValidator::validateLongText($comment);
     if ($error) {
         return $error;
     }
     $comment = UserInputTools::safeLongText($comment);
     $msgObj = $controller->saveMessage($entity, $parentId, $comment, $theme, PsUser::inst());
     if (!$msgObj instanceof DiscussionMsg) {
         return 'Ошибка добавления сообщения';
     }
     return new AjaxSuccess($controller->buildLeaf($msgObj));
 }
Exemplo n.º 2
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $pass = $adapter->str(FORM_PARAM_REG_PASS);
     $passConfirm = $adapter->str(FORM_PARAM_REG_PASS_CONF);
     $error = UserInputValidator::validatePass($pass, $passConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS => $error);
     }
     $error = UserInputValidator::validatePassConfirm($pass, $passConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS_CONF => $error);
     }
     /*
      * Код
      */
     $code = $adapter->str(REMIND_CODE_PARAM);
     if (!$code) {
         return 'Не передан код восстановления';
     }
     $user = PassRecoverManager::changePassWithCode($code, $pass);
     if ($user instanceof PsUser) {
         $authed = AuthManager::loginUser($user->getEmail(), $pass);
         if ($authed) {
             return new AjaxSuccess();
         } else {
             return 'Не удалось авторизоваться после смены пароля';
         }
     } else {
         //Описание - почему код не может быть использован
         return $user;
     }
 }
Exemplo n.º 3
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $FEEDBACK = FeedbackManager::inst();
     /*
      * Тема
      */
     $theme = $adapter->str(FORM_PARAM_THEME);
     $error = UserInputValidator::validateShortText($theme);
     if ($error) {
         return array(FORM_PARAM_THEME => $error);
     }
     $theme = UserInputTools::safeShortText($theme);
     /*
      * Комментарий
      */
     $text = $adapter->str(FORM_PARAM_COMMENT);
     $error = UserInputValidator::validateLongText($text);
     if ($error) {
         return array(FORM_PARAM_COMMENT => $error);
     }
     $text = UserInputTools::safeLongText($text);
     /*
      * АВТОРИЗОВАН - пользуемся стандартным механизмом добавления сообщения в тред.
      * Кодом треда, при этом, является сам пользователь.
      */
     if (AuthManager::isAuthorized()) {
         $msg = $FEEDBACK->saveMessage(PsUser::inst()->getId(), null, $text, $theme, PsUser::inst());
         return new AjaxSuccess($FEEDBACK->buildLeaf($msg));
     }
     /*
      * НЕ АВТОРИЗОВАН - сохраняем сообщение в таблицу анонимных пользователей.
      */
     if (!AuthManager::isAuthorized()) {
         /*
          * Имя пользователя
          */
         $name = $adapter->str(FORM_PARAM_NAME);
         $error = UserInputValidator::validateShortText($name);
         if ($error) {
             return array(FORM_PARAM_NAME => $error);
         }
         $name = UserInputTools::safeShortText($name);
         /*
          * Контакты
          */
         $contacts = $adapter->str(FORM_PARAM_REG_CONTACTS);
         if ($contacts) {
             $error = UserInputValidator::validateShortText($contacts, false);
             if ($error) {
                 return array(FORM_PARAM_REG_CONTACTS => $error);
             }
             $contacts = UserInputTools::safeShortText($contacts);
         }
         $FEEDBACK->saveAnonimousFeedback($name, $contacts, $theme, $text);
         return new AjaxSuccess();
     }
 }
Exemplo n.º 4
0
 protected function processStock(BaseStock $stock, PostArrayAdapter $adapter, $button)
 {
     //ОБРАБОТАЕМ КОММЕНТАРИЙ
     $comment = $adapter->str(FORM_PARAM_COMMENT);
     $error = UserInputValidator::validateShortText($comment, true, MOSAIC_ANS_MAX_LEN);
     if ($error) {
         return array(FORM_PARAM_COMMENT => $error);
     }
     $comment = UserInputTools::safeShortText($comment);
     //ВЫЗОВЕМ ДЕЙСТВИЕ ДЛЯ АКЦИИ
     return $stock->formSaveAnswer($comment);
 }
Exemplo n.º 5
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     /*
      * e-mail
      */
     $mail = $adapter->str(FORM_PARAM_REG_MAIL);
     $error = UserInputValidator::validateEmail($mail, true);
     if ($error) {
         return array(FORM_PARAM_REG_MAIL => $error);
     }
     PassRecoverManager::sendRecoverCode($mail);
     return new AjaxSuccess();
 }
Exemplo n.º 6
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $data = new RegFormData();
     /*
      * Имя пользователя
      */
     $name = $adapter->str(FORM_PARAM_REG_NAME);
     $error = UserInputValidator::validateShortText($name);
     if ($error) {
         return array(FORM_PARAM_REG_NAME => $error);
     }
     $name = UserInputTools::safeShortText($name);
     $data->setUserName($name);
     /*
      * e-mail
      */
     $mail = $adapter->str(FORM_PARAM_REG_MAIL);
     $error = UserInputValidator::validateEmail($mail);
     if ($error) {
         return array(FORM_PARAM_REG_MAIL => $error);
     }
     $data->setUserMail($mail);
     /*
      * Пол
      */
     $sex = $adapter->int(FORM_PARAM_REG_SEX);
     $error = UserInputValidator::validateSex($sex);
     if ($error) {
         return array(FORM_PARAM_REG_SEX => $error);
     }
     $data->setSex($sex);
     /*
      * Пароль
      */
     $pass = $adapter->str(FORM_PARAM_REG_PASS);
     $passConfirm = $adapter->str(FORM_PARAM_REG_PASS_CONF);
     $error = UserInputValidator::validatePass($pass, $passConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS => $error);
     }
     $error = UserInputValidator::validatePassConfirm($pass, $passConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS_CONF => $error);
     }
     $data->setPassword($pass);
     AuthManager::createUser($data);
     return new AjaxSuccess();
 }
Exemplo n.º 7
0
 protected function processImpl(PostArrayAdapter $adapter, $button)
 {
     $oldPass = $adapter->str(FORM_PARAM_REG_OLD_PASS);
     $newPass = $adapter->str(FORM_PARAM_REG_PASS);
     $newPassConfirm = $adapter->str(FORM_PARAM_REG_PASS_CONF);
     $error = UserInputValidator::validateOldPass($oldPass);
     if ($error) {
         return array(FORM_PARAM_REG_OLD_PASS => $error);
     }
     $error = UserInputValidator::validatePass($newPass, $newPassConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS => $error);
     }
     $error = UserInputValidator::validatePassConfirm($newPass, $newPassConfirm);
     if ($error) {
         return array(FORM_PARAM_REG_PASS_CONF => $error);
     }
     PsUser::inst()->changePassword($oldPass, $newPass);
     return new AjaxSuccess();
 }
Exemplo n.º 8
0
 public function getDataImpl()
 {
     $data = new RegFormData();
     /*
      * Имя пользователя
      */
     $name = $adapter->str(FORM_PARAM_REG_NAME);
     $error = UserInputValidator::validateShortText($name);
     if ($error) {
         return array(FORM_PARAM_REG_NAME => $error);
     }
     $name = UserInputTools::safeShortText($name);
     $data->setUserName($name);
     /*
      * Пол
      */
     $sex = $adapter->str(FORM_PARAM_REG_SEX);
     $error = UserInputValidator::validateSex($sex);
     if ($error) {
         return array(FORM_PARAM_REG_SEX => $error);
     }
     $data->setSex($sex);
     /*
      * Обо мне
      */
     $about = $adapter->str(FORM_PARAM_REG_ABOUT);
     if ($about) {
         $error = UserInputValidator::validateLongText($about, false);
         if ($error) {
             return array(FORM_PARAM_REG_ABOUT => $error);
         }
         $data->setAboutSrc($about);
         $data->setAbout(UserInputTools::safeLongText($about));
     }
     /*
      * Контакты
      */
     $contacts = $adapter->str(FORM_PARAM_REG_CONTACTS);
     if ($contacts) {
         $error = UserInputValidator::validateLongText($contacts, false);
         if ($error) {
             return array(FORM_PARAM_REG_CONTACTS => $error);
         }
         $data->setContactsSrc($contacts);
         $data->setContacts(UserInputTools::safeLongText($contacts));
     }
     /*
      * Цитата
      */
     $msg = $adapter->str(FORM_PARAM_REG_MSG);
     if ($msg) {
         $error = UserInputValidator::validateLongText($msg, false);
         if ($error) {
             return array(FORM_PARAM_REG_MSG => $error);
         }
         $data->setMsgSrc($msg);
         $data->setMsg(UserInputTools::safeLongText($msg));
     }
     return $data;
 }
Exemplo n.º 9
0
<?php

require_once 'AjaxTools.php';
$email = RequestArrayAdapter::inst()->str(FORM_PARAM_REG_MAIL);
$mustPresent = RequestArrayAdapter::inst()->bool('mp');
$invalid = true;
if ($email) {
    $email = strtolower($email);
    $invalid = UserInputValidator::validateEmail($email, $mustPresent);
}
echo $invalid ? 'false' : 'true';