?? contentfilter-props-edit-form.jsp
字號:
<%@ page import="java.util.*, org.jivesoftware.wildfire.XMPPServer, org.jivesoftware.wildfire.user.*, org.jivesoftware.wildfire.plugin.ContentFilterPlugin, org.jivesoftware.util.*"%><%@ page import="java.util.regex.Pattern"%><%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %><%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %><% boolean save = request.getParameter("save") != null; boolean reset = request.getParameter("reset") !=null; boolean success = request.getParameter("success") != null; //filter options boolean patternsEnabled = ParamUtils.getBooleanParameter(request, "patternsenabled"); String patterns = ParamUtils.getParameter(request, "patterns"); String [] filterStatusChecked = ParamUtils.getParameters(request, "filterstatus"); boolean filterStatusEnabled = filterStatusChecked.length > 0; //match options boolean allowOnMatch = ParamUtils.getBooleanParameter(request, "allowonmatch"); String [] maskChecked = ParamUtils.getParameters(request, "maskenabled"); boolean maskEnabled = maskChecked.length > 0; String mask = ParamUtils.getParameter(request, "mask"); //rejection options boolean rejectionNotificationEnabled = ParamUtils.getBooleanParameter(request, "rejectionnotificationenabled"); String rejectionMsg = ParamUtils.getParameter(request, "rejectionMsg"); //notification options boolean notificationEnabled = ParamUtils.getBooleanParameter(request, "notificationenabled"); String contactName = ParamUtils.getParameter(request, "contactname"); List<String> notificationOptions = Arrays.asList(ParamUtils.getParameters(request, "notificationcb")); boolean notificationByIMEnabled = notificationOptions.contains("notificationbyim"); boolean notificationByEmailEnabled = notificationOptions.contains("notificationbyemail"); boolean includeOriginalEnabled = notificationOptions.contains("notificationincludeoriginal"); //get handle to plugin ContentFilterPlugin plugin = (ContentFilterPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("contentfilter"); //input validation Map<String, String> errors = new HashMap<String, String>(); if (save) { if (patterns == null) { errors.put("missingPatterns", "missingPatterns"); } else { String[] data = patterns.split(","); try { for (String aData : data) { Pattern.compile(aData); } } catch (java.util.regex.PatternSyntaxException e) { errors.put("patternSyntaxException", e.getMessage()); } } if (mask == null) { errors.put("missingMask", "missingMask"); } if (rejectionMsg == null) { errors.put("missingRejectionMsg", "missingRejectionMsg"); } if (contactName == null) { errors.put("missingContactName", "missingContactName"); } else { contactName = contactName.trim().toLowerCase(); try { User user = UserManager.getInstance().getUser(contactName); if (notificationByEmailEnabled) { //verify that the user has an email address if (user.getEmail() == null) { errors.put("userEmailNotConfigured", "userEmailNotConfigured"); } //verify that the email server is configured if (!JiveGlobals.getBooleanProperty("mail.configured", false)) { errors.put("mailServerNotConfigured", "mailServerNotConfigured"); } } } catch (UserNotFoundException unfe) { errors.put("userNotFound", "userNotFound"); } } if (!notificationByIMEnabled && !notificationByEmailEnabled) { errors.put("notificationFormatNotConfigured", "notificationFormatNotConfigured"); } if (errors.size() == 0) { plugin.setPatternsEnabled(patternsEnabled); plugin.setPatterns(patterns); plugin.setFilterStatusEnabled(filterStatusEnabled); plugin.setAllowOnMatch(allowOnMatch); plugin.setMaskEnabled(maskEnabled); plugin.setMask(mask); plugin.setViolationNotificationEnabled(notificationEnabled); plugin.setViolationContact(contactName); plugin.setViolationNotificationByIMEnabled(notificationByIMEnabled); plugin.setViolationNotificationByEmailEnabled(notificationByEmailEnabled); plugin.setViolationIncludeOriginalPacketEnabled(includeOriginalEnabled); plugin.setRejectionNotificationEnabled(rejectionNotificationEnabled); plugin.setRejectionMessage(rejectionMsg); response.sendRedirect("contentfilter-props-edit-form.jsp?success=true"); return; } } else if (reset) { plugin.reset(); response.sendRedirect("contentfilter-props-edit-form.jsp?success=true"); } else { patterns = plugin.getPatterns(); mask = plugin.getMask(); contactName = plugin.getViolationContact(); rejectionMsg = plugin.getRejectionMessage(); } if (errors.size() == 0) { patterns = plugin.getPatterns(); mask = plugin.getMask(); contactName = plugin.getViolationContact(); rejectionMsg = plugin.getRejectionMessage(); notificationByIMEnabled = plugin.isViolationNotificationByIMEnabled(); notificationByEmailEnabled = plugin.isViolationNotificationByEmailEnabled(); includeOriginalEnabled = plugin.isViolationIncludeOriginalPacketEnabled(); } patternsEnabled = plugin.isPatternsEnabled(); filterStatusEnabled = plugin.isFilterStatusEnabled(); allowOnMatch = plugin.isAllowOnMatch(); maskEnabled = plugin.isMaskEnabled(); notificationEnabled = plugin.isViolationNotificationEnabled(); rejectionNotificationEnabled = plugin.isRejectionNotificationEnabled();%><html> <head> <title>Content Filter</title> <meta name="pageID" content="contentfilter-props-edit-form"/> </head> <body><p>Use the form below to edit content filter settings.<br></p><% if (success) { %> <div class="jive-success"> <table cellpadding="0" cellspacing="0" border="0"> <tbody> <tr> <td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td> <td class="jive-icon-label">Settings updated successfully.</td> </tr> </tbody> </table> </div><br><% } else if (errors.size() > 0) { %> <div class="jive-error"> <table cellpadding="0" cellspacing="0" border="0"> <tbody> <tr> <td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td> <td class="jive-icon-label">Error saving the settings.</td> </tr> </tbody> </table> </div><br><% } %><form action="contentfilter-props-edit-form.jsp" method="post"><fieldset> <legend>Filter</legend> <div> <p> To enable the content filter you need to set up some regular expressions. </p> <table cellpadding="3" cellspacing="0" border="0" width="100%"> <tbody> <tr> <td width="1%"> <input type="radio" name="patternsenabled" value="false" id="not01" <%= ((patternsEnabled) ? "" : "checked") %>> </td> <td width="99%"> <label for="not01"><b>Disabled</b></label> - Packets will not be filtered. </td> </tr> <tr> <td width="1%"> <input type="radio" name="patternsenabled" value="true" id="not02" <%= ((patternsEnabled) ? "checked" : "") %>> </td> <td width="99%"> <label for="not02"><b>Enabled</b></label> - Packets will be filtered. </td> </tr> <tr>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -