亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bbsuseraction.java

?? 個人Blog java編寫的Blog可以直接使用!
?? JAVA
字號:
/*
 *  BBSReplyDAO.java
 *  
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *  
 *  Author: Winter Lau (javayou@gmail.com)
 *  http://dlog4j.sourceforge.net
 */
package com.liusoft.dlog4j.action;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.liusoft.dlog4j.DLOGSecurityManager;
import com.liusoft.dlog4j.TextCacheManager;
import com.liusoft.dlog4j.base.ClientInfo;
import com.liusoft.dlog4j.beans.ForumBean;
import com.liusoft.dlog4j.beans.SiteBean;
import com.liusoft.dlog4j.beans.TopicBean;
import com.liusoft.dlog4j.beans.TopicOutlineBean;
import com.liusoft.dlog4j.beans.TopicReplyBean;
import com.liusoft.dlog4j.beans.UserBean;
import com.liusoft.dlog4j.dao.BBSForumDAO;
import com.liusoft.dlog4j.dao.BBSReplyDAO;
import com.liusoft.dlog4j.dao.BBSTopicDAO;
import com.liusoft.dlog4j.formbean.BBSReplyForm;
import com.liusoft.dlog4j.formbean.BBSTopicForm;
import com.liusoft.dlog4j.search.SearchProxy;
import com.liusoft.dlog4j.util.StringUtils;

/**
 * BBS用戶操作的Action
 * 
 * @author Winter Lau
 */
public class BBSUserAction extends ActionBase {

