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

📄 forum.java

📁 BBS论坛设计JSP+MYSQL
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
							String.valueOf(aid), theMSG);
				}
				//
				String un = rs.getString(2);
				User msgUser = (User) CacheManager.getCache(ENV.FORUM_USER)
						.get(un);
				if (msgUser == null) {
					msgUser = new User();
					SqlQuery userRs = new SqlQuery(
							" select U.username,U.useremail,U.homepage,U.oicq,U.sign,U.userclass, "
									+ " U.title,U.width,U.height,U.article,U.face,U.addDate, "
									+ " U.userWealth,U.userEP,U.userCP from user U where username='"
									+ un + "'");
					userRs.next();
					msgUser.setUserName(un);
					msgUser.setUserEmail(userRs.getString(2));
					msgUser.setHomePage(userRs.getString(3));
					msgUser.setOicq(userRs.getString(4));
					msgUser.setSign(userRs.getString(5));
					msgUser.setUserClass(userRs.getInt(6));
					msgUser.setTitle(userRs.getString(7));
					msgUser.setWidth(userRs.getInt(8));
					msgUser.setHeight(userRs.getInt(9));
					msgUser.setArticle(userRs.getInt(10));
					msgUser.setFace(userRs.getString(11));
					msgUser.setAddDate(userRs.getString(12));
					msgUser.setUserWealth(userRs.getInt(13));
					msgUser.setUserEP(userRs.getInt(14));
					msgUser.setUserCP(userRs.getInt(15));
					CacheManager.getCache(ENV.FORUM_USER).put(un, msgUser);
				}
				theMSG.setUser(msgUser);
				//
				forumMSGs.add(theMSG);
			}
			sql = "update bbs1 set hits=hits+1 where announceID=" + announceID;
			rs.doUpdate(sql);

		} catch (Exception e) {
			log.error(e);
			throw new ForumMSGNotFoundException("无效帖子或者该帖子已经被删除!");
		} finally {
			rs.close();
		}
		return forumMSGs;
	}

	public static Vector getForumTextMSGs(HttpServletRequest request)
			throws ForumMSGNotFoundException {
		SqlQuery rs = new SqlQuery();
		Vector forumMSGs = new Vector();
		try {
			int forumID, rootID;
			try {
				forumID = ParamUtil.getInt(request, "forumID");
				rootID = ParamUtil.getInt(request, "rootID");

			} catch (Exception e) {
				throw new Exception("对不起,没有发现帖子!");
			}

			String sql = "Select announceid from bbs1 where rootid=" + rootID + " order by announceid";

			rs.doQuery(sql);

			while (rs.next()) {
				int aid = rs.getInt(1);
				ForumMSG theMSG = (ForumMSG) CacheManager.getCache(
						ENV.FORUM_NEWS).get(String.valueOf(aid));
				if (theMSG == null) {
					theMSG = new ForumMSG(aid);
					CacheManager.getCache(ENV.FORUM_NEWS).put(
							String.valueOf(aid), theMSG);
				}
				forumMSGs.add(theMSG);
			}
		} catch (Exception e) {
			log.error(e);
			throw new ForumMSGNotFoundException(e.getMessage());
		} finally {
			rs.close();
		}
		return forumMSGs;
	}

	public int getForumMSGsNum() {
		return this.forumMSGsNum;
	}

	public int getForumTopicNum() {
		return forumTopicNum;
	}

	public int getForumID() {
		return forumID;
	}

	public String getForumType() {
		return forumType;
	}

	public int getForumClass() {
		return forumClass;
	}

	public String getReadMe() {
		return readMe;
	}

	public String getForumMaster() {
		return forumMaster;
	}

	public int getLockForum() {
		return lockForum;
	}

	public int getForumSkin() {
		return forumSkin;
	}

	public String getTableBack() {
		return tableBack;
	}

	public String getTableTitle() {
		return tableTitle;
	}

	public String getTableBody() {
		return tableBody;
	}

	public String getATableBody() {
		return aTableBody;
	}

	public String getTableFont() {
		return tableFont;
	}

	public String getTableContent() {
		return tableContent;
	}

	public String getAlertFont() {
		return alertFont;
	}

	public String getLastPostUser() {
		return lastPostUser;
	}

	public String getLastPostTime() {
		return lastPostTime;
	}

	public int getLastBbsNum() {
		return lastBbsNum;
	}

	public int getLastTopicNum() {
		return lastTopicNum;
	}

	public boolean getStrAllowForumCode() {
		if (strAllowForumCode == 1)
			return true;
		else
			return false;
	}

	public boolean getStrAllowHTML() {
		if (strAllowHTML == 1)
			return true;
		else
			return false;
	}

	public boolean getStrIMGInPosts() {
		if (strIMGInPosts == 1)
			return true;
		else
			return false;
	}

	public boolean getStrIcons() {
		if (strIcons == 1)
			return true;
		else
			return false;
	}

	public boolean getStrFlash() {
		if (strFlash == 1)
			return true;
		else
			return false;
	}

	public String getForumLogo() {
		return forumLogo;
	}

	public String getIndexIMG() {
		return indexIMG;
	}

	public int getLastRootID() {
		return lastRootID;
	}

	public String getLastTopic() {
		return StringUtils.escapeHTMLTags(this.lastTopic);
	}

	public int getTodayNum() {
		return todayNum;
	}

	public String getForumUser() {
		return forumUser;
	}

	public Vector getForumOLUsers() {
		return forumOLUsers;
	}

	public int getForumOLGuestUsersNum() {
		return this.forumOLGuestUsersNum;
	}

	public int getForumOLMemberUsersNum() {
		return this.forumOLMemberUsersNum;
	}

	public int getForumsOLUsersNum() {
		return this.forumsOLUsersNum;
	}

	public String getForumIMG(String lastlogin) {
		String strIMG = "";
		switch (this.getForumSkin()) {
		case 1:
			if (Format.compareTo(lastlogin, this.lastPostTime))
				strIMG = "<img src=pic/foldernew.gif alt=常规论坛,有新帖子>";
			else
				strIMG = "<img src=pic/ifolder.gif alt=常规论坛,无新帖子>";
			break;
		case 2:
			if (Format.compareTo(lastlogin, this.lastPostTime))
				strIMG = "<img src=pic/folderallnew.gif alt=开放论坛,有新帖子>";
			else
				strIMG = "<img src=pic/folderall.gif alt=开放论坛,无新帖子>";
			break;
		case 3:
			if (Format.compareTo(lastlogin, this.lastPostTime))
				strIMG = "<img src=pic/follownew.gif alt=评论论坛,有新帖子>";
			else
				strIMG = "<img src=pic/follow.gif alt=评论论坛,无新帖子>";
			break;
		case 4:
			if (Format.compareTo(lastlogin, this.lastPostTime))
				strIMG = "<img src=pic/jinghua.gif alt=精华区,有新帖子>";
			else
				strIMG = "<img src=pic/jinghua.gif alt=精华区,无新帖子>";
			break;
		case 5:
			if (Format.compareTo(lastlogin, this.lastPostTime))
				strIMG = "<img src=pic/lock_l.gif alt=认证论坛,有新帖子>";
			else
				strIMG = "<img src=pic/lock_b.gif alt=认证论坛,无新帖子>";
			break;
		case 6:
			if (Format.compareTo(lastlogin, this.lastPostTime))
				strIMG = "<img src=pic/foldernew.gif alt=正规论坛,有新帖子>";
			else
				strIMG = "<img src=pic/ifolder.gif alt=正规论坛,无新帖子>";
			break;
		default:
		}

		return strIMG;
	}

	public String authorSaveMSG(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		SqlQuery rs = new SqlQuery();
		DBConnect dbc = null;
		String userName = ParamUtil.getString(request, "userName", "");
		String sql = "";
		String char_changed = "[align=right][此贴子已经被作者于" + Format.getDateTime()
				+ "编辑过][/align]";
		char_changed = SysUtil.encodeInDB(char_changed);
		try {
			dbc = new DBConnect();
			// 修改帖子
			SkinUtil.checkUser(request, response, 4);
			//
			int forumID = ParamUtil.getInt(request, "forumID");
			int announceID = ParamUtil.getInt(request, "announceID");
			int rootID = ParamUtil.getInt(request, "rootID");
			sql = "select * from bbs1 where announceID=" + announceID
					+ " and rootID=" + rootID + " and userName='" + userName
					+ "'";
			if (!rs.isExists(sql))
				throw new Exception("<li>对不起,您没有权利编辑此帖子!</li>");
			String subject = ParamUtil.getString(request, "subject", "");
			subject = StringUtil.changeToFull(subject);
			String content = ParamUtil.getString(request, "content", "")
					+ "\n\n\n\n" + char_changed;
			String expression = ParamUtil.getString(request, "expression", "");
			int signFlag = ParamUtil.getInt(request, "signFlag", 1);
			int emailFlag = ParamUtil.getInt(request, "emailFlag", 0);
			if (subject.equals("")){
				throw new Exception("没有主体文字");
			}
			sql = "update bbs1 set Topic=?,Body=?,DateAndTime=now(),length=?,ip=?,expression=?,signflag=?,emailflag=? where announceID=?";
			dbc.prepareStatement(sql);
			dbc.setString(1, subject);
			dbc.setString(2, content);
			dbc.setInt(3, content.length());
			dbc.setString(4, request.getRemoteAddr());
			dbc.setString(5, expression);
			dbc.setInt(6, signFlag);
			dbc.setInt(7, emailFlag);
			dbc.setInt(8, announceID);
			//
			dbc.executeUpdate();
			// 缓存
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(announceID));
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(
					String.valueOf(announceID));
			return "dispbbs.jsp?forumID=" + forumID + "&rootID=" + rootID
					+ "&announceID=" + announceID + "#" + announceID;
		} catch (UserNotFoundException e) {
			throw new Exception("没有发现用户");
		} catch (Exception e) {
			log.error(e);
			throw new Exception(e.getMessage());
		} finally {
			dbc.close();
		}
	}

	public String masterSaveMSG(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		DBConnect dbc = null;
		String userName = GCookie.getCookieValue(request, "UJBBUName", "");
		String sql = "";
		String char_changed = "[align=right][此贴子已经被" + userName + "于"
				+ Format.getDateTime() + "编辑过][/align]";
		char_changed = SysUtil.encodeInDB(char_changed);
		try {
			dbc = new DBConnect();
			// 修改帖子
			SkinUtil.checkUser(request, response, 4);
			//
			int forumID = ParamUtil.getInt(request, "forumID");
			int announceID = ParamUtil.getInt(request, "announceID");
			int rootID = ParamUtil.getInt(request, "rootID");

			String subject = ParamUtil.getString(request, "subject", "");
			subject = StringUtil.changeToFull(subject);
			String content = ParamUtil.getString(request, "content", "")
					+ "\n\n\n\n" + char_changed;
			String expression = ParamUtil.getString(request, "expression", "");
			int signFlag = ParamUtil.getInt(request, "signFlag", 1);
			int emailFlag = ParamUtil.getInt(request, "emailFlag", 0);
			if (subject.equals("")){
				throw new Exception("没有主体文字");
			}
			sql = "update bbs1 set Topic=?,Body=?,DateAndTime=now(),length=?,ip=?,expression=?,signflag=?,emailflag=? where announceID=?";
			dbc.prepareStatement(sql);
			dbc.setString(1, subject);
			dbc.setString(2, content);
			dbc.setInt(3, content.length());
			dbc.setString(4, request.getRemoteAddr());
			dbc.setString(5, expression);
			dbc.setInt(6, signFlag);
			dbc.setInt(7, emailFlag);
			dbc.setInt(8, announceID);
			//			
			dbc.executeUpdate();
			// 缓存
			CacheManager.getCache(ENV.FORUM_NEWS).remove(
					String.valueOf(announceID));
			CacheManager.getCache(ENV.FORUM_TOPIC).remove(

⌨️ 快捷键说明

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