########## admin ##########
# language: english
-# $Id: admin_en.properties,v 1.48.2.11 2003/09/16 12:38:43 zapata Exp $
+# $Id: admin_en.properties,v 1.48.2.12 2003/09/19 02:54:48 zapata Exp $
languagename=English
abuse.log.browser=Browser
abuse.filters = Filters
+abuse.filters.movedown = move down
+abuse.filters.moveup = move up
+
abuse.filter.type = Type
abuse.filter.expression = Expression
abuse.filter.articleaction = Article
log4j.logger.Localizer= INFO, LocalizerA
log4j.logger.Generator= INFO, GeneratorA
log4j.logger.PDFGenerator= INFO, PDFGeneratorA
+log4j.logger.AdminUsage= INFO, AdminUsageA
+log4j.additivity.AdminUsage=false
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.PDFGeneratorA.File=${log.home}/pdf.log
log4j.appender.PDFGeneratorA.layout=org.apache.log4j.PatternLayout
log4j.appender.PDFGeneratorA.layout.ConversionPattern=%d [%p] %c %x %m%n
+
+# remove these lines to have an admin activity logger:
+#
+#log4j.appender.AdminUsageA=org.apache.log4j.RollingFileAppender
+#log4j.appender.AdminUsageA.File=${log.home}/adminusage.log
+#log4j.appender.AdminUsageA.layout=org.apache.log4j.PatternLayout
+#log4j.appender.AdminUsageA.layout.ConversionPattern=%d %m%n
+
import mir.util.HTTPRequestParser;\r
import mir.util.URLBuilder;\r
import mircoders.servlet.ServletHelper;\r
+import mircoders.global.*;\r
\r
/**\r
*\r
}\r
\r
\r
+ public void logAdminUsage(HttpServletRequest aRequest, String anObject, String aDescription) {\r
+ MirGlobal.logAdminUsage(ServletHelper.getUser(aRequest), getOperationModuleName() + ":" + anObject, aDescription);\r
+ }\r
+\r
/**\r
* Singleton instance retrievel method. MUST be overridden in subclasses.\r
*\r
Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());\r
mainModule.set(withValues);\r
\r
+ logAdminUsage(aRequest, id, "object modified");\r
+\r
String returnUrl = requestParser.getParameter("returnurl");\r
\r
if (returnUrl!=null) {\r
\r
String id = processInstertedObject(object, aRequest, aResponse);\r
\r
+ logAdminUsage(aRequest, id, "object inserted");\r
+\r
String returnUrl = requestParser.getParameter("returnurl");\r
\r
if (returnUrl!=null) {\r
\r
if (confirmParam != null && !confirmParam.equals("")) {\r
mainModule.deleteById(idParam);\r
+ logAdminUsage(aRequest, idParam, "object deleted");\r
redirect(aResponse, aRequest.getParameter("okurl"));\r
}\r
else\r
\r
return result.toString();\r
}\r
+ /**\r
+ *\r
+ * @param aText\r
+ * @param anEscapeCharacater\r
+ * @param aCharactersToReplace\r
+ * @param aStringsToSubstitute\r
+ * @return\r
+ */\r
+\r
+ public static String replaceEscapedStringCharacters(String aText, char anEscapeCharacter, char[] aCharactersToReplace, String[] aStringsToSubstitute) {\r
+ if (aText==null)\r
+ return null;\r
+\r
+ int position, nextPosition;\r
+ int i;\r
+ StringBuffer result = new StringBuffer();\r
+\r
+ position=0;\r
+ do {\r
+ nextPosition = aText.indexOf(anEscapeCharacter, position);\r
+\r
+ if (nextPosition<0)\r
+ nextPosition = aText.length();\r
\r
+ result.append(aText.substring(position, nextPosition));\r
+\r
+ if (nextPosition+1<aText.length()) {\r
+ nextPosition = nextPosition+1;\r
+\r
+ boolean found = false;\r
+ for (i = 0; i < aCharactersToReplace.length; i++) {\r
+ if (aCharactersToReplace[i] == aText.charAt(nextPosition)) {\r
+ result.append(aStringsToSubstitute[i]);\r
+ found=true;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (!found) {\r
+ result.append(aText.charAt(nextPosition));\r
+ }\r
+ }\r
+ position=nextPosition+1;\r
+ }\r
+ while (nextPosition<aText.length()) ;\r
+\r
+ return result.toString();\r
+ }\r
\r
public static String interpretAsString(Object aValue) throws Exception {\r
if (aValue instanceof String)\r
currentItem.delete(0, currentItem.length());\r
}\r
else {\r
+ currentItem.append(aString.charAt(position));\r
if (aString.length()>position+1) {\r
position=position+1;\r
currentItem.append(aString.charAt(position));\r
private List filterTypeIds;\r
private int maxIdentifier;\r
private LoggerWrapper logger;\r
- private LoggerWrapper adminUsageLogger;\r
private int logSize;\r
private boolean logEnabled;\r
private boolean openPostingDisabled;\r
\r
private MirPropertiesConfiguration configuration;\r
\r
- private static String cookieName=MirGlobal.config().getString("Abuse.CookieName");\r
- private static int cookieMaxAge = 60*60*MirGlobal.config().getInt("Abuse.CookieMaxAge");\r
+ private static String cookieName = MirGlobal.config().getString("Abuse.CookieName");\r
+ private static int cookieMaxAge = 60 * 60 * MirGlobal.config().getInt("Abuse.CookieMaxAge");\r
\r
public Abuse() {\r
logger = new LoggerWrapper("Global.Abuse");\r
- adminUsageLogger = new LoggerWrapper("AdminUsage");\r
filterRules = new Vector();\r
maxIdentifier = 0;\r
log = new Vector();\r
cookie.setMaxAge(cookieMaxAge);\r
cookie.setPath("/");\r
\r
- if (aResponse!=null)\r
+ if (aResponse != null)\r
aResponse.addCookie(cookie);\r
}\r
\r
\r
FilterRule filterRule = findMatchingFilter(aComment, aRequest);\r
\r
- if (filterRule!=null) {\r
- logger.debug("Match for " + filterRule.getType()+" rule '"+ filterRule.getExpression()+"'");\r
+ if (filterRule != null) {\r
+ logger.debug("Match for " + filterRule.getType() + " rule '" + filterRule.getExpression() + "'");\r
filterRule.setLastHit(new GregorianCalendar().getTime());\r
MirGlobal.performCommentOperation(null, aComment, filterRule.getCommentAction());\r
setCookie(aResponse);\r
save();\r
}\r
\r
- logger.info("checkComment: " + (System.currentTimeMillis()-time) + "ms");\r
+ logger.info("checkComment: " + (System.currentTimeMillis() - time) + "ms");\r
}\r
catch (Throwable t) {\r
t.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
\r
FilterRule filterRule = findMatchingFilter(anArticle, aRequest);\r
\r
- if (filterRule!=null) {\r
- logger.debug("Match for " + filterRule.getType() + " rule '" + filterRule.getExpression()+"'");\r
+ if (filterRule != null) {\r
+ logger.debug("Match for " + filterRule.getType() + " rule '" + filterRule.getExpression() + "'");\r
filterRule.setLastHit(new GregorianCalendar().getTime());\r
MirGlobal.performArticleOperation(null, anArticle, filterRule.getArticleAction());\r
setCookie(aResponse);\r
save();\r
}\r
\r
- logger.info("checkArticle: " + (System.currentTimeMillis()-time) + "ms");\r
+ logger.info("checkArticle: " + (System.currentTimeMillis() - time) + "ms");\r
}\r
catch (Throwable t) {\r
t.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
}\r
\r
public List getLog() {\r
- synchronized(log) {\r
+ synchronized (log) {\r
try {\r
List result = new Vector();\r
\r
public List getFilters() {\r
List result = new Vector();\r
\r
- synchronized(filterRules) {\r
+ synchronized (filterRules) {\r
Iterator i = filterRules.iterator();\r
while (i.hasNext()) {\r
FilterRule filter = (FilterRule) i.next();\r
public FilterRule getFilter(String anId) {\r
synchronized (filterRules) {\r
FilterRule result = (FilterRule) findFilter(filterRules, anId);\r
- if (result==null)\r
+ if (result == null)\r
return result;\r
else\r
return (FilterRule) result.clone();\r
deleteFilter(filterRules, anIdentifier);\r
}\r
\r
+ public void moveFilterUp(String anIdentifier) {\r
+ moveFilter(filterRules, anIdentifier, -1);\r
+ }\r
+\r
+ public void moveFilterDown(String anIdentifier) {\r
+ moveFilter(filterRules, anIdentifier, 1);\r
+ }\r
+\r
private String addFilter(List aFilters, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction, Date aLastHit) {\r
MirAntiAbuseFilterType type = (MirAntiAbuseFilterType) filterTypes.get(aType);\r
\r
- if (type==null)\r
+ if (type == null)\r
return "invalidtype";\r
\r
if (!type.validate(anExpression)) {\r
private String setFilter(List aFilters, String anIdentifier, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction) {\r
MirAntiAbuseFilterType type = (MirAntiAbuseFilterType) filterTypes.get(aType);\r
\r
- if (type==null)\r
+ if (type == null)\r
return "invalidtype";\r
\r
if (!type.validate(anExpression)) {\r
synchronized (aFilters) {\r
FilterRule filter = findFilter(aFilters, anIdentifier);\r
\r
- if (filter!=null) {\r
+ if (filter != null) {\r
filter.setExpression(anExpression);\r
filter.setType(aType);\r
filter.setCommentAction(aCommentAction);\r
return null;\r
}\r
\r
+ private void moveFilter(List aFilters, String anIdentifier, int aDirection) {\r
+ synchronized (aFilters) {\r
+ for (int i = 0; i < aFilters.size(); i++) {\r
+ FilterRule rule = (FilterRule) aFilters.get(i);\r
+\r
+ if (rule.getId().equals(anIdentifier) && (i + aDirection >= 0) && (i + aDirection < aFilters.size())) {\r
+ aFilters.remove(rule);\r
+ aFilters.add(i + aDirection, rule);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
private void deleteFilter(List aFilters, String anIdentifier) {\r
synchronized (aFilters) {\r
FilterRule filter = findFilter(aFilters, anIdentifier);\r
\r
- if (filter!=null) {\r
+ if (filter != null) {\r
aFilters.remove(filter);\r
}\r
}\r
}\r
\r
private String generateId() {\r
- synchronized(this) {\r
- maxIdentifier = maxIdentifier+1;\r
+ synchronized (this) {\r
+ maxIdentifier = maxIdentifier + 1;\r
\r
return Integer.toString(maxIdentifier);\r
}\r
return filterType.test(expression, anEntity, aRequest);\r
}\r
catch (Throwable t) {\r
- logger.error("error while testing "+type+"-filter '"+expression+"'");\r
+ logger.error("error while testing " + type + "-filter '" + expression + "'");\r
}\r
\r
return false;\r
}\r
}\r
\r
+ private String escapeFilterPart(String aFilterPart) {\r
+ return StringRoutines.replaceStringCharacters(aFilterPart,\r
+ new char[] {'\\', ':', '\n', '\r', '\t', ' '}\r
+ ,\r
+ new String[] {"\\\\", "\\:", "\\n", "\\r", "\\t", "\\ "});\r
+ }\r
+\r
+ private String deescapeFilterPart(String aFilterPart) {\r
+ return StringRoutines.replaceEscapedStringCharacters(aFilterPart,\r
+ '\\',\r
+ new char[] {'\\', ':', 'n', 'r', 't', ' '}\r
+ ,\r
+ new String[] {"\\", ":", "\n", "\r", "\t", " "});\r
+ }\r
+\r
private void setFilterConfig(List aFilters, String aConfigKey, ExtendedProperties aConfiguration) {\r
- synchronized(aFilters) {\r
+ synchronized (aFilters) {\r
Iterator i = aFilters.iterator();\r
\r
while (i.hasNext()) {\r
FilterRule filter = (FilterRule) i.next();\r
\r
String filterconfig =\r
- StringRoutines.replaceStringCharacters(filter.getType(), new char[] { '\\', ':'}, new String[] { "\\\\", "\\:"} ) + ":" +\r
- StringRoutines.replaceStringCharacters(filter.getExpression(), new char[] { '\\', ':'}, new String[] { "\\\\", "\\:"} ) + ":" +\r
- StringRoutines.replaceStringCharacters(filter.getArticleAction(), new char[] { '\\', ':'}, new String[] { "\\\\", "\\:"} ) + ":" +\r
- StringRoutines.replaceStringCharacters(filter.getCommentAction(), new char[] { '\\', ':'}, new String[] { "\\\\", "\\:"} ) + ":" +\r
- StringRoutines.replaceStringCharacters(filter.getComments(), new char[] { '\\', ':'}, new String[] { "\\\\", "\\:"}) + ":";\r
+ escapeFilterPart(filter.getType()) + ":" +\r
+ escapeFilterPart(filter.getExpression()) + ":" +\r
+ escapeFilterPart(filter.getArticleAction()) + ":" +\r
+ escapeFilterPart(filter.getCommentAction()) + ":" +\r
+ escapeFilterPart(filter.getComments()) + ":";\r
\r
- if (filter.getLastHit()!=null)\r
+ if (filter.getLastHit() != null)\r
filterconfig = filterconfig + filter.getLastHit().getTime();\r
\r
aConfiguration.addProperty(aConfigKey, filterconfig);\r
}\r
\r
private void getFilterConfig(List aFilters, String aConfigKey, ExtendedProperties aConfiguration) {\r
- synchronized(aFilters) {\r
+ synchronized (aFilters) {\r
aFilters.clear();\r
\r
- if (aConfiguration.getStringArray(aConfigKey)!=null) {\r
+ if (aConfiguration.getStringArray(aConfigKey) != null) {\r
\r
Iterator i = Arrays.asList(aConfiguration.getStringArray(aConfigKey)).\r
iterator();\r
if (parts.size() >= 5) {\r
Date lastHit = null;\r
\r
- if (parts.size()>=6) {\r
+ if (parts.size() >= 6) {\r
String lastHitString = (String) parts.get(5);\r
\r
try {\r
}\r
}\r
\r
- addFilter( (String) parts.get(0), (String) parts.get(1), (String) parts.get(4), (String) parts.get(3), (String) parts.get(2), lastHit);\r
+ addFilter(deescapeFilterPart( (String) parts.get(0)),\r
+ deescapeFilterPart( (String) parts.get(1)),\r
+ deescapeFilterPart( (String) parts.get(4)),\r
+ deescapeFilterPart( (String) parts.get(3)),\r
+ deescapeFilterPart( (String) parts.get(2)), lastHit);\r
}\r
}\r
}\r
browserString = aBrowserString;\r
id = anId;\r
isArticle = anIsArticle;\r
- timeStamp=aTimeStamp;\r
+ timeStamp = aTimeStamp;\r
}\r
\r
public String getIpNumber() {\r
}\r
\r
private void truncateLog() {\r
- synchronized(log) {\r
+ synchronized (log) {\r
if (!logEnabled)\r
log.clear();\r
else {\r
- while (log.size()>0 && log.size()>logSize) {\r
+ while (log.size() > 0 && log.size() > logSize) {\r
log.remove(0);\r
}\r
}\r
}\r
}\r
}\r
-\r
- public void logAdminUsage(EntityUsers aUser, String aDescription) {\r
- try {\r
- String user = "unknown (" + aUser.toString() +")";\r
- if (user!=null)\r
- user = aUser.getValue("login");\r
- adminUsageLogger.info(user + ": " + aDescription);\r
- }\r
- catch (Throwable t) {\r
- logger.error("Error while logging admin usage ("+aUser.toString()+", "+aDescription+"): " +t.toString());\r
- }\r
- }\r
-}
\ No newline at end of file
+}\r
\r
package mircoders.global;\r
\r
-import java.util.*;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
\r
import mir.config.MirPropertiesConfiguration;\r
import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+import mir.log.LoggerWrapper;\r
import mir.misc.ConfigException;\r
+import mircoders.accesscontrol.AccessControl;\r
+import mircoders.entity.EntityComment;\r
+import mircoders.entity.EntityContent;\r
+import mircoders.entity.EntityUsers;\r
+import mircoders.localizer.MirAdminInterfaceLocalizer;\r
import mircoders.localizer.MirCachingLocalizerDecorator;\r
-import mircoders.localizer.*;\r
-import mircoders.accesscontrol.*;\r
-import mircoders.entity.*;\r
-import mir.entity.adapter.*;\r
+import mircoders.localizer.MirLocalizer;\r
\r
public class MirGlobal {\r
static private MirPropertiesConfiguration configuration;\r
static private Map articleOperations;\r
static private Map commentOperations;\r
static private Map loggedInUsers = new HashMap();\r
+ static private LoggerWrapper logger = new LoggerWrapper("Global");\r
+ static private LoggerWrapper adminUsageLogger = new LoggerWrapper("AdminUsage");\r
\r
public synchronized static MirLocalizer localizer() {\r
String localizerClassName;\r
}\r
}\r
}\r
+\r
+ public static void logAdminUsage(EntityUsers aUser, String anObject, String aDescription) {\r
+ try {\r
+ String user = "unknown (" + aUser.toString() +")";\r
+ if (aUser!=null)\r
+ user = aUser.getValue("login");\r
+ adminUsageLogger.info(user + " | " + anObject + " | " + aDescription);\r
+ }\r
+ catch (Throwable t) {\r
+ logger.error("Error while logging admin usage ("+aUser.toString()+", "+aDescription+"): " +t.toString());\r
+ }\r
+ }\r
}\r
\r
\r
\r
if (id.equals("")) {\r
errorMessage = MirGlobal.abuse().addFilter(type, expression,comments, commentaction, articleaction);\r
+ logAdminUsage(aRequest, "?", "object added");\r
}\r
else {\r
errorMessage = MirGlobal.abuse().setFilter(id, type, expression, comments, commentaction, articleaction);\r
+ logAdminUsage(aRequest, id, "object modified");\r
}\r
\r
if (errorMessage!=null) {\r
\r
String id=requestParser.getParameterWithDefault("id", "");\r
MirGlobal.abuse().deleteFilter(id);\r
+ logAdminUsage(aRequest, id, "object deleted");\r
+\r
+ MirGlobal.abuse().save();\r
+\r
+ showfilters(aRequest, aResponse);\r
+ }\r
+\r
+ public void moveup(HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+ String id=requestParser.getParameterWithDefault("id", "");\r
+ MirGlobal.abuse().moveFilterUp(id);\r
+\r
+ MirGlobal.abuse().save();\r
+ logAdminUsage(aRequest, id, "object moved upwards");\r
+\r
+ showfilters(aRequest, aResponse);\r
+ }\r
+\r
+ public void movedown(HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
+ HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
+\r
+ String id=requestParser.getParameterWithDefault("id", "");\r
+ MirGlobal.abuse().moveFilterDown(id);\r
+ logAdminUsage(aRequest, id, "object moved downwards");\r
\r
MirGlobal.abuse().save();\r
\r
public void add(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
editfilter(aRequest, aResponse, "", "", "", "", "", "", "");\r
}\r
+\r
public void showfilters(HttpServletRequest aRequest, HttpServletResponse aResponse) {\r
URLBuilder urlBuilder = new URLBuilder();\r
\r
MirGlobal.abuse().setCommentBlockAction(parser.getParameter("commentaction"));\r
\r
MirGlobal.abuse().save();\r
+ logAdminUsage(aRequest, "settings", "object modified");\r
\r
showsettings(aRequest, aResponse);\r
}\r
throw new ServletModuleFailure(e);\r
}\r
\r
+ logAdminUsage(aRequest, commentId, "media " + mediaIdParam + " attached");\r
+\r
editObject(aRequest, aResponse, commentId);\r
}\r
\r
throw new ServletModuleFailure(e);\r
}\r
\r
+ logAdminUsage(aRequest, commentId, "media " + midParam + " deattached");\r
+\r
editObject(aRequest, aResponse, commentId);\r
}\r
\r
\r
String id = mainModule.set(withValues);\r
\r
+ logAdminUsage(aRequest, id, "object modified");\r
+\r
if (returnUrl!=null){\r
redirect(aResponse, returnUrl);\r
}\r
* ServletModuleContent -\r
* deliver html for the article admin form.\r
*\r
- * @version $Id: ServletModuleContent.java,v 1.52.2.7 2003/09/06 01:01:15 zapata Exp $\r
+ * @version $Id: ServletModuleContent.java,v 1.52.2.8 2003/09/19 02:54:51 zapata Exp $\r
* @author rk, mir-coders\r
*\r
*/\r
withValues.remove("webdb_create");\r
\r
String id = mainModule.add(withValues);\r
+ logAdminUsage(aRequest, id, "object added");\r
+\r
List topics;\r
\r
DatabaseContentToTopics.getInstance().setTopics(id, aRequest.getParameterValues("to_topic"));\r
throw new ServletModuleFailure(e);\r
}\r
\r
+ logAdminUsage(aRequest, articleId, "media " + mediaIdParam + " attached");\r
+\r
editObject(aRequest, aResponse, articleId);\r
}\r
\r
throw new ServletModuleFailure(e);\r
}\r
\r
+ logAdminUsage(aRequest, articleId, "media " + midParam + " deattached");\r
+\r
editObject(aRequest, aResponse, articleId);\r
}\r
\r
withValues.remove("webdb_create");\r
\r
String id = mainModule.set(withValues);\r
+\r
+ logAdminUsage(aRequest, id, "object modified");\r
+\r
DatabaseContentToTopics.getInstance().setTopics(aRequest.getParameter("id"), aRequest.getParameterValues("to_topic"));\r
\r
if (returnUrl!=null && !returnUrl.equals("")){\r
article.setValueForProperty("to_content", parentId);\r
article.setProduced(false);\r
article.update();\r
+ logAdminUsage(aRequest, articleId, "parent set to " + parentId);\r
}\r
catch(Throwable e) {\r
logger.error("ServletModuleContent.setparent: " + e.getMessage());\r
article.setValueForProperty("to_content", "");\r
article.setProduced(false);\r
article.update();\r
+ logAdminUsage(aRequest, articleId, "parent cleared");\r
}\r
catch(Throwable e) {\r
e.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE));\r
* in the config file.
*
* @author $Author: zapata $
- * @version $Revision: 1.13.2.2 $ $Date: 2003/09/03 17:49:40 $
+ * @version $Revision: 1.13.2.3 $ $Date: 2003/09/19 02:54:51 $
*
*/
in.close();
out.close();
+ logAdminUsage(aRequest, f.getAbsolutePath(), "object modified");
+
+
editFile(directory, filename, subDirectory, aRequest, aResponse);
}
}
-/*
- * Copyright (C) 2001, 2002 The Mir-coders group
- *
- * This file is part of Mir.
- *
- * Mir is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Mir is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Mir; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
- * and distribute linked combinations including the two. You must obey the
- * GNU General Public License in all respects for all of the code used other than
- * the above mentioned libraries. If you modify this file, you may extend this
- * exception to your version of the file, but you are not obligated to do so.
- * If you do not wish to do so, delete this exception statement from your version.
- */
-package mircoders.servlet;
-
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with any library licensed under the Apache Software License,\r
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library\r
+ * (or with modified versions of the above that use the same license as the above),\r
+ * and distribute linked combinations including the two. You must obey the\r
+ * GNU General Public License in all respects for all of the code used other than\r
+ * the above mentioned libraries. If you modify this file, you may extend this\r
+ * exception to your version of the file, but you are not obligated to do so.\r
+ * If you do not wish to do so, delete this exception statement from your version.\r
+ */\r
+package mircoders.servlet;\r
+\r
import java.util.HashMap;\r
import java.util.List;\r
import java.util.Map;\r
import mircoders.module.ModuleComment;\r
import mircoders.module.ModuleContent;\r
import mircoders.storage.DatabaseComment;\r
-import mircoders.storage.DatabaseContent;
-
-public class ServletModuleLocalizer extends ServletModule {
- private static ServletModuleLocalizer instance = new ServletModuleLocalizer();
- public static ServletModule getInstance() { return instance; }
-
- private ModuleContent contentModule;
- private ModuleComment commentModule;
- private List administerOperations;
-
- private ServletModuleLocalizer() {
- try {
- logger = new LoggerWrapper("ServletModule.Localizer");
-
- contentModule = new ModuleContent(DatabaseContent.getInstance());
- commentModule = new ModuleComment(DatabaseComment.getInstance());
-
- administerOperations = new Vector();
-
- String settings[] = configuration.getStringArray("Mir.Localizer.Admin.AdministerOperations");
-
- if (settings!=null) {
- for (int i = 0; i < settings.length; i++) {
- String setting = settings[i].trim();
-
- if (setting.length() > 0) {
- List parts = StringRoutines.splitString(setting, ":");
- if (parts.size() != 2) {
- logger.error("config error: " + settings[i] + ", 2 parts expected");
- }
- else {
- Map entry = new HashMap();
- entry.put("name", (String) parts.get(0));
- entry.put("url", (String) parts.get(1));
- administerOperations.add(entry);
- }
- }
- }
- }
- }
- catch (Exception e) {
- logger.error("ServletModuleLocalizer could not be initialized: " + e.getMessage());
- }
-
-
- }
-
- public void performCommentOperation(EntityUsers aUser, String anId, String anOperation) {
- MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation;
- EntityAdapter comment;
- EntityComment entity;
-
- try {
- entity = (EntityComment) commentModule.getById(anId);
-
- if (entity != null) {
- MirGlobal.performCommentOperation(aUser, entity, anOperation);
- logger.info("Operation " + anOperation + " successfully performed on comment " + anId);
- }
- else {
- logger.error("Error while performing " + anOperation + " on comment " + anId + ": comment is null");
- }
- }
- catch (Throwable e) {
- logger.error("Error while performing " + anOperation + " on comment " + anId + ": " + e.getMessage());
- }
- }
-
- public void commentoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
- String commentIdString = aRequest.getParameter("id");
- String operationString = aRequest.getParameter("operation");
- String returnUrlString = aRequest.getParameter("returnurl");
-
- performCommentOperation(ServletHelper.getUser(aRequest), commentIdString, operationString);
-
- redirect(aResponse, returnUrlString);
- }
-
- public void commentoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
- String returnUrlString = aRequest.getParameter("returnurl");
-
- String[] operations = aRequest.getParameterValues("operation");
-
- if (operations!=null) {
- for (int i = 0; i < operations.length; i++) {
- if (operations[i].length() > 0) {
- List parts = StringRoutines.splitString(operations[i], ";");
-
- if (parts.size() != 2) {
- logger.error("commentoperationbatch: operation string invalid: " +
- operations[i]);
- }
- else {
- String commentIdString = (String) parts.get(0);
- String operationString = (String) parts.get(1);
-
- performCommentOperation(ServletHelper.getUser(aRequest), commentIdString, operationString);
- }
- }
- }
- }
-
- redirect(aResponse, returnUrlString);
- }
-
- public void performArticleOperation(EntityUsers aUser, String anId, String anOperation) {
- MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation;
- EntityAdapter article;
- EntityContent entity;
-
- try {
- entity = (EntityContent) contentModule.getById(anId);
-
- if (entity != null) {
- MirGlobal.performArticleOperation(aUser, entity, anOperation);
- logger.info("Operation " + anOperation + " successfully performed on article " + anId);
- }
- else {
- logger.error("Error while performing " + anOperation + " on article " + anId + ": article is null");
- }
- }
- catch (Throwable e) {
- logger.error("Error while performing " + anOperation + " on article " + anId + ": " + e.getMessage());
- }
- }
-
- public void articleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
- String articleIdString = aRequest.getParameter("articleid");
- String operationString = aRequest.getParameter("operation");
- String returnUrlString = aRequest.getParameter("returnurl");
-
- performArticleOperation(ServletHelper.getUser(aRequest), articleIdString, operationString);
- redirect(aResponse, returnUrlString);
- }
-
- public void articleoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
- String returnUrlString = aRequest.getParameter("returnurl");
-
- String[] operations = aRequest.getParameterValues("operation");
-
- if (operations!=null) {
-
- for (int i = 0; i < operations.length; i++) {
- if (operations[i].length() > 0) {
- List parts = StringRoutines.splitString(operations[i], ";");
-
- if (parts.size() != 2) {
- logger.error("articleoperationbatch: operation string invalid: " + operations[i]);
- }
- else {
- String articleIdString = (String) parts.get(0);
- String operationString = (String) parts.get(1);
-
- performArticleOperation(ServletHelper.getUser(aRequest), articleIdString, operationString);
- }
- }
- }
- }
-
- redirect(aResponse, returnUrlString);
- }
-
- public List getAdministerOperations() throws ServletModuleExc {
- return administerOperations;
- }
+import mircoders.storage.DatabaseContent;\r
+\r
+public class ServletModuleLocalizer extends ServletModule {\r
+ private static ServletModuleLocalizer instance = new ServletModuleLocalizer();\r
+ public static ServletModule getInstance() { return instance; }\r
+\r
+ private ModuleContent contentModule;\r
+ private ModuleComment commentModule;\r
+ private List administerOperations;\r
+\r
+ private ServletModuleLocalizer() {\r
+ try {\r
+ logger = new LoggerWrapper("ServletModule.Localizer");\r
+\r
+ contentModule = new ModuleContent(DatabaseContent.getInstance());\r
+ commentModule = new ModuleComment(DatabaseComment.getInstance());\r
+\r
+ administerOperations = new Vector();\r
+\r
+ String settings[] = configuration.getStringArray("Mir.Localizer.Admin.AdministerOperations");\r
+\r
+ if (settings!=null) {\r
+ for (int i = 0; i < settings.length; i++) {\r
+ String setting = settings[i].trim();\r
+\r
+ if (setting.length() > 0) {\r
+ List parts = StringRoutines.splitString(setting, ":");\r
+ if (parts.size() != 2) {\r
+ logger.error("config error: " + settings[i] + ", 2 parts expected");\r
+ }\r
+ else {\r
+ Map entry = new HashMap();\r
+ entry.put("name", (String) parts.get(0));\r
+ entry.put("url", (String) parts.get(1));\r
+ administerOperations.add(entry);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("ServletModuleLocalizer could not be initialized: " + e.getMessage());\r
+ }\r
+\r
+\r
+ }\r
+\r
+ public void performCommentOperation(HttpServletRequest aRequest, String anId, String anOperation) {\r
+ MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation;\r
+ EntityAdapter comment;\r
+ EntityComment entity;\r
+\r
+ try {\r
+ entity = (EntityComment) commentModule.getById(anId);\r
+\r
+ if (entity != null) {\r
+ MirGlobal.performCommentOperation(ServletHelper.getUser(aRequest), entity, anOperation);\r
+ logger.info("Operation " + anOperation + " successfully performed on comment " + anId);\r
+ logAdminUsage(aRequest, "comment."+anId, "operation " + anOperation + " performed");\r
+ }\r
+ else {\r
+ logger.error("Error while performing " + anOperation + " on comment " + anId + ": comment is null");\r
+ }\r
+ }\r
+ catch (Throwable e) {\r
+ logger.error("Error while performing " + anOperation + " on comment " + anId + ": " + e.getMessage());\r
+ }\r
+ }\r
+\r
+ public void commentoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
+ String commentIdString = aRequest.getParameter("id");\r
+ String operationString = aRequest.getParameter("operation");\r
+ String returnUrlString = aRequest.getParameter("returnurl");\r
+\r
+ performCommentOperation(aRequest, commentIdString, operationString);\r
+\r
+ redirect(aResponse, returnUrlString);\r
+ }\r
+\r
+ public void commentoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
+ String returnUrlString = aRequest.getParameter("returnurl");\r
+\r
+ String[] operations = aRequest.getParameterValues("operation");\r
+\r
+ if (operations!=null) {\r
+ for (int i = 0; i < operations.length; i++) {\r
+ if (operations[i].length() > 0) {\r
+ List parts = StringRoutines.splitString(operations[i], ";");\r
+\r
+ if (parts.size() != 2) {\r
+ logger.error("commentoperationbatch: operation string invalid: " +\r
+ operations[i]);\r
+ }\r
+ else {\r
+ String commentIdString = (String) parts.get(0);\r
+ String operationString = (String) parts.get(1);\r
+\r
+ performCommentOperation(aRequest, commentIdString, operationString);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ redirect(aResponse, returnUrlString);\r
+ }\r
+\r
+ public void performArticleOperation(HttpServletRequest aRequest, String anId, String anOperation) {\r
+ MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation;\r
+ EntityAdapter article;\r
+ EntityContent entity;\r
+\r
+ try {\r
+ entity = (EntityContent) contentModule.getById(anId);\r
+\r
+ if (entity != null) {\r
+ MirGlobal.performArticleOperation(ServletHelper.getUser(aRequest), entity, anOperation);\r
+ logger.info("Operation " + anOperation + " successfully performed on article " + anId);\r
+ logAdminUsage(aRequest, "article."+anId, "operation " + anOperation + " performed");\r
+ }\r
+ else {\r
+ logger.error("Error while performing " + anOperation + " on article " + anId + ": article is null");\r
+ }\r
+ }\r
+ catch (Throwable e) {\r
+ logger.error("Error while performing " + anOperation + " on article " + anId + ": " + e.getMessage());\r
+ }\r
+ }\r
+\r
+ public void articleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
+ String articleIdString = aRequest.getParameter("articleid");\r
+ String operationString = aRequest.getParameter("operation");\r
+ String returnUrlString = aRequest.getParameter("returnurl");\r
+\r
+ performArticleOperation(aRequest, articleIdString, operationString);\r
+ redirect(aResponse, returnUrlString);\r
+ }\r
+\r
+ public void articleoperationbatch(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {\r
+ String returnUrlString = aRequest.getParameter("returnurl");\r
+\r
+ String[] operations = aRequest.getParameterValues("operation");\r
+\r
+ if (operations!=null) {\r
+\r
+ for (int i = 0; i < operations.length; i++) {\r
+ if (operations[i].length() > 0) {\r
+ List parts = StringRoutines.splitString(operations[i], ";");\r
+\r
+ if (parts.size() != 2) {\r
+ logger.error("articleoperationbatch: operation string invalid: " + operations[i]);\r
+ }\r
+ else {\r
+ String articleIdString = (String) parts.get(0);\r
+ String operationString = (String) parts.get(1);\r
+\r
+ performArticleOperation(aRequest, articleIdString, operationString);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ redirect(aResponse, returnUrlString);\r
+ }\r
+\r
+ public List getAdministerOperations() throws ServletModuleExc {\r
+ return administerOperations;\r
+ }\r
}
\ No newline at end of file
i=mediaList.iterator();\r
\r
while (i.hasNext()) {\r
- entContent.attach(((EntityUploadedMedia) i.next()).getId());\r
+ String id = ((EntityUploadedMedia) i.next()).getId();\r
+\r
+ entContent.attach(id);\r
+ logAdminUsage(aRequest, id, "object attached to article " + articleid);\r
}\r
\r
((ServletModuleContent) ServletModuleContent.getInstance()).editObject(aRequest, aResponse, articleid);\r
\r
+\r
return;\r
}\r
\r
i=mediaList.iterator();\r
\r
while (i.hasNext()) {\r
- comment.attach( ( (EntityUploadedMedia) i.next()).getId());\r
+ String id = ((EntityUploadedMedia) i.next()).getId();\r
+\r
+ comment.attach(id);\r
+\r
+ logAdminUsage(aRequest, id, "object attached to comment " + commentid);\r
}\r
\r
((ServletModuleComment) ServletModuleComment.getInstance()).editObject(aRequest, aResponse, commentid);\r
return;\r
}\r
\r
+ logAdminUsage(aRequest, "", mediaList.size() + " objects added");\r
+\r
returnUploadedMediaList(aRequest, aResponse, mediaList, 1, mediaList.size(), mediaList.size(), "", null, null);\r
}\r
catch (Throwable t) {\r
\r
String id = mainModule.set(mediaValues);\r
logger.debug("update: media ID = " + id);\r
+ logAdminUsage(aRequest, id, "object modified");\r
\r
editUploadedMediaObject(id, aRequest, aResponse);\r
}\r
throw new ServletModuleUserExc("user.error.missingpassword", new String[] {});\r
\r
String id = mainModule.add(withValues);\r
+\r
+ logAdminUsage(aRequest, id, "object added");\r
+\r
if (requestParser.hasParameter("returnurl"))\r
redirect(aResponse, requestParser.getParameter("returnurl"));\r
else\r
{\r
try {\r
HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
- EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));\r
+ String id = requestParser.getParameter("id");\r
+ EntityUsers user = (EntityUsers) mainModule.getById(id);\r
MirGlobal.accessControl().user().assertMayEditUser(ServletHelper.getUser(aRequest), user);\r
\r
Map withValues = getIntersectingValues(aRequest, mainModule.getStorageObject());\r
\r
mainModule.set(withValues);\r
\r
+ logAdminUsage(aRequest, id, "object modified");\r
+\r
if (requestParser.hasParameter("returnurl"))\r
redirect(aResponse, requestParser.getParameter("returnurl"));\r
else\r
{\r
try {\r
HTTPRequestParser requestParser = new HTTPRequestParser(aRequest);\r
- EntityUsers user = (EntityUsers) mainModule.getById(requestParser.getParameter("id"));\r
+ String id = requestParser.getParameter("id");\r
+ EntityUsers user = (EntityUsers) mainModule.getById(id);\r
MirGlobal.accessControl().user().assertMayChangeUserPassword(ServletHelper.getUser(aRequest), user);\r
\r
String newPassword=validatePassword(ServletHelper.getUser(aRequest), requestParser);\r
user.setValueForProperty("password", MirGlobal.localizer().adminInterface().makePasswordDigest(newPassword));\r
user.update();\r
\r
+ logAdminUsage(aRequest, id, "password changed");\r
+\r
// hackish: to make sure the cached logged in user is up-to-date:\r
ServletHelper.setUser(aRequest, (EntityUsers) mainModule.getById(ServletHelper.getUser(aRequest).getId()));\r
}\r
utility.encodeHTML(f.expression),
lang("content.operation."+f.articleAction),
lang("comment.operation."+f.commentAction),
- f.comments,
+ utility.prettyEncodeHTML(f.comments),
f.lastHit.format(config["Mir.DefaultDateTimeFormat"], config["Mir.DefaultTimezone"])
],
"module=Abuse&id="+f.id,
- ["&do=edit", "&do=delete"],
- [lang("edit"), lang("delete")])
+ ["&do=edit", "&do=delete", "&do=moveup", "&do=movedown"],
+ [lang("edit"), lang("delete"), lang("abuse.filters.moveup"), lang("abuse.filters.movedown")])
>
<else>
<call ListEntry([
utility.encodeHTML(f.expression),
lang("content.operation."+f.articleAction),
lang("comment.operation."+f.commentAction),
- f.comments,
+ utility.prettyEncodeHTML(f.comments),
"-"
],
"module=Abuse&id="+f.id,
- ["&do=edit", "&do=delete"],
- [lang("edit"), lang("delete")])
+ ["&do=edit", "&do=delete", "&do=moveup", "&do=movedown"],
+ [lang("edit"), lang("delete"), lang("abuse.filters.moveup"), lang("abuse.filters.movedown")])
>
</if>
</list>\r