Exemple #1
0
 public function run()
 {
     parent::run();
     $data['user']['total'] = Member::model()->count();
     $data['user']['new'] = Member::model()->find(array("order" => "id desc"));
     $this->render('statistics', $data);
 }
 public function actionEmail()
 {
     if (empty(Yii::app()->session['ValidateMid'])) {
         throw new CHttpException(400, '链接已失效!');
         exit;
     }
     if ($_GET['mid'] == Yii::app()->session['ValidateMid'] && base64_decode($_GET['key']) > time()) {
         /*if(empty($_GET['mid'])){
         			header("Content-Type: text/html; charset=utf-8");
         			echo "<script>alert('没有此用户!');</script>";
         			exit;
         		}*/
         $returnValue = Member::model()->updateAll(array('email_validate' => 1), "id=" . Yii::app()->session['ValidateMid']);
         if ($returnValue > 0) {
             unset(Yii::app()->session['ValidateMid']);
             $this->redirect(array('member/email'));
         } else {
             echo "shibai";
         }
     } else {
         if ($_GET['mid'] != Yii::app()->session['mid']) {
             header("Content-Type: text/html; charset=utf-8");
             echo "<script>alert('用户名不匹配!');</script>";
             exit;
         }
         if (base64_decode($_GET['key']) < time()) {
             header("Content-Type: text/html; charset=utf-8");
             echo "<script>alert('时间超时请重新申请!');</script>";
             exit;
         }
     }
 }
 public function actionLogin()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect(array('site/index'));
     }
     $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'];
         if ($model->validate() && $model->login()) {
             $this->redirect(Yii::app()->request->urlReferrer);
         } else {
             $returnName = Member::model()->findByAttributes(array('mname' => trim($_POST['LoginForm']['username'])));
             if (empty($returnName)) {
                 echo 'namenull';
             } elseif ($returnName->password != Member::model()->encrypt($_POST['LoginForm']['password'])) {
                 echo 'passworderror';
             } else {
                 echo 'verifyCodeerror';
             }
         }
     }
     // display the login form
     $this->render('login', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionIndex()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (empty(Yii::app()->user->id)) {
         throw new CHttpException(400, '您目前还没有登录请登录!');
         exit;
     }
     $email = Member::model()->findByAttributes(array('id' => Yii::app()->user->id));
     if (empty($email->email)) {
         throw new CHttpException(400, '您的个人资料里邮箱没有填写!');
         exit;
     }
     if ($email->email_validate == 0) {
         throw new CHttpException(400, '您的个人资料里邮箱没有验证!');
         //header("Location: ../member/update/".Yii::app()->user->id.".html");
     }
     if (isset($_POST['Order'])) {
         $model->attributes = $_POST['Order'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function authenticate($isopenid = false, $memberid = null, $key = null)
 {
     if ($isopenid) {
         $this->_id = $memberid;
         return true;
     }
     $member = Member::model()->getMember($this->username);
     if ($member === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         // activate the member if key matches the invite key
         // if(!empty($key) && $key === $member->invitekey)
         //	{$member->active = 1;$member->save(false);}
         if ($member["password"] !== Member::model()->encrypt($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($member["active"] == 0) {
                 $this->errorCode = self::ERROR_MEMBER_INACTIVE;
             } else {
                 $this->_id = $member["memberid"];
                 if (null === $member["lastlogintime"]) {
                     $lastLogin = time();
                 } else {
                     $lastLogin = strtotime($member["lastlogintime"]);
                 }
                 $this->setState('lastLoginTime', $lastLogin);
                 $this->setState('membername', $member["membername"]);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
     }
     return !$this->errorCode;
 }
 public function actionSave()
 {
     if ($_POST) {
         $trans = Yii::app()->db->beginTransaction();
         try {
             $id_member = $_POST['id_member'];
             $new_id_member = $_POST['new_id_member'];
             $member = Member::model()->findByPk($id_member);
             $member->id_member = $new_id_member;
             $member->type_card = 'Diamond';
             if ($member->validate() && $member->update()) {
                 $upgrade = new UpgradeMembership();
                 $upgrade->old_idmember = $_POST['id_member'];
                 $upgrade->new_idmember = $_POST['new_id_member'];
                 $upgrade->username = Yii::app()->user->getId();
                 $upgrade->upgrade_date = date('Y-m-d');
                 $upgrade->old_point = $member->point;
                 if ($upgrade->validate() && $upgrade->save()) {
                     $trans->commit();
                     echo CJSON::encode(array('message' => 'Membership has been upgrade successfully to Diamond'));
                 } else {
                     throw new Exception('Rollback on Upgrade Table');
                 }
             } else {
                 throw new Exception('Rollback on Member Table');
             }
         } catch (CDbException $e) {
             $trans->rollback();
         }
     }
 }
Exemple #7
0
	/**
	 * Authenticates a user.
	 * The example implementation makes sure if the username and password
	 * are both 'demo'.
	 * In practical applications, this should be changed to authenticate
	 * against some persistent user identity storage (e.g. database).
	 * @return boolean whether authentication succeeds.
	 */
	public function authenticate()
	{
		//$valid = preg_match('/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/',$this->username);//验证是否为邮箱
		$admins = Member::model()->find(array('condition'=>"name='$this->username' or email='$this->username'"));
		//$admins = Member::model()->find('name=:name',array(':name'=>$this->username));//获取这个用户名下的信息
		if($admins == NULL){
			$this->errorCode=self::ERROR_USERNAME_INVALID;
			return false;
		}
		if($admins->password !== md5($this->password)){
			$this->errorCode=self::ERROR_PASSWORD_INVALID;
			return false;
		}
		
		$this->errorCode=self::ERROR_NONE;
		return true;
		
		/* if(!isset($users[$this->username]))
			$this->errorCode=self::ERROR_USERNAME_INVALID;
		elseif($users[$this->username]!==$this->password)
			$this->errorCode=self::ERROR_PASSWORD_INVALID;
		else
			$this->errorCode=self::ERROR_NONE;
		return !$this->errorCode; */
	}
 public function authenticate()
 {
     $this->username = trim($this->username);
     $user = Member::model()->findByAttributes(array('mname' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== $user->encrypt($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             //if($this->createAction('captcha')->getVerifyCode()!=$this->verifyCode){
             //$this->errorCode=self::ERROR_VERIFYCODE_INVALID;
             //}else{
             $this->_id = $user->id;
             if (null === $user->login_time) {
                 $lastLogin = time();
             } else {
                 $lastLogin = strtotime($user->login_time);
             }
             $this->_name = $user->mname;
             $this->setState('lastLoginTime', $lastLogin);
             $this->errorCode = self::ERROR_NONE;
             //}
         }
     }
     return !$this->errorCode;
 }
Exemple #9
0
 public static function get_vip($id)
 {
     $user = Member::model()->findByPk($id);
     if (!is_array($user)) {
         return 0;
     }
     return $user->premium == '' ? 0 : $user->premium;
 }
Exemple #10
0
 public function run()
 {
     parent::run();
     $data['mem_nhiettinh'] = Member::model()->findAll(array("limit" => 6, "order" => "point desc"));
     $data['mem_chuyencan'] = Member::model()->findAll(array("limit" => 6, "order" => "diligent_point desc"));
     $data['mem_thanhtich'] = Member::model()->findAll(array("limit" => 6, "order" => "mark desc"));
     $this->render('top_member', $data);
 }
 /**
  * Fifth sequence
  * Method mencari data member berdasarkan id member
  */
 public function actionSearchMember()
 {
     $id_member = $_POST['id_member'];
     $criteria = new CDbCriteria();
     $criteria->condition = 'id_member=:id_member';
     $criteria->params = array(':id_member' => $id_member);
     $model = Member::model()->find($criteria);
     echo CJSON::encode($model);
 }
 public function actionSave()
 {
     if ($_POST) {
         $trans = Yii::app()->db->beginTransaction();
         try {
             $redeem = new Redeem();
             $autonumber = $redeem->autonumber();
             $table_length = $_POST['table_length'];
             $point = 0;
             $member_name = '';
             $voucher_list = array();
             if ($table_length < 1) {
                 throw new Exception('Rollback Table Length');
             }
             if (empty($_POST['id_member'])) {
                 throw new Exception('Rollback ID Member');
             }
             $redeem->id_redeem = $autonumber;
             $redeem->redeem_point = $_POST['redeem_point'];
             $redeem->username = Yii::app()->user->getId();
             $redeem->redeem_date = date('Y-m-d');
             $redeem->id_member = $_POST['id_member'];
             if (!$redeem->validate() or !$redeem->save()) {
                 throw new Exception('Rollback Redeem');
             }
             for ($i = 0; $i < $table_length; $i++) {
                 $detail_redeem = new DetailRedeem();
                 $detail_redeem->id_redeem = $autonumber;
                 $detail_redeem->id_voucher = $_POST['id_voucher_list'][$i];
                 $detail_redeem->voucher_number = $_POST['number_voucher_list'][$i];
                 // mendapatkan nama voucher dan jumlah voucher yang diredeem untuk dicetak distruk
                 $voucher = Voucher::model()->findByPk($_POST['id_voucher_list'][$i]);
                 $voucher_list[] = array($voucher->voucher_name, $_POST['number_voucher_list'][$i]);
                 if ($detail_redeem->validate() and $detail_redeem->save()) {
                     $member = Member::model()->findByPk($_POST['id_member']);
                     $member_name = $member->first_name . ' ' . $member->family_name;
                     $member->point -= $_POST['total_redeem_list'][$i];
                     if (!$member->update()) {
                         throw new Exception('Rollback Update Point Member');
                     }
                     $point = $member->point;
                 } else {
                     throw new Exception('Rollback Detail Redeem');
                 }
             }
             $trans->commit();
             $get_name = User::model()->findByPk(Yii::app()->user->getId());
             $dataRedeem = $this->renderPartial('_receipt', array('id_member' => $_POST['id_member'], 'member_name' => $member_name, 'point' => $point + $redeem->redeem_point, 'redeem_point' => $redeem->redeem_point, 'remaining' => $point, 'vouchers' => $voucher_list, 'name' => $get_name->name), true, false);
             echo CJSON::encode(array('message' => 'Transaction redeem point has been saved Successfully!', 'receipt' => $dataRedeem));
         } catch (CDbException $e) {
             $trans->rollback();
         }
     }
 }
Exemple #13
0
 public function run()
 {
     parent::run();
     $user = array();
     if ($this->_session['isLogin'] == 1 & $this->_session['login_id'] > 0) {
         $user = Member::model()->findByPk($this->_session['login_id']);
     }
     //$this->_session['login_id']
     $user_login = new UserLoginForm();
     $this->render('login', array('iUser' => $user_login, 'user' => $user));
 }
Exemple #14
0
 protected function MemberTipe()
 {
     $user = $this->loadModel();
     $user = $user->username;
     if ($user) {
         $tipe = Member::model()->find("email = '{$user}' ")->type_account;
         return $tipe;
     } else {
         return "Guest";
     }
 }
	public function actionIndex()
	{
		//如果已经登录直接跳到账号中心的密码修改界面
		if(!Yii::app()->user->isGuest){
			$this->redirect('/account.html?r=pwd');
			exit;
		}
		
		$model = new Forget;
		
		if(isset($_POST['Forget']))
		{
			$_POST['Forget']['username'] = htmlspecialchars($_POST['Forget']['username'],ENT_QUOTES);
			$model->attributes = $_POST['Forget'];
			/* $model->username = $_POST['Forget']['username'];
			$model->email = $_POST['Forget']['email']; */
			if($model->validate()){
				$name = $_POST['Forget']['username'];
				$email = $_POST['Forget']['email'];
				$record = Member::model()->find(array(
						'condition'=>"name='".$name."'and email='".$email."'",
						));
				if($record){
					//产生新密码
					$newpwd = $this->randCode(8);
					$record->password = md5($newpwd);
					if($record->save(false)){
						//发送邮件
						$httphost = $_SERVER['HTTP_HOST'];
						$message = "<div><b>亲爱的,$name</b><div>你的密码被重置为:<b>$newpwd</b> ,请点击网址(<a href='$httphost'>$httphost</a>)去重新登录并修改密码</div><div>如果以上的网址不能点击进入,请复制该网址到浏览器地址栏中</div></div>";
						$subject = '莱斯旅游--密码找回';
						if($this->sendEmail($email,$name,$message,$subject,$attach= '')){
							$model->unsetAttributes();
							Yii::app()->user->setFlash('success', "成功,<b>请查收邮件</b>");
						}else{
							Yii::app()->user->setFlash('error', "没有成功,请重试!");
						}
					}
				}else{
					Yii::app()->user->setFlash('error', "用户名或邮箱没有注册过!");
				}
			}else{
				Yii::app()->user->setFlash('error', "用户名或邮箱不合法!");
			}
		}
		
		$this->render('index',array(
				'model'=>$model,
				));
	}
 public function submit()
 {
     if ($this->hasErrors()) {
         return false;
     } else {
         $member = Member::model()->findByPk($this->member_id);
         if (empty($member)) {
             $this->addError('member_id', '会员不存在');
             return false;
         }
         $member->password = md5($this->new_password);
         return $member->save(true, array('password'));
     }
 }
Exemple #17
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Member::model()->findByAttributes(array('username' => $this->username));
     if (!isset($user)) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif ($user->password !== md5($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->errorCode = self::ERROR_NONE;
         $this->_id = $user->member_id;
         $this->setState('backEnd', false);
     }
     return !$this->errorCode;
 }
 public function actionPrint()
 {
     $id_member = !empty($_GET['id_member']) ? $_GET['id_member'] : '';
     $member = Member::model()->findByPk($id_member);
     if ($member === null) {
         throw new CHttpException(400, 'Invalid request');
     }
     $receipt = Receipt::model()->find(array('condition' => 'id_member = :id_member', 'params' => array(':id_member' => $id_member), 'order' => 'receipt_date DESC'));
     $last_update = is_null($receipt) ? $member->register_date : $receipt->receipt_date;
     $user = User::model()->findByPk(Yii::app()->user->getId());
     if ($user === null) {
         throw new CHttpException(400, 'Invalid request');
     }
     $receipt = $this->renderPartial('_receipt', array('id_member' => $member->id_member, 'member_name' => $member->first_name . ' ' . $member->family_name, 'point' => $member->point, 'last_update' => date('d F Y', strtotime($last_update)), 'name' => $user->name), true, false);
     echo CJSON::encode($receipt);
 }
 public function actionSave()
 {
     if (isset($_POST)) {
         $trans = Yii::app()->db->beginTransaction();
         $member_name = '';
         $total = 0;
         $point = 0;
         try {
             $table_length = $_POST['table_length'];
             if ($table_length < 1) {
                 throw new Exception('Rollback Input');
             }
             if (empty($_POST['id_member'])) {
                 throw new Exception('Rollback Input');
             }
             for ($i = 0; $i < $table_length; $i++) {
                 $receipt = new Receipt();
                 $receipt->id_receipt = $_POST['id_receipt_list'][$i];
                 $receipt->receipt_date = $_POST['receipt_date_list'][$i];
                 $receipt->total_purchase = $_POST['total_purchase_list'][$i];
                 $receipt->nominal_point = $_POST['pointearned_list'][$i];
                 $receipt->id_member = $_POST['id_member'];
                 $receipt->id_rule = $_POST['id_rule_list'][$i];
                 $receipt->id_tenant = $_POST['id_tenant_list'][$i];
                 $receipt->username = Yii::app()->user->getId();
                 if ($receipt->validate() and $receipt->save()) {
                     $member = Member::model()->findByPk($_POST['id_member']);
                     $member_name = $member->first_name . ' ' . $member->family_name;
                     $member->point += $receipt->nominal_point;
                     if (!$member->update()) {
                         throw new Exception('Rollback on Update Point Member');
                     }
                     $total += $receipt->nominal_point;
                     $point = $member->point;
                 } else {
                     throw new Exception('Rollback on Receipt');
                 }
             }
             $trans->commit();
             $get_name = User::model()->findByPk(Yii::app()->user->getId());
             $dataReceipt = $this->renderPartial('_receipt', array('id_member' => $_POST['id_member'], 'member_name' => $member_name, 'new_point' => $total, 'old_point' => $point - $total, 'total_point' => $point, 'name' => $get_name->name), true, false);
             echo CJSON::encode(array('message' => 'Transaction add point has been saved Successfully!', 'receipt' => $dataReceipt));
         } catch (CDbException $e) {
             $trans->rollback();
         }
     }
 }
 protected function renderContent()
 {
     $member = new Member();
     $member->scenario = 'newAccountForm';
     if (isset($_GET['ahash'])) {
         if (($existingMember = Member::model()->findByAttributes(array('activation_hash' => $_GET['ahash']))) && $existingMember->activation_time >= date('Y-m-d H:i:s', strtotime('-1 day'))) {
             $existingMember->activation_hash = '';
             $existingMember->activation_time = null;
             $existingMember->save();
             $originalLayout = $this->controller->layout;
             $this->controller->layout = '//layouts/email';
             $to = $existingMember->email;
             $subject = Yii::t('memberModule.common', 'Bienvenue');
             $body = $this->controller->render('member.components.views.emailWelcome', array(), true);
             $this->controller->layout = $originalLayout;
             Helper::sendMail($to, $subject, $body);
             // Login user
             Yii::app()->authManager->assign('Member', 'Member-' . $existingMember->id);
             $identity = new MemberIdentity($existingMember->email, '');
             $identity->authenticate(true);
             Yii::app()->user->login($identity, 0);
             $this->controller->redirect($this->controller->createUrl('/member/default/account', array('new' => 1)));
         } else {
             $this->controller->redirect($this->controller->createUrl('/site/index', array('message' => 'newaccountexpired')));
         }
     }
     if (isset($_POST['Member'])) {
         if ($existingMember = Member::model()->findByAttributes(array('email' => $_POST['Member']['email']), "activation_hash <> ''")) {
             $member = $existingMember;
         }
         $member->scenario = 'newAccountForm';
         $member->attributes = $_POST['Member'];
         $member->activation_hash = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 32);
         $member->activation_time = date('Y-m-d H:i:s');
         if ($member->save()) {
             $originalLayout = $this->controller->layout;
             $this->controller->layout = '//layouts/email';
             $to = $member->email;
             $subject = Yii::t('memberModule.common', 'Votre nouveau compte a besoin d’être activé');
             $body = $this->controller->render('member.components.views.emailActivation', array('member' => $member), true);
             $this->controller->layout = $originalLayout;
             Helper::sendMail($to, $subject, $body);
             $this->controller->redirect($this->controller->createUrl('/site/index', array('message' => 'newaccount')));
         }
     }
     $this->render('newAccountFormWidget', array('member' => $member));
 }
Exemple #21
0
 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function login()
 {
     if ($this->_identity === null) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
     }
     if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
         $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
         // 30 days
         Yii::app()->user->login($this->_identity, $duration);
         Member::model()->updateByPk($this->_identity->id, array('login_time' => time()));
         Member::model()->updateByPk($this->_identity->id, array('ip' => Yii::app()->request->userHostAddress));
         return true;
     } else {
         return false;
     }
 }
 public function authenticate()
 {
     $record = Member::model()->findByAttributes(array('email' => $this->username));
     if ($record === null || $record->status != 1 || $record->delete == 1) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->initialPassword !== crypt($this->password, $record->initialPassword) && !$this->notCheckPass) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->id;
             $this->setState('username', $record->email);
             $this->setCookiesMember();
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
Exemple #23
0
 public function actionVerify($id, $hash)
 {
     $request = $this->loadModel($id);
     if ($hash == $request->hash) {
         $mglist = Mglist::model()->findByPk($request->mglist_id);
         // insert new Member
         $member_id = $request->insertMember($request->name, $request->address);
         // add member to this list
         Member::model()->addToList($member_id, $request->mglist_id);
         // add member at Mailgun
         $yg = new Yiigun();
         $yg->memberAdd($mglist->address, $request->address, $request->name);
         $this->render('verify', array('model' => $this->loadModel($id), 'mglist' => $mglist));
     } else {
         echo 'Sorry, your request is invalid.';
         yexit();
     }
 }
Exemple #24
0
 public function actionRecoverpassword($uid)
 {
     if (!($memberModel = Member::model()->findByAttributes(array('recover_hash' => $uid), 'recover_time > :time', array(':time' => date('Y-m-d H:i:s', time() - 60 * 60))))) {
         $this->redirect($this->createUrl('/member/default/recoverexpire'));
     }
     $memberModel->password = '';
     if (isset($_POST['Member'])) {
         $memberModel->attributes = $_POST['Member'];
         $validators = $memberModel->getValidatorList();
         $validators->add(CValidator::createValidator('required', $memberModel, 'password'));
         if ($memberModel->validate()) {
             $memberModel->recover_hash = '';
             $memberModel->recover_time = null;
             $memberModel->save();
             $this->redirect($this->createUrl('/member/default/recoversuccess'));
         }
     }
     $this->render('recoverPassword', array('memberModel' => $memberModel));
 }
Exemple #25
0
 public function authenticate($skipPwVerification = false)
 {
     $record = Member::model()->findByAttributes(array('email' => $this->username), "activation_hash = ''");
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$skipPwVerification && $record->password !== md5($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = 'Member-' . $record->id;
             $this->errorCode = self::ERROR_NONE;
             $record->last_login_date = date('Y-m-d H:i:s');
             if (!$record->save()) {
                 throw new CHttpException(500);
             }
         }
     }
     return !$this->errorCode;
 }
 public function actionIndex()
 {
     $data = strtotime(date('Y-m-d', time()));
     $ArticleTotal = Article::model()->findAllByAttributes(array('display' => 1));
     $DayArticle = Article::model()->findAllBySql("select id from renyu_article where display=1 and create_time>:create_time", array(':create_time' => $data));
     $UpArticle = Article::model()->findAllBySql("select id from renyu_article where display=1 and up_time>:up_time", array(':up_time' => $data));
     $DayOrder = Order::model()->findAllBySql("select * from renyu_order where pay=1 and pay_time>:pay_time", array(':pay_time' => $data));
     $OrderTotal = Order::model()->findAllByAttributes(array('pay' => 1));
     $MemberTotal = Member::model()->findAll();
     if ($_GET['game']) {
         $GameArticle = Article::model()->findAllByAttributes(array('display' => 1, 'gid' => $_GET['game']));
         $DayGameArticle = Article::model()->findAllBySql("select id from renyu_article where display=1 and gid=" . $_GET['game'] . " and create_time>:create_time", array(':create_time' => $data));
         $UpGameArticle = Article::model()->findAllBySql("select id from renyu_article where display=1 and gid=" . $_GET['game'] . " and up_time>:up_time", array(':up_time' => $data));
         $OrderGame = Order::model()->findAllByAttributes(array('pay' => 1, 'gid' => $_GET['game']));
         $DayOrderGame = Order::model()->findAllBySql("select * from renyu_order where pay=1 and gid=" . $_GET['game'] . " and pay_time>:pay_time", array(':pay_time' => $data));
     } else {
         $GameArticle = Article::model()->findAllByAttributes(array('display' => 1, 'gid' => 1));
         $DayGameArticle = Article::model()->findAllBySql("select id from renyu_article where display=1 and gid=1 and create_time>:create_time", array(':create_time' => $data));
         $UpGameArticle = Article::model()->findAllBySql("select id from renyu_article where display=1 and gid=1 and up_time>:up_time", array(':up_time' => $data));
         $OrderGame = Order::model()->findAllByAttributes(array('pay' => 1, 'gid' => 1));
         $DayOrderGame = Order::model()->findAllBySql("select * from renyu_order where pay=1 and gid=1 and pay_time>:pay_time", array(':pay_time' => $data));
     }
     $DayOrder = CHtml::listData($DayOrder, 'id', 'price');
     $OrderTotal = CHtml::listData($OrderTotal, 'id', 'price');
     $OrderGame = CHtml::listData($OrderGame, 'id', 'price');
     $DayOrderGame = CHtml::listData($DayOrderGame, 'id', 'price');
     $model['articletotal'] = count($ArticleTotal);
     $model['dayarticle'] = count($DayArticle);
     $model['uparticle'] = count($UpArticle);
     $model['gamearticle'] = count($GameArticle);
     $model['daygamearticle'] = count($DayGameArticle);
     $model['upgamearticle'] = count($UpGameArticle);
     $model['dayorder'] = count($DayOrder);
     $model['dayordergame'] = count($DayOrderGame);
     $model['membertotal'] = count($MemberTotal);
     $model['dayorderprice'] = Order::model()->getNumOrder($DayOrder);
     $model['ordertotalprice'] = Order::model()->getNumOrder($OrderTotal);
     $model['ordergameprice'] = Order::model()->getNumOrder($OrderGame);
     $model['dayordergameprice'] = Order::model()->getNumOrder($DayOrderGame);
     $ArticleModel = Article::model()->findAllBySql("select id from renyu_article where display=1 and create_time<:create_time", array(':create_time' => $data));
     $this->render('index', array('model' => $model));
 }
 public function actionIndex()
 {
     $model = new Receipt('Search');
     if (!empty($_GET['ajax']) and $_GET['ajax'] === 'receipt-grid') {
         // cari apakah id_member yang dikirim ada ditabel member
         $member = Member::model()->findByPk($_GET['id_member']);
         // Jika tidak ada di table member coba cari di table upgrade membership
         if ($member !== null) {
             // cari old_idmember ditabel upgrade_membership apakah ada, jika
             // ada ambil old_idmember tersebut dan ambil data transactionnya ditabel receipt berdasarkan old_idmember
             $upgrade_membership = new UpgradeMembership();
             $model->id_member = $member->id_member;
             $upgrade_idmember = $upgrade_membership->GetOldIdMember($member->id_member);
             if ($upgrade_idmember !== null) {
                 $model->old_idmember = $upgrade_idmember->old_idmember;
             }
         }
     }
     $this->render('index', array('model' => $model));
 }
Exemple #28
0
 public function actionUpdateprofile()
 {
     if (Yii::app()->session['id'] != null) {
         $members = Member::model()->findByPk(Yii::app()->session['id']);
         $members->username = $_POST['username'];
         $members->password = $_POST['password'];
         $members->email = $_POST['email'];
         $members->fname = $_POST['fname'];
         $members->lname = $_POST['lname'];
         $members->gender = $_POST['gender'];
         $members->phone = $_POST['phone'];
         //$members->create_date 	= date('Y-m-d h:i:sa');
         if ($members->save()) {
             Yii::app()->session['ck'] = '1';
             Yii::app()->session['fname'] = $_POST['fname'];
             $this->redirect(array("Member/Profile"));
         }
     }
     $this->render('//Member/Updateprofile', array("member" => $members));
 }
Exemple #29
0
 public function authenticate()
 {
     $user = Member::model()->findByAttributes(array('username' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== md5($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             //set session
             $this->_session = new CHttpSession();
             $this->_session->open();
             $this->_session['isLogin'] = true;
             $this->_session['login_id'] = $user->id;
             $this->_session['login_name'] = $user->username;
             $this->_id = $user->id;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
     return true;
 }
 public function actionEmail()
 {
     if (empty(Yii::app()->session['mid'])) {
         throw new CHttpException(400, '链接已失效!');
         exit;
     }
     if ($_POST && $_POST['password'] == $_POST['repassword']) {
         /*if(empty($_GET['mid'])){
         			header("Content-Type: text/html; charset=utf-8");
         			echo "<script>alert('没有此用户!');</script>";
         			exit;
         		}*/
         $returnValue = Member::model()->updateAll(array('password' => Member::model()->encrypt($_POST['password'])), "id=" . Yii::app()->session['mid']);
         if ($returnValue > 0) {
             unset(Yii::app()->session['mid']);
             header("Location:" . Yii::app()->params['returnHost']);
         } else {
             echo "shibai";
         }
     } else {
         if ($_GET['mid'] && $_GET['key']) {
             if ($_GET['mid'] != Yii::app()->session['mid']) {
                 header("Content-Type: text/html; charset=utf-8");
                 echo "<script>alert('用户名不匹配!');</script>";
                 exit;
             }
             if (base64_decode($_GET['key']) < time()) {
                 header("Content-Type: text/html; charset=utf-8");
                 echo "<script>alert('时间超时请重新申请!');</script>";
                 exit;
             }
         } else {
             header("Content-Type: text/html; charset=utf-8");
             echo "<script>alert('用户名或秘钥为空!');</script>";
             exit;
         }
     }
     $this->render('email');
 }