ForumPropertiesManager.java
上传用户:yuyunping
上传日期:2013-03-21
资源大小:1844k
文件大小:9k
源码类别:

Java书籍

开发平台:

Java

  1. package net.acai.forum;
  2. /**
  3.  * Title:        清清网络
  4.  * Description:
  5.  * Copyright:    Copyright (c) 2002
  6.  * Company:      www.SuperSpace.com
  7.  * @author:       SuperSpace
  8.  * @version 1.0
  9.  */
  10. /**
  11.  * Title:        清清网络
  12.  * Description:
  13.  * Copyright:    Copyright (c) 2002
  14.  * Company:      211.68.39.120、webcpu.51.net
  15.  * @author:       SuperSpace
  16.  * @version 1.0
  17.  */
  18. import net.acai.database.*;
  19. import net.acai.util.*;
  20. import java.sql.*;
  21. import java.util.Hashtable;
  22. import javax.servlet.http.*;
  23. public class ForumPropertiesManager{
  24. private static ForumPropertiesManager manager=null;
  25. private static Object managerLock=new Object();
  26. public static void resetManager(){
  27. manager=null;
  28. }
  29. public static String getString(String name) throws Exception{
  30. if(manager==null){
  31. synchronized(managerLock){
  32. if(manager==null){
  33. manager=new ForumPropertiesManager();
  34. }
  35. }
  36. }
  37. return manager.getStr(name);
  38. }
  39. public static void setString(String name){
  40. if(manager==null){
  41. synchronized(managerLock){
  42. if(manager==null){
  43. manager=new ForumPropertiesManager();
  44. }
  45. }
  46. }
  47. manager.setStr(name);
  48. }
  49. private static Hashtable forumHash=new Hashtable();
  50. public ForumPropertiesManager() {
  51. try{
  52. DBConnect dbc=new DBConnect("select * from bbs.config");
  53. ResultSet rs=dbc.executeQuery();
  54. ResultSetMetaData rsmd=rs.getMetaData();
  55. rs.next();
  56. for(int i=1;i<=rsmd.getColumnCount();i++){
  57. forumHash.put(rsmd.getColumnName(i),rs.getString(i));
  58. }
  59. dbc.close();
  60. }
  61. catch(SQLException e)
  62. {
  63. System.out.println("ResultSetMetaData出现问题!");
  64. }
  65. catch(Exception e)
  66. {
  67. System.out.println("DBConnect 出现问题!");
  68. }
  69. }
  70. public String getStr(String name) throws Exception{
  71. if(forumHash.isEmpty())
  72. throw new Exception("好像数据库连接有问题,请您确定您安装了数据库了吗?n<br>如果您没有安装数据库,请您运行install.jsp,安装数据库!");
  73. return (String)forumHash.get(name);
  74. }
  75. public void setStr(String name)
  76. {
  77. }
  78. public Hashtable getHashtable(){
  79. return forumHash;
  80. }
  81. public static void saveGrade(HttpServletRequest request) throws Exception{
  82. int wealthReg,wealthLogin,wealthAnnounce,wealthReAnnounce,wealthDel;
  83. int epReg,epLogin,epAnnounce,epReAnnounce,epDel;
  84. int cpReg,cpLogin,cpAnnounce,cpReAnnounce,cpDel;
  85. try{
  86. wealthReg=ParamUtil.getInt(request,"wealthReg");
  87. wealthLogin=ParamUtil.getInt(request,"wealthLogin");
  88. wealthAnnounce=ParamUtil.getInt(request,"wealthAnnounce");
  89. wealthReAnnounce=ParamUtil.getInt(request,"wealthReAnnounce");
  90. wealthDel=ParamUtil.getInt(request,"wealthDel");
  91. epReg=ParamUtil.getInt(request,"epReg");
  92. epLogin=ParamUtil.getInt(request,"epLogin");
  93. epAnnounce=ParamUtil.getInt(request,"epAnnounce");
  94. epReAnnounce=ParamUtil.getInt(request,"epReAnnounce");
  95. epDel=ParamUtil.getInt(request,"epDel");
  96. cpReg=ParamUtil.getInt(request,"cpReg");
  97. cpLogin=ParamUtil.getInt(request,"cpLogin");
  98. cpAnnounce=ParamUtil.getInt(request,"cpAnnounce");
  99. cpReAnnounce=ParamUtil.getInt(request,"cpReAnnounce");
  100. cpDel=ParamUtil.getInt(request,"cpDel");
  101. }
  102. catch(Exception e){
  103. e.printStackTrace();
  104. throw new Exception("请您输入的为数字!");
  105. }
  106. String sql="update bbs.config set "+
  107. "wealthReg="+wealthReg+",wealthLogin="+wealthLogin+",wealthAnnounce="+wealthAnnounce+",wealthDel="+wealthDel+",wealthReAnnounce="+wealthReAnnounce+
  108. ",epReg="+epReg+",epLogin="+epLogin+",epAnnounce="+epAnnounce+",epDel="+epDel+",epReAnnounce="+epReAnnounce+
  109. ",cpReg="+cpReg+",cpLogin="+cpLogin+",cpAnnounce="+cpAnnounce+",cpDel="+cpDel+",cpReAnnounce="+cpReAnnounce;
  110. DBConnect dbc=new DBConnect(sql);
  111. dbc.executeUpdate();
  112. dbc.close();
  113. ForumPropertiesManager.resetManager();
  114. }
  115. public static void saveConst(HttpServletRequest request) throws Exception{
  116. String forumName=ParamUtil.getString(request,"forumName");
  117. if(forumName==null||"".equals(forumName.trim()))
  118. throw new Exception("请您输入论坛的名称!");
  119. String forumURL=ParamUtil.getString(request,"forumURL");
  120. if(forumURL==null||"".equals(forumURL.trim()))
  121. throw new Exception("请您输入论坛的连接地址!");
  122. String companyName=ParamUtil.getString(request,"companyName");
  123. if(companyName==null||"".equals(companyName.trim()))
  124. throw new Exception("请您输入主页的名称!");
  125. String hostURL=ParamUtil.getString(request,"hostURL");
  126. if(hostURL==null||"".equals(hostURL.trim()))
  127. throw new Exception("请您输入主页的地址!~");
  128. String SMTPServer=ParamUtil.getString(request,"SMTPServer");
  129. if(SMTPServer==null||"".equals(SMTPServer.trim()))
  130. throw new Exception("请您输入邮件服务器的地址!");
  131. String systemEmail=ParamUtil.getString(request,"systemEmail");
  132. if(systemEmail==null||"".equals(systemEmail.trim()))
  133. throw new Exception("请您填写邮件的发送人地址");
  134. int timeAdjust=ParamUtil.getInt(request,"timeAdjust",0);
  135. int scriptTimeOut=ParamUtil.getInt(request,"scriptTimeOut",300);
  136. String logo=ParamUtil.getString(request,"forumLogo");
  137. if(logo==null||"".equals(logo.trim()))
  138. throw new Exception("请您填写论坛的logo地址!");
  139. String picURL=ParamUtil.getString(request,"picURL");
  140. if(picURL==null||"".equals(picURL.trim()))
  141. throw new Exception("请您填写论坛图片的目录!");
  142. String faceURL=ParamUtil.getString(request,"faceURL");
  143. if(faceURL==null||"".equals(faceURL.trim()))
  144. throw new Exception("请您填写论坛的表情目录!");
  145. int emailFlag=ParamUtil.getInt(request,"emailFlag",0);
  146. int uploadPic=ParamUtil.getInt(request,"uploadPic",0);
  147. int ipFlag=ParamUtil.getInt(request,"ipFlag",0);
  148. int fromFlag=ParamUtil.getInt(request,"fromFlag",0);
  149. int titleFlag=ParamUtil.getInt(request,"titleFlag",0);
  150. int uploadFlag=ParamUtil.getInt(request,"uploadFlag",0);
  151. int guestUser=ParamUtil.getInt(request,"guestUser",0);
  152. String  openMSG=ParamUtil.getString(request,"openMSG","");
  153. String  announceMaxBytes=ParamUtil.getString(request,"announceMaxBytes","");
  154. String maxAnnouncePerPage=ParamUtil.getString(request,"maxAnnouncePerPage","");
  155. String maxTitleList=ParamUtil.getString(request,"maxTitleList","");
  156. String tableBackColor=ParamUtil.getString(request,"tableBackColor");
  157. String aTableBackColor=ParamUtil.getString(request,"aTableBackColor");
  158. String tableTitleColor=ParamUtil.getString(request,"tableTitleColor");
  159. String aTableTitleColor=ParamUtil.getString(request,"aTableTitleColor");
  160. String tableFontColor=ParamUtil.getString(request,"tableFontColor");
  161. String tableContentColor=ParamUtil.getString(request,"tableContentColor");
  162. String alertFontColor=ParamUtil.getString(request,"alertFontColor");
  163. String contentTitle=ParamUtil.getString(request,"contentTitle");
  164. String tableBodyColor=ParamUtil.getString(request,"tableBodyColor");
  165. String aTableBodyColor=ParamUtil.getString(request,"aTableBodyColor");
  166. String ads1=ParamUtil.getString(request,"ads1","");
  167. String ads2=ParamUtil.getString(request,"ads2","");
  168. String copyRight=ParamUtil.getString(request,"copyRight","");
  169. String version=ParamUtil.getString(request,"version","");
  170. //////////////////////////插入数据库中!//////////////////////////////////
  171. DBConnect dbc=new DBConnect();
  172. String sql="update bbs.config set forumName=?,forumURL=?,companyName=?,hostURL=?,SMTPServer=?n"+
  173. ",systemEmail=?,timeAdjust="+timeAdjust+",scriptTimeOut="+scriptTimeOut+",logo=?n"+
  174. ",picURL=?,faceURL=?,emailFlag="+emailFlag+",uploadPic="+uploadPic+",ipFlag="+ipFlag+"n"+
  175. ",fromFlag="+fromFlag+",uploadFlag="+uploadFlag+",guestUser="+guestUser+"n"+
  176. ",openMSG='"+openMSG+"',maxAnnouncePerPage='"+maxAnnouncePerPage+"'n"+
  177. ",announceMaxBytes='"+announceMaxBytes+"'n"+
  178. ",maxTitleList='"+maxTitleList+"',tableBackColor='"+tableBackColor+"'n"+
  179. ",aTableBackColor='"+aTableBackColor+"',tableTitleColor='"+tableTitleColor+"'n"+
  180. ",aTableTitleColor='"+aTableTitleColor+"',tableFontColor='"+tableFontColor+"'n"+
  181. ",tableContentColor='"+tableContentColor+"',alertFontColor='"+alertFontColor+"'n"+
  182. ",contentTitle='"+contentTitle+"',tableBodyColor='"+tableBodyColor+"'n"+
  183. ",aTableBodyColor='"+aTableBodyColor+"',ads1=?n"+
  184. ",ads2=?,copyRight=?n"+
  185. ",version=?";
  186. dbc.prepareStatement(sql);
  187. dbc.setBytes(1,(new String(forumName.getBytes("ISO-8859-1"),"GBK")).getBytes());
  188. dbc.setBytes(2,(new String(forumURL.getBytes("ISO-8859-1"),"GBK")).getBytes());
  189. dbc.setBytes(3,(new String(companyName.getBytes("ISO-8859-1"),"GBK")).getBytes());
  190. dbc.setBytes(4,(new String(hostURL.getBytes("ISO-8859-1"),"GBK")).getBytes());
  191. dbc.setBytes(5,(new String(SMTPServer.getBytes("ISO-8859-1"),"GBK")).getBytes());
  192. dbc.setBytes(6,(new String(systemEmail.getBytes("ISO-8859-1"),"GBK")).getBytes());
  193. dbc.setBytes(7,(new String(logo.getBytes("ISO-8859-1"),"GBK")).getBytes());
  194. dbc.setBytes(8,(new String(picURL.getBytes("ISO-8859-1"),"GBK")).getBytes());
  195. dbc.setBytes(9,(new String(faceURL.getBytes("ISO-8859-1"),"GBK")).getBytes());
  196. dbc.setBytes(10,(new String(ads1.getBytes("ISO-8859-1"),"GBK")).getBytes());
  197. dbc.setBytes(11,(new String(ads2.getBytes("ISO-8859-1"),"GBK")).getBytes());
  198. dbc.setBytes(12,(new String(copyRight.getBytes("ISO-8859-1"),"GBK")).getBytes());
  199. dbc.setBytes(13,(new String(version.getBytes("ISO-8859-1"),"GBK")).getBytes());
  200. dbc.executeUpdate();
  201. dbc.close();
  202. resetManager();
  203. }
  204. }