📄 _threadcontent__jsp.java
字号:
/*
* JSP generated by Resin 2.1.2 (built Tue Jun 11 08:26:56 PDT 2002)
*/
package _forum._admin;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import java.util.*;
import java.text.SimpleDateFormat;
import com.coolservlets.forum.*;
import com.coolservlets.forum.util.*;
import com.coolservlets.forum.util.admin.*;
public class _threadcontent__jsp extends com.caucho.jsp.JavaPage{
private boolean _caucho_isDead;
/**
* Print a child message
*/
private String printChildMessage( Forum forum, ForumThread thread, ForumMessage message, int indentation )
{
StringBuffer buf = new StringBuffer();
try {
if( message.getID() == thread.getRootMessage().getID() ) {
return "";
}
String subject = message.getSubject();
boolean msgIsAnonymous = message.isAnonymous();
User author = message.getUser();
String authorName = author.getName();
String authorEmail = author.getEmail();
int forumID = forum.getID();
int threadID = thread.getID();
int messageID = message.getID();
Date creationDate = message.getCreationDate();
String msgBody = message.getBody();
buf.append("<tr>");
buf.append("<form>");
buf.append("<td width=\"1%\" class=\"forumListCell\" align=\"center\">");
buf.append("<input type=\"radio\"");
buf.append("onclick=\"if(confirm('Are you sure you want to delete this message and its replies?')){");
buf.append("location.href='threadContent.jsp?message=").append(messageID).append("&doDeleteMessage=true");
buf.append("&forum=").append(forumID).append("&thread=").append(threadID).append("';}\">");
buf.append("</td>");
buf.append("<td class=\"forumListCell\" width=\"").append(99-indentation).append("%\">");
buf.append("<table cellpadding=2 cellspacing=0 border=0 width=\"100%\">");
buf.append("<tr bgcolor=\"#dddddd\">");
int i = indentation;
while(i-- >= 0 ) {
buf.append("<td bgcolor=\"#ffffff\"> </td>");
}
buf.append("<td><b>").append( message.getSubject() ).append("</b></td>");
buf.append("</tr>");
buf.append("<tr bgcolor=\"#eeeeee\">");
String rootMsgUsername = "<i>匿名</i>";
User rootMsgUser = message.getUser();
if( !message.getUser().isAnonymous() ) {
rootMsgUsername = rootMsgUser.getUsername();
}
i = indentation;
while(i-- >= 0 ) {
buf.append("<td bgcolor=\"#ffffff\"> </td>");
}
buf.append("<td><font size=\"-2\"><b>发送自 ").append( rootMsgUsername ).append(", on some date ").append( message.getCreationDate() ).append("</b></font></td>");
buf.append("</tr>");
buf.append("<tr>");
i = indentation;
while(i-- >= 0 ) {
buf.append("<td> </td>");
}
buf.append("<td>").append( message.getBody() ).append("</td>");
buf.append("</tr>");
buf.append("</table></td></form></tr>");
} catch( Exception ignored ) {}
return buf.toString();
}
/**
* Recursive method to print all the children of a message.
*/
private String printChildren( TreeWalker walker, Forum forum, ForumThread thread, ForumMessage message, int indentation )
{
StringBuffer buf = new StringBuffer();
buf.append( printChildMessage( forum, thread, message, indentation ) );
// recursive call
int numChildren = walker.getChildCount(message);
if( numChildren > 0 ) {
for( int i=0; i<numChildren; i++ ) {
buf.append(
printChildren( walker, forum, thread, walker.getChild(message,i), (indentation+1) )
);
}
}
return buf.toString();
}
//////////////////////////
// global vars
// date formatter for message dates
private final SimpleDateFormat dateFormatter
= new SimpleDateFormat( "EEE, MMM d 'at' hh:mm:ss z" );
private final static int RANGE = 15;
private final static int START = 0;
public void
_jspService(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException
{
com.caucho.jsp.QPageContext pageContext = (com.caucho.jsp.QPageContext) com.caucho.jsp.QJspFactory.create().getPageContext(this, request, response, "/forum/admin/error.jsp", true, 8192, true);
javax.servlet.jsp.JspWriter out = (javax.servlet.jsp.JspWriter) pageContext.getOut();
javax.servlet.ServletConfig config = getServletConfig();
javax.servlet.Servlet page = this;
javax.servlet.http.HttpSession session = pageContext.getSession();
javax.servlet.ServletContext application = pageContext.getServletContext();
response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("GB2312");
try {
pageContext.write(_jsp_string0, 0, _jsp_string0.length);
/**
* $RCSfile: threadContent.jsp,v $
* $Revision: 1.3 $
* $Date: 2000/12/18 02:06:21 $
*/
pageContext.write(_jsp_string0, 0, _jsp_string0.length);
pageContext.write(_jsp_string0, 0, _jsp_string0.length);
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
com.coolservlets.forum.util.admin.AdminBean adminBean;
synchronized (session) {
adminBean = (com.coolservlets.forum.util.admin.AdminBean) session.getValue("adminBean");
if (adminBean == null) {
adminBean = new com.coolservlets.forum.util.admin.AdminBean();
session.putValue("adminBean", adminBean);
}
}
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
pageContext.write(_jsp_string2, 0, _jsp_string2.length);
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
////////////////////////////////
// Jive authorization check
// check the bean for the existence of an authorization token.
// Its existence proves the user is valid. If it's not found, redirect
// to the login page
Authorization authToken = adminBean.getAuthToken();
if( authToken == null ) {
response.sendRedirect( "login.jsp" );
return;
}
pageContext.write(_jsp_string3, 0, _jsp_string3.length);
////////////////////
// Security check
// make sure the user is authorized to administer users:
ForumFactory forumFactory = ForumFactory.getInstance(authToken);
ForumPermissions permissions = forumFactory.getPermissions(authToken);
boolean isSystemAdmin = permissions.get(ForumPermissions.SYSTEM_ADMIN);
boolean isUserAdmin = permissions.get(ForumPermissions.FORUM_ADMIN);
// redirect to error page if we're not a forum admin or a system admin
if( !isUserAdmin && !isSystemAdmin ) {
request.setAttribute("message","No permission to administer forums");
response.sendRedirect("error.jsp");
return;
}
pageContext.write(_jsp_string3, 0, _jsp_string3.length);
////////////////////
// get parameters
int forumID = ParamUtils.getIntParameter(request,"forum",-1);
boolean doDeleteThread = ParamUtils.getBooleanParameter(request,"doDeleteThread");
boolean doDeleteMessage = ParamUtils.getBooleanParameter(request,"doDeleteMessage");
int threadID = ParamUtils.getIntParameter(request,"thread",-1);
int messageID = ParamUtils.getIntParameter(request,"message",-1);
int start = ParamUtils.getIntParameter(request,"start",START);
int range = ParamUtils.getIntParameter(request,"range",RANGE);
pageContext.write(_jsp_string3, 0, _jsp_string3.length);
//////////////////////////////////
// global error variables
String errorMessage = "";
boolean noForumSpecified = (forumID < 0);
boolean noThreadSpecified = (threadID < 0);
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
////////////////////
// make a profile manager
ProfileManager manager = forumFactory.getProfileManager();
pageContext.write(_jsp_string1, 0, _jsp_string1.length);
//////////////////////////
// delete an entire thread
if( doDeleteThread ) {
Forum tempForum = forumFactory.getForum(forumID);
ForumThread tempThread = tempForum.getThread(threadID);
tempForum.deleteThread(tempThread);
response.sendRedirect("forumContent.jsp?forum=" + forumID);
return;
}
else if( doDeleteMessage ) {
Forum tempForum = forumFactory.getForum(forumID);
ForumThread tempThread = tempForum.getThread(threadID);
ForumMessage tempMessage = tempThread.getMessage(messageID);
tempThread.deleteMessage(tempMessage);
response.sendRedirect("threadContent.jsp?forum=" + forumID + "&thread=" + threadID);
return;
}
pageContext.write(_jsp_string4, 0, _jsp_string4.length);
///////////////////////
// pageTitleInfo variable (used by include/pageTitle.jsp)
String[] pageTitleInfo = { "论坛 : 管理线索内容" };
pageContext.write(_jsp_string0, 0, _jsp_string0.length);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -