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

Java书籍

开发平台:

Java

  1. package net.acai.forum.admin;
  2. /**
  3.  * Title:        清清网络
  4.  * Description:
  5.  * Copyright:    Copyright (c) 2002
  6.  * Company:      www.SuperSpace.com
  7.  * @author:       SuperSpace
  8.  * @version 1.0
  9.  */
  10. import net.acai.forum.*;
  11. import net.acai.database.*;
  12. import javax.servlet.http.*;
  13. import java.sql.*;
  14. import net.acai.util.*;
  15. public class ForumNewsAdmin
  16. {
  17. int forumID;
  18. String userName,sql;
  19. User theUser;
  20. public ForumNewsAdmin(HttpServletRequest request,HttpServletResponse response) throws Exception{
  21. userName=GCookie.getCookieValue(request,"UJBBUName","");
  22. theUser=SkinUtil.checkUser(request,response,4);
  23. checkAdmin(request,response);
  24. adminNews(request,response);
  25. }
  26. public void checkAdmin(HttpServletRequest request,HttpServletResponse response) throws Exception{
  27. forumID=ParamUtil.getInt(request,"forumID");
  28. if(forumID==0){
  29. if(theUser.getUserClass()<20)
  30. throw new Exception("请指定论坛版面");
  31. }
  32. else{
  33. Forum theForum=new Forum(forumID);
  34. if((theForum==null||theForum.getForumMaster().indexOf(userName)<0)&&theUser.getUserClass()<20)
  35. throw new Exception("您不是该版面斑竹或者系统管理员。");
  36. }
  37. }
  38. public void adminNews(HttpServletRequest request,HttpServletResponse response) throws Exception {
  39. String action=ParamUtil.getString(request,"action");
  40. if(action==null||"".equals(action))
  41. return;
  42. if(action.equals("new"))
  43. saveNews(request);
  44. else if(action.equals("update"))
  45. updateNews(request);
  46. else if(action.equals("del"))
  47. delNews(request);
  48. else if(action.equals("saveditbm"))
  49. saveForumMaster(request);
  50. else if(action.equals("savebmset"))
  51. saveForumInfo(request);
  52. else if(action.equals("savebmcolor"))
  53. saveForumColor(request);
  54. }
  55. public void  saveNews(HttpServletRequest request) throws Exception{
  56. String title=ParamUtil.getString(request,"title");
  57. if(title==null||"".equals(title.trim()))
  58. throw new Exception("请输入新闻标题。");
  59. String content=ParamUtil.getString(request,"content");
  60. if(content==null||"".equals(content.trim()))
  61. throw new Exception("请输入新闻内容。");
  62. sql="insert into bbs.bbsnews(userName,title,content,addtime,boardID) values(?,?,?,getdate(),"+forumID+")";
  63. DBConnect dbc=new DBConnect();
  64. dbc.prepareStatement(sql);
  65. dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
  66. dbc.setBytes(2,(new String(title.getBytes("ISO-8859-1"),"GBK")).getBytes());
  67. dbc.setBytes(3,(new String(content.getBytes("ISO-8859-1"),"GBK")).getBytes());
  68. dbc.executeUpdate();
  69. dbc.close();
  70. }
  71. public void updateNews(HttpServletRequest request) throws Exception{
  72. String title=ParamUtil.getString(request,"title");
  73. if(title==null||"".equals(title.trim()))
  74. throw new Exception("请输入新闻标题。");
  75. String content=ParamUtil.getString(request,"content");
  76. if(content==null||"".equals(content.trim()))
  77. throw new Exception("请输入新闻内容。");
  78. int newsID=ParamUtil.getInt(request,"newsID");
  79. sql="update bbs.bbsnews set username=?,title=?,content=?,addtime=getdate(),boardID="+forumID+" where ID="+newsID;
  80. DBConnect dbc=new DBConnect();
  81. dbc.prepareStatement(sql);
  82. dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
  83. dbc.setBytes(2,(new String(title.getBytes("ISO-8859-1"),"GBK")).getBytes());
  84. dbc.setBytes(3,(new String(content.getBytes("ISO-8859-1"),"GBK")).getBytes());
  85. dbc.executeUpdate();
  86. dbc.close();
  87. }
  88. public void delNews(HttpServletRequest request) throws Exception{
  89. int newsID=ParamUtil.getInt(request,"newsID");
  90. sql="delete from bbs.bbsnews where ID="+newsID;
  91. DBConnect dbc=new DBConnect();
  92. dbc.prepareStatement(sql);
  93. dbc.executeUpdate();
  94. dbc.close();
  95. }
  96. public void saveForumMaster(HttpServletRequest request) throws Exception{
  97. String boardmaster=ParamUtil.getString(request,"boardmaster","");
  98. String readme=ParamUtil.getString(request,"readme","");
  99. sql = "update bbs.board set boardmaster=?,readme=? where boardID="+forumID;
  100. DBConnect dbc=new DBConnect();
  101. dbc.prepareStatement(sql);
  102. dbc.setBytes(1,(new String(boardmaster.getBytes("ISO-8859-1"),"GBK")).getBytes());
  103. dbc.setBytes(2,(new String(readme.getBytes("ISO-8859-1"),"GBK")).getBytes());
  104. dbc.executeUpdate();
  105. dbc.close();
  106. }
  107. public void saveForumInfo(HttpServletRequest request) throws Exception{
  108. /*
  109. Forum_Setting=TimeAdjust & "," & ScriptTimeOut & "," & EmailFlag & "," & request("Uploadpic") & "," & request("IpFlag") & "," & request("FromFlag") & "," & TitleFlag & "," & uploadFlag & "," & kicktime & "," & request("guestlogin") & "," & openmsg & "," & request("MaxAnnouncePerPage") & "," & request("Maxtitlelist") & "," & request("AnnounceMaxBytes") & "," & request("online_u") & "," & request("online_g") & "," & LinkFlag & "," & request("TopicFlag") & "," & request("VoteFlag") & "," & request("ReflashFlag") & "," & request("ReflashTime") & "," & ForumStop & "," & RegTime & "," & EmailReg & "," & EmailRegOne & "," & RegFlag & "," & online_n & "," & ViewUser_g & "," & ViewUser_u & "," & BirthFlag & "," & request("runtime") & "," & FastLogin & "," & GroupFlag & "," & request("uploadsize") & "," & request("strAllowForumCode") & "," & request("strAllowHTML") & "," & request("strIMGInPosts") & "," & request("strIcons") & "," & request("strflash") & "," & request("vote_num") & "," & facenum & "," & imgnum & "," & request("relaypost") & "," & request("relayposttime") & "," & facename & "," & imgname & "," & smsflag & "," & SendRegEmail & "," & request("Search_G") & "," & bmFlag_1 & "," & bmFlag_2 & "," & bmFlag_3 & "," & bmFlag_4 & "," & bmFlag_5 & "," & RegFaceNum & "," & request("viewcolor")
  110. 'response.write forum_setting
  111. 'response.end
  112. sql="update board set Forum_Setting='"&Forum_Setting&"',Forum_upload='"&request("Forum_upload")&"' where forumID="&request("forumID")
  113. conn.execute(sql)
  114. response.write "设置成功。"*/
  115. }
  116. public void saveForumColor(HttpServletRequest request) throws Exception{
  117. /*
  118. Forum_body=request("tableBackColor") & "," & request("aTablebackcolor") & "," & request("tableTitleColor") & "," & request("aTableTitleColor") & "," & request("tableBodyColor") & "," & request("aTablebodycolor") & "," & request("tableFontColor") & "," & request("tableContentColor") & "," & request("AlertFontColor") & "," & request("ContentTitle") & "," & request("AlertFontColor") & "," & request("ForumBody") & "," & request("tableWidth") & "," & request("bodyFontColor") & "," & request("BoardLinkColor") & "," & request("user_fc") & "," & request("user_mc") & "," & request("bmaster_fc") & "," & request("bmaster_mc") & "," & request("master_fc") & "," & request("master_mc") & "," & request("vip_fc") & "," & request("vip_mc")
  119. 'response.write Forum_body
  120. 'response.end
  121. sql = "update board set Forum_body='"&Forum_body&"' where forumID="&request("forumID")
  122. conn.execute(sql)
  123. response.write "设置成功!"*/
  124. }
  125. }