📄 postdo.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.bbscs.sys.mail.*;
import com.laoer.comm.util.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.util.*;
import org.apache.struts.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 PostDo
extends BaseAction {
public PostDo() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
ActionErrors errors = new ActionErrors();
ReadForm form = (ReadForm) 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);
}
//Del a Post
if (form.getAction().equals("dela")) {
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.getCanNotRe() == 0 && forum.getUserID() == uc.getId()))) {
errors.add("error.purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
forum.setDelIP(httpServletRequest.getRemoteAddr());
forum.setDelSign( (short) 1);
forum.setDelTime(SysUtil.getLongTime());
forum.setDelUserID(uc.getId());
forum.setDelUserName(uc.getUsername());
this.getForumService().delaPost(forum, 0);
ActionForward f = new ActionForward("/forum" + Constant.FILEPREFIX +
"?bid=" + form.getBid() +
"&page=" + form.getPage(), true);
return f;
}
if (form.getAction().equals("undel")) {
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()) {
errors.add("error.purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
forum.setDelSign( (short) 0);
/*
if (uc.getBs().getAttrib8() == 1) {
forum.setAuditing( (short) 1);
}*/
this.getForumService().saveForum(forum);
if (forum.getId().longValue() != forum.getId2() &&
forum.getAuditing() == 0) {
forum = getForumService().getForum(forum.getId2(), form.getBid());
if (forum != null) {
forum.setReNum(forum.getReNum() + 1);
this.getForumService().saveForum(forum);
}
}
ActionForward f = new ActionForward("/manage" + Constant.FILEPREFIX +
"?action=w&bid=" +
form.getBid() + "&page=" +
form.getPage(), true);
return f;
}
if (form.getAction().equals("auditing")) {
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()) {
errors.add("error.purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (forum.getIsNew() != 1) {
Forum mainForum = this.getForumService().getForum(forum.getId2(),
forum.getBoardID());
if (mainForum != null) {
mainForum.setLastPostNickName(forum.getNickName());
mainForum.setLastPostTitle(forum.getTitle());
mainForum.setLastPostUserName(forum.getUserName());
mainForum.setLastTime(forum.getPostTime());
mainForum.setReNum(mainForum.getReNum() + 1);
this.getForumService().saveForum(mainForum);
}
}
forum.setAuditing( (short) 0);
this.getForumService().saveForum(forum);
ActionForward f = new ActionForward("/auditingRead" + Constant.FILEPREFIX +
"?bid=" + form.getBid() + "&id=" +
form.getId() + "&page=" +
form.getPage(), true);
return f;
}
//Set Elite
if (form.getAction().equals("setelite")) {
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()) {
errors.add("error.purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
if (forum.getElite() == 0) {
forum.setElite(form.getBid());
forum.setDoEliteName(uc.getUsername());
forum.setDoEliteTime(SysUtil.getLongTime());
if (this.getForumService().saveForum(forum) == null) {
errors.add("error.elite.add", new ActionError("error.elite.add"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
this.getUserCache().removeFromCache(forum.getUserID());
UserInfo ui = this.getUserInfoService().findUserInfoById(new Long(forum.
getUserID()));
if (ui != null) {
ui.setExpression(ui.getExpression() + 5);
this.getUserInfoService().saveUserInfo(ui);
}
}
ActionForward f = new ActionForward("/read" + Constant.FILEPREFIX +
"?bid=" + form.getBid() +
"&id=" + form.getMainid() + "&page=" +
form.getPage() + "&inpages=" +
form.getInpages(), true);
return f;
}
//Del up file
if (form.getAction().equals("delfile")) {
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()) {
errors.add("error.purviewerror", new ActionError("error.purviewerror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
String filePath = SysUtil.getUpFilePath(forum.getBoardID(),
forum.getPostTime()) +
forum.getPicName();
SysUtil.delFile(filePath);
forum.setHavePic( (short) 0);
forum.setPicName("");
if (this.getForumService().saveForum(forum) == null) {
errors.add("error.post.delimg", new ActionError("error.post.delimg"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
ActionForward f = new ActionForward("/read" + Constant.FILEPREFIX +
"?bid=" + form.getBid() +
"&id=" + form.getMainid() + "&page=" +
form.getPage() + "&inpages=" +
form.getInpages(), true);
return f;
}
//Send Mail
if (form.getAction().equals("mailsend")) {
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.isGuest()) {
UserInfo ui = this.getUserCache().getUserInfoFromCache(uc.getId());
if (ui == null) {
errors.add("error.getusererror", new ActionError("error.getusererror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
String content = FileIO.readFile(SysUtil.getForumPath(forum.
getBoardID(), forum.getPostTime()) + forum.getDetail(),
Constant.CHARSET);
SendMail.sendMail(ui.getEmail(), forum.getTitle(), content);
}
ActionForward forward = new ActionForward(SysUtil.getResultUrl(
"succeed.mailsend",
"read" + Constant.FILEPREFIX + "?bid=" + form.getBid() +
"&id=" + form.getMainid() + "&page=" + form.getPage() + "&inpages=" +
form.getInpages()), true);
return forward;
}
if (form.getAction().equals("jubao")) {
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");
}
MessageResources messages = getResources(httpServletRequest);
Locale locale = getLocale(httpServletRequest);
String title = messages.getMessage(locale, "jubao.msg", uc.getUsername(),
forum.getBoardName(), forum.getTitle());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -