📄 posttag.java
字号:
package com.laoer.bbscs.web.tag;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import com.laoer.bbscs.web.servlet.*;
import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.sys.*;
//import org.springframework.web.context.WebApplicationContext;
//import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* <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 PostTag
extends TagSupport {
private String scope = null;
private String type = null;
private String userCheck = null;
private long bid = 0;
private String form = null;
private String property = null;
public PostTag() {
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUserCheck() {
return userCheck;
}
public void setUserCheck(String userCheck) {
this.userCheck = userCheck;
}
public long getBid() {
return bid;
}
public void setBid(long bid) {
this.bid = bid;
}
public int doStartTag() throws JspException {
return (SKIP_BODY);
}
public int doEndTag() throws JspException {
UserCheck uc = (UserCheck) RequestUtils.lookup(pageContext, userCheck,
scope);
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
/*
WebApplicationContext wac = WebApplicationContextUtils.
getRequiredWebApplicationContext(pageContext.getServletContext());*/
if (uc == null) {
HttpServletResponse response = (HttpServletResponse) pageContext.
getResponse();
//uc = new UserCheck(request, response, wac, bid);
if (form == null || property == null) {
uc = new UserCheck(request, response, bid);
//uc = new UserCheck(request, response, wac, bid);
}
else {
Object value = RequestUtils.lookup(pageContext, form, property, scope);
uc = new UserCheck(request, response, ( (Long) value).longValue());
//uc = new UserCheck(request, response, wac, ( (Long) value).longValue());
}
}
if (type.equals("votenotice")) {
StringBuffer sb = new StringBuffer();
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.youatboardsvote",
uc.getBs().getBoardsName(),
uc.getBs().getBoardsEName()));
ResponseUtils.write(pageContext, sb.toString());
return (SKIP_BODY);
}
if (type.equals("notice")) {
PostForm form = (PostForm) RequestUtils.lookup(pageContext, "postForm",
scope);
StringBuffer sb = new StringBuffer();
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.youatboards",
uc.getBs().getBoardsName(),
uc.getBs().getBoardsEName()));
sb.append(" ");
//System.out.println(uc.getBs().getAttrib2());
if (SysInfo.getInstance().getPosthtml() == 1 &&
SysInfo.getInstance().getHtmledit() == 1 &&
uc.getBs().getAttrib2() == 1) {
//System.out.println(form.getAction());
if (form.getAction().equals("add")) {
if (form.getUseedit().equals("no")) {
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.cannotpost",
"post" + Constant.FILEPREFIX +
"?bid=" + uc.getBid() +
"&action=new&useedit=yes"));
}
else {
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.cannotpost1",
"post" + Constant.FILEPREFIX +
"?bid=" + uc.getBid() +
"&action=new&useedit=no"));
}
}
if (form.getAction().equals("addre")) {
if (form.getUseedit().equals("no")) {
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.cannotpost",
"post" + Constant.FILEPREFIX +
"?bid=" + uc.getBid() +
"&action=re&useedit=yes&id=" +
form.getId() + "&mainid=" +
form.getMainid() + "&page=" +
form.getPage() + "&totalnum=" +
form.getTotalnum() +
"&title=" +
SysUtil.encodeURL(form.
getTitle(), Constant.CHARSET)));
}
else {
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.cannotpost1",
"post" + Constant.FILEPREFIX +
"?bid=" + uc.getBid() +
"&action=re&useedit=no&id=" +
form.getId() + "&mainid=" +
form.getMainid() + "&page=" +
form.getPage() + "&totalnum=" +
form.getTotalnum() +
"&title=" +
SysUtil.encodeURL(form.
getTitle(), Constant.CHARSET)));
}
}
}
ResponseUtils.write(pageContext, sb.toString());
return (SKIP_BODY);
}
if (type.equals("upfile")) {
StringBuffer sb = new StringBuffer();
if (SysInfo.getInstance().getUpfile() == 1 &&
uc.getBs().getAttrib9() == 1) {
sb.append("<input type=\"file\" name=\"upfile\" class=\"INPUT1\"><br>");
sb.append(Constant.MESSAGE.getMessage(request.getLocale(),
"post.upnotice",
String.valueOf(SysInfo.
getInstance().getUpfilesize()), SysInfo.getInstance().getUpfilename()));
}
ResponseUtils.write(pageContext, sb.toString());
return (SKIP_BODY);
}
return (SKIP_BODY);
}
public String getForm() {
return form;
}
public void setForm(String form) {
this.form = form;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -