📄 sysutil.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: SysUtil.java
package com.laoer.bbscs.sys;
import com.laoer.comm.util.Util;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import org.apache.struts.util.LabelValueBean;
import org.apache.struts.util.MessageResources;
// Referenced classes of package com.laoer.bbscs.sys:
// UserLevel, Result, AutoFilter, Constant,
// SysInfo, Forbid
public class SysUtil
{
private static final Log logger;
static Class class$com$laoer$bbscs$sys$SysUtil; /* synthetic field */
public SysUtil()
{
}
public static String getMsg(String key, HttpServletRequest request)
{
return Constant.MESSAGE.getMessage(request.getLocale(), key);
}
public static String[] getPagesign(MessageResources messages, HttpServletRequest request)
{
String pagessign[] = {
messages.getMessage(request.getLocale(), "bbscs.pages.first"), messages.getMessage(request.getLocale(), "bbscs.pages.previous"), messages.getMessage(request.getLocale(), "bbscs.pages.next"), messages.getMessage(request.getLocale(), "bbscs.pages.end")
};
return pagessign;
}
public static String[] getPagesign(HttpServletRequest request)
{
String pagessign[] = {
Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.pages.first"), Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.pages.previous"), Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.pages.next"), Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.pages.end")
};
return pagessign;
}
public static Vector getUserType0(HttpServletRequest request)
{
Vector v = new Vector();
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.user.guest"), "0"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.user.user"), "1"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.user.usermanager"), "2"));
return v;
}
public static Vector getUserType1(HttpServletRequest request)
{
Vector v = new Vector();
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.user.guest"), "0"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "bbscs.user.user"), "1"));
return v;
}
public static Vector getBoardAttrib(HttpServletRequest request)
{
Vector v = new Vector();
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "admin.board.cb"), "1"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "admin.board.eb"), "2"));
return v;
}
public static Vector getBoardsUseStat(HttpServletRequest request)
{
Vector v = new Vector();
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "admin.boards.usestat.yes"), "1"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "admin.boards.usestat.no"), "2"));
return v;
}
public static Vector getNoteType(HttpServletRequest request)
{
Vector v = new Vector();
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle0"), "0"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle1"), "1"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle2"), "2"));
v.add(new LabelValueBean(Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle3"), "3"));
return v;
}
public static String getNoteType(short mtype, HttpServletRequest request)
{
String type = "";
switch(mtype)
{
case 0: // '\0'
type = Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle0");
break;
case 1: // '\001'
type = Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle1");
break;
case 2: // '\002'
type = Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle2");
break;
case 3: // '\003'
type = Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle3");
break;
default:
type = Constant.MESSAGE.getMessage(request.getLocale(), "note.nstyle0");
break;
}
return type;
}
public static Vector getForbid(HashMap forbid)
{
Iterator i = forbid.values().iterator();
Vector v = new Vector();
String s;
for(; i.hasNext(); v.add(new LabelValueBean(s, s)))
s = (String)i.next();
return v;
}
public static long getLongTime()
{
return System.currentTimeMillis();
}
public static String getResultUrl(String msg, String tourl)
{
if(tourl == null || tourl.length() == 0 || tourl.equals(Constant.GOBACK))
tourl = "tourl=" + Constant.GOBACK;
else
try
{
tourl = "tourl=" + URLEncoder.encode(tourl, Constant.CHARSET);
}
catch(Exception e) { }
return "/result.jsp?msg=" + msg + "&" + tourl;
}
public static UserLevel getUserLevel(int exp)
{
List l = SysInfo.getInstance().getUserlevel();
for(int i = 0; i < l.size(); i++)
{
UserLevel ul = (UserLevel)l.get(i);
if(ul.getMin() <= exp && exp <= ul.getMax())
return ul;
}
return (UserLevel)l.get(0);
}
public static String getIncludeFilePath()
{
String filePath = Constant.ROOTPATH + "file/include/";
File ft = new File(filePath);
if(!ft.exists())
ft.mkdirs();
return filePath;
}
public static String getUserFilePath(String username, long userID)
{
int num = Math.abs(username.hashCode());
String filePath = "";
filePath = Constant.ROOTPATH + "file/user/" + num % 100 + "/" + userID + "/";
File ft = new File(filePath);
if(!ft.exists())
ft.mkdirs();
return filePath;
}
public static String getUserFileWebPath(String username, long userID)
{
int num = Math.abs(username.hashCode());
String filePath = "";
filePath = "file/user/" + num % 100 + "/" + userID + "/";
return filePath;
}
public static String getForumPath(long bid, long adate)
{
int num = Math.abs(String.valueOf(bid).hashCode());
String filePath = "";
filePath = Constant.ROOTPATH + "file/postfile/" + num % 20 + "/" + bid + "/" + Util.formatDate4(new Date(adate)) + "/";
File ft = new File(filePath);
if(!ft.exists())
ft.mkdirs();
return filePath;
}
public static String getUpFilePath(long bid, long adate)
{
int num = Math.abs(String.valueOf(bid).hashCode());
String filePath = "";
filePath = Constant.ROOTPATH + "file/imgup/" + num % 20 + "/" + bid + "/" + Util.formatDate4(new Date(adate)) + "/";
File ft = new File(filePath);
if(!ft.exists())
ft.mkdirs();
return filePath;
}
public static String getUpFileWebPath(long bid, long adate)
{
int num = Math.abs(String.valueOf(bid).hashCode());
String filePath = "";
filePath = "file/imgup/" + num % 20 + "/" + bid + "/" + Util.formatDate4(new Date(adate)) + "/";
return filePath;
}
public static void saveUpFile(String path, FormFile upfile)
{
try
{
InputStream stream = upfile.getInputStream();
OutputStream bos = new FileOutputStream(path);
int bytesRead = 0;
byte buffer[] = new byte[8192];
while((bytesRead = stream.read(buffer, 0, 8192)) != -1)
bos.write(buffer, 0, bytesRead);
bos.close();
stream.close();
bos = null;
stream = null;
}
catch(FileNotFoundException ex)
{
logger.error(ex);
}
catch(IOException ex)
{
logger.error(ex);
}
}
public static int getStrLength(String txt, String charset)
{
return txt.getBytes(charset).length;
UnsupportedEncodingException ex;
ex;
return txt.length();
}
public static short getCookieValue(String value, String perfix)
{
if(value.length() != 2 || !value.startsWith(perfix))
break MISSING_BLOCK_LABEL_29;
return Short.parseShort(value.substring(1, 2));
NumberFormatException ex;
ex;
return 0;
return 0;
}
public static short getCookieValue(String value, String perfix, short defaultnum)
{
if(value.length() != 2 || !value.startsWith(perfix))
break MISSING_BLOCK_LABEL_29;
return Short.parseShort(value.substring(1, 2));
NumberFormatException ex;
ex;
return defaultnum;
if(value.length() <= 2 || !value.startsWith(perfix))
break MISSING_BLOCK_LABEL_61;
return Short.parseShort(value.substring(1, value.length()));
ex;
return defaultnum;
return defaultnum;
}
public static short getGuestCookieValue(String value, String perfix)
{
if(value.length() != 2 || !value.startsWith(perfix))
break MISSING_BLOCK_LABEL_29;
return Short.parseShort(value.substring(1, 2));
NumberFormatException ex;
ex;
return 1;
return 1;
}
public static String getClassName(String className, long userID)
{
className = Constant.BEANPERFIX + className + userID % 10L;
return className;
}
public static String getForumClassName(long bid)
{
int num = Math.abs(String.valueOf(bid).hashCode());
String className = Constant.BEANPERFIX + "Forum" + num % 20;
return className;
}
public static int getTableID(long userID, int num)
{
return (int)(userID % (long)num);
}
public static int getForumTableID(long bid)
{
int num = Math.abs(String.valueOf(bid).hashCode());
return num % 20;
}
public static boolean isBadNickName(String nickName)
{
if(SysInfo.getInstance().getForbidnickname() != null && SysInfo.getInstance().getForbidnickname().length() > 0)
{
String badNickNames[] = SysInfo.getInstance().getForbidnickname().split(",");
if(badNickNames != null)
{
for(int i = 0; i < badNickNames.length; i++)
if(nickName.indexOf(badNickNames[i]) != -1)
return true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -