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

📄 forummsgadmin.java

📁 BBS论坛设计JSP+MYSQL
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			//
			dbc.close();
		}
	}

	public void unlockMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set locktopic=0 where boardID=" + forumID
					+ " and rootID=" + rootID;
			dbc.executeUpdate(sql);
			url = "dispbbs.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + rootID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "解除锁定");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(rootID));
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}

	public void topMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set istop=1 where boardID=" + forumID
					+ " and rootID=" + rootID;
			dbc.executeUpdate(sql);
			url = "dispbbs.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + rootID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "固顶帖子");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(rootID));
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}

	public void untopMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set istop=0 where boardID=" + forumID
					+ " and rootID=" + rootID;
			dbc.executeUpdate(sql);
			url = "dispbbs.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + rootID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "解除固顶");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(rootID));
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}

	public void allTopMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set istop=2 where boardID=" + forumID
					+ " and rootID=" + rootID;
			dbc.executeUpdate(sql);
			url = "dispbbs.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + rootID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "总固顶帖子");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(rootID));
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}

	public void unAlltopMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set istop=0 where (boardID=" + forumID
					+ " or istop=2) and rootID=" + rootID;
			dbc.executeUpdate(sql);
			url = "dispbbs.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + rootID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "解除总固顶");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(rootID));
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}
	
	public void bestMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set isbest=1 where boardID=" + forumID
					+ " and announceid=" + announceID;
			dbc.executeUpdate(sql);
			url = "showannounce.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + announceID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "加入精华");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(rootID));
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}

	public void unbestMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set isbest=0 where boardID=" + forumID
					+ " and announceid=" + announceID;
			dbc.executeUpdate(sql);
			url = "showannounce.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + announceID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "解除精华");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(rootID));
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}

	public void delMSG() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			sql = "update bbs1 set locktopic=2 where boardID=" + forumID
					+ " and ParentID!=0 and announceid=" + announceID;
			dbc.executeUpdate(sql);
			sql = "select Max(announceid) from bbs1 where  locktopic!=2 and rootID="
					+ rootID + " and boardID=" + forumID;
			ResultSet rs = dbc.executeQuery(sql);
			rs.next();
			int lastPostime = rs.getInt(1);
			rs.close();

			int todayNum;
			sql = "select count(*) from bbs1 where announceid=" + announceID
					+ " and TO_DAYS(dateandtime)=TO_DAYS(now())";
			rs = dbc.executeQuery(sql);
			rs.next();
			todayNum = rs.getInt(1);
			rs.close();

			lastCount(forumID);
			forumNumSub(forumID, 0, 1, todayNum, dbc);

			allForumNumSub(todayNum, 1, 0, dbc);

			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 times=" + lastPostime + " where rootID="
					+ rootID + " and boardID=" + forumID;
			dbc.executeUpdate(sql);
			sql = "update bbs1 set child=child-1 where announceid=" + rootID
					+ " and boardID=" + forumID;
			dbc.executeUpdate(sql);

			sql = "update user set article=article-1,userWealth=userWealth-"
					+ wealthDel + ",userEP=userEP-" + epDel + ",userCP=userCP-"
					+ cpDel + "  where username=?";
			dbc.prepareStatement(sql);
			dbc.setBytes(1, userName.getBytes("GBK"));

			dbc.executeUpdate();
			url = "showannounce.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + announceID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "删除帖子");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(announceID));
			ForumPropertiesManager.resetManager();
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}
	}

	public void delTopic() throws Exception {
		DBConnect dbc = null;
		try {
			dbc = new DBConnect();
			int todayNum, postNum;
			sql = "select count(*) from bbs1 where rootID=" + rootID;
			ResultSet rs = dbc.executeQuery(sql);
			rs.next();
			postNum = rs.getInt(1);
			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();
			int wealthDel = Integer.parseInt(ForumPropertiesManager
					.getString("wealthDel"));

			int epDel = Integer.parseInt(ForumPropertiesManager
					.getString("epDel"));

			int cpDel = Integer.parseInt(ForumPropertiesManager
					.getString("cpDel"));
			sql = "select username from bbs1 where rootID=" + rootID;

			rs = dbc.executeQuery(sql);

			while (rs.next()) {
				String tempName = rs.getString(1);
				if (tempName != null && !"".equals(tempName)) {
					sql = "update user set article=article-1,userWealth=userWealth-"
							+ wealthDel
							+ ",userEP=userEP-"
							+ epDel
							+ " where username=?";
					dbc.prepareStatement(sql);
					dbc.setBytes(1, tempName.getBytes("GBK"));
					dbc.executeUpdate();
				}
			}

			rs.close();
			sql = "update bbs1 set locktopic=2 where rootID=" + rootID;
			dbc.executeUpdate(sql);

			lastCount(forumID);
			forumNumSub(forumID, 1, postNum, todayNum, dbc);
			allForumNumSub(todayNum, postNum, 1, dbc);

			url = "dispbbs.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + rootID;
			sql = "insert into log (l_username,l_content,l_url,l_addtime) values (?,?,'"
					+ url + "','" + DateUtil.getLocalDate() + "')";
			dbc.prepareStatement(sql);
			dbc.setString(1, userName);
			dbc.setString(2, "删除主题");
			dbc.executeUpdate();
			// 清除缓存
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(rootID));
			ForumPropertiesManager.resetManager();
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		} finally {
			dbc.close();
		}

	}

	public void lastCount(int forumID) throws Exception {
		//
		SqlQuery rs = new SqlQuery(
				"select topic,body,rootID,dateandtime,username from bbs1 where locktopic!=2 and boardID="
						+ forumID + " order by announceid desc limit 0,1");
		String lastTopic, body, lastPost, lastPostUser;
		int lastRootID;
		if (rs.next()) {
			lastTopic = rs.getString(1);
			body = rs.getString(2);
			if (lastTopic == null || "".equals(lastTopic)) {
				if (body.length() > 14)
					lastTopic = body.substring(0, 14);
				else
					lastTopic = body;
			}

			lastRootID = rs.getInt(3);
			lastPost = rs.getString(4);
			lastPostUser = rs.getString(5);
		} else {
			lastTopic = "无";
			lastRootID = 0;
			lastPost = Format.getDateTime();
			lastPostUser = "无";
		}
		rs.close();

		sql = "update board set lastTopic='" + lastTopic + "',lastRootID='"
				+ lastRootID + "',lastPosttime='" + lastPost
				+ "',lastPostuser='" + lastPostUser + "' where boardID="
				+ forumID;
		rs.doUpdate(sql);
	}

	public void forumNumAdd(int forumID, int topicNum, int postNum,
			int todayNum, DBConnect dbc) throws Exception {
		sql = "update board set lastbbsnum=lastbbsnum+" + postNum
				+ ",lastTopicNum=lastTopicNum+" + topicNum
				+ ",todayNum=todayNum+" + todayNum + " where boardID="
				+ forumID;
		dbc.executeUpdate(sql);
	}

	// '版面发帖数减少
	public void forumNumSub(int forumID, int topicNum, int postNum,
			int todayNum, DBConnect dbc) throws Exception {
		sql = "update board set lastbbsnum=lastbbsnum-" + postNum
				+ ",lastTopicNum=lastTopicNum-" + topicNum
				+ ",todayNum=todayNum-" + todayNum + " where boardID="
				+ forumID;
		// 
		dbc.executeUpdate(sql);
	}

	// '所有论坛发帖数增加
	public void allForumNumAdd(int todayNum, int postNum, int topicNum,
			DBConnect dbc) throws Exception {
		sql = "update config set TodayNum=todayNum+" + todayNum
				+ ",BbsNum=bbsNum+" + postNum + ",TopicNum=topicNum+"
				+ topicNum;
		dbc.executeUpdate(sql);
	}

	// '所有论坛发帖数减少
	public void allForumNumSub(int todayNum, int postNum, int topicNum,
			DBConnect dbc) throws Exception {
		sql = "update config set TodayNum=todayNum-" + todayNum
				+ ",BbsNum=bbsNum-" + postNum + ",TopicNum=topicNum-"
				+ topicNum;
		dbc.executeUpdate(sql);
	}

}

⌨️ 快捷键说明

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