⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usersessioncheck.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
字号:
package com.laoer.bbscs.servlet;

import javax.servlet.http.*;
import com.laoer.bbscs.bbs.business.*;
import com.laoer.bbscs.util.*;
import java.util.*;
import com.laoer.bbscs.util.*;

/**
 * <p>Title: 天乙社区V5.0</p>
 * <p>Description: BBS-CS天乙社区V5.0</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: laoer.com</p>
 * @author 龚天乙
 * @version 5.0
 */

public class UserSessionCheck {

  String sid = "";
  HttpServletRequest request;
  boolean sessionOK = true;
  User myUser;
  AdminUserInfo myAdminUserInfo;
  long userID = 0;
  String userName = "";
  String nickName = "";
  boolean isGuest = false;
  boolean isSuperAdmin = false;
  boolean isManager = false;
  boolean isBoardManager = false;
  boolean isBulletinManager = false;
  boolean isUserAdmin = false;
  String logintime = "";
  boolean[] iAttribs;
  BoardsInfo theBoards;
  BoardInfo theBoard;
  boolean isMainMaster = false;
  boolean isAssiMaster = false;
  boolean isHideMaster = false;
  boolean BMaster = false;
  boolean buAtBoards = false;
  String buOutTime = "";

  public UserSessionCheck(String asid, HttpServletRequest arequest) {
    this.sid = asid;
    this.request = arequest;
  }

  public boolean checkSession() {
    UserSession myUserSession = ServerSession.getSession(this.sid, this.request);
    if (myUserSession == null) {
      sessionOK = false;
      return sessionOK;
    }
    myUser = (User) myUserSession.getAttribute("user");
    if (myUser == null) {
      sessionOK = false;
      return sessionOK;
    }
    myAdminUserInfo = (AdminUserInfo) myUserSession.getAttribute("adminUser");
    if (myAdminUserInfo == null) {
      sessionOK = false;
      return sessionOK;
    }
    logintime = (String) myUserSession.getAttribute("logintime");
    this.userID = myUser.getUserInfo().getID();
    this.userName = myUser.getUserInfo().getUserName();
    this.nickName = myUser.getUserInfo().getNickName();
    this.isGuest = myUser.getUserInfo().getIsGuest();
    this.isSuperAdmin = (myAdminUserInfo.getSuperAdmin() == 1);
    this.isManager = (myAdminUserInfo.getManager() == 1);
    this.isBoardManager = (myAdminUserInfo.getBoard() == 1);
    this.isBulletinManager = (myAdminUserInfo.getBulletin() == 1);
    this.isUserAdmin = (myAdminUserInfo.getUserAdmin() == 1);
    if (Util.getaLongTime() - myUserSession.getNowTime() >= (5 * 60000)) {
      myUserSession.upTime();
      ServerSession.upSession(myUserSession);
    }
    return sessionOK;
  }

  public boolean checkSession(String bid) {
    if (checkSession()) {
      this.theBoards = (BoardsInfo) BoardList.boardslist.get(bid);
      if (theBoards == null) {
        return false;
      }
      boolean[] _iAttribs = {
          (theBoards.getAttrib1() == 1), (theBoards.getAttrib2() == 1),
          (theBoards.getAttrib3() == 1), (theBoards.getAttrib4() == 1),
          (theBoards.getAttrib5() == 1),
          (theBoards.getAttrib6() == 1), (theBoards.getAttrib7() == 1),
          (theBoards.getAttrib8() == 1), (theBoards.getAttrib9() == 1),
          (theBoards.getAttrib10() == 1)};
      this.iAttribs = _iAttribs;
      this.theBoard = (BoardInfo) BoardList.boardlist.get(String.valueOf(
          theBoards.
          getBoardID()));
      if (theBoard == null) {
        return false;
      }
      BoardsMaster myBoardsMaster = new BoardsMaster(this.userName, theBoards);
      this.isMainMaster = myBoardsMaster.isMainMaster();
      this.isAssiMaster = myBoardsMaster.isAssiMaster();
      this.isHideMaster = myBoardsMaster.isHideMaster();
      if (theBoard.getBMaster().equals(this.userName)) {
        this.BMaster = true;
      }

      List buList = (List) BoardList.blackuserlist.get(bid);
      BlackUserInfo myBlackUserInfo;
      for (int i = 0; i < buList.size(); i++) {
        myBlackUserInfo = (BlackUserInfo) buList.get(i);
        if (myBlackUserInfo.getUserID() == userID) {
          buAtBoards = true;
          buOutTime = Util.fotmatDate3(new Date(myBlackUserInfo.getOutTime()));
        }
      }
      return true;
    }
    else {
      return false;
    }
  }

  public User getUser() {
    return this.myUser;
  }

  public AdminUserInfo getAdminUserInfo() {
    return this.myAdminUserInfo;
  }

  public long getUserID() {
    return this.userID;
  }

  public String getUserName() {
    return this.userName;
  }

  public String getNickName() {
    return this.nickName;
  }

  public boolean isGuest() {
    return this.isGuest;
  }

  public boolean isSuperAdmin() {
    return this.isSuperAdmin;
  }

  public boolean isManager() {
    return this.isManager;
  }

  public boolean isBoardManager() {
    return this.isBoardManager;
  }

  public boolean isBulletinManager() {
    return this.isBulletinManager;
  }

  public boolean isUserAdmin() {
    return this.isUserAdmin;
  }

  public String getLogintime() {
    return this.logintime;
  }

  public boolean[] getiAttribs() {
    return this.iAttribs;
  }

  public BoardsInfo getTheBoards() {
    return this.theBoards;
  }

  public BoardInfo getTheBoard() {
    return this.theBoard;
  }

  public boolean isMainMaster() {
    return this.isMainMaster;
  }

  public boolean isAssiMaster() {
    return this.isAssiMaster;
  }

  public boolean isHideMaster() {
    return this.isHideMaster;
  }

  public boolean isBMaster() {
    return this.BMaster;
  }

  public boolean getBuAtBoards() {
    return this.buAtBoards;
  }

  public String getBuOutTime() {
    return this.buOutTime;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -