📄 forumpropertiesmanager.java
字号:
package net.acai.forum;
/**
* Title: 清清网络
* Description:
* Copyright: Copyright (c) 2002
* Company: www.SuperSpace.com
* @author: SuperSpace
* @version 1.0
*/
/**
* Title: 清清网络
* Description:
* Copyright: Copyright (c) 2002
* Company: 211.68.39.120、webcpu.51.net
* @author: SuperSpace
* @version 1.0
*/
import net.acai.database.*;
import net.acai.util.*;
import java.sql.*;
import java.util.Hashtable;
import javax.servlet.http.*;
public class ForumPropertiesManager{
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() {
try{
DBConnect dbc=new DBConnect("select * from config");
ResultSet rs=dbc.executeQuery();
ResultSetMetaData rsmd=rs.getMetaData();
int cols = rsmd.getColumnCount();
if(rs.next()){
//System.out.println("in--------------1");
for(int i=1;i<=cols;i++){
String field = (String)(rsmd.getColumnName(i));
String value = (String)(rs.getString(i));
//System.out.println("cols="+cols);
//System.out.println("field="+field);
//System.out.println("value="+value);
//System.out.println("i="+i);
forumHash.put(field,value);
}
//System.out.println("in--------------3");
}
dbc.close();
}
catch(SQLException e)
{
System.out.println("ResultSetMetaData出现问题!");
}
catch(Exception e)
{
System.out.println("DBConnect 出现问题!");
}
}
public String getStr(String name) throws Exception{
if(forumHash.isEmpty())
throw new Exception("好像数据库连接有问题,请您确定您安装了数据库了吗?\n<br>如果您没有安装数据库,请您运行install.jsp,安装数据库!");
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=new DBConnect(sql);
dbc.executeUpdate();
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 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=new DBConnect();
forumName = new String(forumName.getBytes("ISO-8859-1"),"GBK");
forumURL = new String(forumURL.getBytes("ISO-8859-1"),"GBK");
companyName = new String(companyName.getBytes("ISO-8859-1"),"GBK");
hostURL = new String(hostURL.getBytes("ISO-8859-1"),"GBK");
SMTPServer = new String(SMTPServer.getBytes("ISO-8859-1"),"GBK");
systemEmail = new String(systemEmail.getBytes("ISO-8859-1"),"GBK");
logo = new String(logo.getBytes("ISO-8859-1"),"GBK");
picURL = new String(picURL.getBytes("ISO-8859-1"),"GBK");
faceURL = new String(faceURL.getBytes("ISO-8859-1"),"GBK");
ads1 = new String(ads1.getBytes("ISO-8859-1"),"GBK");
ads2 = new String(ads2.getBytes("ISO-8859-1"),"GBK");
copyRight = new String(copyRight.getBytes("ISO-8859-1"),"GBK");
version = new String(version.getBytes("ISO-8859-1"),"GBK");
String sql="update config set forumName='"+forumName+"',forumURL='"+forumURL
+"',companyName='"+companyName+"',hostURL='"+hostURL+"',SMTPServer='"+SMTPServer+"' "
+",systemEmail='"+systemEmail+"',timeAdjust="+timeAdjust+",scriptTimeOut="+scriptTimeOut+",logo='"+logo+"'"
+",picURL='"+picURL+"',faceURL='"+faceURL+"',emailFlag="+emailFlag+",uploadPic="+uploadPic+",ipFlag="+ipFlag
+",fromFlag="+fromFlag+",uploadFlag="+uploadFlag+",guestUser="+guestUser
+",openMSG='"+openMSG+"',maxAnnouncePerPage='"+maxAnnouncePerPage+"'"
+",announceMaxBytes='"+announceMaxBytes+"'"
+",maxTitleList='"+maxTitleList+"',tableBackColor='"+tableBackColor+"'"
+",aTableBackColor='"+aTableBackColor+"',tableTitleColor='"+tableTitleColor+"'"
+",aTableTitleColor='"+aTableTitleColor+"',tableFontColor='"+tableFontColor+"'"
+",tableContentColor='"+tableContentColor+"',alertFontColor='"+alertFontColor+"'"
+",contentTitle='"+contentTitle+"',tableBodyColor='"+tableBodyColor+"'"
+",aTableBodyColor='"+aTableBodyColor+"',ads1='"+ads1+"'"
+",ads2='"+ads2+"',copyRight='"+copyRight+"'"
+",version='"+version+"'";
System.out.println("sql:"+sql);
System.out.println("forumName:"+forumName);
System.out.println("forumURL:"+forumURL);
System.out.println("companyName:"+companyName);
System.out.println("hostURL:"+hostURL);
dbc.prepareStatement(sql);
/*dbc.setBytes(1,forumName.getBytes());
dbc.setBytes(2,forumURL.getBytes());
dbc.setBytes(3,companyName.getBytes());
dbc.setBytes(4,hostURL.getBytes());
dbc.setBytes(5,SMTPServer.getBytes());
dbc.setBytes(6,systemEmail.getBytes());
dbc.setBytes(7,logo.getBytes());
dbc.setBytes(8,(new String(picURL.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(9,(new String(faceURL.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(10,(new String(ads1.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(11,(new String(ads2.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(12,(new String(copyRight.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(13,(new String(version.getBytes("ISO-8859-1"),"GBK")).getBytes());*/
dbc.executeUpdate();
dbc.close();
resetManager();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -