当前位置: 首页>>代码示例>>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;未经允许,请勿转载。