⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forummsgadmin.java

📁 源码 / 社区论坛 阿菜java论坛
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package net.acai.forum.admin;
/**
 * Title:        阿菜网络
 * Description:
 * Copyright:    Copyright (c) 2002
 * Company:      www.justhis.com
 * @author:       acai
 * @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 bbs1 where boardID="+forumID+" and username=?";
		dbc.prepareStatement(sql);
		dbc.setBytes(1,username.getBytes("GBK"));
		
		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 bbs1 set locktopic=2 where boardID="+forumID+" and  username=?";
			dbc.prepareStatement(sql);
			dbc.setBytes(1,username.getBytes("GBK"));
			dbc.executeUpdate();
			sql="update user set article=article-"+titlenum+",userWealth=userWealth-"+(titlenum*wealthDel)+",userEP=userEP-"+(titlenum*epDel)+",userCP=userCP-"+(titlenum*cpDel)+" where username=?";
			dbc.prepareStatement(sql);
			dbc.setBytes(1,username.getBytes("GBK"));
			dbc.executeUpdate();


			sql="select count(announceid) from bbs1 where boardID="+forumID;
			rs=dbc.executeQuery(sql);
			rs.next();
			int NewAnnounceNum=rs.getInt(1);
			rs.close();

			sql="select count(announceid) from bbs1 where ParentID=0 and boardID="+forumID;
			rs=dbc.executeQuery(sql);
			rs.next();
			int NewTopicNum=rs.getInt(1);
			rs.close();

			sql="update 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 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 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 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,username.getBytes("GBK"));
		dbc.setBytes(2,newtopic.getBytes("GBK"));
		dbc.setBytes(3,body.getBytes("GBK"));
		dbc.executeUpdate();

		
		sql="select announceID from bbs1 order by announceID desc";
		rs=dbc.executeQuery(sql);
		rs.next();
		announceid=rs.getInt(1);
		rs.close();

		sql="update bbs1 set rootID="+announceid+",times="+announceid+" where announceID="+announceid;
		dbc.executeUpdate(sql);


		int postNum,todayNum;
		
		sql="select count(*) from bbs1 where rootID="+rootID;
		dbc.prepareStatement(sql);
		rs=dbc.executeQuery();
		rs.next();
		postNum=rs.getInt(1);
		rs.close();
		
		sql="select count(*) from bbs1 where rootID="+rootID+" and TO_DAYS(dateandtime)=TO_DAYS(now())";
		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 log (l_username,l_content,l_url) values (?,?,'"+url+"')";
		dbc.prepareStatement(sql);
		dbc.setBytes(1,userName.getBytes("GBK"));
		dbc.setBytes(2,"拷贝帖子".getBytes("GBK"));
		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 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 bbs1 where announceid="+rootID;
			dbc.prepareStatement(sql);
			rs=dbc.executeQuery();
			rs.next();
			newtopic=rs.getString(1)+ "-->" + userName + "转移";
			rs.close();
			
			sql="update bbs1 set topic=? where announceid="+rootID;
			dbc.prepareStatement(sql);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -