當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::getUserByUserId方法代碼示例

本文整理匯總了PHP中Model\User::getUserByUserId方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getUserByUserId方法的具體用法?PHP User::getUserByUserId怎麽用?PHP User::getUserByUserId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model\User的用法示例。


在下文中一共展示了User::getUserByUserId方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buy

 /**
  * 購買邀請碼,必要權限檢查
  *
  * @JSON
  * @Authorization
  * @return array
  */
 public function buy()
 {
     $user = User::getUserByUserId(User::getCurrent()->uid);
     $result = array('error' => 1, 'message' => '購買失敗,至少需要20GB流量才能購買邀請碼。');
     $transfer = Utils::GB * 10;
     // update by github.com/BorLee
     // 1abd9e6be7bfd7e3b1e9f34acd357fa7fa29923c
     if ($user->transfer > $transfer * 2 && $user->transfer - $user->getUseTransfer() > $transfer) {
         $user->transfer = $user->transfer - $transfer;
         $user->invite_num = $user->invite_num + 1;
         $user->save();
         $result = array('error' => 0, 'message' => '購買成功,扣除手續費10GB流量', 'invite_num' => $user->invite_num);
     }
     return $result;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:22,代碼來源:Invite.php

示例2: update

 /**
  * 添加一個邀請碼
  * @JSON
  */
 public function update()
 {
     $result = array('error' => -1, 'message' => 'Request failed');
     $user = User::getCurrent();
     if ($_POST['invite'] == null) {
         $result = array('error' => 0, 'message' => '添加成功,刷新可見');
         $plan = 'A';
         $add_uid = -1;
         $inviteNumber = 1;
         if ($_POST['plan'] != null) {
             $plan = $_POST['plan'];
         }
         if ($_POST['add_uid'] != null) {
             $add_uid = trim($_POST['add_uid']);
             if ($add_uid != $user->uid && $add_uid != -1) {
                 if (!User::getUserByUserId($add_uid)) {
                     $result['error'] = 1;
                     $result['message'] = "此UID: " . $add_uid . " 的用戶不存在,添加失敗";
                     return $result;
                 }
             }
         }
         if ($_POST['number'] != null) {
             $inviteNumber = $_POST['number'];
         }
         if ($inviteNumber > 1) {
             for ($i = 0; $i < $inviteNumber; $i++) {
                 InviteModel::addInvite($add_uid, $plan);
             }
         } else {
             InviteModel::addInvite($add_uid, $plan);
         }
         $result['inviteNumber'] = $inviteNumber;
         $result['plan'] = $plan;
     } else {
         if ($_POST['invite'] != null) {
             $invite = InviteModel::getInviteByInviteCode(trim($_POST['invite']));
             if ($invite != null) {
                 $invite->dateLine = time();
                 $invite->expiration = $_POST['expiration'];
                 $invite->plan = $_POST['plan'];
                 $invite->save();
                 $result = array('error' => 0, 'message' => '更新邀請碼成功');
             }
         }
     }
     return $result;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:52,代碼來源:Invite.php

示例3: getNodeInfo

 /**
  * @JSON
  * @return array
  */
 public function getNodeInfo()
 {
     $id = trim($_REQUEST['id']);
     $result = array('error' => -1, 'message' => 'Request failed');
     $user = User::getUserByUserId(User::getCurrent()->uid);
     $node = MNode::getNodeById($id);
     $method = $node->method;
     if ($node->custom_method == 1 && $user->method != '' && $user->method != null) {
         $method = $user->method;
     }
     $info = self::nodeDetail($node->server, $user->port, $user->sspwd, $method, $node->name);
     if (self::verifyPlan($user->plan, $node->type)) {
         $result = array('error' => 0, 'message' => '獲取成功', 'info' => $info, 'node' => $node);
     } else {
         $result = array('error' => -1, 'message' => '你不是 VIP, 無法使用高級節點!');
     }
     return $result;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:22,代碼來源:Node.php

示例4: activation

 /**
  * 激活(使用)卡號
  * @JSON
  */
 public function activation()
 {
     $user = User::getUserByUserId(User::getCurrent()->uid);
     $result = array('error' => 1, 'message' => '該卡已經被使用或不存在。');
     if ($_POST['actCard'] != null) {
         $actCard = htmlspecialchars(trim($_POST['actCard']));
         $card = Mcard::queryCard($actCard);
         if (!$card || !$card->status) {
             return $result;
         }
         $custom_transfer_level = json_decode(Option::get('custom_transfer_level'), true);
         $custom_transfer_repeat = json_decode(Option::get('custom_transfer_repeat'), true);
         /* 0-套餐卡 1-流量卡 2-測試卡 3-餘額卡 */
         if ($card->type == 0) {
             if ($user->plan == 'Z' && $user->transfer > $user->flow_up + $user->flow_down) {
                 $result['message'] = '您的流量套餐尚未使用完畢。無法轉換到 ' . Utils::planAutoShow($card->info) . ' 套餐';
                 return $result;
             }
             //判斷賬戶卡號類型是否一致 一致則無視係統疊加開關進行 疊加時間
             $user->payTime = time();
             if ($user->flow_up + $user->flow_down < $user->transfer) {
                 $user->enable = 1;
             } else {
                 $user->enable = 0;
             }
             $cardDay = 31;
             if (is_numeric($card->expireTime)) {
                 $cardDay = intval($card->expireTime);
             }
             $expireTime = 0;
             if ($user->plan == $card->info) {
                 // 卡片與賬戶類型相等
                 if ($user->expireTime > time()) {
                     $expireTime = $user->expireTime + 3600 * 24 * $cardDay;
                     // 到期時間 = 當前賬戶到期時間+卡片時間
                 } else {
                     $expireTime = time() + 3600 * 24 * $cardDay;
                     // 到期時間 = 當前係統續費時間+卡片時間
                 }
             } else {
                 if ($user->expireTime < time() || !$custom_transfer_repeat) {
                     $expireTime = time() + 3600 * 24 * $cardDay;
                     // 到期時間 = 不疊加原時間 (當前係統續費時間+卡片時間)
                 } else {
                     $expireTime = $user->expireTime + 3600 * 24 * $cardDay;
                     // 到期時間 = 當前賬戶到期時間+卡片時間
                 }
             }
             $user->expireTime = $expireTime;
             $user->plan = $card->info;
             $user->transfer = Utils::GB * intval($custom_transfer_level[$user->plan]);
             $result['message'] = '您的賬戶已升級到 ' . Utils::planAutoShow($user->plan) . ' ,共有流量 ' . Utils::flowAutoShow($user->transfer) . ', 已用 ' . Utils::flowAutoShow($user->flow_down + $user->flow_up) . ', 到期時間:' . date('Y-m-d H:i:s', $user->expireTime);
         } elseif ($card->type == 1) {
             if ($user->plan == 'Z') {
                 $user->transfer += intval($card->info) * Utils::GB;
                 // 如果之前是 流量 套餐,則遞增
             } else {
                 $user->transfer = intval($card->info) * Utils::GB;
                 // 如果之前是 普通套餐,則清空總流量並設定新流量
                 $user->flow_up = 0;
                 $user->flow_down = 0;
             }
             if ($user->flow_up + $user->flow_down < $user->transfer) {
                 $user->enable = 1;
             } else {
                 $user->enable = 0;
             }
             $user->plan = 'Z';
             // 強製設定為Z
             $user->expireTime = strtotime("+1 year");
             // 賬戶可用時間增加一年
             $result['message'] = '您的賬戶已經激活固定流量套餐,共有流量' . Utils::flowAutoShow($user->transfer) . ' ,該流量到期時間 ' . date('Y-m-d H:i:s', $user->expireTime) . ', 感謝您的使用(注意:流量使用完畢前無法通過套餐卡轉換為套餐包月用戶)';
         } elseif ($card->type == 2) {
             $user_test_day = Option::get('user_test_day') ?: 7;
             if ($user->plan != 'A') {
                 return array('error' => 1, 'message' => '喂喂,你不是測試賬戶誒? 沒辦法幫你續命。');
             }
             $user->plan = 'A';
             $user->payTime = time();
             if ($user->expireTime < time()) {
                 $user->expireTime = time() + 3600 * 24 * intval($user_test_day);
                 // 到期時間
             } else {
                 $user->expireTime = $user->expireTime + 3600 * 24 * intval($user_test_day);
                 // 到期時間
             }
             $user->transfer = Utils::GB * intval($custom_transfer_level[$user->plan]);
             $user->flow_down = 0;
             $user->flow_up = 0;
             $user->enable = 1;
             $result['message'] = '您的賬戶已經激活測試套餐,共有流量' . Utils::flowAutoShow($user->transfer) . ' ,到期時間 ' . date('Y-m-d H:i:s', $user->expireTime) . ', 感謝您的使用';
         } elseif ($card->type == 3) {
             // 餘額卡
             $user->money += intval($card->info);
             $user->save();
             $result['message'] = '餘額充值成功,您當前餘額為 ' . $user->money . ' 元';
//.........這裏部分代碼省略.........
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:101,代碼來源:Card.php

示例5: checkIn

 /**
  * 簽到
  *
  * @JSON
  */
 public function checkIn()
 {
     $user = User::getCurrent();
     $result = array('error' => 1, 'message' => '簽到失敗或已簽到。');
     if ($user->lastCheckinTime <= strtotime(date('Y-m-d 00:00:00', time()))) {
         $user = User::getUserByUserId($user->uid);
         $user->lastCheckinTime = time();
         $checkinTransfer = rand(intval(Option::get('check_transfer_min')), intval(Option::get('check_transfer_max'))) * Utils::MB;
         $user->transfer = $user->transfer + $checkinTransfer;
         $_SESSION['currentUser'] = $user;
         $user->save();
         $result['time'] = date("m-d H:i:s", $user->lastCheckinTime);
         $result['message'] = '簽到成功, 獲得' . Utils::flowAutoShow($checkinTransfer) . ' 流量';
         $result['error'] = 0;
     } else {
         $result['message'] = '你已經在 ' . date('Y-m-d H:i:s', $user->lastCheckinTime) . " 時簽到過.";
     }
     return $result;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:24,代碼來源:Member.php

示例6: update

 /**
  * 修改用戶信息
  * @JSON
  */
 public function update()
 {
     $result = array("error" => 1, "message" => "Request failed");
     if ($_POST['user_uid'] != null) {
         $us = UserModel::getUserByUserId(trim($_POST['user_uid']));
         if ($us) {
             if ($_POST['user_email'] != null) {
                 $us->email = $_POST['user_email'];
             }
             if ($_POST['user_nickname'] != null) {
                 $us->nickname = $_POST['user_nickname'];
             }
             if ($_POST['user_port'] != null) {
                 $us->port = $_POST['user_port'];
             }
             if ($_POST['user_sspwd'] != null) {
                 $us->sspwd = $_POST['user_sspwd'];
             }
             if ($_POST['user_plan'] != null) {
                 $us->plan = $_POST['user_plan'];
             }
             if ($_POST['user_invite_num'] != null) {
                 $us->invite_num = $_POST['user_invite_num'];
             }
             if ($_POST['user_transfer'] != null) {
                 $us->transfer = floatval($_POST['user_transfer']) * Utils::GB;
             }
             if ($_POST['user_flow_down'] != null) {
                 $us->flow_down = floatval($_POST['user_flow_down']) * Utils::GB;
                 $us->flow_up = 0;
             }
             if ($_POST['user_enable'] != null) {
                 $us->enable = intval($_POST['user_enable']);
             }
             // 是否啟用該用戶。該字段會強製用戶無法鏈接到所有服務器!
             if ($_POST['user_payTime'] != null) {
                 $us->payTime = strtotime($_POST['user_payTime']);
             }
             if ($_POST['user_expireTime'] != null) {
                 $us->expireTime = strtotime($_POST['user_expireTime']);
             }
             if ($us->enable != 0 && $us->enable != 1) {
                 $us->enable = 0;
             }
             if ($us->port != null && $us->port != 0) {
                 $rs = UserModel::checkUserPortIsAvailable($us->port, $us->uid);
                 if ($rs) {
                     $result = array("error" => 1, "message" => "端口{$rs->port}已被占用,請更換");
                     return $result;
                 }
             }
             if ($_POST['user_password'] != null && $_POST['user_password'] != '') {
                 // change password
                 $us->setPassword(trim($_POST['user_password']));
             }
             $us->save();
             if ($_POST['user_isAdmin'] != null) {
                 // 如果選中了管理員,設置管理員的值
                 $us->setAdmin($_POST['user_isAdmin']);
             }
             $result['error'] = 0;
             $result['message'] = '更新信息成功';
             $us->plan = Utils::planAutoShow($us->plan);
             $us->transfer = Utils::flowAutoShow($us->transfer);
             $us->flow_down = ($us->flow_up + $us->flow_down) / Utils::GB;
             $us->payTime = date('Y-m-d H:i:s', $us->payTime);
             $us->expireTime = date('Y-m-d H:i:s', $us->expireTime);
             $result['user'] = $us;
         }
     }
     return $result;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:76,代碼來源:User.php

示例7: method

 /**
  * 修改 自定義加密方式
  * @JSON
  * @throws Error
  */
 public function method()
 {
     $user = MUser::getCurrent();
     if ($_POST['method'] != null) {
         $method = null;
         if ($_POST['method'] != '-1') {
             $method = htmlspecialchars(trim($_POST['method']));
         }
         $user = MUser::getUserByUserId($user->uid);
         $user->method = $method;
         $user->save();
         $_SESSION['currentUser'] = $user;
         return array('error' => 0, 'message' => '修改加密方式成功,全部節點同步大約5分鍾內生效。');
     } else {
         $nodeList = Node::getSupportCustomMethodArray();
         Template::putContext('user', $user);
         Template::putContext('nodeList', $nodeList);
         Template::setView("panel/change_method");
     }
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:25,代碼來源:User.php

示例8: addInvite

 /**
  * Add a invite
  * @param $uid
  * @param string $plan
  * @param bool $isTransfer
  * @return bool
  */
 public static function addInvite($uid, $plan = 'A', $isTransfer = false)
 {
     $inviteStr = substr(hash("sha256", $uid . Utils::randomChar(10)), 0, 26) . $uid;
     $obj = new self();
     $obj->inviteIp = Utils::getUserIP();
     $obj->invite = $inviteStr;
     $obj->plan = $plan;
     $obj->uid = $uid;
     if ($isTransfer) {
         $user = User::getUserByUserId($uid);
         $user->transfer = $user->transfer - Utils::GB * 10;
         $user->invite_num = $user->invite_num - 1;
         $user->save();
     }
     $result = $obj->save();
     return $obj;
 }
開發者ID:sendya,項目名稱:shadowsocks-panel,代碼行數:24,代碼來源:Invite.php


注:本文中的Model\User::getUserByUserId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。