📄 dopostaction.java
字号:
package com.laoer.bbscs.bbs.action;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.laoer.bbscs.bbs.actionform.*;
import com.laoer.bbscs.bbs.business.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.util.*;
import com.laoer.bbscs.servlet.*;
import com.laoer.bbscs.db.*;
import org.apache.struts.util.*;
import java.util.*;
import java.io.*;
import com.laoer.bbscs.mail.*;
public class DoPostAction
extends Action {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
ActionErrors errors = new ActionErrors();
ReadActionForm form = (ReadActionForm) actionForm;
UserSessionCheck myUserSessionCheck = new UserSessionCheck(form.getSid(),
httpServletRequest);
if (!myUserSessionCheck.checkSession(form.getBid())) {
errors.add("error.timeout", new ActionError("error.timeout"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (myUserSessionCheck.isGuest()) {
errors.add("noguest", new ActionError("error.user.noguest"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
httpServletRequest.setAttribute("myUserSessionCheck", myUserSessionCheck);
httpServletRequest.setAttribute("sid", form.getSid());
httpServletRequest.setAttribute("bid", form.getBid());
if (form.getAction().equals("delapost")) {
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 (! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
myUserSessionCheck.isMainMaster() ||
myUserSessionCheck.isAssiMaster() ||
myUserSessionCheck.isHideMaster() ||
(afi.getCanNotRe() == 0 &&
afi.getUserName().equals(myUserSessionCheck.getUserName())))) {
errors.add("purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
afi.setDelUserID(myUserSessionCheck.getUserID());
afi.setDelUserName(myUserSessionCheck.getUserName());
afi.setDelTime(Util.getaLongTime());
afi.setDelIP(httpServletRequest.getRemoteAddr());
af.setForumInfo(afi);
af.setUserSessionCheck(myUserSessionCheck);
//af.setBoardsInfo(myUserSessionCheck.getTheBoards());
if (af.delaPost(null, "delaPost", 0) != Sys.RESULT_RIGHT) {
errors.add("error.post.del1", new ActionError("error.post.del1"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("",
Sys.getURL() + "rightAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&pages=" + form.getPages()));*/
errors = null;
//form = null;
myUserSessionCheck = null;
afi = null;
af = null;
//return actionMapping.findForward("forwards");
ActionForward f = new ActionForward("/rightAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&pages=" +
form.getPages(), true);
return f;
}
if (form.getAction().equals("setelite")) {
if (! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
myUserSessionCheck.isMainMaster() ||
myUserSessionCheck.isAssiMaster() ||
myUserSessionCheck.isHideMaster())) {
errors.add("purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
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.getElite() == 0) {
afi.setElite(myUserSessionCheck.getTheBoards().getID());
afi.setDoEliteName(myUserSessionCheck.getUserName());
afi.setDoEliteTime(Util.getaLongTime());
af.setForumInfo(afi);
int result = af.updatePost(null, "doelite");
if (result != Sys.RESULT_RIGHT) {
errors.add("error.elite.add", new ActionError("error.elite.add"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
UserInfo ui = new UserInfo();
ui.setID(afi.getUserID());
User au = UserFactory.getInstance();
au.setUserInfo(ui);
au.getUser(null, "ID", true);
ui = au.getUserInfo();
ui.setExpression(ui.getExpression() + 5);
au.setUserInfo(ui);
result = au.updateUser(null, "datapost");
if (result != Sys.RESULT_RIGHT) {
errors.add("error.elite.add", new ActionError("error.elite.add"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
ui = null;
au = null;
}
afi = null;
af = null;
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("",
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;
//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;
}
if (form.getAction().equals("delpic")) {
if (! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
myUserSessionCheck.isMainMaster() ||
myUserSessionCheck.isAssiMaster() ||
myUserSessionCheck.isHideMaster())) {
errors.add("purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
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();
String picFileName = afi.getPicName();
File picFile = new File(Util.getImgPath(form.getBid(), afi.getPostTime()) +
picFileName);
if (picFile.exists()) {
picFile.delete();
}
if (af.updatePost(null, "delpic") != Sys.RESULT_RIGHT) {
errors.add("error.post.delimg", new ActionError("error.post.delimg"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
afi = null;
af = null;
picFile = null;
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("",
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;
//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;
}
if (form.getAction().equals("settopok")) {
if (! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
myUserSessionCheck.isMainMaster() ||
myUserSessionCheck.isAssiMaster() ||
myUserSessionCheck.isHideMaster())) {
errors.add("purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
ForumInfo afi = new ForumInfo();
afi.setBoardID(Long.parseLong(form.getBid()));
afi.setID(Long.parseLong(form.getRecid()));
afi.setIsTop(1);
Forum af = ForumFactory.getInstance();
af.setForumInfo(afi);
if (af.updatePost(null, "settop") != Sys.RESULT_RIGHT) {
errors.add("error.handlerror", new ActionError("error.handlerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("",
Sys.getURL() + "readAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&pages=" + form.getPages() + "&recid=" +
form.getMainid()));*/
errors = null;
//form = null;
myUserSessionCheck = null;
afi = null;
af = null;
//return actionMapping.findForward("forwards");
ActionForward f = new ActionForward("/readAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&pages=" +
form.getPages() + "&recid=" +
form.getMainid(), true);
return f;
}
if (form.getAction().equals("settopno")) {
if (! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
myUserSessionCheck.isMainMaster() ||
myUserSessionCheck.isAssiMaster() ||
myUserSessionCheck.isHideMaster())) {
errors.add("purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
ForumInfo afi = new ForumInfo();
afi.setBoardID(Long.parseLong(form.getBid()));
afi.setID(Long.parseLong(form.getRecid()));
afi.setIsTop(0);
Forum af = ForumFactory.getInstance();
af.setForumInfo(afi);
if (af.updatePost(null, "settop") != Sys.RESULT_RIGHT) {
errors.add("error.handlerror", new ActionError("error.handlerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("",
Sys.getURL() + "readAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&pages=" + form.getPages() + "&recid=" +
form.getMainid()));*/
errors = null;
//form = null;
myUserSessionCheck = null;
afi = null;
af = null;
//return actionMapping.findForward("forwards");
ActionForward f = new ActionForward("/readAction.do?sid=" + form.getSid() +
"&bid=" + form.getBid() + "&pages=" +
form.getPages() + "&recid=" +
form.getMainid(), true);
return f;
}
if (form.getAction().equals("cannotdel")) {
if (! (myUserSessionCheck.isSuperAdmin() || myUserSessionCheck.isBMaster() ||
myUserSessionCheck.isMainMaster() ||
myUserSessionCheck.isAssiMaster() ||
myUserSessionCheck.isHideMaster())) {
errors.add("purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
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.updatePost(null, "cannotdel") != Sys.RESULT_RIGHT) {
errors.add("error.handlerror", new ActionError("error.handlerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
/*
httpServletRequest.setAttribute("aForwardInfo",
new ForwardInfo("",
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;
//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;
}
if (form.getAction().equals("lock")) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -