当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getInstance方法代码示例

本文整理汇总了PHP中common\models\User::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getInstance方法的具体用法?PHP User::getInstance怎么用?PHP User::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\User的用法示例。


在下文中一共展示了User::getInstance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 public function actionIndex()
 {
     $this->layout = false;
     if (\Yii::$app->request->isAjax) {
         $user = new User();
         $data = \Yii::$app->request->post();
         $userInfo = $user->getFindUser(['name' => $data['name']]);
         $pass = md5(md5($data['password']));
         \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         //将响应数据转json格式
         if (!$userInfo || $userInfo['password'] != $pass) {
             //验证用户登录信息
             return ['msg' => '用户名或密码错误', 'status' => 0];
         } else {
             if ($member = \common\models\User::getInstance()->getUserByPhone($userInfo['phone'])) {
                 $userInfo['member'] = $member;
             }
             $auth = \Yii::$app->authManager;
             $userRole = $auth->getAssignments($userInfo['id']);
             $role = "";
             foreach ($userRole as $k => $v) {
                 if ($k == 'admin') {
                     $role = "admin";
                     break;
                 }
                 $role .= "," . $k;
             }
             $userInfo['role'] = $role;
             $user->setUserSession($userInfo);
             //设置Session
             return ['msg' => '登录成功', 'status' => 1];
         }
     }
     return $this->render('index.html');
 }
开发者ID:xswolf,项目名称:baihey,代码行数:35,代码来源:LoginController.php

示例2: actionAjaxSiteSearch

 public function actionAjaxSiteSearch()
 {
     $andWhere = [];
     User::getInstance()->processAgeAndHeight($this->get);
     User::getInstance()->searchWhere($andWhere, $this->get);
     $andWhere[] = ['in', 'status', [1, 2]];
     $andWhere[] = ['like', "json_extract(info,'\$.head_pic')", '/images/'];
     $list = User::getInstance()->lists(($this->get['page'] - 1) * 18, 18, $andWhere, 'last_login_time');
     foreach ($list as $k => $v) {
         $list[$k]['info'] = json_decode($list[$k]['info']);
     }
     if ($list) {
         return $this->renderAjax('ajax_search_data.html', ['list' => $list]);
     } else {
         echo 'null_data';
         return;
     }
 }
开发者ID:xswolf,项目名称:baihey,代码行数:18,代码来源:SiteController.php

示例3: actionAuth

 public function actionAuth()
 {
     $data = $this->post;
     if ($data['status'] != 3) {
         $date = date('Y-m-d', $data['vo']['create_time']);
         if ($data['type'] == 1) {
             $msg['message'] = '你已被举报,被举报内容:' . $data['vo']['content'] . ';被举报时间:' . $date . ';审核情况:情况属实;处理结果:给予警告一次;如有疑问请拨打客服电话023-68800997。';
         } elseif ($data['type'] == 2) {
             UserInformation::getInstance()->updateUserInfo($data['vo']['feedback_id'], ['report_flag' => 1]);
             $msg['message'] = '你已被举报,被举报内容:' . $data['vo']['content'] . ';被举报时间:' . $date . ';审核情况:情况属实;处理结果:资料卡标记;如有疑问请拨打客服电话023-68800997。';
         } elseif ($data['type'] == 3) {
             UserInformation::getInstance()->updateUserInfo($data['vo']['feedback_id'], ['report_flag' => 1]);
             User::getInstance()->editUserTableInfo($data['vo']['feedback_id'], ['status' => 3]);
             $msg['message'] = '你已被举报,被举报内容:' . $data['vo']['content'] . ';被举报时间:' . $date . ';审核情况:情况属实;处理结果:永久封禁;如有疑问请拨打客服电话023-68800997。';
         }
         // 此处处理发送给被举报人
         $msg['send_user_id'] = isset($_SESSION[USER_SESSION]['member']) ? $_SESSION[USER_SESSION]['member']['id'] : 1;
         $msg['receive_user_id'] = $data['vo']['feedback_id'];
         UserMessage::getInstance()->addMessage($msg);
         // 是否发送给举报人
         if (isset($data['ret']) && $data['ret'] == 'on') {
             $retMsg['send_user_id'] = isset($_SESSION[USER_SESSION]['member']) ? $_SESSION[USER_SESSION]['member']['id'] : 1;
             $retMsg['receive_user_id'] = $data['vo']['user_id'];
             $retMsg['message'] = '感谢您对本网站文明建设的支持,经查证情况属实,我们已对该账号做出相应处理';
             UserMessage::getInstance()->addMessage($retMsg);
         }
     } else {
         // 是否发送给举报人
         if (isset($data['ret']) && $data['ret'] == 'on') {
             $retMsg['send_user_id'] = isset($_SESSION[USER_SESSION]['member']) ? $_SESSION[USER_SESSION]['member']['id'] : 1;
             $retMsg['receive_user_id'] = $data['vo']['user_id'];
             $retMsg['message'] = '感谢您对本网站文明建设的支持,但因证据不足,暂时不予处理';
             UserMessage::getInstance()->addMessage($retMsg);
         }
     }
     if (Feedback::getInstance()->auth($data['id'], $data['status'])) {
         $this->renderAjax(['status' => 1, 'message' => '成功']);
     } else {
         $this->renderAjax(['status' => 0, 'message' => '失败']);
     }
 }
