?? post.java
字號:
package com.laoer.bbscs.web.action;
import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.web.servlet.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.sys.*;
import com.laoer.comm.util.*;
import org.apache.struts.action.*;
import org.apache.struts.util.*;
import javax.servlet.http.*;
import java.util.*;
/**
* <p>Title: TianYi BBS</p>
* <p>Description: TianYi BBS System</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: LAOER.COM/TIANYISOFT.NET</p>
* @author laoer
* @version 6.0
*/
public class Post
extends BaseAction {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
ActionErrors errors = new ActionErrors();
PostForm form = (PostForm) actionForm;
UserCheck uc = this.getUserCheck(httpServletRequest, httpServletResponse,
form.getBid());
if (uc.isGuest()) {
errors.add("error.pleaselogin", new ActionError("error.pleaselogin"));
saveErrors(httpServletRequest, errors);
//return actionMapping.findForward("login");
return SysUtil.getPassLogin(actionMapping);
}
if (uc.getBs() == null) {
errors.add("error.baordsno", new ActionError("error.baordsno"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (!uc.isCanPost()) {
errors.add("error.forum.cannotpost",
new ActionError("error.forum.cannotpost"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
UserInfo ui = getUserCache().getUserInfoFromCache(uc.getId());
if (ui == null) {
errors.add("error.getusererror", new ActionError("error.getusererror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (form.getAction().equals("add") || form.getAction().equals("addre") ||
form.getAction().equals("changedo")) {
if (!uc.isCanPostNotNeedExp()) {
BlackUser bu = getBlackUserService().findBlackUserByUserName(uc.
getUsername(), (short) 0, 0, form.getBid());
if (bu != null) {
if (bu.getOutTime() > Util.getLongTime()) {
errors.add("error.login.notlogin",
new ActionError("error.login.notlogin",
Util.formatDate(new Date(bu.getOutTime()))));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
}
}
}
httpServletRequest.setAttribute("ui", ui);
httpServletRequest.setAttribute("uc", uc);
if (form.getAction().equals("new")) {
form.setAction("add");
form.setFace( (short) 1);
httpServletRequest.setAttribute("postForm", form);
return actionMapping.findForward("post");
}
if (form.getAction().equals("re")) {
form.setAction("addre");
form.setFace( (short) 1);
/*
Forum forum = this.getForumService().getForum(form.getId(), form.getBid());
if (forum != null) {
form.setTitle("Re:" + forum.getTitle());
}*/
//form.setTitle(Util.unescapeFromXML(form.getTitle()));
httpServletRequest.setAttribute("postForm", form);
return actionMapping.findForward("post");
}
if (form.getAction().equals("change")) {
form.setAction("changedo");
Forum forum = this.getForumService().getForum(form.getId(), form.getBid());
if (forum == null) {
errors.add("getpost", new ActionError("error.post.getpost"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (! (uc.isCanPostNotNeedExp() ||
(forum.getUserID() == uc.getId() && forum.getCanNotRe() == 0))) {
errors.add("error.purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
form.setCanReadExp(forum.getCanReadExp());
String content = FileIO.readFile(SysUtil.getForumPath(forum.
getBoardID(), forum.getPostTime()) + forum.getDetail(),
Constant.CHARSET);
content = SysUtil.getPostDetail(content);
form.setFace(forum.getFace());
//form.setTitle(Util.unescapeFromXML(forum.getTitle()));
form.setTitle(forum.getTitle());
if (SysInfo.getInstance().getPosthtml() == 1 &&
SysInfo.getInstance().getHtmledit() == 1 &&
uc.getBs().getAttrib2() == 1) {
form.setUseedit("yes");
form.setDetail(content);
}
else {
form.setUseedit("no");
content = SysUtil.unBr(content);
content = Util.unescapeFromXML(content);
form.setDetail(content);
}
httpServletRequest.setAttribute("postForm", form);
return actionMapping.findForward("post");
}
if (form.getAction().equals("add")) {
long atime = SysUtil.getLongTime();
String IP = httpServletRequest.getRemoteAddr();
int artSize = SysUtil.getStrLength(form.getDetail(), Constant.CHARSET);
if (uc.getPower() <= 0 && !uc.isCanPostNotNeedExp()) {
errors.add("nopower", new ActionError("error.post.nopower"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
Forum forum = ForumFactory.getInstance(form.getBid());
forum.setAgree(0);
forum.setAmend("");
forum.setArtSize(artSize);
forum.setAuditing(uc.getBs().getAttrib8());
forum.setBeAgainst(0);
forum.setBoardID(form.getBid());
forum.setBoardName(uc.getBs().getBoardsName());
forum.setCanNotDel( (short) 0);
forum.setCanNotRe( (short) 0);
forum.setCanReadExp(form.getCanReadExp());
forum.setClick(0);
forum.setDelIP("");
forum.setDelSign( (short) 0);
forum.setDelTime(0);
forum.setDelUserID(0);
forum.setDelUserName("");
forum.setDetail(form.getDetail());
forum.setDoEliteName("");
forum.setDoEliteTime(0);
forum.setElite(0);
forum.setEliteID(0);
forum.setEmailInform(form.getEmailInform());
forum.setFace(form.getFace());
forum.setHavePic( (short) 0);
forum.setId1(0);
forum.setId2(0);
forum.setIpAddress(IP);
forum.setIsB( (short) 0);
forum.setIsLock( (short) 0);
forum.setIsNew( (short) 1);
forum.setIsTop( (short) 0);
forum.setIsVote( (short) 0);
forum.setLastPostNickName("---");
forum.setLastPostTitle("---");
forum.setLastPostUserName("---");
forum.setLastTime(atime);
forum.setMsgInform(form.getMsgInform());
forum.setNickName(uc.getNickname());
forum.setPicName("");
forum.setPostTime(atime);
forum.setReNum(0);
forum.setSign(form.getSign());
forum.setTitle(form.getTitle());
forum.setUserID(uc.getId());
forum.setUserName(uc.getUsername());
forum.setVtime("");
Result r = getForumService().createForum("new", forum, uc, form.getUpfile());
if (!r.isRight()) {
errors.add("posterror", new ActionError(r.getMsg()));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (uc.getBs().getAttrib3() == 0) {
if (artSize > this.getSysInfo().getPostminsize()) {
ui.setArticleNum(ui.getArticleNum() + 1);
}
if (!uc.isCanPostNotNeedExp()) {
ui.setPower( (short) (ui.getPower() - 1));
}
ui = this.getUserInfoService().saveUserInfo(ui);
if (ui != null) {
uc.addCookies(ui);
getUserCache().putUserInfoInCache(ui);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -