public function goSubscription() { $this->date_create = time(); $this->hash = md5($this->email . microtime() . rand(0, 1000000)); if ($this->save(false)) { $link = Yii::app()->controller->createAbsoluteUrl('site/subscriptionConform', array('hash' => $this->hash)); $message = Yii::app()->controller->renderPartial('/messages/subscription', array('link' => CHtml::link($link, $link)), true); MyPhpMailer::send($this->email, 'Подписка - ' . $_SERVER['SERVER_NAME'], $message); return true; } else { return false; } }
public function actionRecover() { $model = new RecoverForm(); if (isset($_POST['ajax']) && $_POST['ajax'] === 'recover-form') { echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['RecoverForm'])) { $model->attributes = $_POST['RecoverForm']; if ($model->validate()) { $user = Users::model()->findByAttributes(array("email" => $model->email)); $password = md5(uniqid()); $user->hash = md5($user->email . uniqid()); $user->userkey = sha1($user->email . uniqid()); $user->password = md5($password . $user->hash); if ($user->save()) { $message = $this->renderPartial('/messages/recover', array("username" => $user->username, "password" => $password), true); MyPhpMailer::send($user->email, "Восстановление пароля на FermionAm.ru", $message); $this->redirect(array('site/index')); } else { print CHtml::errorSummary($user); Yii::app()->end(); } } else { print CHtml::errorSummary($model); Yii::app()->end(); } } $this->render('recover', array('model' => $model)); }
public function newPassword() { $password = $this->pass; $this->password = CPasswordHelper::hashPassword($this->pass); $this->hash = null; if ($this->save(false)) { $message = Yii::app()->controller->renderPartial('/messages/newPassword', array('name' => $this->name, 'login' => $this->login, 'password' => $password), true); MyPhpMailer::send($this->login, 'Новый пароль - ' . $_SERVER['SERVER_NAME'], $message); return true; } else { return false; } }