예제 #1
0
 /**
  * Обработка напоминания пароля
  *
  */
 protected function EventReminder()
 {
     $this->Viewer_AddHtmlTitle($this->Lang_Get('password_reminder'));
     if ($this->GetParam(0) == 'send') {
         $this->SetTemplateAction('reminder_send');
         return;
     }
     /**
      * Проверка кода на восстановление пароля и генерация нового пароля
      */
     if (func_check($this->GetParam(0), 'md5')) {
         if ($oReminder = $this->User_GetReminderByCode($this->GetParam(0))) {
             if (!$oReminder->getIsUsed() and strtotime($oReminder->getDateExpire()) > time() and $oUser = $this->User_GetUserById($oReminder->getUserId())) {
                 $sNewPassword = func_generator(7);
                 $oUser->setPassword(func_encrypt($sNewPassword));
                 if ($this->User_Update($oUser)) {
                     $oReminder->setDateUsed(date("Y-m-d H:i:s"));
                     $oReminder->setIsUsed(1);
                     $this->User_UpdateReminder($oReminder);
                     $this->Notify_SendReminderPassword($oUser, $sNewPassword);
                     $this->SetTemplateAction('reminder_confirm');
                     return;
                 }
             }
         }
         $this->Message_AddErrorSingle($this->Lang_Get('password_reminder_bad_code'), $this->Lang_Get('error'));
         return Router::Action('error');
     }
     /**
      * Обрабатываем запрос на смену пароля
      */
     if (isPost('submit_reminder')) {
         if (func_check(getRequest('mail'), 'mail') and $oUser = $this->User_GetUserByMail(getRequest('mail'))) {
             /**
              * Формируем и отправляем ссылку на смену пароля
              */
             $oReminder = Engine::GetEntity('User_Reminder');
             $oReminder->setCode(func_generator(32));
             $oReminder->setDateAdd(date("Y-m-d H:i:s"));
             $oReminder->setDateExpire(date("Y-m-d H:i:s", time() + 60 * 60 * 24 * 7));
             $oReminder->setDateUsed(null);
             $oReminder->setIsUsed(0);
             $oReminder->setUserId($oUser->getId());
             if ($this->User_AddReminder($oReminder)) {
                 $this->Notify_SendReminderCode($oUser, $oReminder);
                 Router::Location(Router::GetPath('login') . 'reminder/send/');
             }
         } else {
             $this->Message_AddError($this->Lang_Get('password_reminder_bad_email'), $this->Lang_Get('error'));
         }
     }
 }
예제 #2
0
 /**
  * Авторизация пользователя
  *
  * @param <type> $sUserLogin
  * @param <type> $sUserPassword
  */
 static function Login($sUserLogin, $sUserPassword)
 {
     if (!self::Enabled(__METHOD__)) {
         return null;
     }
     if ($sUserLogin) {
         $oUser = self::$oEngine->User_GetUserByLogin($sUserLogin);
         if ($oUser && $oUser->getPassword() == func_encrypt($sUserPassword) && $oUser->getActivate()) {
             self::$oEngine->User_Authorization($oUser, true);
             self::LoadData();
         }
     }
     return self::GetUserLogin() == $sUserLogin;
 }
