/** * Returns the error text if needed to prevent user activation * Пароль до активации и регистрации пользователя в phpBB хранится в открытом виде! * @param struct_core_users $user * @return string */ protected function beforeActivateUser($user) { if (!($error = $this->phpBBRegister($user))) { $user->u_pass = rad_session::encodePassword($user->u_pass); } return $error; }
/** * Register new user * @param struct_core_users $item */ public function register($item, $encode_password = true) { $item->u_active = 1; $item->u_subscribe_active = 1; $item->u_subscribe_langid = $this->getCurrentLangID(); $clearpass = empty($item->u_pass) ? rad_session::genereCode(6) : $item->u_pass; $item->u_pass = $encode_password ? rad_session::encodePassword($clearpass) : $clearpass; $this->insertItem($item); $item->u_id = $this->inserted_id(); rad_instances::get('model_coremail_subscribes')->removeExpired(); $item_url = new struct_coremail_subscribers_activationurl(); $item_url->sac_url = md5(rad_session::genereCode(31) . now() . $item->u_id); $item_url->sac_scrid = $item->u_id; $item_url->sac_type = 2; $item_url->email = $item->u_email; $item_url->date_created = time(); $item_url->save(); rad_mailtemplate::send($item->u_email, $this->config('registration.template'), array('user' => $item, 'link' => rad_input::makeURL('alias=register&c=' . urlencode($item_url->sac_url)), 'clearpass' => $clearpass), $this->config('mail_format', 'html')); }
/** * Check and validate input data about user before saving * @return TRUE if OK, FALSE if wrong * @author Slavik Tereshchenko * @package RADCMS * @datecreated 21.12.2011 */ private function _verifyInputData($item) { $messages = array(); $req = $this->getAllRequest(); foreach ($req as $key => $value) { if (is_string($value)) { $req[$key] = strip_tags(stripslashes($value)); } } $item->MergeArrayToStruct($req); if (empty($item->u_login)) { $messages[] = $this->lang('emptylogin.session.error'); } elseif (rad_instances::get('model_core_users')->loginExists($item->u_login, $item->u_id)) { $messages[] = $this->lang('loginexists.session.error'); } if (!filter_var($item->u_email, FILTER_VALIDATE_EMAIL)) { $messages[] = $this->lang('entervalidemail.session.error'); } elseif (rad_instances::get('model_core_users')->emailExists($item->u_email, $item->u_id)) { $messages[] = $this->lang('mailexsists.session.message'); } if ($this->request('changepass') !== NULL && $this->request('changepass') === 'on') { if ($this->request('u_pass') && $this->request('u_pass1') && $this->request('u_pass2')) { if (!strcmp($this->getCurrentUser()->u_pass, rad_session::encodePassword($this->request('u_pass')))) { if (strlen($this->request('u_pass1')) >= 6) { if (!strcmp($this->request('u_pass1'), $this->request('u_pass2'))) { $item->u_pass = rad_session::encodePassword($this->request('u_pass1')); } else { $messages[] = $this->lang('passwordnotpassed.session.error'); } } else { $messages[] = $this->lang('passwordishort.session.error'); } } else { $messages[] = $this->lang('passwordnotmatch.session.error'); } } else { $messages[] = $this->lang('passwordishort.session.error'); } } else { $item->u_pass = $this->getCurrentUser()->u_pass; } if (count($messages)) { $this->setVar('message', implode('<br />', $messages)); return false; } return true; }
protected function sendNewPassword() { $messages = array(); $actcode = $this->request('actcode'); $model = rad_instances::get('model_coremail_subscribes'); $item = $model->removeExpired()->setState('sac_url', $actcode)->setState('sac_type', 3)->getActivationUrl(); if (!empty($item->sac_id)) { $user = rad_instances::get('model_core_users')->setState('u_id', (int) $item->sac_scrid)->getItem(); if (!empty($user->u_id)) { $password = rad_session::genereCode(6); $user->u_pass = rad_session::encodePassword($password); if (!($error = $this->beforeSaveNewPassword($user, $password))) { $user->save(); $item->remove(); $this->_sendMail($user, 'newpass', array('clearpass' => $password)); $this->setVar('pass_sent', true); } else { $messages[] = $error; } } else { $messages[] = $this->lang('usernotfound.session.error'); } } else { $messages[] = $this->lang('wrongcode.session.error'); } if (count($messages)) { $this->setVar('message', implode('<br />', $messages)); } }