コード例 #1
0
 public function actionConfirm()
 {
     if (!isset($_GET['email']) && !isset($_GET['key'])) {
         $this->redirect(array('index/index'));
     }
     switch (EmailVerification::model()->confirm($_GET['email'], $_GET['key'])) {
         case EmailVerification::CONFIRM_ALREADY_ACTIVE:
             echo UserModule::t('This email address has already been verified. Thank you!');
             break;
         case EmailVerification::CONFIRM_INVALID_KEY:
             echo UserModule::t('The confirmation key is invalid!');
             break;
         case EmailVerification::CONFIRM_KEY_NOT_ACTIVE:
             echo UserModule::t('This key is no longer active');
             break;
         case EmailVerification::CONFIRM_USER_BLOCKED:
             echo UserModule::t('This account is currently blocked');
             break;
         case EmailVerification::CONFIRM_SUCCESS:
             echo UserModule::t('This email is now verified. You can log in your account using this email. Thank you!');
             break;
         case EmailVerification::CONFIRM_ERROR:
         default:
             echo UserModule::t('Oops, an error has occurred! Please try again.');
     }
 }
コード例 #2
0
ファイル: User.php プロジェクト: redlaw/lintinzone
 public static function sendRegisterVerification($email, $username)
 {
     if (empty($email)) {
         return false;
     }
     $key = sha1(uniqid(rand()));
     $data = array('verification_key' => $key);
     $model = EmailVerification::model()->get($email);
     if ($model === null) {
         /*$model = new EmailVerification();
         		$model->email = $email;
         		$model->verification_key = $key;*/
         $mailParams = array('from' => Yii::app()->params['adminEmail'], 'fromName' => 'LintinZone', 'to' => $email, 'subject' => 'LintinZone ' . UserModule::t('Xác nhận đăng ký thành viên'), 'body' => array('{receiver}' => empty($username) ? UserModule::t('my friend') : $username, '{confirm_link}' => Yii::app()->createAbsoluteUrl('user/registration/confirm', array('key' => $key, 'email' => $email)), '{support_link}' => Yii::app()->createAbsoluteUrl('site/contact', array('email' => $email)), '{home_link}' => Yii::app()->createAbsoluteUrl('')));
         if (MailSender::sendSMTP($mailParams, 'register', 'text/html')) {
             /*$model->sent_date = new CDbExpression('NOW()');
             		$model->save();*/
             $data['sent'] = true;
             $data['active'] = true;
             $data['verified'] = false;
             EmailVerification::model()->insert($email, $data);
             return true;
         }
         //$model->save();
         $data['sent'] = false;
         $data['active'] = true;
         $data['verified'] = false;
         EmailVerification::model()->insert($email, $data);
         return false;
     } else {
         if (!$model->verified) {
             //$model->verification_key = $key;
             $mailParams = array('from' => Yii::app()->params['adminEmail'], 'fromName' => 'LintinZone', 'to' => $email, 'subject' => 'LintinZone ' . UserModule::t('Xác nhận đăng ký thành viên'), 'body' => array('{receiver}' => empty($username) ? UserModule::t('my friend') : $username, '{confirm_link}' => Yii::app()->createAbsoluteUrl('user/registration/confirm', array('key' => $key, 'email' => $email)), '{support_link}' => Yii::app()->createAbsoluteUrl('site/contact', array('email' => $email)), '{home_link}' => Yii::app()->createAbsoluteUrl('')));
             if (MailSender::sendSMTP($mailParams, 'register', 'text/html')) {
                 $data['sent'] = true;
                 $data['active'] = true;
                 $data['verified'] = false;
                 EmailVerification::model()->insert($email, $data);
                 return true;
             }
             $data['sent'] = false;
             $data['active'] = true;
             $data['verified'] = false;
             EmailVerification::model()->insert($email, $data);
             return false;
         } else {
             return true;
         }
     }
 }