public function actionRegister() { $this->pageTitle = Yii::t('title', 'Registration'); $settings = Settings::model()->find(); $form = new AccountData(); $form->scenario = 'register'; if (isset($_GET['id'])) { $id = $_GET['id']; $cookie = new CHttpCookie('pow_referal', $id); $cookie->expire = time() + 60 * 60 * 24; Yii::app()->request->cookies['pow_referal'] = $cookie; } if (isset($_POST['AccountData'])) { $form->attributes = $_POST['AccountData']; if ($form->save()) { if ($settings->referal_enable == 1 and isset(Yii::app()->request->cookies['pow_referal']->value)) { $master = AccountData::model()->findByPk(Yii::app()->request->cookies['pow_referal']->value); $model = new LogReferals(); $model->master = $master->name; $model->master_id = $master->id; $model->slave = $form->name; $model->slave_id = $form->id; $model->save(false); unset(Yii::app()->request->cookies['pow_referal']); } if ($settings->trial_enable == 1) { $model = AccountData::model()->findByPk($form->id); $model->scenario = 'membership'; $model->membership = $settings->trial_type; $model->expire = date("Y-m-d", mktime() + $settings->trial_days * 86400); $model->save(false); } if ($settings->email_activation == 1) { $code = substr(md5(uniqid(rand(), true)), 0, rand(10, 15)); $link = '<a href="' . Yii::app()->homeUrl . 'account/activation/' . $code . '">' . Yii::app()->homeUrl . 'account/activation/' . $code . '</a>'; $model = AccountData::model()->findByPk($form->id); $model->activated = 0; $model->activation = $code; $model->save(false); $to = $model->email; $subject = 'Account activation'; $message = 'You have successfully registered as <a href="' . Yii::app()->homeUrl . '">' . Yii::app()->name . '</a><br /><br />To activate your account, click the following link: ' . $link; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; $headers .= 'To: ' . $model->name . ' <' . $model->email . '>' . "\r\n"; $headers .= 'From: ' . Yii::app()->name . ' <' . Yii::app()->params['adminEmail'] . '>' . "\r\n"; mail($to, $subject, $message, $headers); Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('account', 'Account successfully created! Please check your email inbox for the activation link.') . '</div>'); $this->refresh(); } Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('account', 'Account creation successful!') . '</div>'); $this->refresh(); } } $this->render('register', array('form' => $form)); }