开发者ID:xswolf,项目名称:baihey,代码行数:41,代码来源:FeedbackController.php

示例4: actionQuickLogin

 public function actionQuickLogin()
 {
     // QQ登陆
     if ($this->get['t'] == 'qq' && isset($this->get['code']) && $this->get['code'] != '') {
         $qqUser = Qq::getInstance()->getUser($this->get['code']);
         if ($qqUser) {
             if (!($user = User::getInstance()->getUser(['username' => $qqUser['openId']]))) {
                 $user = ['username' => $qqUser['openId'], 'password' => $qqUser['openId'], 'login_type' => 2, 'sex' => $qqUser['sex']];
                 $user['id'] = User::getInstance()->addUser($user);
             }
         }
     } else {
         if ($this->get['t'] == 'weibo' && isset($this->get['code']) && $this->get['code'] != '') {
             $weiboUser = Weibo::getInstance()->getUser($this->get['code']);
             print_r($weiboUser);
             exit;
         }
     }
     \common\models\User::getInstance()->loginLog($user['id']);
     Cookie::getInstance()->setLoginCookie($user, '/qt');
     return $this->render();
 }
开发者ID:xswolf,项目名称:baihey,代码行数:22,代码来源:UserController.php

示例5: updateUserInfo

 /**
  * 更新用户数据(目前用于资料子页面)
  * @param $user_id
  * @param $data array
  * @return bool
  */
 public function updateUserInfo($user_id, $data)
 {
     $row = false;
     $userInfo = User::getInstance()->getUserById($user_id);
     if ($data && $userInfo) {
         $_user_information_table = $this->tablePrefix . 'user_information';
         // 表名
         switch (key($data)) {
             case 'personalized':
                 // 个性签名
             // 个性签名
             case 'honesty_value':
                 // 诚信认证值
             // 诚信认证值
             case 'went_travel':
                 // 去过的地方
             // 去过的地方
             case 'want_travel':
                 // 想去的地方
             // 想去的地方
             case 'love_sport':
                 // 喜欢的运动
             // 喜欢的运动
             case 'want_film':
                 // 想看的电影
             // 想看的电影
             case 'like_food':
                 // 喜欢的美食
             // 喜欢的美食
             case 'privacy_pic':
                 // 照片权限
             // 照片权限
             case 'privacy_per':
                 // 动态权限
             // 动态权限
             case 'privacy_wechat':
                 // 微信显示
             // 微信显示
             case 'privacy_qq':
                 // QQ显示(1全部2关注3vip4不公开)
             // QQ显示(1全部2关注3vip4不公开)
             case 'mature_time':
                 // 到期时间
             // 到期时间
             case 'service_status':
                 // 服务状态 1:已申请,0:未申请
             // 服务状态 1:已申请,0:未申请
             case 'has_identify':
                 // 是否认证 1:已申请,0:未申请
             // 是否认证 1:已申请,0:未申请
             case 'report_flag':
                 // 标记被举报 1:已标记,0:未标记
             // 标记被举报 1:已标记,0:未标记
             case 'intention':
                 // 意向类别ID
             // 意向类别ID
             case 'reason':
                 // 回访内容
             // 回访内容
             case 'contact_time':
                 // 电话联系时间
             // 电话联系时间
             case 'return_time':
                 // 回访时间(放弃时间)
             // 回访时间(放弃时间)
             case 'matchmaker':
                 // 专属红娘
             // 专属红娘
             case 'mature_time':
                 // 服务到期时间
                 $sql = "UPDATE {$_user_information_table} SET " . key($data) . " = '" . $data[key($data)] . "' WHERE user_id={$user_id}";
                 break;
             case 'matchmaking':
                 // 服务红娘
                 $sql = "UPDATE {$_user_information_table} SET " . key($data) . " = '" . $data[key($data)] . "' WHERE user_id={$user_id}";
                 break;
             case 'auth':
                 // 诚信认证
                 $arr = explode('_', $data['auth'], 3);
                 $sql = "UPDATE {$_user_information_table} SET auth = JSON_REPLACE(auth,'\$." . $arr[0] . '_' . $arr[1] . "','" . $arr[2] . "'), auth = JSON_REPLACE(auth,'\$." . $arr[0] . '_time' . "','" . YII_BEGIN_TIME . "'), auth = JSON_REPLACE(auth,'\$." . $arr[0] . '_check' . "','" . false . "') WHERE user_id={$user_id}";
                 break;
             case 'identity':
                 // 身份证认证
                 $arr = $data['identity'];
                 $sql = "UPDATE {$_user_information_table} SET info = JSON_REPLACE(info,'\$." . 'real_name' . "','" . $arr . "') WHERE user_id={$user_id}";
                 break;
             case 'occupation':
                 // 职业
                 $arr = explode('-', $data['occupation']);
                 $sql = "UPDATE {$_user_information_table} SET info = JSON_REPLACE(info,'\$.occupation','" . $arr[0] . "'), info = JSON_REPLACE(info,'\$.children_occupation','" . $arr[1] . "') WHERE user_id={$user_id}";
                 break;
             case 'address':
                 // 地区
                 $arr = explode('-', $data['address']);
//.........这里部分代码省略.........
开发者ID:xswolf,项目名称:baihey,代码行数:101,代码来源:UserInformation.php

示例6: actionEditUserStatus

 /**
  * 修改用户状态(后台使用)
  */
 public function actionEditUserStatus()
 {
     $user_id = $this->get['user_id'];
     unset($this->get['user_id']);
     if ($data = \common\models\User::getInstance()->editUserTableInfo($user_id, $this->get)) {
         return $this->renderAjax(['status' => 1, 'data' => $data, 'message' => '修改成功']);
     } else {
         return $this->renderAjax(['status' => 0, 'data' => [], 'message' => '修改失败']);
     }
 }
开发者ID:xswolf,项目名称:baihey,代码行数:13,代码来源:UserController.php

示例7: addAdminUser

 /**
  * 添加管理员用户
  * @param $id
  * @param $data
  */
 public function addAdminUser($id, $data)
 {
     $member['id'] = $id;
     $member['phone'] = $data['phone'];
     $member['personalized'] = $data['introduction'];
     $member['info']['real_name'] = $data['name'];
     $member['info']['qq'] = isset($data['qq']) && !empty($data['qq']) ? $data['qq'] : '';
     $member['info']['wechat'] = isset($data['wechat']) && !empty($data['wechat']) ? $data['wechat'] : '';
     $member['password'] = $data['password'];
     $member['sex'] = !empty($data['sex']) ? $data['sex'] : 1;
     if (\common\models\User::getInstance()->addUser($member) && !empty($data['photo'])) {
         $photo['type'] = 1;
         $photo['thumb_path'] = $data['photo'];
         $photo['pic_path'] = str_replace('thumb', 'picture', $data['photo']);
         $photo['time'] = time();
         $photo['is_check'] = 1;
         UserPhoto::getInstance()->addPhoto($id, $photo, 1);
     } else {
         return false;
     }
     return true;
 }
开发者ID:xswolf,项目名称:baihey,代码行数:27,代码来源:User.php

示例8: editUser

 public function editUser($data)
 {
     $user = $data['user'];
     $user['id'] = $data['user_id'];
     unset($data['user']);
     $userInfo = $data;
     if (isset($userInfo['info']['age']) && !empty($data['info']['age'])) {
         $userInfo['age'] = floor((time() - $userInfo['info']['age']) / 365 / 24 / 3600);
     }
     if (isset($userInfo['info']['real_name']) && !empty($data['info']['real_name'])) {
         $userInfo['info']['real_name'] = trim($userInfo['info']['real_name']);
     }
     $oldUser = $this->getUserById($data['user_id']);
     $defaultInfo = json_decode($oldUser['info']);
     if (is_object($defaultInfo)) {
         $defaultInfo = (array) $defaultInfo;
     }
     //var_dump($defaultInfo);exit;
     $userInfo['info'] = json_encode(array_merge($defaultInfo, $userInfo['info']));
     $this->getDb()->createCommand()->update($this->tablePrefix . "user_information", $userInfo, ['user_id' => $data['user_id']])->execute();
     $this->getDb()->createCommand()->update($this->tablePrefix . "user", $user, ['id' => $data['user_id']])->execute();
     // 添加图片
     if (isset($data['cardFace_List'])) {
         User::getInstance()->insertUserPhoto($user['id'], $data);
     }
     return $user;
 }
开发者ID:xswolf,项目名称:baihey,代码行数:27,代码来源:User.php

示例9: actionGetUser

 public function actionGetUser()
 {
     if ($data = User::getInstance()->getUserById($this->post['user_id'])) {
         $this->renderAjax(['status' => 1, 'data' => $data, 'message' => '成功']);
     } else {
         $this->renderAjax(['status' => 0, 'data' => [], 'message' => '失败']);
     }
 }
开发者ID:xswolf,项目名称:baihey,代码行数:8,代码来源:MemberController.php

示例10: actionForgotPassword

 /**
  * 找回密码
  */
 public function actionForgotPassword()
 {
     $user = \common\models\User::getInstance()->getUserByPhone($this->get['phone']);
     $data['password'] = md5(md5($this->get['password']));
     $data['reset_pass_time'] = time();
     if ($list = \common\models\User::getInstance()->editUserTableInfo($user['id'], $data)) {
         $this->renderAjax(['status' => 1, 'data' => $list, 'msg' => '修改成功']);
     } else {
         $this->renderAjax(['status' => 0, 'data' => [], 'msg' => '修改失败']);
     }
 }
开发者ID:xswolf,项目名称:baihey,代码行数:14,代码来源:UserController.php

示例11: actionLoginOut

 /**
  * 退出登录
  */
 public function actionLoginOut()
 {
     $data = User::getInstance()->loginOut();
     $this->renderAjax(['status' => 1, 'data' => $data]);
 }
开发者ID:xswolf,项目名称:baihey,代码行数:8,代码来源:MemberController.php

示例12: setOrderStatus

 /**
  * 设置订单状态
  * @param $orderId
  * @param int $status
  * @param bool $isAdmin
  * @return bool
  */
 public function setOrderStatus($orderId, $status = 1, $isAdmin = false)
 {
     $orderInfo = $this->getInstance()->getOne($orderId);
     // 订单信息
     if ($orderInfo['status'] == 1) {
         return true;
     }
     // 异常情况,不予处理,订单已经成功
     $tran = \Yii::$app->db->beginTransaction();
     $row = $this->updateAll(['status' => $status, 'finsh_time' => time()], ['order_id' => $orderId]);
     // 修改订单状态
     $bal = true;
     if (!$isAdmin) {
         $bal = User::getInstance()->changeBalance($orderInfo['user_id'], -$orderInfo['money']);
         // 充值余额
     }
     if ($orderInfo['charge_goods_id'] != 8) {
         $mat = User::getInstance()->changeMatureTime($orderInfo['user_id'], $orderInfo, 0, $isAdmin);
         // 开通服务
     } else {
         $mat = true;
     }
     if ($row && $bal && $mat) {
         $tran->commit();
         // 提交
         return true;
     }
     $tran->rollBack();
     // 回滚
     return false;
 }
开发者ID:xswolf,项目名称:baihey,代码行数:38,代码来源:ChargeOrder.php

示例13: weChatMember

 /**
  * 微信登录获取微信用户信息
  * @return array|bool
  */
 protected function weChatMember()
 {
     $code = \Yii::$app->request->get('code');
     if ($code == null) {
         return false;
     } else {
         setcookie('wx_login', 'login', time() + 3600 * 24 * 30, '/wap');
     }
     $memberInfo = \Yii::$app->wechat->getMemberByCode($code);
     // 从微信获取用户
     //        $memberInfo['openid'] = 'oEQpts_MMapxllPTfwRw0VfGeLSg'; // 测试
     $data = ['wx_id' => $memberInfo['openid'], 'username' => $memberInfo['openid'], 'password' => 'wx_xx', 'login_type' => 3, 'sex' => isset($memberInfo['sex']) && $memberInfo['sex'] == 2 ? 0 : 1];
     $user = User::getInstance()->getUser(['wx_id' => $data['wx_id']]);
     if (!$user) {
         // 用户不存在,虚拟账号登陆
         setcookie('wx_id', $data['wx_id'], time() + 3600 * 24 * 30, '/');
         $data['sex'] == 1 ? $user = User::getInstance()->getUserById(10011) : ($user = User::getInstance()->getUserById(10016));
     }
     // 登录日志
     \common\models\User::getInstance()->loginLog($user['id']);
     // 设置登录cookie
     Cookie::getInstance()->setLoginCookie($user);
     return $user;
 }
开发者ID:xswolf,项目名称:baihey,代码行数:28,代码来源:BaseController.php


注:本文中的common\models\User::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。