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

📄 postaction.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      return f;

    }
    if (form.getAction().equals("repost")) {
      UserInfo myUserInfo = myUserSessionCheck.getUser().getUserInfo();
      BoardsInfo theBoards = myUserSessionCheck.getTheBoards();
      String IP = httpServletRequest.getRemoteAddr();
      int artSize = 0;
      try {
        artSize = form.getDetail().getBytes(Sys.SYSINFO.CHARSET).length;
      }
      catch (Exception e) {
        System.out.println(e);
      }

      int mypower = 0; //气力值
      mypower = myUserInfo.getPower();
      if (mypower <= 0 &&
          ! (myUserSessionCheck.isSuperAdmin() ||
             myUserSessionCheck.isBMaster() ||
             myUserSessionCheck.isMainMaster() ||
             myUserSessionCheck.isAssiMaster() ||
             myUserSessionCheck.isHideMaster())) {
        errors.add("nopower", new ActionError("error.post.nopower"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      String sign_detail = "";
      if (form.getSign().equals("0")) {
        sign_detail = "";
      }
      else {
        sign_detail = Util.addSlashes(myUserInfo.getSing_Detail(Integer.
            parseInt(form.getSign())));
      }

      ForumInfo aForumInfo = new ForumInfo();
      long postTime = Util.getaLongTime();
      long aID = TableID.nextID(4);
      aForumInfo.setID(aID);
      aForumInfo.setID1(Long.parseLong(form.getRecid()));
      aForumInfo.setID2(Long.parseLong(form.getMainid()));
      aForumInfo.setBoardID(theBoards.getID());
      aForumInfo.setBoardName(theBoards.getBoardsName());
      aForumInfo.setFace(Integer.parseInt(form.getBq()));
      aForumInfo.setUserID(myUserInfo.getID());
      aForumInfo.setUserName(myUserInfo.getUserName());
      aForumInfo.setTitle(form.getTitle());
      aForumInfo.setDetail(form.getDetail());
      aForumInfo.setSign(sign_detail);
      aForumInfo.setArtSize(artSize);
      aForumInfo.setEmail_Inform(Integer.parseInt(form.getEmail_inform()));
      aForumInfo.setMsg_Inform(Integer.parseInt(form.getMsg_inform()));
      aForumInfo.setPostTime(postTime);
      aForumInfo.setLastTime(postTime);
      aForumInfo.setIPAddress(IP);
      aForumInfo.setIsNew(0);
      aForumInfo.setNickName(myUserInfo.getNickName());
      FormFile file = form.getForm_data();
      boolean isHavePic = false;

      if (file != null && file.getFileName() != null &&
          file.getFileName().length() > 0) {
        if (Util.isAllowFile("pic", file.getFileName()) &&
            file.getFileSize() > 0 &&
            file.getFileSize() <= (Sys.SYSINFO.UPIMGSIZE * 1024)) {
          String imgFileName = "img_" + aID + "_" + postTime +
              Util.getFileExt(file.getFileName());
          aForumInfo.setHavePic(1);
          aForumInfo.setPicName(imgFileName);
          isHavePic = true;
        }
        else {
          errors.add("upnotice",
                     new ActionError("post.upnotice",
                                     String.valueOf(Sys.SYSINFO.UPIMGSIZE)));
          saveErrors(httpServletRequest, errors);
          return actionMapping.findForward("error");
        }
      }

      Forum aForum = ForumFactory.getInstance();
      aForum.setUserInfo(myUserInfo);
      aForum.setForumInfo(aForumInfo);
      aForum.setUserSessionCheck(myUserSessionCheck);

      int result = 0;
      if (isHavePic) {
        result = aForum.createPost(null, "re", file);
      }
      else {
        result = aForum.createPost(null, "re");
      }
      if (result != Sys.RESULT_RIGHT) {
        errors.add("posterror", new ActionError("error.posterror"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      User myUser = myUserSessionCheck.getUser();
      myUser.setUserInfo(aForum.getUserInfo());
      UserSession myUserSession = ServerSession.getSession(form.getSid(),
          httpServletRequest);
      myUserSession.setAttribute("user", myUser);
      ServerSession.upSession(myUserSession);

      int inpages = (int) Math.ceil( ( (Integer.parseInt(form.getTotalnum()) +
                                        1) + Sys.SYSINFO.POSTPERNUM - 1) /
                                    Sys.SYSINFO.POSTPERNUM);
      /*
       httpServletRequest.setAttribute("aForwardInfo",
                                       new ForwardInfo("succeed.jrzc",
           Sys.getURL() + "readAction.do?sid=" + form.getSid() +
           "&bid=" + form.getBid() + "&pages=" + form.getPages() + "&recid=" +
           form.getMainid() + "&inpages=" + inpages));*/

      errors = null;
      //form = null;
      myUserSessionCheck = null;
      myUserInfo = null;
      theBoards = null;
      IP = null;
      sign_detail = null;
      aForumInfo = null;
      file = null;
      aForum = null;
      myUser = null;
      myUserSession = null;

      //return actionMapping.findForward("forwards");

      ActionForward f = new ActionForward("/readAction.do?sid=" +
                                          form.getSid() +
                                          "&bid=" + form.getBid() + "&pages=" +
                                          form.getPages() + "&recid=" +
                                          form.getMainid() + "&inpages=" +
                                          inpages
                                          , true);
      return f;

    }
    if (form.getAction().equals("change")) {
      ForumInfo afi = new ForumInfo();
      afi.setBoardID(Long.parseLong(form.getBid()));
      afi.setID(Long.parseLong(form.getRecid()));
      Forum af = ForumFactory.getInstance();
      af.setForumInfo(afi);
      if (af.getPost(null, "ID", true) != Sys.RESULT_RIGHT) {
        errors.add("getpost", new ActionError("error.post.getpost"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      afi = af.getForumInfo();
      if (! (afi.getUserName().equals(myUserSessionCheck.getUserName()) ||
             myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
             myUserSessionCheck.isMainMaster() ||
             myUserSessionCheck.isAssiMaster() ||
             myUserSessionCheck.isHideMaster())) {
        errors.add("purviewerror", new ActionError("error.purviewerror"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      int artSize = 0;
      try {
        artSize = form.getDetail().getBytes(Sys.SYSINFO.CHARSET).length;
      }
      catch (Exception e) {
        System.out.println(e);
      }
      String IP = httpServletRequest.getRemoteAddr();
      String amend = "";
      MessageResources messages = getResources(httpServletRequest);
      Locale locale = getLocale(httpServletRequest);
      java.util.Date nowDate = new java.util.Date();
      amend = messages.getMessage(locale, "change.text",
                                  myUserSessionCheck.getUserName(),
                                  Util.fotmatDate3(nowDate), IP);
      afi.setFace(Integer.parseInt(form.getBq()));
      afi.setTitle(form.getTitle());
      afi.setDetail(form.getDetail());
      afi.setArtSize(artSize);
      afi.setIPAddress(IP);
      afi.setAmend(amend);
      af.setForumInfo(afi);
      af.setUserSessionCheck(myUserSessionCheck);
      af.setUserInfo(myUserSessionCheck.getUser().getUserInfo());
      /*
             if ( (artSize <= 20) &&
           ! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
             myUserSessionCheck.isMainMaster() ||
             myUserSessionCheck.isAssiMaster() ||
             myUserSessionCheck.isHideMaster())) {
        User myUser = myUserSessionCheck.getUser();
        UserInfo myUserInfo = myUser.getUserInfo();
        myUserInfo.setPower(myUserInfo.getPower() - 1);
        myUser.setUserInfo(myUserInfo);
        myUser.updateUser(null,"datapost");
             }*/
      if (af.changePost(null) != Sys.RESULT_RIGHT) {
        errors.add("changepost", new ActionError("error.changepost"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      User myUser = myUserSessionCheck.getUser();
      myUser.setUserInfo(af.getUserInfo());
      UserSession myUserSession = ServerSession.getSession(form.getSid(),
          httpServletRequest);
      myUserSession.setAttribute("user", myUser);
      ServerSession.upSession(myUserSession);
      /*
             httpServletRequest.setAttribute("aForwardInfo",
                                      new ForwardInfo("succeed.jrzc",
          Sys.getURL() + "readAction.do?sid=" + form.getSid() +
          "&bid=" + form.getBid() + "&pages=" + form.getPages() + "&recid=" +
          form.getMainid() + "&inpages=" + form.getInpages()));*/

      errors = null;
      //form = null;
      myUserSessionCheck = null;
      afi = null;
      af = null;
      IP = null;
      amend = null;
      messages = null;
      locale = null;
      nowDate = null;
      myUser = null;
      myUserSession = null;

      //return actionMapping.findForward("forwards");

      ActionForward f = new ActionForward("/readAction.do?sid=" +
                                          form.getSid() +
                                          "&bid=" + form.getBid() + "&pages=" +
                                          form.getPages() + "&recid=" +
                                          form.getMainid() + "&inpages=" +
                                          form.getInpages(), true);
      return f;

    }
    return actionMapping.findForward("error");
  }
}

⌨️ 快捷键说明

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