Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Проверка капчи. */
- if($this->config->get('captcha.gregwar') == true and $this->request->isMethod('POST') == true) {
- if($user != false) {
- $lastCaptchaDate = $user->getLastCaptchaDate();
- $newCaptchaDate = new \DateTime();
- $intervalCaptchaDate = $lastCaptchaDate->diff($newCaptchaDate);
- if($this->config->get('captcha.interval.hour') == 0) {
- $hoursCaptcha = 0;
- } else {
- $hoursCaptcha = $intervalCaptchaDate->format('%h');
- }
- if($this->config->get('captcha.interval.minutes') == 0) {
- $minutesCaptcha = 0;
- } else {
- $minutesCaptcha = $intervalCaptchaDate->format('%i');
- }
- }
- if(
- (!isset($hoursCaptcha) and !isset($minutesCaptcha)) or
- $hoursCaptcha * 60 + $minutesCaptcha < $this->config->get('captcha.interval.hour') * 60 + $this->config->get('captcha.interval.minutes')
- or $this->config->get('captcha.interval_on') != true)
- {
- if(!isset($_POST['gregwar_captcha_value'])) {
- return $this->response->error($this->translator->trans('Не отправлена капча.'));
- }
- if ($this->captchaSession->check($_POST['gregwar_captcha_value']) == true) {
- $this->captchaSession->delete();
- /** Создание профиля пользователя. */
- if($user == false) {
- $user = new User;
- $userPassword = $this->password->random();
- $user->setPassword($this->password->hash($userPassword));
- $user->setPostsCount(0);
- $user->setVerifiedPostsCount(0);
- $user->setLastCaptchaDate(new \DateTime);
- $this->userRepository->save($user);
- /** Отправка cookie пользователю. */
- if($this->auth->getAnonymous() == false) {
- $this->cookie->setUser($user->getId(), $userPassword);
- }
- } else {
- $user->setLastCaptchaDate(new \Datetime);
- $this->userRepository->save($user);
- }
- } else {
- return $this->response->error($this->translator->trans('Неправильно введена капча.'));
- }
- }
- } else {
- $user = new User;
- $userPassword = $this->password->random();
- $user->setPassword($this->password->hash($userPassword));
- $user->setPostsCount(0);
- $user->setVerifiedPostsCount(0);
- $user->setLastCaptchaDate(new \DateTime);
- $this->userRepository->save($user);
- /** Отправка cookie пользователю. */
- if($this->auth->getAnonymous() == false) {
- $this->cookie->setUser($user->getId(), $userPassword);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement