⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _forumfilters__jsp.java

📁 JSP聊天系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * JSP generated by Resin 2.1.2 (built Tue Jun 11 08:26:56 PDT 2002)
 */

package _admin._forum;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import java.util.*;
import com.coolservlets.forum.*;
import com.coolservlets.forum.util.*;
import com.coolservlets.forum.util.admin.*;

public class _forumfilters__jsp extends com.caucho.jsp.JavaPage{
  private boolean _caucho_isDead;
  	// Global variables/methods
	private final int ADD_FILTER = 1;
	private final int REMOVE_FILTER = 2;
	private final int EDIT_FILTER = 3;
	private final int SAVE_MODIFIED_FILTER = 4;
	private final int SAVE_PROPERTIES = 5;
	private final String[] classNames = { "com.coolservlets.forum.filter.FilterHtml",
			"com.coolservlets.forum.filter.FilterCodeHighlight",
			"com.coolservlets.forum.filter.FilterFontStyle",
			"com.coolservlets.forum.filter.FilterNewline",
			"com.coolservlets.forum.filter.FilterSmileyFace",
			"com.coolservlets.forum.filter.FilterURLConverter",
			"com.coolservlets.forum.filter.FilterProfanity",
			"com.coolservlets.forum.filter.FilterHackerSpeak"};
   	private boolean containsString( ForumMessageFilter[] installedFilters, String filterName ) {
		for( int i=0; i<installedFilters.length; i++ ) {
			if( installedFilters[i].getName().equals(filterName) ) {
				return true;
			}
		}
		return false;
	}
	private String escapeHTML( String line ) {
		StringBuffer buf = new StringBuffer();
		for( int i=0; i<line.length(); i++ ) {
			char ch = line.charAt(i);
			if( ch == '"' ) {
				buf.append( "&quot;" ); //"
			} else if( ch == '&' ) {
				buf.append( "&amp;" );
			} else {
				buf.append( ch );
			}
		}
		return buf.toString();
	}
	private String unescapeHTML( String line ) {
		//line = replace( line, "&gt;", ">" );
		//line = replace( line, "&lt;", "<" );
		line = replace( line, "&quot;", "\"" ); //"
		line = replace( line, "&amp;", "&" );
		return line;
	}
	private String replace( String line, String oldString, String newString ) {
		int i=0;
		if ( ( i=line.indexOf( oldString, i ) ) >= 0 ) {
			int oLength = oldString.length();
			int nLength = newString.length();
			StringBuffer buf = new StringBuffer();
			buf.append(line.substring(0,i)).append(newString);
			i += oLength;
			int j = i;
			while( ( i=line.indexOf( oldString, i ) ) > 0 ) {
				buf.append(line.substring(j,i)).append(newString);
				i += oLength;
				j = i;
			}
			buf.append(line.substring(j));
			return buf.toString();
		}
		return line;
	}

  
  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, null, 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: forumFilters.jsp,v $
 *	$Revision: 1.4.2.1 $
 *	$Date: 2001/05/10 02:06:19 $
 */

      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);
      	////////////////////////////////
	// 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;
	}
	////////////////////
	// 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","您无权管理论坛");
		response.sendRedirect("error.jsp");
		return;
	}

      pageContext.write(_jsp_string1, 0, _jsp_string1.length);
      pageContext.write(_jsp_string2, 0, _jsp_string2.length);
      	////////////////////
	// get parameters
	
	int forumID   = ParamUtils.getIntParameter(request,"forum",-1);
	int mode      = ParamUtils.getIntParameter(request,"mode",-1);
	int filterID  = ParamUtils.getIntParameter(request,"filter",-1);
	//////////////////////////////////
	// global error variables
	
	String errorMessage = "";
	
	boolean noForumSpecified = (forumID < 0);
	
	boolean filterIDOK = (filterID != -1 );
	boolean doMode = (mode != -1);
    ////////////////////
	// make a profile manager
	ProfileManager manager = forumFactory.getProfileManager();

    // Create the factory and forum objects
	Forum forum = null;
	if (!noForumSpecified)
	{
	    try {
		    forum = forumFactory.getForum(forumID);
	    }
	    catch( UnauthorizedException ue ) { System.err.println( "... in admin/admin-filter.jsp: " + ue ); }
	    catch( ForumNotFoundException fnfe ) { System.err.println( "... in admin/admin-filter.jsp: " + fnfe ); }
	    catch( Exception e ) {
		    System.err.println( "... in admin/admin-filter.jsp: " + e );
		    e.printStackTrace( System.err );
	    }
	}
	boolean forumOK = (forum != null);
	// Get an array of all filters in the system
	ForumMessageFilter[] allFilters = null;
	if (!noForumSpecified)
	{
	    try {
		    allFilters = new ForumMessageFilter[classNames.length];
		    for( int i=0; i<classNames.length; i++ ) {
			    Class c = Class.forName(classNames[i]); // load the name of the filter
			    allFilters[i] = (ForumMessageFilter)(c.newInstance());
		    }
	    }
	    catch( ClassNotFoundException cnfe ) { System.err.println( "... in admin/admin-filter.jsp: " + cnfe ); }
	    catch( IllegalAccessException iae ) { System.err.println( "... in admin/admin-filter.jsp: " + iae ); }
	    catch( InstantiationException ie ) { System.err.println( "... in admin/admin-filter.jsp: " + ie ); }
	}
	    // Get an array of installed filters
	    ForumMessageFilter[] installedFilters = null;
	    String[] installedFilterNames = null;
	    if( forumOK ) {
		    try {
			    installedFilters = forum.getForumMessageFilters();
		    }
		    catch( UnauthorizedException ue ) { 
			    System.err.println( "... in admin/admin-filter.jsp: " + ue );
		    }
		    if( installedFilters != null ) {
			    // build up list of class names of the forums (so we can not display the ones that are
			    // installed in the "add new webfilter box"
			    installedFilterNames = new String[installedFilters.length];
			    for( int i=0; i<installedFilterNames.length; i++ ) {
				    installedFilterNames[i] = installedFilters[i].getClass().getName();
			    }
		    }
	    }
	    // Based on the mode, do an action:
	    if( doMode ) {
		    // Add a filter
		    if( mode == ADD_FILTER ) {		
			    if( filterIDOK ) {	
		            try {
		                Class c = Class.forName(classNames[filterID]); // load the name of the filter
					    ForumMessageFilter newFilter = (ForumMessageFilter)(c.newInstance());
					    forum.addForumMessageFilter( newFilter );
		            }
		            catch( ClassNotFoundException cnfe ) { System.err.println( "... in admin/admin-filter.jsp: " + cnfe ); }
				    catch( IllegalAccessException iae ) { System.err.println( "... in admin/admin-filter.jsp: " + iae ); }
				    catch( InstantiationException ie ) { System.err.println( "... in admin/admin-filter.jsp: " + ie ); }
				    catch( UnauthorizedException ue ) { System.err.println( "... in admin/admin-filter.jsp: " + ue ); }
			    }
			    // redirect to same page 
			    response.sendRedirect( "forumFilters.jsp?forum=" + forumID );
				return;
		    }
		    else if( mode == REMOVE_FILTER ) {
			    if( filterIDOK ) {
				    try {
					    forum.removeForumMessageFilter(filterID);
				    } catch( UnauthorizedException ue ) { System.err.println( "... in admin/admin-filter.jsp: " + ue ); }
			    }
			    // redirect to same page
			    response.sendRedirect( "forumFilters.jsp?forum=" + forumID );
				return;
		    }
		    else if( mode == SAVE_PROPERTIES ) {
			    if( filterIDOK ) {
				    Enumeration props = installedFilters[filterID].filterPropertyNames();
				    while( props.hasMoreElements() ) {
					    String propName = (String)props.nextElement();
					    String propValue = request.getParameter(propName);
					    if( propValue != null ) {
						    try {
							    installedFilters[filterID].setFilterProperty(propName,propValue);
						    } catch( IllegalArgumentException iae ) { System.err.println( "... in admin/admin-filter.jsp: " + iae ); }
					    }
				    }
			    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -