當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。