?? forummsgadmin.java
字號:
package net.acai.forum.admin;
/**
* Title: 清清網絡
* Description:
* Copyright: Copyright (c) 2002
* Company: www.SuperSpace.com
* @author: SuperSpace
* @version 1.0
*/
import net.acai.forum.*;
import net.acai.database.*;
import javax.servlet.http.*;
import java.sql.*;
import net.acai.util.*;
public class ForumMSGAdmin
{ int forumID,rootID,announceID;
String userName,sql,url,action;
User theUser;
public ForumMSGAdmin(){
}
public ForumMSGAdmin(HttpServletRequest request,HttpServletResponse response) throws Exception{
userName=GCookie.getCookieValue(request,"UJBBUName","");
theUser=SkinUtil.checkUser(request,response,4);
checkAdmin(request,response);
adminMSG(request,response);
}
public void checkAdmin(HttpServletRequest request,HttpServletResponse response) throws Exception{
action=ParamUtil.getString(request,"action");
if(action==null||"".equals(action))
throw new Exception("錯誤請求!");
forumID=ParamUtil.getInt(request,"forumID");
if(!action.equals("delall")){
rootID=ParamUtil.getInt(request,"rootID");
announceID=ParamUtil.getInt(request,"announceID");
}
if(forumID==0)
throw new Exception("請指定論壇版面");
Forum theForum=new Forum(forumID);
if(theForum==null||(theForum.getForumMaster().indexOf(userName)<0&&theUser.getUserClass()<20))
throw new Exception("您不是該版面斑竹或者系統管理員。");
}
public void adminMSG(HttpServletRequest request,HttpServletResponse response) throws Exception{
if (action.equals("lock"))
lockMSG();
else if (action.equals("unlock"))
unlockMSG();
else if (action.equals("deltopic"))
delTopic();
else if (action.equals("move")){
String tempString=ParamUtil.getString(request,"checked");
if(tempString!=null&&"yes".equals(tempString))
moveTopic(request);
else
return;
}
else if (action.equals("delall")){
String tempString=ParamUtil.getString(request,"checked");
if(tempString!=null&&"yes".equals(tempString))
delAll(request);
else
return;
}
else if (action.equals("copy")){
String tempString=ParamUtil.getString(request,"checked");
if(tempString!=null&&"yes".equals(tempString))
copyTopic(request);
}
else if (action.equals("top"))
topMSG();
else if (action.equals("untop"))
untopMSG();
else if (action.equals("delmsg" ))
delMSG();
else if (action.equals("isbest"))
bestMSG();
else if (action.equals("nobest" ))
unbestMSG();
else
throw new Exception ("請選擇相應操作。");
}
public void delAll(HttpServletRequest request) throws Exception{
String username=ParamUtil.getString(request,"username");
if(username==null||"".equals(username))
throw new Exception("請輸入被帖子刪除用戶名。");
DBConnect dbc=new DBConnect();
sql="Select Count(announceID) from bbs.bbs1 where boardID="+forumID+" and username=?";
dbc.prepareStatement(sql);
dbc.setBytes(1,(new String(username.getBytes("ISO-8859-1"),"GBK")).getBytes());
ResultSet rs=dbc.executeQuery();
rs.next();
int titlenum=rs.getInt(1);
rs.close();
if(titlenum!=0){
int wealthDel=Integer.parseInt(ForumPropertiesManager.getString("wealthDel"));
int epDel=Integer.parseInt(ForumPropertiesManager.getString("epDel"));
int cpDel=Integer.parseInt(ForumPropertiesManager.getString("cpDel"));
sql="update bbs.bbs1 set locktopic=2 where boardID="+forumID+" and username=?";
dbc.prepareStatement(sql);
dbc.setBytes(1,(new String(username.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.executeUpdate();
sql="update bbs.myuser set article=article-"+titlenum+",userWealth=userWealth-"+(titlenum*wealthDel)+",userEP=userEP-"+(titlenum*epDel)+",userCP=userCP-"+(titlenum*cpDel)+" where username=?";
dbc.prepareStatement(sql);
dbc.setBytes(1,(new String(username.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.executeUpdate();
sql="select count(announceid) from bbs.bbs1 where boardID="+forumID;
rs=dbc.executeQuery(sql);
rs.next();
int NewAnnounceNum=rs.getInt(1);
rs.close();
sql="select count(announceid) from bbs.bbs1 where ParentID=0 and boardID="+forumID;
rs=dbc.executeQuery(sql);
rs.next();
int NewTopicNum=rs.getInt(1);
rs.close();
sql="update bbs.board set lastbbsnum="+NewAnnounceNum+",lasttopicnum="+NewTopicNum+" where boardID="+forumID;
dbc.executeUpdate();
}
dbc.close();
}
public void copyTopic(HttpServletRequest request) throws Exception{
int newForumID=ParamUtil.getInt(request,"newForumID");
DBConnect dbc=new DBConnect();
ResultSet rs;
if (forumID==newForumID){
dbc.close();
throw new Exception("不能在相同版面內進行轉移操作。");
}
else{
sql="select boardID,announceid,Parentid from bbs.bbs1 where announceid="+announceID+" and boardID="+forumID;
dbc.prepareStatement(sql);
rs=dbc.executeQuery();
if(!rs.next()){
dbc.close();
throw new Exception ("您選擇的貼子并不存在。");
}
else {
//rs.next();
if(rs.getInt(3)!=0){
dbc.close();
throw new Exception("您必須選擇一個主題,而不是貼子。");
}
}
}
String newtopic,username,body,dateandtime,ip,Expression;
int msgLength, announceid;
sql="select topic,username,body,dateAndTime,length,ip,Expression from bbs.bbs1 where announceid="+announceID;
rs=dbc.executeQuery(sql);
if(!rs.next()){
dbc.close();
throw new Exception("沒有此貼!");
}
//rs.next();
newtopic=rs.getString(1) + "-->" + userName + "添加";
username=rs.getString(2);
body=rs.getString(3);
dateandtime=rs.getString(4);
msgLength=rs.getInt(5);
ip=rs.getString(6);
Expression=rs.getString(7);
rs.close();
sql="insert into bbs.bbs1(boardID,parentID,child,userName,topic,\n body,dateandtime,hits,length,rootID,layer,orders,ip,Expression,locktopic,signflag,emailflag,times,isvote,istop,isbest) \n values("+newForumID+",0,0,?,?,?,'"+dateandtime+"', 0,"+msgLength+",0,1,0,'"+ip+"','"+Expression+"',\n 0,0,0,0,0,0,0)";
dbc.prepareStatement(sql);
dbc.setBytes(1,(new String(username.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(2,(new String(newtopic.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(3,(new String(body.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.executeUpdate();
sql="select announceID from bbs.bbs1 order by announceID desc";
rs=dbc.executeQuery(sql);
rs.next();
announceid=rs.getInt(1);
rs.close();
sql="update bbs.bbs1 set rootID="+announceid+",times="+announceid+" where announceID="+announceid;
dbc.executeUpdate(sql);
int postNum,todayNum;
sql="select count(*) from bbs.bbs1 where rootID="+rootID;
dbc.prepareStatement(sql);
rs=dbc.executeQuery();
rs.next();
postNum=rs.getInt(1);
rs.close();
sql="select count(*) from bbs.bbs1 where rootID="+rootID+" and day(dateandtime)=day(getdate())";
rs=dbc.executeQuery(sql);
rs.next();
todayNum=rs.getInt(1);
rs.close();
//'更新論壇貼子數據
//LastCount(forumID)
//LastCount(newForumID)
//call BoardNumAdd(newForumID,1,postNum,todayNum)
//call AllboardNumAdd(todayNum,postNum,1)
lastCount(forumID);
lastCount(newForumID);
forumNumAdd(newForumID,0,1,todayNum,dbc);
allForumNumAdd(todayNum,1,0,dbc);
url="dispbbs.jsp?forumID="+newForumID+"&rootID="+announceid+"&announceID="+announceid;
sql="insert into bbs.log (l_username,l_content,l_url) values (?,?,'"+url+"')";
dbc.prepareStatement(sql);
dbc.setBytes(1,(new String(userName.getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.setBytes(2,(new String("拷貝帖子".getBytes("ISO-8859-1"),"GBK")).getBytes());
dbc.executeUpdate();
dbc.close();
ForumPropertiesManager.resetManager();
}
public void moveTopic(HttpServletRequest request) throws Exception{
int newForumID=ParamUtil.getInt(request,"newForumID");
DBConnect dbc=new DBConnect();
ResultSet rs;
if (forumID==newForumID){
dbc.close();
throw new Exception("不能在相同版面內進行轉移操作。");
}
else{
sql="select boardID,announceid,Parentid from bbs.bbs1 where announceid="+announceID+" and boardID="+forumID;
dbc.prepareStatement(sql);
rs=dbc.executeQuery();
if(!rs.next()){
dbc.close();
throw new Exception ("您選擇的貼子并不存在。");
}
else {
//rs.next();
if(rs.getInt(3)!=0){
dbc.close();
throw new Exception("您必須選擇一個主題,而不是貼子。");
}
}
}
String leavemessage=ParamUtil.getString(request,"leavemessage");
if(leavemessage==null||leavemessage.equals("")){
dbc.close();
throw new Exception("請選擇相應的操作!");
}
if (leavemessage.equals("yes")) {
//'ON ERROR RESUME NEXT
}
else if (leavemessage.equals("no")) {
String newtopic;
sql="select topic from bbs.bbs1 where announceid="+rootID;
dbc.prepareStatement(sql);
rs=dbc.executeQuery();
rs.next();
newtopic=rs.getString(1)+ "-->" + userName + "轉移";
rs.close();
sql="update bbs.bbs1 set topic=? where announceid="+rootID;
dbc.prepareStatement(sql);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -