countUser() публичный статический Метод

Count all user
public static countUser ( ) : integer
Результат integer
Пример #1
0
 public function index()
 {
     $data['user'] = User::getCurrent();
     $data['flow_num10'] = Stats::dataUsage(0);
     $data['flow_num30'] = Stats::dataUsage(1);
     $data['flow_num100'] = Stats::dataUsage(2);
     $data['flow_max'] = Stats::dataUsage(3);
     $data['userCount'] = Stats::countUser();
     $data['money'] = Stats::countMoney();
     Template::setContext($data);
     Template::setView('admin/index');
 }
Пример #2
0
 /**
  * 主页面 仪表盘
  */
 public function index()
 {
     $user = User::getUserByUserId(User::getCurrent()->uid);
     $data['user'] = $user;
     $data['online'] = Stats::countOnline();
     $data['userCount'] = Stats::countUser();
     $data['useUserCount'] = Stats::countUseUser();
     // 使用过服务的用户数
     $data['checkCount'] = Stats::countSignUser();
     $data['onlineNum'] = 0.0;
     // default online number.
     if ($data['online'] !== 0 && $data['userCount'] !== 0) {
         $data['onlineNum'] = round($data['online'] / $data['userCount'], 2) * 100;
     }
     $data['allTransfer'] = Utils::flowAutoShow($user->transfer);
     $data['useTransfer'] = $user->flow_up + $user->flow_down;
     // round(() / Utils::mb(), 2);
     $data['slaTransfer'] = Utils::flowAutoShow($user->transfer - $data['useTransfer']);
     $data['pctTransfer'] = 0.0;
     if (is_numeric($data['useTransfer']) && $data['useTransfer'] > 0 && is_numeric($user->transfer) && $user->transfer > 0) {
         $data['pctTransfer'] = round($data['useTransfer'] / $user->transfer, 2) * 100;
     }
     $data['useTransfer'] = Utils::flowAutoShow($data['useTransfer'], 1);
     $tmp = explode(" ", $data['useTransfer']);
     $data['useTransfer'] = $tmp[0];
     $data['useTransferUnit'] = count($tmp) > 1 ? $tmp[1] : 'KB';
     $data['systemTransfer'] = round(Stats::countTransfer() / Utils::gb(), 2);
     // 全部用户产生的流量
     $data['checkedTime'] = date('m-d H:i', $user->lastCheckinTime);
     $data['lastOnlineTime'] = date('Y-m-d H:i:s', $user->lastConnTime);
     $data['checked'] = strtotime(date('Y-m-d 00:00:00', time())) > strtotime(date('Y-m-d H:i:s', $user->lastCheckinTime));
     $data['userIp'] = Utils::getUserIP();
     // Message
     $data['globalMessage'] = Message::getGlobalMessage();
     $data['allNode'] = Stats::countNode();
     Template::setContext($data);
     Template::setView('panel/member');
 }
Пример #3
0
 /**
  * @JSON
  */
 public function register()
 {
     $result = array('error' => 1, 'message' => '注册失败');
     $email = strtolower(trim($_POST['r_email']));
     $userName = trim($_POST['r_user_name']);
     $passwd = trim($_POST['r_passwd']);
     $repasswd = trim($_POST['r_passwd2']);
     $inviteCode = trim($_POST['r_invite']);
     $invite = Invite::getInviteByInviteCode($inviteCode);
     //校验 invite 是否可用
     if ($invite->status != 0 || $invite == null || empty($invite)) {
         $result['message'] = '邀请码不可用';
     } else {
         if ($repasswd != $passwd) {
             $result['message'] = '两次密码输入不一致';
         } else {
             if (strlen($passwd) < 6) {
                 $result['message'] = '密码太短,至少8字符';
             } else {
                 if ($chkEmail = Utils::mailCheck($email)) {
                     $result['message'] = $chkEmail;
                 } else {
                     $user = new User();
                     $user->email = $email;
                     if ($userName == null) {
                         $userName = $email;
                     }
                     $userCount = Stats::countUser();
                     $user->nickname = $userName;
                     // LEVEL 从数据库中获取
                     $custom_transfer_level = json_decode(Option::get('custom_transfer_level'), true);
                     // 定义邀请码套餐与流量单位
                     $transferNew = Utils::GB * intval($custom_transfer_level[$invite->plan]);
                     $user->transfer = $transferNew;
                     $user->invite = $inviteCode;
                     $user->plan = $invite->plan;
                     // 将邀请码的账户类型设定到注册用户上.
                     $user->regDateLine = time();
                     $user->lastConnTime = $user->regDateLine;
                     $user->sspwd = Utils::randomChar();
                     $user->payTime = time();
                     // 注册时支付时间
                     $user_test_day = Option::get('user_test_day') ?: 7;
                     $user->expireTime = time() + 3600 * 24 * intval($user_test_day);
                     // 到期时间
                     $mailVerify = Option::get('mail_verify');
                     // 邮件验证是否开启
                     if ($userCount > 0 && $mailVerify) {
                         $user->enable = 0;
                         // 停止账户
                         $code = Utils::randomChar(10);
                         $forgePwdCode['verification'] = $code;
                         $forgePwdCode['time'] = time();
                         $user->forgePwdCode = json_encode($forgePwdCode);
                         $mailer = Mailer::getInstance();
                         $mailer->toQueue(false);
                         $mail = new Mail();
                         $mail->to = $user->email;
                         $mail->subject = '[' . SITE_NAME . '] 新账户注册邮箱校验';
                         $mail->content = Option::get('custom_mail_verification_content');
                         $params = ['code' => $code, 'nickname' => $user->nickname, 'email' => $user->email, 'useTraffic' => Utils::flowAutoShow($user->flow_up + $user->flow_down), 'transfer' => Utils::flowAutoShow($user->transfer), 'expireTime' => date('Y-m-d H:i:s', $user->expireTime), 'REGISTER_URL' => base64_encode($user->email . "\t" . $forgePwdCode['verification'] . "\t" . $forgePwdCode['time'])];
                         $mail->content = Utils::placeholderReplace($mail->content, $params);
                         $mailer->send($mail);
                     } else {
                         $user->enable = 1;
                         // 第一个账户,默认设定为启用
                         $user->forgePwdCode = null;
                     }
                     $user->port = Utils::getNewPort();
                     // 端口号
                     $user->setPassword($passwd);
                     $user->save();
                     $invite->reguid = $user->uid;
                     $invite->regDateLine = $user->regDateLine;
                     $invite->status = 1;
                     // -1过期 0-未使用 1-已用
                     $invite->inviteIp = Utils::getUserIP();
                     $invite->save();
                     if (null != $user->uid && 0 != $user->uid) {
                         $result['error'] = 0;
                         $result['message'] = '注册成功';
                     }
                     if ($mailVerify) {
                         $result['message'] .= ',您需要验证邮箱后才能使用本站功能。';
                     }
                     Logger::getInstance()->info('user [' . $user->email . '] register success');
                 }
             }
         }
     }
     return $result;
 }