	/**
	 * 刪除回帖
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doDeleteTopic(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		BBSTopicForm tform = (BBSTopicForm) form;

		while (true) {
			UserBean loginUser = super.getLoginUser(request, response);
			if (loginUser == null)
				break;
			TopicOutlineBean tbean = BBSTopicDAO.getTopicOutlineByID(tform
					.getId());
			if (tbean == null)
				break;
			if (tbean.getUser().getId() != loginUser.getId()
					&& loginUser.getOwnSiteId() != tform.getSid())
				break;
			BBSTopicDAO.delete(tbean);
			TopicBean topic = new TopicBean();
			topic.setId(tbean.getId());
			SearchProxy.remove(topic);
			break;
		}
		StringBuffer ext = new StringBuffer();
		ext.append("fid=");
		ext.append(tform.getForum());
		return makeForward(mapping.findForward("forum"), tform.getSid(), ext
				.toString());
	}

	/**
	 * 回復帖子
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doPublishReply(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		BBSReplyForm rform = (BBSReplyForm) form;
		super.validateClientId(request, rform);
		ActionMessages msgs = new ActionMessages();
		while (true) {
			if (StringUtils.isEmpty(rform.getTitle())) {
				msgs.add("title", new ActionMessage("error.empty_not_allowed"));
				break;
			}
			if (StringUtils.isEmpty(rform.getContent())) {
				msgs.add("content", new ActionMessage("error.empty_not_allowed"));
				break;
			}
			UserBean loginUser = super.getLoginUser(request, response);
			if (loginUser == null) {
				msgs.add("reply", new ActionMessage("error.user_not_login"));
				break;
			}
			if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
				msgs.add("reply", new ActionMessage("error.user_not_available"));
				break;
			}
			SiteBean site = getSiteByID(rform.getSid());
			if (site == null) {
				msgs.add("reply", new ActionMessage("error.site_not_available"));
				break;
			}
			//檢查黑名單
			if(isUserInBlackList(site, loginUser)){
				msgs.add("reply", new ActionMessage("error.user_in_blacklist"));
				break;
			}
			TopicOutlineBean topic = BBSTopicDAO.getTopicOutlineByID(rform.getTid());
			if (topic == null
					|| topic.getStatus() != TopicBean.STATUS_NORMAL
					|| topic.getSite().getId() != site.getId()
					|| !topic.getForum().canCreateOrUpdateTopic(loginUser)) {
				msgs.add("log", new ActionMessage("error.topic_not_available",
						new Integer(rform.getTid())));
				break;
			}
			// 創建TopicBean
			TopicReplyBean reply = new TopicReplyBean();
			reply.setClient(new ClientInfo(request, rform.getClientType()));
			String content = StringUtils.abbreviate(super.autoFiltrate(null,
					rform.getContent()), MAX_REPLY_LENGTH);
			reply.setContent(super.filterScriptAndStyle(content));
			reply.setReplyTime(new Date());
			reply.setSite(site);
			reply.setTitle(super.autoFiltrate(site, rform.getTitle()));
			reply.setTopic(topic);
			reply.setUser(loginUser);
			BBSReplyDAO.create(reply);
			break;
		}
		if (!msgs.isEmpty()) {
			saveMessages(request, msgs);
			return mapping.findForward("new_reply");
		}
		StringBuffer ext = new StringBuffer();
		ext.append("fid=");
		ext.append(rform.getFid());
		ext.append("&tid=");
		ext.append(rform.getTid());
		return makeForward(mapping.findForward("topic"), rform.getSid(), ext
				.toString());
	}

	/**
	 * 修改回帖
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doEditReply(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		BBSReplyForm rform = (BBSReplyForm) form;
		super.validateClientId(request, rform);
		ActionMessages msgs = new ActionMessages();
		while (true) {
			if (StringUtils.isEmpty(rform.getTitle())) {
				msgs.add("title", new ActionMessage("error.empty_not_allowed"));
				break;
			}
			if (StringUtils.isEmpty(rform.getContent())) {
				msgs.add("content",
						new ActionMessage("error.empty_not_allowed"));
				break;
			}
			UserBean loginUser = super.getLoginUser(request, response);
			if (loginUser == null) {
				msgs.add("reply", new ActionMessage("error.user_not_login"));
				break;
			}
			if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
				msgs.add("reply", new ActionMessage("error.user_not_available"));
				break;
			}
			SiteBean site = super.getSiteByID(rform.getSid());
			if (site == null) {
				msgs.add("reply", new ActionMessage("error.site_not_available"));
				break;
			}
			TopicReplyBean rbean = BBSReplyDAO.getTopicReplyByID(rform.getId());
			if (rbean != null
					&& rbean.getStatus() == TopicReplyBean.STATUS_NORMAL) {
				String title = super.autoFiltrate(site, rform.getTitle());
				if (!StringUtils.equals(title, rbean.getTitle()))
					rbean.setTitle(title);
				String content = StringUtils.abbreviate(super.autoFiltrate(
						null, rform.getContent()), MAX_REPLY_LENGTH);
				if (!StringUtils.equals(content, rbean.getContent()))
					rbean.setContent(super.filterScriptAndStyle(content));
				BBSReplyDAO.flush();
			}
			break;
		}
		if (!msgs.isEmpty()) {
			saveMessages(request, msgs);
			return mapping.findForward("new_reply");
		}
		StringBuffer ext = new StringBuffer();
		ext.append("fid=");
		ext.append(rform.getFid());
		ext.append("&tid=");
		ext.append(rform.getTid());
		if (rform.getPage() > 1) {
			ext.append("&page=");
			ext.append(rform.getPage());
		}
		return makeForward(mapping.findForward("topic"), rform.getSid(), ext
				.toString());
	}

	/**
	 * 刪除回帖
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doDeleteReply(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		BBSReplyForm rform = (BBSReplyForm) form;

		while (true) {
			UserBean loginUser = super.getLoginUser(request, response);
			if (loginUser == null)
				break;
			TopicReplyBean trb = BBSReplyDAO.getTopicReplyByID(rform.getId());
			if (trb == null)
				break;
			if (trb.getUser().getId() != loginUser.getId()
					&& loginUser.getOwnSiteId() != rform.getSid())
				break;
			BBSReplyDAO.delete(trb);
			break;
		}
		StringBuffer ext = new StringBuffer();
		ext.append("fid=");
		ext.append(rform.getFid());
		ext.append("&tid=");
		ext.append(rform.getTid());
		ext.append("&page=");
		ext.append(rform.getPage());
		return makeForward(mapping.findForward("topic"), rform.getSid(), ext
				.toString());
	}

	/**
	 * 發表帖子
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doPublishTopic(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		BBSTopicForm log = (BBSTopicForm) form;
		super.validateClientId(request, log);
		ActionMessages msgs = new ActionMessages();
		UserBean loginUser = super.getLoginUser(request, response);
		while (true) {
			if (loginUser == null) {
				msgs.add("topic", new ActionMessage("error.user_not_login"));
				break;
			}
			if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
				msgs.add("topic", new ActionMessage("error.user_not_available"));
				break;
			}
			if (StringUtils.isEmpty(log.getTitle())) {
				msgs.add("title", new ActionMessage("error.empty_not_allowed"));
				break;
			}
			if (StringUtils.isEmpty(log.getContent())) {
				msgs.add("content",
						new ActionMessage("error.empty_not_allowed"));
				break;
			}
			SiteBean site = super.getSiteByID(log.getSid());
			if (site == null) {
				msgs.add("topic", new ActionMessage("error.site_not_available"));
				break;
			}
			//檢查黑名單
			if(isUserInBlackList(site, loginUser)){
				msgs.add("topic", new ActionMessage("error.user_in_blacklist"));
				break;
			}
			ForumBean forum = BBSForumDAO.getForumByID(log.getForum());
			if (forum == null || forum.getSite().getId() != site.getId()
					|| !forum.canCreateOrUpdateTopic(loginUser)) {
				msgs.add("topic", new ActionMessage("error.forum_not_available",
						new Integer(log.getForum())));
				break;
			}			
			
			// 創建TopicBean
			TopicBean topic = new TopicBean();
			topic.setUser(loginUser);
			topic.setUsername(loginUser.getName());
			topic.setSite(site);
			// 對發貼的標題以及內容自動進行敏感字詞過濾
			topic.setTitle(super.autoFiltrate(site, log.getTitle()));
			String content = StringUtils.abbreviate(super.autoFiltrate(null,
					log.getContent()), MAX_TOPIC_LENGTH);
			topic.setContent(super.filterScriptAndStyle(content));
			// FIXME: 處理當關鍵字太長導致數據庫寫入失敗的問題
			topic.setKeyword(DLOGSecurityManager.IllegalGlossary
					.deleteIllegalWord(log.getSearchKey()));
			topic.setClient(new ClientInfo(request, log.getClientType()));
			topic.setCreateTime(new Date());
			topic.setForum(forum);
			topic.setStatus(TopicBean.STATUS_NORMAL);
			if(site.getOwner().getId()==loginUser.getId()){
				if (log.getTop() == 1)
					topic.setTop(true);
				if (log.getElite() == 1)
					topic.setElite(true);
			}
			BBSTopicDAO.create(topic, (log.getBookmark() == 1));

			// 檢索上傳的信息
			pickupUploadFileItems(request, response, loginUser.getId(), site, topic
					.getId(), TopicBean.TYPE_BBS);
			break;
		}
		if (!msgs.isEmpty()) {
			saveMessages(request, msgs);
			return mapping.findForward("new_topic");
		}
		return makeForward(mapping.findForward("forum"), log.getSid(), "fid",
				log.getForum());
	}

	/**
	 * 修改帖子
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doEditTopic(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		BBSTopicForm log = (BBSTopicForm) form;
		super.validateClientId(request, log);
		ActionMessages msgs = new ActionMessages();
		UserBean loginUser = super.getLoginUser(request, response);
		while (true) {
			if (loginUser == null) {
				msgs.add("log", new ActionMessage("error.user_not_login"));
				break;
			}
			if (loginUser.getStatus() != UserBean.STATUS_NORMAL) {
				msgs.add("log", new ActionMessage("error.user_not_available"));
				break;
			}
			if (StringUtils.isEmpty(log.getTitle())) {
				msgs.add("title", new ActionMessage("error.empty_not_allowed"));
				break;
			}
			if (StringUtils.isEmpty(log.getContent())) {
				msgs.add("content",
						new ActionMessage("error.empty_not_allowed"));
				break;
			}
			// 檢查用戶的權限
			TopicBean topic = BBSTopicDAO.getTopicByID(log.getId());
			if (topic != null) {
				if (topic.getUser().getId() != loginUser.getId()
						&& loginUser.getOwnSiteId() != log.getSid()) {
					msgs.add("bbs", new ActionMessage("error.access_deny"));
					break;
				}
				// 對發貼的標題以及內容自動進行敏感字詞過濾
				String title = super.autoFiltrate(topic.getSite(),log.getTitle());
				if (!StringUtils.equals(title, topic.getTitle()))
					topic.setTitle(title);
				String content = StringUtils.abbreviate(super.autoFiltrate(
						null, log.getContent()), MAX_TOPIC_LENGTH);				
				if (!StringUtils.equals(content, topic.getContent())){
					topic.setContent(super.filterScriptAndStyle(content));
					//更新文本緩存(Winter Lau, 2006-5-12)
					TextCacheManager.updateTextContent(
							TopicBean.TYPE_BBS, topic.getId(), topic.getContent());
				}
				String keyword = super.autoFiltrate(topic.getSite(),log.getSearchKey());
				boolean updateTags = false;
				if (!StringUtils.equals(keyword, topic.getKeyword())) {
					topic.setKeyword(keyword);
					updateTags = true;
				}
				topic.setModifyTime(new Date());
				if(topic.getSite().getOwner().getId()==loginUser.getId()){
					topic.setTop(log.getTop() == 1);
					topic.setElite(log.getElite() == 1);
				}
				BBSTopicDAO.update(topic, updateTags);
			}
			break;
		}
		if (!msgs.isEmpty()) {
			saveMessages(request, msgs);
			return mapping.findForward("edit_topic");
		}

		StringBuffer ext = new StringBuffer("fid=");
		ext.append(log.getForum());
		ext.append("&tid=");
		ext.append(log.getId());
		return makeForward(mapping.findForward("topic"), log.getSid(), ext
				.toString());

	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品乱人伦小说| 天天综合网 天天综合色| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲一区二区三区视频在线播放| 国精产品一区一区三区mba视频| 国产伦精品一区二区三区在线观看 | 久久久国产午夜精品| 一区二区三区波多野结衣在线观看| 蜜臂av日日欢夜夜爽一区| 99久久免费精品| 久久久久国产精品免费免费搜索| 亚洲一区二区三区四区中文字幕| 国产精品资源网站| 日韩一区二区三区视频在线观看| 亚洲欧美日韩久久精品| 国产一区二区导航在线播放| 91精品国产综合久久精品app| 亚洲欧洲精品一区二区三区不卡| 久久99精品久久久久久国产越南 | 欧美日韩精品高清| 国产精品女人毛片| 国产一区二区福利| 欧美videos中文字幕| 亚洲一区二区三区免费视频| 91在线精品一区二区| 欧美高清在线视频| 经典三级一区二区| 欧美理论在线播放| 亚洲国产美女搞黄色| 色天天综合久久久久综合片| 一区免费观看视频| 成人动漫一区二区在线| 国产精品久久久久久久岛一牛影视| hitomi一区二区三区精品| 精品91自产拍在线观看一区| 久久精品久久综合| 日韩欧美一级二级三级久久久| 日韩专区在线视频| 91精品国产综合久久精品麻豆| 日本欧美一区二区在线观看| 欧美日韩成人在线| 天天综合日日夜夜精品| 51精品国自产在线| 久久精品噜噜噜成人88aⅴ| 日韩一二在线观看| 国精产品一区一区三区mba桃花| 欧美精品一区二区三区高清aⅴ | 福利视频网站一区二区三区| 国产精品水嫩水嫩| 91免费版在线看| 亚洲妇女屁股眼交7| 欧美综合天天夜夜久久| 日韩av午夜在线观看| 日韩欧美国产一区二区在线播放| 狠狠色2019综合网| 日韩码欧中文字| 欧美天堂一区二区三区| 日本va欧美va瓶| 国产欧美va欧美不卡在线| 91麻豆精品视频| 午夜精品福利一区二区蜜股av| 欧美一区二区三区小说| 欧美日韩一区视频| 男女性色大片免费观看一区二区 | 成人精品视频一区二区三区尤物| 国产精品久久久久久久久晋中| 97aⅴ精品视频一二三区| 亚洲18色成人| 国产三区在线成人av| 日本高清不卡在线观看| 视频一区二区欧美| 国产精品久久三区| 777色狠狠一区二区三区| 国产91丝袜在线观看| 亚洲一区二区三区四区五区黄| 精品国产露脸精彩对白| 91亚洲精品久久久蜜桃| 美女一区二区三区| 一区二区三区毛片| 国产亚洲一区字幕| 欧美午夜精品一区二区三区| 国产91色综合久久免费分享| 亚洲成人777| 中文一区二区完整视频在线观看| 欧美日韩国产一级片| av午夜一区麻豆| 久久99精品国产.久久久久久| 成人免费一区二区三区在线观看| 91精品国产91久久综合桃花| 91小视频免费看| 狠狠色丁香婷综合久久| 日韩精品1区2区3区| 亚洲日本在线天堂| 久久精品一区二区三区av| 欧美一区二区久久| 欧美性淫爽ww久久久久无| 欧美一区二区三区免费视频| 一本久久a久久精品亚洲| 国产乱人伦偷精品视频免下载| 天天做天天摸天天爽国产一区| 一区二区三区鲁丝不卡| 国产精品卡一卡二| 久久久综合激的五月天| 日韩视频永久免费| 在线成人av影院| 欧美在线视频日韩| 色婷婷综合五月| 成人激情图片网| 国产成人午夜精品影院观看视频 | 久久久电影一区二区三区| 日韩一区二区免费在线电影| 欧美三级乱人伦电影| 在线观看免费成人| 欧美亚洲高清一区| 在线观看一区二区精品视频| 色偷偷成人一区二区三区91| 97久久精品人人做人人爽 | 激情久久久久久久久久久久久久久久| 亚洲午夜在线观看视频在线| 一区二区三区日韩精品视频| 一区二区三区成人在线视频| 亚洲天堂2016| 亚洲乱码中文字幕| 亚洲一二三区在线观看| 亚洲一区二区免费视频| 亚洲国产精品久久人人爱蜜臀| 亚洲国产日韩av| 日韩av网站免费在线| 日本欧美大码aⅴ在线播放| 奇米色一区二区| 精品夜夜嗨av一区二区三区| 韩国欧美国产一区| 国产白丝精品91爽爽久久| 成人亚洲一区二区一| 色婷婷久久一区二区三区麻豆| 在线视频国内一区二区| 欧美日韩国产另类不卡| 欧美一级高清片| 久久免费偷拍视频| 亚洲你懂的在线视频| 日韩高清在线电影| 国产精品一二一区| 一本大道综合伊人精品热热| 欧美精品在线观看播放| 欧美精品一区二区三区一线天视频 | 亚洲人被黑人高潮完整版| 午夜国产不卡在线观看视频| 麻豆极品一区二区三区| 成人久久视频在线观看| 欧美日韩国产天堂| 久久久久一区二区三区四区| 国产精品夫妻自拍| 三级不卡在线观看| 成人永久免费视频| 欧美日韩一区二区三区不卡| 欧美不卡123| 亚洲精品视频观看| 麻豆一区二区三| 成人va在线观看| 欧美一区日本一区韩国一区| 国产精品天干天干在观线| 亚洲不卡av一区二区三区| 盗摄精品av一区二区三区| 欧美三级中文字幕在线观看| 久久久精品一品道一区| 午夜视频久久久久久| www.成人在线| 日韩亚洲欧美综合| 亚洲综合在线五月| 国产一区二区三区美女| 久久久高清一区二区三区| 午夜欧美一区二区三区在线播放| 国产91综合一区在线观看| 欧美日韩亚洲国产综合| 中文字幕在线视频一区| 激情深爱一区二区| 欧美日韩小视频| 亚洲欧美韩国综合色| 国产一区二三区| 欧美二区乱c少妇| 亚洲综合色网站| 91偷拍与自偷拍精品| 国产亲近乱来精品视频 | 精品1区2区在线观看| 日av在线不卡| 9191成人精品久久| 亚洲国产精品一区二区久久恐怖片 | 国产黄色91视频| 精品剧情在线观看| 日本不卡1234视频| 欧美一区午夜精品| 青青草97国产精品免费观看无弹窗版| 日本电影亚洲天堂一区| 综合久久久久久| 99久久久免费精品国产一区二区| 亚洲国产成人午夜在线一区| 国产激情偷乱视频一区二区三区| 欧美tk—视频vk| 久久精品久久综合| 337p日本欧洲亚洲大胆精品|