예제 #3
0
 /**
  * Выводит форму для редактирования профиля и обрабатывает её
  *
  */
 protected function EventProfile()
 {
     $this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_profile'));
     /**
      * Если нажали кнопку "Сохранить"
      */
     if (isPost('submit_profile_edit')) {
         $this->Security_ValidateSendForm();
         $bError = false;
         /**
          * Заполняем профиль из полей формы
          */
         /**
          * Проверяем имя
          */
         if (func_check(getRequest('profile_name'), 'text', 2, 20)) {
             $this->oUserCurrent->setProfileName(getRequest('profile_name'));
         } else {
             $this->oUserCurrent->setProfileName(null);
         }
         /**
          * Проверка мыла
          */
         if (func_check(getRequest('mail'), 'mail')) {
             if ($oUserMail = $this->User_GetUserByMail(getRequest('mail')) and $oUserMail->getId() != $this->oUserCurrent->getId()) {
                 $this->Message_AddError($this->Lang_Get('settings_profile_mail_error_used'), $this->Lang_Get('error'));
                 $bError = true;
             } else {
                 $this->oUserCurrent->setMail(getRequest('mail'));
             }
         } else {
             $this->Message_AddError($this->Lang_Get('settings_profile_mail_error'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * Проверяем пол
          */
         if (in_array(getRequest('profile_sex'), array('man', 'woman', 'other'))) {
             $this->oUserCurrent->setProfileSex(getRequest('profile_sex'));
         } else {
             $this->oUserCurrent->setProfileSex('other');
         }
         /**
          * Проверяем дату рождения
          */
         if (func_check(getRequest('profile_birthday_day'), 'id', 1, 2) and func_check(getRequest('profile_birthday_month'), 'id', 1, 2) and func_check(getRequest('profile_birthday_year'), 'id', 4, 4)) {
             $this->oUserCurrent->setProfileBirthday(date("Y-m-d H:i:s", mktime(0, 0, 0, getRequest('profile_birthday_month'), getRequest('profile_birthday_day'), getRequest('profile_birthday_year'))));
         } else {
             $this->oUserCurrent->setProfileBirthday(null);
         }
         /**
          * Проверяем страну
          */
         if (func_check(getRequest('profile_country'), 'text', 1, 30)) {
             $this->oUserCurrent->setProfileCountry(getRequest('profile_country'));
         } else {
             $this->oUserCurrent->setProfileCountry(null);
         }
         /**
          * Проверяем регион
          * пока отключим регион, т.к. не понятно нужен ли он вообще =)
          */
         /*
         if (func_check(getRequest('profile_region'),'text',1,30)) {
         	$this->oUserCurrent->setProfileRegion(getRequest('profile_region'));
         } else {
         	$this->oUserCurrent->setProfileRegion(null);
         }
         */
         /**
          * Проверяем город
          */
         if (func_check(getRequest('profile_city'), 'text', 1, 30)) {
             $this->oUserCurrent->setProfileCity(getRequest('profile_city'));
         } else {
             $this->oUserCurrent->setProfileCity(null);
         }
         /**
          * Проверяем ICQ
          */
         if (func_check(getRequest('profile_icq'), 'id', 4, 15)) {
             $this->oUserCurrent->setProfileIcq(getRequest('profile_icq'));
         } else {
             $this->oUserCurrent->setProfileIcq(null);
         }
         /**
          * Проверяем сайт
          */
         if (func_check(getRequest('profile_site'), 'text', 3, 200)) {
             $this->oUserCurrent->setProfileSite(getRequest('profile_site'));
         } else {
             $this->oUserCurrent->setProfileSite(null);
         }
         /**
          * Проверяем название сайта
          */
         if (func_check(getRequest('profile_site_name'), 'text', 3, 50)) {
             $this->oUserCurrent->setProfileSiteName(getRequest('profile_site_name'));
         } else {
             $this->oUserCurrent->setProfileSiteName(null);
         }
         /**
          * Проверяем информацию о себе
          */
         if (func_check(getRequest('profile_about'), 'text', 1, 3000)) {
             $this->oUserCurrent->setProfileAbout(getRequest('profile_about'));
         } else {
             $this->oUserCurrent->setProfileAbout(null);
         }
         /**
          * Проверка на смену пароля
          */
         if (getRequest('password', '') != '') {
             if (func_check(getRequest('password'), 'password', 5)) {
                 if (getRequest('password') == getRequest('password_confirm')) {
                     if (func_encrypt(getRequest('password_now')) == $this->oUserCurrent->getPassword()) {
                         $this->oUserCurrent->setPassword(func_encrypt(getRequest('password')));
                     } else {
                         $bError = true;
                         $this->Message_AddError($this->Lang_Get('settings_profile_password_current_error'), $this->Lang_Get('error'));
                     }
                 } else {
                     $bError = true;
                     $this->Message_AddError($this->Lang_Get('settings_profile_password_confirm_error'), $this->Lang_Get('error'));
                 }
             } else {
                 $bError = true;
                 $this->Message_AddError($this->Lang_Get('settings_profile_password_new_error'), $this->Lang_Get('error'));
             }
         }
         /**
          * Загрузка аватара, делаем ресайзы
          */
         if (isset($_FILES['avatar']) and is_uploaded_file($_FILES['avatar']['tmp_name'])) {
             /**
              * Получаем список текущих аватаров
              */
             $sPathOld = $this->oUserCurrent->getProfileAvatar();
             $aUserAvatars = array();
             if ($sPathOld) {
                 foreach (array_merge(Config::Get('module.user.avatar_size'), array(100)) as $iSize) {
                     $aUserAvatars[$iSize] = $this->oUserCurrent->getProfileAvatarPath($iSize);
                 }
             }
             if ($sPath = $this->User_UploadAvatar($_FILES['avatar'], $this->oUserCurrent)) {
                 $this->oUserCurrent->setProfileAvatar($sPath);
                 /**
                  * Удаляем старые, если путь не совпадает с текущими аватарками
                  */
                 if ($sPathOld and $sPath != $sPathOld and count($aUserAvatars)) {
                     foreach ($aUserAvatars as $iSize => $sAvatarPath) {
                         @unlink($this->Image_GetServerPath($sAvatarPath));
                     }
                 }
             } else {
                 $bError = true;
                 $this->Message_AddError($this->Lang_Get('settings_profile_avatar_error'), $this->Lang_Get('error'));
             }
         }
         /**
          * Удалить аватара
          */
         if (getRequest('avatar_delete')) {
             $this->User_DeleteAvatar($this->oUserCurrent);
             $this->oUserCurrent->setProfileAvatar(null);
         }
         /**
          * Загрузка фото, делаем ресайзы
          */
         if (isset($_FILES['foto']) and is_uploaded_file($_FILES['foto']['tmp_name'])) {
             if ($sFileFoto = $this->User_UploadFoto($_FILES['foto'], $this->oUserCurrent)) {
                 $this->oUserCurrent->setProfileFoto($sFileFoto);
             } else {
                 $bError = true;
                 $this->Message_AddError($this->Lang_Get('settings_profile_foto_error'), $this->Lang_Get('error'));
             }
         }
         /**
          * Удалить фото
          */
         if (isset($_REQUEST['foto_delete'])) {
             $this->User_DeleteFoto($this->oUserCurrent);
             $this->oUserCurrent->setProfileFoto(null);
         }
         /**
          * Ставим дату последнего изменения профиля
          */
         $this->oUserCurrent->setProfileDate(date("Y-m-d H:i:s"));
         /**
          * Сохраняем изменения профиля
          */
         if (!$bError) {
             if ($this->User_Update($this->oUserCurrent)) {
                 /**
                  * Добавляем страну
                  */
                 if ($this->oUserCurrent->getProfileCountry()) {
                     if (!($oCountry = $this->User_GetCountryByName($this->oUserCurrent->getProfileCountry()))) {
                         $oCountry = Engine::GetEntity('User_Country');
                         $oCountry->setName($this->oUserCurrent->getProfileCountry());
                         $this->User_AddCountry($oCountry);
                     }
                     $this->User_SetCountryUser($oCountry->getId(), $this->oUserCurrent->getId());
                 }
                 /**
                  * Добавляем город
                  */
                 if ($this->oUserCurrent->getProfileCity()) {
                     if (!($oCity = $this->User_GetCityByName($this->oUserCurrent->getProfileCity()))) {
                         $oCity = Engine::GetEntity('User_City');
                         $oCity->setName($this->oUserCurrent->getProfileCity());
                         $this->User_AddCity($oCity);
                     }
                     $this->User_SetCityUser($oCity->getId(), $this->oUserCurrent->getId());
                 }
                 $this->Message_AddNoticeSingle($this->Lang_Get('settings_profile_submit_ok'));
             } else {
                 $this->Message_AddErrorSingle($this->Lang_Get('system_error'));
             }
         }
     }
 }
 /**
  * Форма смены пароля, емайла
  */
 protected function EventAccount()
 {
     /**
      * Устанавливаем title страницы
      */
     $this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_profile'));
     $this->sMenuSubItemSelect = 'account';
     /**
      * Если нажали кнопку "Сохранить"
      */
     if (isPost('submit_account_edit')) {
         $this->Security_ValidateSendForm();
         $bError = false;
         /**
          * Проверка мыла
          */
         if (func_check(getRequestStr('mail'), 'mail')) {
             if ($oUserMail = $this->User_GetUserByMail(getRequestStr('mail')) and $oUserMail->getId() != $this->oUserCurrent->getId()) {
                 $this->Message_AddError($this->Lang_Get('settings_profile_mail_error_used'), $this->Lang_Get('error'));
                 $bError = true;
             }
         } else {
             $this->Message_AddError($this->Lang_Get('settings_profile_mail_error'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * Проверка на смену пароля
          */
         if (getRequestStr('password', '') != '') {
             if (func_check(getRequestStr('password'), 'password', 5)) {
                 if (getRequestStr('password') == getRequestStr('password_confirm')) {
                     if (func_encrypt(getRequestStr('password_now')) == $this->oUserCurrent->getPassword()) {
                         $this->oUserCurrent->setPassword(func_encrypt(getRequestStr('password')));
                     } else {
                         $bError = true;
                         $this->Message_AddError($this->Lang_Get('settings_profile_password_current_error'), $this->Lang_Get('error'));
                     }
                 } else {
                     $bError = true;
                     $this->Message_AddError($this->Lang_Get('settings_profile_password_confirm_error'), $this->Lang_Get('error'));
                 }
             } else {
                 $bError = true;
                 $this->Message_AddError($this->Lang_Get('settings_profile_password_new_error'), $this->Lang_Get('error'));
             }
         }
         /**
          * Ставим дату последнего изменения
          */
         $this->oUserCurrent->setProfileDate(date("Y-m-d H:i:s"));
         /**
          * Запускаем выполнение хуков
          */
         $this->Hook_Run('settings_account_save_before', array('oUser' => $this->oUserCurrent, 'bError' => &$bError));
         /**
          * Сохраняем изменения
          */
         if (!$bError) {
             if ($this->User_Update($this->oUserCurrent)) {
                 $this->Message_AddNoticeSingle($this->Lang_Get('settings_account_submit_ok'));
                 /**
                  * Подтверждение смены емайла
                  */
                 if (getRequestStr('mail') and getRequestStr('mail') != $this->oUserCurrent->getMail()) {
                     if ($oChangemail = $this->User_MakeUserChangemail($this->oUserCurrent, getRequestStr('mail'))) {
                         if ($oChangemail->getMailFrom()) {
                             $this->Message_AddNotice($this->Lang_Get('settings_profile_mail_change_from_notice'));
                         } else {
                             $this->Message_AddNotice($this->Lang_Get('settings_profile_mail_change_to_notice'));
                         }
                     }
                 }
                 $this->Hook_Run('settings_account_save_after', array('oUser' => $this->oUserCurrent));
             } else {
                 $this->Message_AddErrorSingle($this->Lang_Get('system_error'));
             }
         }
     }
 }
 /**
  * Обработка напоминания пароля, подтверждение смены пароля
  *
  */
 protected function EventReminder()
 {
     /**
      * Устанавливаем title страницы
      */
     $this->Viewer_AddHtmlTitle($this->Lang_Get('password_reminder'));
     /**
      * Проверка кода на восстановление пароля и генерация нового пароля
      */
     if (func_check($this->GetParam(0), 'md5')) {
         /**
          * Проверка кода подтверждения
          */
         if ($oReminder = $this->User_GetReminderByCode($this->GetParam(0))) {
             if (!$oReminder->getIsUsed() and strtotime($oReminder->getDateExpire()) > time() and $oUser = $this->User_GetUserById($oReminder->getUserId())) {
                 $sNewPassword = func_generator(7);
                 $oUser->setPassword(func_encrypt($sNewPassword));
                 if ($this->User_Update($oUser)) {
                     $oReminder->setDateUsed(date("Y-m-d H:i:s"));
                     $oReminder->setIsUsed(1);
                     $this->User_UpdateReminder($oReminder);
                     $this->Notify_SendReminderPassword($oUser, $sNewPassword);
                     $this->SetTemplateAction('reminder_confirm');
                     return;
                 }
             }
         }
         $this->Message_AddErrorSingle($this->Lang_Get('password_reminder_bad_code'), $this->Lang_Get('error'));
         return Router::Action('error');
     }
 }
예제 #6
0
 /**
  * Показывает страничку регистрации и обрабатывает её
  *
  * @return unknown
  */
 protected function EventIndex()
 {
     /**
      * Если нажали кнопку "Зарегистрироваться"
      */
     if (isPost('submit_register')) {
         //Проверяем  входные данные
         $bError = false;
         /**
          * Проверка логина
          */
         if (!func_check(getRequest('login'), 'login', 3, 30)) {
             $this->Message_AddError($this->Lang_Get('registration_login_error'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * Проверка мыла
          */
         if (!func_check(getRequest('mail'), 'mail')) {
             $this->Message_AddError($this->Lang_Get('registration_mail_error'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * Проверка пароля
          */
         if (!func_check(getRequest('password'), 'password', 5)) {
             $this->Message_AddError($this->Lang_Get('registration_password_error'), $this->Lang_Get('error'));
             $bError = true;
         } elseif (getRequest('password') != getRequest('password_confirm')) {
             $this->Message_AddError($this->Lang_Get('registration_password_error_different'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * Проверка капчи(циферки с картинки)
          */
         if (!isset($_SESSION['captcha_keystring']) or $_SESSION['captcha_keystring'] != strtolower(getRequest('captcha'))) {
             $this->Message_AddError($this->Lang_Get('registration_captcha_error'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * А не занят ли логин?
          */
         if ($this->User_GetUserByLogin(getRequest('login'))) {
             $this->Message_AddError($this->Lang_Get('registration_login_error_used'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * А не занято ли мыло?
          */
         if ($this->User_GetUserByMail(getRequest('mail'))) {
             $this->Message_AddError($this->Lang_Get('registration_mail_error_used'), $this->Lang_Get('error'));
             $bError = true;
         }
         /**
          * Если всё то пробуем зарегить
          */
         if (!$bError) {
             /**
              * Создаем юзера
              */
             $oUser = Engine::GetEntity('User');
             $oUser->setLogin(getRequest('login'));
             $oUser->setMail(getRequest('mail'));
             $oUser->setPassword(func_encrypt(getRequest('password')));
             $oUser->setDateRegister(date("Y-m-d H:i:s"));
             $oUser->setIpRegister(func_getIp());
             /**
              * Если используется активация, то генерим код активации
              */
             if (Config::Get('general.reg.activation')) {
                 $oUser->setActivate(0);
                 $oUser->setActivateKey(md5(func_generator() . time()));
             } else {
                 $oUser->setActivate(1);
                 $oUser->setActivateKey(null);
             }
             /**
              * Регистрируем
              */
             if ($this->User_Add($oUser)) {
                 /**
                  * Убиваем каптчу
                  */
                 unset($_SESSION['captcha_keystring']);
                 /**
                  * Создаем персональный блог
                  */
                 $this->Blog_CreatePersonalBlog($oUser);
                 /**
                  * Если юзер зарегистрировался по приглашению то обновляем инвайт
                  */
                 if (Config::Get('general.reg.invite') and $oInvite = $this->User_GetInviteByCode($this->GetInviteRegister())) {
                     $oInvite->setUserToId($oUser->getId());
                     $oInvite->setDateUsed(date("Y-m-d H:i:s"));
                     $oInvite->setUsed(1);
                     $this->User_UpdateInvite($oInvite);
                 }
                 /**
                  * Если стоит регистрация с активацией то проводим её
                  */
                 if (Config::Get('general.reg.activation')) {
                     /**
                      * Отправляем на мыло письмо о подтверждении регистрации						 
                      */
                     $this->Notify_SendRegistrationActivate($oUser, getRequest('password'));
                     Router::Location(Router::GetPath('registration') . 'confirm/');
                 } else {
                     $this->Notify_SendRegistration($oUser, getRequest('password'));
                     $this->Viewer_Assign('bRefreshToHome', true);
                     $oUser = $this->User_GetUserById($oUser->getId());
                     $this->User_Authorization($oUser, false);
                     $this->SetTemplateAction('ok');
                     $this->DropInviteRegister();
                 }
             } else {
                 $this->Message_AddErrorSingle($this->Lang_Get('system_error'));
                 return Router::Action('error');
             }
         }
     }
 }
예제 #7
0
 protected function EventAddWidget()
 {
     $this->SetTemplateAction('addwidget');
     /*$aWidgetsProducers=$this->PluginAceadminpanel_Widgets_GetWidgetsProducers();
       $this->Viewer_Assign('aWidgetsProducers', $aWidgetsProducers);*/
     $this->Viewer_Assign('hash', func_encrypt(date("Y-m-d H:i:s")));
     if (isPost('submit_widget')) {
         /*$oProducerNew='';
           if (getRequest('wid_new') && !$oProducerNew=$this->PluginAceadminpanel_Widgets_GetWidgetProducerByName(getRequest('wid_new'))) {
               $oProducerNew=$this->PluginAceadminpanel_Widgets_AddWidgetProducer(getRequest('wid_new'));
           }*/
         //$oProducerNew=$this->PluginAceadminpanel_Widgets_GetWidgetProducerByName(getRequest('wid_new'));
         /**
          * Проверка корректности полей формы
          */
         if (!$this->checkWidFields()) {
             return false;
         }
         /**
          * Если всё ок то пытаемся создать блог
          */
         $oWid = Engine::GetEntity('PluginAceadminpanel_Widgets_Widgets');
         /**
          * Парсим текст на предмет разных ХТМЛ тегов
          */
         //$sText=$this->Text_Parser(getRequest('wid_description'));
         $oWid->setWidDescription(getRequest('wid_description'));
         $oWid->setWidTitle(getRequest('wid_title'));
         $oWid->setWidName(getRequest('wid_name'));
         $oWid->setWidCategory(getRequest('wid_category'));
         $oWid->setWidDateAdd(date("Y-m-d H:i:s"));
         $oWid->setWidPrice(getRequest('wid_price'));
         //$oWid->setUrl(getRequest('blog_url'));
         /**
          * Загрузка аватара, делаем ресайзы
          */
         if (isset($_FILES['avatar']) and is_uploaded_file($_FILES['avatar']['tmp_name'])) {
             if ($sPath = $this->UploadAvatarFile($_FILES['avatar'], 'widget')) {
                 $oWid->setWidAvatar($sPath);
             } else {
                 $this->Message_AddError($this->Lang_Get('blog_create_avatar_error'), $this->Lang_Get('error'));
                 return false;
             }
         }
         if ($this->PluginAceadminpanel_Widgets_AddWidget($oWid)) {
             func_header_location(Router::GetPath('admin') . 'widgets');
             $this->Message_AddNotice($this->Lang_Get('adm_wid_add_success'), $this->Lang_Get('attention'));
         } else {
             $this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         }
     }
 }
예제 #8
0
 /**
  * Обработка Ajax регистрации
  */
 protected function EventAjaxRegister()
 {
     /**
      * Устанавливаем формат Ajax ответа
      */
     $this->Viewer_SetResponseAjax('json');
     /**
      * Создаем объект пользователя и устанавливаем сценарий валидации
      */
     $oUser = Engine::GetEntity('ModuleUser_EntityUser');
     $oUser->_setValidateScenario('registration');
     /**
      * Заполняем поля (данные)
      */
     $oUser->setLogin(getRequestStr('login'));
     $oUser->setMail(getRequestStr('mail'));
     $oUser->setPassword(getRequestStr('password'));
     $oUser->setPasswordConfirm(getRequestStr('password_confirm'));
     $oUser->setCaptcha(getRequestStr('captcha'));
     $oUser->setDateRegister(date("Y-m-d H:i:s"));
     $oUser->setIpRegister(func_getIp());
     /**
      * Если используется активация, то генерим код активации
      */
     if (Config::Get('general.reg.activation')) {
         $oUser->setActivate(0);
         $oUser->setActivateKey(md5(func_generator() . time()));
     } else {
         $oUser->setActivate(1);
         $oUser->setActivateKey(null);
     }
     $this->Hook_Run('registration_validate_before', array('oUser' => $oUser));
     /**
      * Запускаем валидацию
      */
     if ($oUser->_Validate()) {
         $this->Hook_Run('registration_validate_after', array('oUser' => $oUser));
         $oUser->setPassword(func_encrypt($oUser->getPassword()));
         if ($this->User_Add($oUser)) {
             $this->Hook_Run('registration_after', array('oUser' => $oUser));
             /**
              * Убиваем каптчу
              */
             $this->Session_Drop('captcha_keystring_user_signup');
             /**
              * Подписываем пользователя на дефолтные события в ленте активности
              */
             $this->Stream_switchUserEventDefaultTypes($oUser->getId());
             /**
              * Если юзер зарегистрировался по приглашению то обновляем инвайт
              */
             if ($sCode = $this->GetInviteRegister()) {
                 $this->Invite_UseCode($sCode, $oUser);
             }
             /**
              * Если стоит регистрация с активацией то проводим её
              */
             if (Config::Get('general.reg.activation')) {
                 /**
                  * Отправляем на мыло письмо о подтверждении регистрации
                  */
                 $this->User_SendNotifyRegistrationActivate($oUser, getRequestStr('password'));
                 $this->Viewer_AssignAjax('sUrlRedirect', Router::GetPath('auth/register-confirm'));
             } else {
                 $this->User_SendNotifyRegistration($oUser, getRequestStr('password'));
                 $oUser = $this->User_GetUserById($oUser->getId());
                 /**
                  * Сразу авторизуем
                  */
                 $this->User_Authorization($oUser, false);
                 $this->DropInviteRegister();
                 /**
                  * Определяем URL для редиректа после авторизации
                  */
                 $sUrl = Config::Get('module.user.redirect_after_registration');
                 if (getRequestStr('return-path')) {
                     $sUrl = getRequestStr('return-path');
                 }
                 $this->Viewer_AssignAjax('sUrlRedirect', $sUrl ? $sUrl : Router::GetPath('/'));
                 $this->Message_AddNoticeSingle($this->Lang_Get('auth.registration.notices.success'));
             }
         } else {
             $this->Message_AddErrorSingle($this->Lang_Get('common.error.system.base'));
             return;
         }
     } else {
         /**
          * Получаем ошибки
          */
         $this->Viewer_AssignAjax('aErrors', $oUser->_getValidateErrors());
     }
 }