public function actionIndex($id) { $this->processPageRequest('page'); if ($dataStr = Yii::app()->request->getParam('data')) { if (!empty($dataStr)) { if ($id == null) { $id = 1; } $data = strtotime($dataStr); $criteria = new CDbCriteria(); $criteria->condition = 'category_id =:id AND status=2 AND DATE_FORMAT(FROM_UNIXTIME(created), "%Y%m%d")=:data'; $criteria->params = array(':data' => date('Ymd', $data), ':id' => $id); $model = CmsSetting::model()->findByPk(1); $prow = new CActiveDataProvider('CmsPage', array('criteria' => $criteria, 'pagination' => array('pageSize' => $model->ct_page, 'pageVar' => 'page'))); } } else { $category = CmsCategory::model()->findByPk($id); $criteria = new CDbCriteria(); $criteria->condition = 'status = 2 AND category_id =:id AND ' . 'created < :time'; $criteria->params = array(':id' => $id, ':time' => time()); $criteria->order = 'created DESC'; $model = CmsSetting::model()->findByPk(1); $prow = new CActiveDataProvider('CmsPage', array('criteria' => $criteria, 'pagination' => array('pageSize' => $model->ct_page, 'pageVar' => 'page'))); } if (Yii::app()->request->isAjaxRequest) { $this->renderPartial('widget_ajax', array('category' => $category, 'data' => $prow)); Yii::app()->end(); } else { $this->render('index', array('category' => $category, 'data' => $prow, 'val' => $dataStr)); } }
public function actionChangePassword($id, $time) { $model = CmsSetting::model()->findByPk(1); if ($id == 0 && $time == 0) { if (CmsUser::sendPas()) { Yii::app()->user->setFlash('success', 'На ваш email отправлено письмо. Для смены пароля перейдите по ссылке в письме'); } else { Yii::app()->user->setFlash('error', 'Письмо не отправленно'); } $flag = false; } else { if ($id == Yii::app()->user->id) { $flag = true; if ($model->time < time() - $time) { if (isset($_POST['password'])) { if (CmsUser::model()->updateByPk(Yii::app()->user->id, array('password' => md5('lkjhgfd' . $_POST['password'])))) { $flag = false; Yii::app()->user->setFlash('success', 'Ваш пароль изменён'); } else { Yii::app()->user->setFlash('error', 'пароль не изменён'); } $this->render('ChangePassword', array('flag' => $flag)); Yii::app()->end(); } } } } $this->render('ChangePassword', array('flag' => $flag)); }
public function actionIndex() { $model = new CmsSetting(); if (isset($_POST['CmsSetting'])) { $model->attributes = $_POST['CmsSetting']; $flag = CmsSetting::model()->updateByPk(1, array('ct_page' => $model->ct_page, 'time' => $model->time, 'podtv_email' => $model->podtv_email, 'poblicazia_com' => $model->poblicazia_com, 'publicazia_stat' => $model->publicazia_stat, 'gost_com' => $model->gost_com)); } $model = CmsSetting::model()->findByPk(1); $this->render('index', array('model' => $model)); }
/** * Displays the login page */ public function actionLogin() { /** * Авторизация по токену для восстановления пароля */ if ($recoveryPasswordToken = Yii::app()->request->getParam('token')) { if ($user = CmsUser::getByRecoveryPasswordToken($recoveryPasswordToken)) { $log = new LoginForm(); $log->username = $user->username; $log->password = $user->password; $log->login(); $this->redirect($this->createAbsoluteUrl('UserPersonal/index', array('id' => $user->id))); } } $service = Yii::app()->request->getQuery('service'); if (isset($service)) { $authIdentity = Yii::app()->eauth->getIdentity($service); $authIdentity->redirectUrl = Yii::app()->user->returnUrl; $authIdentity->cancelUrl = $this->createAbsoluteUrl('site/login'); if ($authIdentity->authenticate()) { $identity = new ServiceUserIdentity($authIdentity); // Успешный вход if ($identity->authenticate()) { Yii::app()->user->login($identity); // Специальный редирект с закрытием popup окна $authIdentity->redirect(); } else { // Закрываем popup окно и перенаправляем на cancelUrl $authIdentity->cancel(); } } $this->redirect(array('site/login')); } //авторизация с помошью соц сетей $model = new LoginForm(); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid // $model1=CmsUser::model()->findByAttributes(array('username'=>$model->username)); $model_set = CmsSetting::model()->findByPk(1); if ($model_set->podtv_email == 1) { $user = CmsUser::model()->findByAttributes(array('username' => $model->username)); $user->sendRecoveryPasswordMessage(); $this->render('login', array('model' => $model, 'flag' => true)); Yii::app()->end(); } else { if ($model->validate() && $model->login()) { $this->redirect(array('UserPersonal/index', 'id' => Yii::app()->user->id)); } } } // display the login form $this->render('login', array('model' => $model)); }
public function getRecoveryPasswordToken($expires = 5, $time = null) { $set = CmsSetting::model()->findByPk(1); $expires = $set->time; $passHash = self::hashPassword($this->password); $time = is_null($time) ? time() : $time; $hash = sha1(Yii::app()->params['recoveryPasswordPrivateKey'] . $passHash . $this->username . $this->id . $time . $expires); return implode(':', array($time, $expires, $this->id, $hash)); }
public static function vivod($id) { $criteria = new CDbCriteria(); $criteria->condition = 'page_id=:id AND status=0 OR status=2'; $criteria->params = array(':id' => $id); $model = CmsSetting::model()->findByPk(1); return new CActiveDataProvider('CmsComment', array('criteria' => $criteria)); }
</div> </div> <div class="row"> <div class="thumbnail textCom"> <?php echo CmsComment::model()->countByAttributes(array('page_id' => $model->id, 'status' => 1)); ?> коментариев <?php $flag = CmsSetting::model()->findByPk(1); if (!Yii::app()->user->isGuest || Yii::app()->user->isGuest && $flag->gost_com) { ?> <a class="linkCom" id="linkComId"><i class="fa fa-pencil-square-o"> Оставить Комментарий</i></a> <?php } ?> </div> </div> <?php if ($model->status != 0 && $model->status != 1) { $this->renderPartial('_view', array('comments' => $comments)); $this->renderPartial('newcomment', array('model' => $model1)); } ?>
public function actionEditPassword() { $model = CmsSetting::model()->findByPk(1); if (!Yii::app()->request->getParam('id') && !Yii::app()->request->getParam('time')) { if (CmsUser::sendPas()) { $this->sendResponse(self::STATUS_OK, "email отправлен"); } else { $this->sendResponse(self::STATUS_INTERNAL_SERVER_ERROR, "email не отправлен"); } } else { $id = Yii::app()->request->getParam('id'); $time = Yii::app()->request->getParam('time'); if ($id == Yii::app()->user->id) { if ($model->time < time() - $time) { if (isset($_POST['password'])) { if (CmsUser::model()->updateByPk(Yii::app()->user->id, array('password' => md5('lkjhgfd' . $_POST['password'])))) { $this->actionResponse = array('user' => CmsUser::model()->findByPk(Yii::app()->user->id)); } else { $this->sendResponse(self::STATUS_INTERNAL_SERVER_ERROR, "пароль изменён"); } } } } } }
public static function vivod($id) { $criteria = new CDbCriteria(); $criteria->condition = 'status = 2'; $criteria->compare('category_id', $id); $model = CmsSetting::model()->findByPk(1); return new CActiveDataProvider('CmsPage', array('criteria' => $criteria, 'pagination' => array('pageSize' => $model->ct_page))); }