Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Удалил лишние файлы(неиспользуемые, остались с тестов) Поменял описание и текст в некоторых местах Авторизация- убрал в описании лишние слова. вход только по почте Поменял цвет фона.(проба) изменил шрифт Убрал лишние модули(login form от стандарной версии) Добавил пункты меню "о проекте" и "Обратная связь" (для смены содержимого "о проекте" менять статичный файл punk-shop-yii\protected\views\site\pages\about.php) favicon.ico перерисовал(был битый), переместил в папку с самим сайтом, поменял адрес в main.php. теперь отображается Поменял цветовую гамму на свой вкус, Попытался сделать закачку картинок пользователя при регистрации - пока не удачно. закомментировал фрагменты кода //!!!!!!!!!!!! таким образом в файле RegistrationController.php
- Loading branch information
Showing
18 changed files
with
1,343 additions
and
1,166 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* ContactForm class. | ||
* ContactForm is the data structure for keeping | ||
* contact form data. It is used by the 'contact' action of 'SiteController'. | ||
*/ | ||
class ContactForm extends CFormModel | ||
{ | ||
public $name; | ||
public $email; | ||
public $subject; | ||
public $body; | ||
public $verifyCode; | ||
|
||
/** | ||
* Declares the validation rules. | ||
*/ | ||
public function rules() | ||
{ | ||
return array( | ||
// name, email, subject and body are required | ||
array('name, email, subject, body', 'required'), | ||
// email has to be a valid email address | ||
array('email', 'email'), | ||
// verifyCode needs to be entered correctly | ||
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()), | ||
); | ||
} | ||
|
||
/** | ||
* Declares customized attribute labels. | ||
* If not declared here, an attribute would have a label that is | ||
* the same as its name with the first letter in upper case. | ||
*/ | ||
public function attributeLabels() | ||
{ | ||
return array( | ||
'verifyCode'=>'Verification Code', | ||
); | ||
} | ||
<?php | ||
|
||
/** | ||
* ContactForm class. | ||
* ContactForm is the data structure for keeping | ||
* contact form data. It is used by the 'contact' action of 'SiteController'. | ||
*/ | ||
class ContactForm extends CFormModel | ||
{ | ||
public $name; | ||
public $email; | ||
public $subject; | ||
public $body; | ||
public $verifyCode; | ||
|
||
/** | ||
* Declares the validation rules. | ||
*/ | ||
public function rules() | ||
{ | ||
return array( | ||
// name, email, subject and body are required | ||
array('name, email, subject, body', 'required'), | ||
// email has to be a valid email address | ||
array('email', 'email'), | ||
// verifyCode needs to be entered correctly | ||
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()), | ||
); | ||
} | ||
|
||
/** | ||
* Declares customized attribute labels. | ||
* If not declared here, an attribute would have a label that is | ||
* the same as its name with the first letter in upper case. | ||
*/ | ||
public function attributeLabels() | ||
{ | ||
return array( | ||
'verifyCode'=>'Код проверки', | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
188 changes: 105 additions & 83 deletions
188
punk-shop-yii/protected/modules/user/controllers/RegistrationController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,106 @@ | ||
<?php | ||
|
||
class RegistrationController extends Controller | ||
{ | ||
public $defaultAction = 'registration'; | ||
|
||
|
||
|
||
/** | ||
* Declares class-based actions. | ||
*/ | ||
public function actions() | ||
{ | ||
return (isset($_POST['ajax']) && $_POST['ajax']==='registration-form')?array():array( | ||
'captcha'=>array( | ||
'class'=>'CCaptchaAction', | ||
'backColor'=>0xFFFFFF, | ||
), | ||
); | ||
} | ||
/** | ||
* Registration user | ||
*/ | ||
public function actionRegistration() { | ||
$model = new RegistrationForm; | ||
$profile=new Profile; | ||
$profile->regMode = true; | ||
|
||
// ajax validator | ||
if(isset($_POST['ajax']) && $_POST['ajax']==='registration-form') | ||
{ | ||
echo UActiveForm::validate(array($model,$profile)); | ||
Yii::app()->end(); | ||
} | ||
|
||
if (Yii::app()->user->id) { | ||
$this->redirect(Yii::app()->controller->module->profileUrl); | ||
} else { | ||
if(isset($_POST['RegistrationForm'])) { | ||
$model->attributes=$_POST['RegistrationForm']; | ||
$profile->attributes=((isset($_POST['Profile'])?$_POST['Profile']:array())); | ||
if($model->validate()&&$profile->validate()) | ||
{ | ||
$soucePassword = $model->password; | ||
$model->activkey=UserModule::encrypting(microtime().$model->password); | ||
$model->password=UserModule::encrypting($model->password); | ||
$model->verifyPassword=UserModule::encrypting($model->verifyPassword); | ||
$model->createtime=time(); | ||
$model->lastvisit=((Yii::app()->controller->module->loginNotActiv||(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false))&&Yii::app()->controller->module->autoLogin)?time():0; | ||
$model->superuser=0; | ||
$model->status=((Yii::app()->controller->module->activeAfterRegister)?User::STATUS_ACTIVE:User::STATUS_NOACTIVE); | ||
|
||
if ($model->save()) { | ||
$profile->user_id=$model->id; | ||
$profile->save(); | ||
if (Yii::app()->controller->module->sendActivationMail) { | ||
$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $model->activkey, "email" => $model->email)); | ||
UserModule::sendMail($model->email,UserModule::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url))); | ||
} | ||
|
||
if ((Yii::app()->controller->module->loginNotActiv||(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false))&&Yii::app()->controller->module->autoLogin) { | ||
$identity=new UserIdentity($model->username,$soucePassword); | ||
$identity->authenticate(); | ||
Yii::app()->user->login($identity,0); | ||
$this->redirect(Yii::app()->controller->module->returnUrl); | ||
} else { | ||
if (!Yii::app()->controller->module->activeAfterRegister&&!Yii::app()->controller->module->sendActivationMail) { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Contact Admin to activate your account.")); | ||
} elseif(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false) { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please {{login}}.",array('{{login}}'=>CHtml::link(UserModule::t('Login'),Yii::app()->controller->module->loginUrl)))); | ||
} elseif(Yii::app()->controller->module->loginNotActiv) { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email or login.")); | ||
} else { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email.")); | ||
} | ||
$this->refresh(); | ||
} | ||
} | ||
} else $profile->validate(); | ||
} | ||
$this->render('/user/registration',array('model'=>$model,'profile'=>$profile)); | ||
} | ||
} | ||
<?php | ||
|
||
class RegistrationController extends Controller | ||
{ | ||
public $defaultAction = 'registration'; | ||
|
||
|
||
|
||
/** | ||
* Declares class-based actions. | ||
*/ | ||
public function actions() | ||
{ | ||
return (isset($_POST['ajax']) && $_POST['ajax']==='registration-form')?array():array( | ||
'captcha'=>array( | ||
'class'=>'CCaptchaAction', | ||
'backColor'=>0xFFFFFF, | ||
), | ||
); | ||
} | ||
/** | ||
* Registration user | ||
*/ | ||
public function actionRegistration() { | ||
$model = new RegistrationForm; | ||
$profile=new Profile; | ||
$profile->regMode = true; | ||
//!!!!!!!!!!!! | ||
if(!is_dir(Yii::getPathOfAlias('webroot').'/img/Users')) | ||
{ | ||
mkdir(Yii::getPathOfAlias('webroot').'/img/Users', 0755); | ||
} | ||
//;!!!!!!!!!!!! | ||
|
||
// ajax validator | ||
if(isset($_POST['ajax']) && $_POST['ajax']==='registration-form') | ||
{ | ||
echo UActiveForm::validate(array($model,$profile)); | ||
Yii::app()->end(); | ||
} | ||
|
||
if (Yii::app()->user->id) { | ||
$this->redirect(Yii::app()->controller->module->profileUrl); | ||
} else { | ||
if(isset($_POST['RegistrationForm'])) { | ||
$model->attributes=$_POST['RegistrationForm']; | ||
$profile->attributes=((isset($_POST['Profile'])?$_POST['Profile']:array())); | ||
//!!!!!!!!!!!! | ||
$images = CUploadedFile::getInstancesByName('Images'); | ||
|
||
foreach ($images as $image => $pic) { | ||
$file = $model->id.'_'.$pic->name; | ||
$savefile = Yii::getPathOfAlias('webroot').'/img/Users/'. $file; | ||
|
||
if ($pic->saveAs($savefile)) { | ||
|
||
$img_add = new Images; | ||
$img_add->src = $file; | ||
$img_add->good_id = $model->id; | ||
$img_add->save(); // DONE | ||
} | ||
} | ||
//;!!!!!!!!!!!! | ||
if($model->validate()&&$profile->validate()) | ||
{ | ||
$soucePassword = $model->password; | ||
$model->activkey=UserModule::encrypting(microtime().$model->password); | ||
$model->password=UserModule::encrypting($model->password); | ||
$model->verifyPassword=UserModule::encrypting($model->verifyPassword); | ||
$model->createtime=time(); | ||
$model->lastvisit=((Yii::app()->controller->module->loginNotActiv||(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false))&&Yii::app()->controller->module->autoLogin)?time():0; | ||
$model->superuser=0; | ||
$model->status=((Yii::app()->controller->module->activeAfterRegister)?User::STATUS_ACTIVE:User::STATUS_NOACTIVE); | ||
|
||
if ($model->save()) { | ||
$profile->user_id=$model->id; | ||
$profile->save(); | ||
if (Yii::app()->controller->module->sendActivationMail) { | ||
$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $model->activkey, "email" => $model->email)); | ||
UserModule::sendMail($model->email,UserModule::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url))); | ||
} | ||
|
||
if ((Yii::app()->controller->module->loginNotActiv||(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false))&&Yii::app()->controller->module->autoLogin) { | ||
$identity=new UserIdentity($model->username,$soucePassword); | ||
$identity->authenticate(); | ||
Yii::app()->user->login($identity,0); | ||
$this->redirect(Yii::app()->controller->module->returnUrl); | ||
} else { | ||
if (!Yii::app()->controller->module->activeAfterRegister&&!Yii::app()->controller->module->sendActivationMail) { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Contact Admin to activate your account.")); | ||
} elseif(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false) { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please {{login}}.",array('{{login}}'=>CHtml::link(UserModule::t('Login'),Yii::app()->controller->module->loginUrl)))); | ||
} elseif(Yii::app()->controller->module->loginNotActiv) { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email or login.")); | ||
} else { | ||
Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email.")); | ||
} | ||
$this->refresh(); | ||
} | ||
} | ||
} else $profile->validate(); | ||
} | ||
$this->render('/user/registration',array('model'=>$model,'profile'=>$profile)); | ||
} | ||
} | ||
} |
Oops, something went wrong.