📄 forbid.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: Forbid.java
package com.laoer.bbscs.sys;
import java.io.*;
import java.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.*;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
// Referenced classes of package com.laoer.bbscs.sys:
// Result, Constant
public class Forbid
{
private static final Log logger;
public static Forbid instance;
private HashMap forbidipHm;
private HashMap forbidwordsHm;
static Class class$com$laoer$bbscs$sys$Forbid; /* synthetic field */
public static synchronized Forbid getInstance()
{
if(instance == null)
instance = new Forbid();
return instance;
}
public Forbid()
{
forbidipHm = new HashMap();
forbidwordsHm = new HashMap();
load();
}
public void load()
{
SAXBuilder sb = new SAXBuilder();
try
{
Document doc = sb.build(new FileInputStream(Constant.CONFIGPATH + Constant.FORBIDXMLFILE));
logger.info("Load forbid xml file:" + Constant.CONFIGPATH + Constant.FORBIDXMLFILE);
Element root = doc.getRootElement();
Element forbidip = root.getChild("forbidip");
List forbidiplist = forbidip.getChildren();
String address = "";
for(int i = 0; i < forbidiplist.size(); i++)
{
Element ip = (Element)forbidiplist.get(i);
address = ip.getAttribute("address").getValue();
forbidipHm.put(address, address);
}
Element forbidwords = root.getChild("forbidwords");
List forbidwordslist = forbidwords.getChildren();
String content = "";
for(int i = 0; i < forbidwordslist.size(); i++)
{
Element word = (Element)forbidwordslist.get(i);
content = word.getAttribute("content").getValue();
forbidwordsHm.put(content, content);
}
}
catch(Exception ex)
{
logger.error(ex);
}
}
public synchronized void save()
{
Element rootElement = new Element("forbid");
Document forbidDocument = new Document(rootElement);
Element forbidip = new Element("forbidip");
Element ip;
for(Iterator i = forbidipHm.values().iterator(); i.hasNext(); forbidip.addContent(ip))
{
ip = new Element("ip");
ip.addAttribute("address", (String)i.next());
}
rootElement.addContent(forbidip);
Element forbidwords = new Element("forbidwords");
Element word;
for(Iterator i = forbidwordsHm.values().iterator(); i.hasNext(); forbidwords.addContent(word))
{
word = new Element("word");
word.addAttribute("content", (String)i.next());
}
rootElement.addContent(forbidwords);
try
{
XMLOutputter xmlo = new XMLOutputter(" ", true, "UTF-8");
xmlo.output(forbidDocument, new FileOutputStream(Constant.CONFIGPATH + Constant.FORBIDXMLFILE));
logger.info("Save forbid xml file:" + Constant.CONFIGPATH + Constant.FORBIDXMLFILE);
}
catch(IOException e)
{
logger.error(e);
}
}
public HashMap getForbidipHm()
{
return forbidipHm;
}
public HashMap getForbidwordsHm()
{
return forbidwordsHm;
}
public void setForbidwordsHm(HashMap forbidwordsHm)
{
this.forbidwordsHm = forbidwordsHm;
}
public void setForbidipHm(HashMap forbidipHm)
{
this.forbidipHm = forbidipHm;
}
public Result addIp(String ip)
{
if(forbidipHm.get(ip) != null)
{
return new Result(false, "error.adminforbid.ipexist");
} else
{
forbidipHm.put(ip, ip);
save();
return new Result(true, "");
}
}
public Result removeIp(String ip)
{
forbidipHm.remove(ip);
save();
return new Result(true, "");
}
public Result addWord(String word)
{
if(forbidwordsHm.get(word) != null)
{
return new Result(false, "error.adminforbid.wordexist");
} else
{
forbidwordsHm.put(word, word);
save();
return new Result(true, "");
}
}
public Result removeWord(String word)
{
forbidwordsHm.remove(word);
save();
return new Result(true, "");
}
static Class class$(String x0)
{
return Class.forName(x0);
ClassNotFoundException x1;
x1;
throw new NoClassDefFoundError(x1.getMessage());
}
static
{
logger = LogFactory.getLog(class$com$laoer$bbscs$sys$Forbid != null ? class$com$laoer$bbscs$sys$Forbid : (class$com$laoer$bbscs$sys$Forbid = class$("com.laoer.bbscs.sys.Forbid")));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -