/**
  * Обновляет юзера
  *
  * @param ModuleUser_EntityUser $oUser Объект пользователя
  * @return bool
  */
 public function Update(ModuleUser_EntityUser $oUser)
 {
     $sql = "UPDATE " . Config::Get('db.table.user') . "\n      SET\n        user_password = ? ,\n        user_mail = ? ,\n        user_skill = ? ,\n        user_date_activate = ? ,\n        user_date_comment_last = ? ,\n        user_rating = ? ,\n        user_count_vote = ? ,\n        user_activate = ? ,\n                user_activate_key = ? ,\n        user_profile_name = ? ,\n        user_profile_sex = ? ,\n        user_profile_country = ? ,\n        user_profile_region = ? ,\n        user_profile_city = ? ,\n        user_profile_birthday = ? ,\n        user_profile_about = ? ,\n        user_profile_date = ? ,\n        user_profile_avatar = ?  ,\n        user_profile_foto = ? ,\n        user_settings_notice_new_topic = ?  ,\n        user_settings_notice_new_comment = ? ,\n        user_settings_notice_new_talk = ?  ,\n        user_settings_notice_reply_comment = ? ,\n        user_settings_notice_new_friend = ? ,\n        user_settings_timezone = ?\n      WHERE user_id = ?\n    ";
     if ($this->oDb->query($sql, $oUser->getPassword(), $oUser->getMail(), $oUser->getSkill(), $oUser->getDateActivate(), $oUser->getDateCommentLast(), $oUser->getRating(), $oUser->getCountVote(), $oUser->getActivate(), $oUser->getActivateKey(), $oUser->getProfileName(), $oUser->getProfileSex(), $oUser->getProfileCountry(), $oUser->getProfileRegion(), $oUser->getProfileCity(), $oUser->getProfileBirthday(), $oUser->getProfileAbout(), $oUser->getProfileDate(), $oUser->getProfileAvatar(), $oUser->getProfileFoto(), $oUser->getSettingsNoticeNewTopic(), $oUser->getSettingsNoticeNewComment(), $oUser->getSettingsNoticeNewTalk(), $oUser->getSettingsNoticeReplyComment(), $oUser->getSettingsNoticeNewFriend(), $oUser->getSettingsTimezone(), $oUser->getId())) {
         return true;
     }
     return false;
 }
예제 #2
0
 /**
  * Compares user's password and passed password
  *
  * @param ModuleUser_EntityUser $oUser
  * @param string $sCheckPassword
  *
  * @return bool
  */
 public function CheckPassword($oUser, $sCheckPassword)
 {
     $sUserPassword = $oUser->getPassword();
     if (E::ModuleSecurity()->CheckSalted($sUserPassword, $sCheckPassword, 'pass') || E::ModuleSecurity()->CheckSalted($sUserPassword, trim($sCheckPassword), 'pass')) {
         return true;
     }
     return false;
 }
예제 #3
0
 /**
  * Форма смены пароля, емайла
  */
 protected function EventAccount()
 {
     /**
      * Устанавливаем title страницы
      */
     E::ModuleViewer()->AddHtmlTitle(E::ModuleLang()->Get('settings_menu_profile'));
     $this->sMenuSubItemSelect = 'account';
     /**
      * Если нажали кнопку "Сохранить"
      */
     if (isPost('submit_account_edit')) {
         E::ModuleSecurity()->ValidateSendForm();
         $bError = false;
         /**
          * Проверка мыла
          */
         if (F::CheckVal(F::GetRequestStr('mail'), 'mail')) {
             if (($oUserMail = E::ModuleUser()->GetUserByMail(F::GetRequestStr('mail'))) && $oUserMail->getId() != $this->oUserCurrent->getId()) {
                 E::ModuleMessage()->AddError(E::ModuleLang()->Get('settings_profile_mail_error_used'), E::ModuleLang()->Get('error'));
                 $bError = true;
             }
         } else {
             E::ModuleMessage()->AddError(E::ModuleLang()->Get('settings_profile_mail_error'), E::ModuleLang()->Get('error'));
             $bError = true;
         }
         /**
          * Проверка на смену пароля
          */
         if ($sPassword = $this->GetPost('password')) {
             if (($nMinLen = Config::Get('module.security.password_len')) < 3) {
                 $nMinLen = 3;
             }
             if (F::CheckVal($sPassword, 'password', $nMinLen)) {
                 if ($sPassword == $this->GetPost('password_confirm')) {
                     if (E::ModuleSecurity()->CheckSalted($this->oUserCurrent->getPassword(), $this->GetPost('password_now'), 'pass')) {
                         $this->oUserCurrent->setPassword($sPassword, true);
                     } else {
                         $bError = true;
                         E::ModuleMessage()->AddError(E::ModuleLang()->Get('settings_profile_password_current_error'), E::ModuleLang()->Get('error'));
                     }
                 } else {
                     $bError = true;
                     E::ModuleMessage()->AddError(E::ModuleLang()->Get('settings_profile_password_confirm_error'), E::ModuleLang()->Get('error'));
                 }
             } else {
                 $bError = true;
                 E::ModuleMessage()->AddError(E::ModuleLang()->Get('settings_profile_password_new_error', array('num' => $nMinLen)), E::ModuleLang()->Get('error'));
             }
         }
         /**
          * Ставим дату последнего изменения
          */
         $this->oUserCurrent->setProfileDate(F::Now());
         /**
          * Запускаем выполнение хуков
          */
         E::ModuleHook()->Run('settings_account_save_before', array('oUser' => $this->oUserCurrent, 'bError' => &$bError));
         /**
          * Сохраняем изменения
          */
         if (!$bError) {
             if (E::ModuleUser()->Update($this->oUserCurrent)) {
                 E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('settings_account_submit_ok'));
                 /**
                  * Подтверждение смены емайла
                  */
                 if (F::GetRequestStr('mail') && F::GetRequestStr('mail') != $this->oUserCurrent->getMail()) {
                     if ($oChangemail = E::ModuleUser()->MakeUserChangemail($this->oUserCurrent, F::GetRequestStr('mail'))) {
                         if ($oChangemail->getMailFrom()) {
                             E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('settings_profile_mail_change_from_notice'));
                         } else {
                             E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('settings_profile_mail_change_to_notice'));
                         }
                     }
                 }
                 E::ModuleHook()->Run('settings_account_save_after', array('oUser' => $this->oUserCurrent));
             } else {
                 E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->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'));
             }
         }
     }
 }