getGlobalMessage() public static method

Get global message
public static getGlobalMessage ( ) : array
return array
Beispiel #1
0
 /**
  * Login
  *
  * @JSON
  */
 public function login()
 {
     /**
      * 1. 判断用户是否已经登录,
      *      若已经登录,则直接跳转到控制面板(仪表盘)中.
      * 2. 加载登录页面模板,进入登录页面.
      */
     $user = User::getCurrent();
     if ($user->uid) {
         header("Location:/member");
     } else {
         if (isset($_REQUEST['email']) && isset($_REQUEST['passwd'])) {
             $result = array('error' => 1, 'message' => '账户不存在啊喂!');
             $email = htmlspecialchars(trim($_REQUEST['email']));
             $passwd = htmlspecialchars(trim($_REQUEST['passwd']));
             $remember_me = htmlspecialchars(trim($_REQUEST['remember_me']));
             $user = User::getUserByEmail($email);
             if ($user) {
                 if ($user->verifyPassword($passwd)) {
                     $result['error'] = 0;
                     $result['message'] = '登录成功,即将跳转到 >仪表盘';
                     $remember_me == 'week' ? $ext = 3600 * 24 * 7 : ($ext = 3600);
                     $expire = time() + $ext;
                     $token = md5($user->uid . ":" . $user->email . ":" . $user->passwd . ":" . $expire . ":" . COOKIE_KEY);
                     setcookie("uid", base64_encode(Encrypt::encode($user->uid, ENCRYPT_KEY)), $expire, "/");
                     setcookie("expire", base64_encode(Encrypt::encode($expire, ENCRYPT_KEY)), $expire, "/");
                     setcookie("token", base64_encode(Encrypt::encode($token, ENCRYPT_KEY)), $expire, "/");
                     $_SESSION['currentUser'] = $user;
                     Logger::getInstance()->info('user [' . $user->email . '] Login success');
                 } else {
                     $result['message'] = "账户名或密码错误, 请检查后再试!";
                     Logger::getInstance()->info('user [' . $user->email . '] Login failed! wrong password');
                 }
             }
             return $result;
         } else {
             $data['globalMessage'] = MessageModel::getGlobalMessage();
             Template::setContext($data);
             Template::setView('panel/login');
         }
     }
 }
Beispiel #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');
 }