📄 forumpropertiesmanager.java
字号:
package com.bcxy.bbs.forum;
/**
* Title:
* Description:
* Copyright:
* Company: www.liyunet.com
*
* @author lishujiang
* @version 1.0
*/
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Hashtable;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import com.bcxy.bbs.database.DBConnect;
import com.bcxy.bbs.util.ParamUtil;
import com.bcxy.util.SysUtil;
public class ForumPropertiesManager {
private Logger log = Logger.getLogger(ForumPropertiesManager.class);
private static ForumPropertiesManager manager = null;
private static Object managerLock = new Object();
public static void resetManager() {
manager = null;
}
public static String getString(String name) throws Exception {
if (manager == null) {
synchronized (managerLock) {
if (manager == null) {
manager = new ForumPropertiesManager();
}
}
}
return manager.getStr(name);
}
public static void setString(String name) {
if (manager == null) {
synchronized (managerLock) {
if (manager == null) {
manager = new ForumPropertiesManager();
}
}
}
manager.setStr(name);
}
private static Hashtable forumHash = new Hashtable();
public ForumPropertiesManager() {
DBConnect dbc = null;
try {
dbc = new DBConnect("select * from config");
ResultSet rs = dbc.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
rs.next();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
String col = rs.getString(i);
col = SysUtil.encodeOutDB(col);
forumHash.put(rsmd.getColumnName(i), col);
}
} catch (SQLException e) {
log.error("ResultSetMetaData出现问题!");
} catch (Exception e) {
log.error("DBConnect 出现问题!");
}finally{
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public String getStr(String name) throws Exception {
if (forumHash.isEmpty())
throw new Exception(
"好像数据库连接有问题,请您确定您安装了数据库了吗?");
return (String) forumHash.get(name);
}
public void setStr(String name) {
}
public Hashtable getHashtable() {
return forumHash;
}
public static void saveGrade(HttpServletRequest request) throws Exception {
int wealthReg, wealthLogin, wealthAnnounce, wealthReAnnounce, wealthDel;
int epReg, epLogin, epAnnounce, epReAnnounce, epDel;
int cpReg, cpLogin, cpAnnounce, cpReAnnounce, cpDel;
try {
wealthReg = ParamUtil.getInt(request, "wealthReg");
wealthLogin = ParamUtil.getInt(request, "wealthLogin");
wealthAnnounce = ParamUtil.getInt(request, "wealthAnnounce");
wealthReAnnounce = ParamUtil.getInt(request, "wealthReAnnounce");
wealthDel = ParamUtil.getInt(request, "wealthDel");
epReg = ParamUtil.getInt(request, "epReg");
epLogin = ParamUtil.getInt(request, "epLogin");
epAnnounce = ParamUtil.getInt(request, "epAnnounce");
epReAnnounce = ParamUtil.getInt(request, "epReAnnounce");
epDel = ParamUtil.getInt(request, "epDel");
cpReg = ParamUtil.getInt(request, "cpReg");
cpLogin = ParamUtil.getInt(request, "cpLogin");
cpAnnounce = ParamUtil.getInt(request, "cpAnnounce");
cpReAnnounce = ParamUtil.getInt(request, "cpReAnnounce");
cpDel = ParamUtil.getInt(request, "cpDel");
} catch (Exception e) {
e.printStackTrace();
throw new Exception("请您输入的为数字!");
}
String sql = "update config set " + "wealthReg=" + wealthReg
+ ",wealthLogin=" + wealthLogin + ",wealthAnnounce="
+ wealthAnnounce + ",wealthDel=" + wealthDel
+ ",wealthReAnnounce=" + wealthReAnnounce + ",epReg=" + epReg
+ ",epLogin=" + epLogin + ",epAnnounce=" + epAnnounce
+ ",epDel=" + epDel + ",epReAnnounce=" + epReAnnounce
+ ",cpReg=" + cpReg + ",cpLogin=" + cpLogin + ",cpAnnounce="
+ cpAnnounce + ",cpDel=" + cpDel + ",cpReAnnounce="
+ cpReAnnounce;
DBConnect dbc = null;
try{
dbc = new DBConnect(sql);
dbc.executeUpdate();
}catch(Exception e){
e.printStackTrace();
throw new Exception("设置出错,请检查输入是否正确!");
}finally{
dbc.close();
}
ForumPropertiesManager.resetManager();
}
public static void saveConst(HttpServletRequest request) throws Exception {
String forumName = ParamUtil.getString(request, "forumName");
if (forumName == null || "".equals(forumName.trim()))
throw new Exception("请您输入论坛的名称!");
String forumURL = ParamUtil.getString(request, "forumURL");
if (forumURL == null || "".equals(forumURL.trim()))
throw new Exception("请您输入论坛的连接地址!");
String companyName = ParamUtil.getString(request, "companyName");
if (companyName == null || "".equals(companyName.trim()))
throw new Exception("请您输入主页的名称!");
String hostURL = ParamUtil.getString(request, "hostURL");
if (hostURL == null || "".equals(hostURL.trim()))
throw new Exception("请您输入主页的地址!~");
String SMTPServer = ParamUtil.getString(request, "SMTPServer");
if (SMTPServer == null || "".equals(SMTPServer.trim()))
throw new Exception("请您输入邮件服务器的地址!");
String systemEmail = ParamUtil.getString(request, "systemEmail");
if (systemEmail == null || "".equals(systemEmail.trim()))
throw new Exception("请您填写邮件的发送人地址");
int timeAdjust = ParamUtil.getInt(request, "timeAdjust", 0);
int scriptTimeOut = ParamUtil.getInt(request, "scriptTimeOut", 300);
String logo = ParamUtil.getString(request, "forumLogo");
if (logo == null || "".equals(logo.trim()))
throw new Exception("请您填写论坛的logo地址!");
String picURL = ParamUtil.getString(request, "picURL");
if (picURL == null || "".equals(picURL.trim()))
throw new Exception("请您填写论坛图片的目录!");
String faceURL = ParamUtil.getString(request, "faceURL");
if (faceURL == null || "".equals(faceURL.trim()))
throw new Exception("请您填写论坛的表情目录!");
int emailFlag = ParamUtil.getInt(request, "emailFlag", 0);
int uploadPic = ParamUtil.getInt(request, "uploadPic", 0);
int ipFlag = ParamUtil.getInt(request, "ipFlag", 0);
int fromFlag = ParamUtil.getInt(request, "fromFlag", 0);
int titleFlag = ParamUtil.getInt(request, "titleFlag", 0);
int uploadFlag = ParamUtil.getInt(request, "uploadFlag", 0);
int guestUser = ParamUtil.getInt(request, "guestUser", 0);
String openMSG = ParamUtil.getString(request, "openMSG", "");
String announceMaxBytes = ParamUtil.getString(request,
"announceMaxBytes", "");
String maxAnnouncePerPage = ParamUtil.getString(request,
"maxAnnouncePerPage", "");
String maxTitleList = ParamUtil.getString(request, "maxTitleList", "");
String tableBackColor = ParamUtil.getString(request, "tableBackColor");
String aTableBackColor = ParamUtil
.getString(request, "aTableBackColor");
String tableTitleColor = ParamUtil
.getString(request, "tableTitleColor");
String aTableTitleColor = ParamUtil.getString(request,
"aTableTitleColor");
String tableFontColor = ParamUtil.getString(request, "tableFontColor");
String tableContentColor = ParamUtil.getString(request,
"tableContentColor");
String alertFontColor = ParamUtil.getString(request, "alertFontColor");
String contentTitle = ParamUtil.getString(request, "contentTitle");
String tableBodyColor = ParamUtil.getString(request, "tableBodyColor");
String aTableBodyColor = ParamUtil
.getString(request, "aTableBodyColor");
String bodyBgImage = ParamUtil.getString(request, "bodyBgImage","");
String ads1 = ParamUtil.getString(request, "ads1", "");
String ads2 = ParamUtil.getString(request, "ads2", "");
String copyRight = ParamUtil.getString(request, "copyRight", "");
String version = ParamUtil.getString(request, "version", "");
// ////////////////////////插入数据库中!//////////////////////////////////
DBConnect dbc = null;
try {
dbc = new DBConnect();
String sql = "update config set forumName=?,forumURL=?,companyName=?,hostURL=?,SMTPServer=?\n"
+ ",systemEmail=?,timeAdjust="
+ timeAdjust
+ ",scriptTimeOut="
+ scriptTimeOut
+ ",logo=?\n"
+ ",picURL=?,faceURL=?,emailFlag="
+ emailFlag
+ ",uploadPic="
+ uploadPic
+ ",ipFlag="
+ ipFlag
+ "\n"
+ ",fromFlag="
+ fromFlag
+ ",uploadFlag="
+ uploadFlag
+ ",guestUser="
+ guestUser
+ "\n"
+ ",openMSG='"
+ openMSG
+ "',maxAnnouncePerPage='"
+ maxAnnouncePerPage
+ "'\n"
+ ",announceMaxBytes='"
+ announceMaxBytes
+ "',maxAnnouncePerPage='"
+ maxAnnouncePerPage
+ "'\n"
+ ",maxTitleList='"
+ maxTitleList
+ "',tableBackColor='"
+ tableBackColor
+ "'\n"
+ ",aTableBackColor='"
+ aTableBackColor
+ "',tableTitleColor='"
+ tableTitleColor
+ "'\n"
+ ",aTableTitleColor='"
+ aTableTitleColor
+ "',tableFontColor='"
+ tableFontColor
+ "'\n"
+ ",tableContentColor='"
+ tableContentColor
+ "',alertFontColor='"
+ alertFontColor
+ "'\n"
+ ",contentTitle='"
+ contentTitle
+ "',tableBodyColor='"
+ tableBodyColor
+ "'\n"
+ ",aTableBodyColor='"
+ aTableBodyColor
+ "',ads1=?\n"
+ ",ads2=?,copyRight=?\n"
+ ",version=?,bodyBgImage=?";
dbc.prepareStatement(sql);
dbc.setString(1, forumName);
dbc.setString(2, forumURL);
dbc.setString(3, companyName);
dbc.setString(4, hostURL);
dbc.setString(5, SMTPServer);
dbc.setString(6, systemEmail);
dbc.setString(7, logo);
dbc.setString(8, picURL);
dbc.setString(9, faceURL);
dbc.setString(10, ads1);
dbc.setString(11, ads2);
dbc.setString(12, copyRight);
dbc.setString(13, version);
dbc.setString(14, bodyBgImage);
dbc.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw new Exception("设置出错,请检查输入是否正确!");
}finally{
dbc.close();
}
resetManager();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -