post.java
来自「一个jsp写的bbs」· Java 代码 · 共 1,187 行 · 第 1/4 页
JAVA
1,187 行
uploadFile = null;
}
catch (IOException ex2) {
uploadFile = null;
}
}
Forum mainForum = this.getForumService().findForumByID(postForm.getMainID(), bid);
if (mainForum == null) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
this.setNeedsAttributeRe(request, us, board);
return mapping.getInputForward();
}
if (mainForum.getIsLock() == 1) {
messages.add("error.post.islock", new ActionMessage("error.post.islock"));
this.saveErrors(request, messages);
this.setNeedsAttributeRe(request, us, board);
return mapping.getInputForward();
}
long nowtime = System.currentTimeMillis();
Forum f = new Forum();
f.setAgree(0);
f.setAmend("");
f.setArtSize(BBSCSUtil.getSysCharsetStrLength(detail));
f.setAttachFileName(new ArrayList());
f.setAuditing(board.getAuditPost());
//f.setAuditingAttachFile(board.getAuditAttach());
if (board.getAuditAttach() == 1 && uploadFile != null) {
f.setAuditingAttachFile(board.getAuditAttach());
}
else {
f.setAuditingAttachFile(0);
}
f.setBeAgainst(0);
f.setBoardID(bid);
f.setBoardName(board.getBoardName());
f.setCanNotDel(0);
f.setCanNotRe(0);
f.setClick(0);
f.setCommend(0);
f.setDelIP("");
f.setDelSign(0);
f.setDelTime(0);
f.setDelUserID("");
f.setDelUserName("");
f.setDetail(detail);
f.setDoEliteName("");
f.setDoEliteTime(0);
f.setEditType(postForm.getEditType());
f.setElite(0);
f.setEliteID(0);
f.setFace(postForm.getFace());
f.setHaveAttachFile(0);
f.setIpAddress(request.getRemoteAddr());
f.setIsHidden(postForm.getIsHidden());
if (postForm.getIsHidden() == 2) {
f.setIsHiddenValue(postForm.getUseCoin());
}
else if (postForm.getIsHidden() == 3) {
f.setIsHiddenValue(postForm.getNeedArtNum());
}
else {
f.setIsHiddenValue(0);
}
f.setIsLock(0);
f.setIsNew(0);
f.setIsTop(0);
f.setIsVote(0);
f.setLastPostNickName("---");
f.setLastPostTitle("");
f.setLastPostUserName("---");
f.setLastTime(nowtime);
f.setMainID(postForm.getMainID());
f.setNickName(us.getNickName());
f.setParentID(postForm.getParentID());
f.setPostTime(nowtime);
f.setPostType(postForm.getPostType());
/*
if (postForm.getAction().equalsIgnoreCase("addrequote")) {
f.setQuoteEditType(mainForum.getEditType());
if (this.getSysConfig().getQuoteMaxSize() > 0) {
f.setQuoteText(BBSCSUtil.getSpeShortString(mainForum.getDetail(),
this.getSysConfig().getQuoteMaxSize(), "..."));
}
else {
f.setQuoteText(mainForum.getDetail());
}
}
else {
f.setQuoteText("");
}*/
f.setQuoteText("");
f.setReNum(0);
if (postForm.getSign() == -1) {
f.setSign("");
}
else {
f.setSign(us.getSignDetail()[postForm.getSign()]);
}
f.setTitle(title);
f.setTitleColor(postForm.getTitleColor());
f.setUserID(us.getId());
f.setUserName(us.getUserName());
f.setEmailInform(postForm.getEmailInform());
f.setMsgInform(postForm.getMsgInform());
f.setUserBlog(postForm.getUserBlog());
if (board.getAuditPost() == 0) {
f.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
}
else {
f.setIndexStatus(Constant.INDEX_STATUS_AUDIT);
}
f.setTagID(mainForum.getTagID());
f.setTagName(mainForum.getTagName());
//f.setIsGuest(0);
f.setPreviewAttach(postForm.getPreviewAttach());
int userPostPerNum = this.getUserPostPerNum(uc.getPostPerNum(),
this.getSysConfig().getPostPerPage());
int inpages = (int) Math.ceil( (postForm.getTotalnum() + 1) + userPostPerNum - 1) /
userPostPerNum;
if (mainForum.getIsHidden() == 1) {
inpages = 1;
}
try {
UserInfo ui = this.getUserService().findUserInfoById(us.getId());
if (ui == null) {
messages.add("error.post.guest", new ActionMessage("error.post.guest"));
this.saveErrors(request, messages);
this.setNeedsAttributeRe(request, us, board);
return mapping.getInputForward();
}
f = this.getForumService().createReForum(f, mainForum, board, ui, uploadFile, isQuote);
uc.addLastPostTime();
if (board.getAuditPost() == 0) {
if (Constant.USE_URL_REWRITE) {
return new ActionForward("/read-topic-" + bid + "-" + postForm.getMainID() + "-" + tagId + "-" +
postForm.getFcpage() + "-index-" + inpages + ".html", true);
}
else {
return new ActionForward(BBSCSUtil.getActionMappingURL("/read?action=topic&id=" +
postForm.getMainID() + "&bid=" + bid + "&fcpage=" + postForm.getFcpage() + "&fcaction=index" +
"&inpages=" + inpages + "&tagId=" + tagId), true);
}
}
else {
return new ActionForward(BBSCSUtil.getActionMappingURL("/postWaitAudit?bid=" + bid), true);
}
}
catch (BbscsException ex1) {
messages.add("error.post.add", new ActionMessage("error.post.add"));
this.saveErrors(request, messages);
this.setNeedsAttributeRe(request, us, board);
return mapping.getInputForward();
}
}
if (postForm.getAction().equalsIgnoreCase("upfiledo")) {
MessageResources mr = this.getResources(request);
Locale locale = this.getLocale(request);
Forum f = this.getForumService().findForumByID(postForm.getId(), postForm.getBid());
if (this.getSysConfig().getAttachmentNum() == 0) {
if (f.getAttachFileName().size() >= 20) {
request.setAttribute("codeid", "2");
request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.num", "20"));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
}
else if (this.getSysConfig().getAttachmentNum() > 0 &&
f.getAttachFileName().size() >= this.getSysConfig().getAttachmentNum()) {
request.setAttribute("codeid", "2");
request.setAttribute("msg",
mr.getMessage(locale, "error.post.upfile.num",
String.valueOf(this.getSysConfig().getAttachmentNum())));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
if (!us.getId().equals(f.getUserID())) {
request.setAttribute("codeid", "4");
request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.user"));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
UploadFile uploadFile = null;
if (postForm.getUpdateFile() != null &&
StringUtils.isNotBlank(postForm.getUpdateFile().getFileName()) &&
postForm.getUpdateFile().getFileSize() > 0) {
if (!this.getSysConfig().isAllowAttachFileType(postForm.getUpdateFile().getFileName().
toLowerCase()) || postForm.getUpdateFile().getFileSize() >
(this.getSysConfig().getAttachFileSize() * 1024)) {
/*
messages.add("post.upnotice",
new ActionMessage("post.upnotice",
String.valueOf(this.getSysConfig().getAttachFileSize()),
this.getSysConfig().getAttachFileType()));
this.saveErrors(request, messages);
return mapping.findForward("error");*/
request.setAttribute("codeid", "1");
request.setAttribute("msg",
mr.getMessage(locale, "post.upnotice",
String.valueOf(this.getSysConfig().getAttachFileSize()),
this.getSysConfig().getAttachFileType()));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
try {
uploadFile = new UploadFile();
uploadFile.setFileName(postForm.getUpdateFile().getFileName().toLowerCase());
uploadFile.setInputStream(postForm.getUpdateFile().getInputStream());
}
catch (FileNotFoundException ex2) {
uploadFile = null;
request.setAttribute("codeid", "3");
request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.error"));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
catch (IOException ex2) {
uploadFile = null;
request.setAttribute("codeid", "3");
request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.error"));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
}
try {
if (board.getAuditAttach() == 1) {
f.setAuditingAttachFile(1);
}
f = this.getForumService().createForumUpFile(f, uploadFile);
if (board.getAuditAttach() == 0) {
request.setAttribute("codeid", "0");
request.setAttribute("msg", mr.getMessage(locale, "post.upfile.upok"));
}
else {
request.setAttribute("codeid", "99");
request.setAttribute("msg", mr.getMessage(locale, "post.upfile.upok1"));
}
request.setAttribute("codeid", "0");
request.setAttribute("msg", mr.getMessage(locale, "post.upfile.upok"));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
catch (BbscsException ex3) {
request.setAttribute("codeid", "3");
request.setAttribute("msg", mr.getMessage(locale, "error.post.upfile.error"));
request.setAttribute("pid", postForm.getId());
request.setAttribute("bid", new Long(postForm.getBid()));
return mapping.findForward("forumUpComponent");
}
}
if (postForm.getAction().equalsIgnoreCase("edit")) {
Forum f = this.getForumService().findForumByID(postForm.getId(), postForm.getBid());
if (f == null) {
messages.add("error.post.getpost", new ActionMessage("error.post.getpost"));
this.saveErrors(request, messages);
return mapping.findForward(this.FORWARD_ERROR);
}
if (! (f.getUserID().equals(us.getId()) ||
us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST))) {
messages.add("error.noPermission", new ActionMessage("error.noPermission"));
this.saveErrors(request, messages);
return mapping.findForward(this.FORWARD_ERROR);
}
if (this.getSysConfig().getEditPostLimit() > 0) {
if (! (us.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST) ||
(System.currentTimeMillis() - f.getPostTime()) <
this.getSysConfig().getEditPostLimit() * 60000)) {
messages.add("error.post.edit.timeout", new ActionMessage("error.post.edit.timeout"));
this.saveErrors(request, messages);
return mapping.findForward(this.FORWARD_ERROR);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?