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

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

?? dlogaction.java

?? 個人Blog java編寫的Blog可以直接使用!
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
/*
 *  SiteAction.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
 *  http://dlog4j.sourceforge.net
 */
package com.liusoft.dlog4j.action;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Date;

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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 org.apache.struts.upload.FormFile;
import org.htmlparser.Node;
import org.htmlparser.Parser;

import com.liusoft.dlog4j.DLOGUserManager;
import com.liusoft.dlog4j.Globals;
import com.liusoft.dlog4j.HtmlNodeFilters;
import com.liusoft.dlog4j.MailTransportQueue;
import com.liusoft.dlog4j.SessionUserObject;
import com.liusoft.dlog4j.UserLoginManager;
import com.liusoft.dlog4j.beans.FriendBean;
import com.liusoft.dlog4j.beans.UserBean;
import com.liusoft.dlog4j.dao.UserDAO;
import com.liusoft.dlog4j.formbean.FormBean;
import com.liusoft.dlog4j.formbean.UserForm;
import com.liusoft.dlog4j.util.DateUtils;
import com.liusoft.dlog4j.util.ImageUtils;
import com.liusoft.dlog4j.util.MailSender;
import com.liusoft.dlog4j.util.RequestUtils;
import com.liusoft.dlog4j.util.StringUtils;

/**
 * 個人網記相關的Action類
 * @author Winter Lau
 */
public class DlogAction extends ActionBase {

	private final static Log log = LogFactory.getLog(DlogAction.class);
	
	/**
	 * 存放用戶頭像文件的路徑
	 */
	public final static String PORTRAIT_PATH = "/uploads/portrait/";

	/**
	 * 用戶頭像的最大寬度
	 */
	public final static int PORTRAIT_WIDTH = 155;
	
	/**
	 * 用戶頭像的最大高度
	 */
	public final static int PORTRAIT_HEIGHT = 200;
	
	public final static int MIN_SITENAME_LEN = 3;

	/**
	 * 獲取用戶密碼
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doFetchPwd(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		UserForm uform = (UserForm) form;
		validateClientId(request, uform);
		ActionMessages msgs = new ActionMessages();
		do{
			if(StringUtils.isEmpty(uform.getName())){
				msgs.add("name", new ActionMessage("error.username_empty"));
				break;
			}
			UserBean ubean = UserDAO.getUserByName(uform.getName());
			if(ubean==null){
				msgs.add("name", new ActionMessage("error.user_not_found"));
				break;
			}
			if (ubean.getStatus() != UserBean.STATUS_NORMAL) {
				msgs.add("name", new ActionMessage("error.user_disabled"));
				break;
			}
			if(!StringUtils.isEmail(ubean.getEmail())){
				msgs.add("name", new ActionMessage("error.email_format"));
				break;
			}
			//發送郵件
			int siteid = (ubean.getSite()!=null)?ubean.getSite().getId():-1;
			sendPasswordNotify(request, siteid, ubean);
			msgs.add("name", new ActionMessage("mail.sent"));
			break;
		}while(true);
			
		if(!msgs.isEmpty())
			saveMessages(request, msgs);
		
		return mapping.findForward("fetchpwd");
	}

	/**
	 * 發送忘記密碼郵件提醒
	 * 
	 * @param request
	 * @param rbean
	 * @throws Exception
	 */
	protected void sendPasswordNotify(HttpServletRequest request, final int site_id, 
			final UserBean ubean) throws Exception {
		
		//final String contextPath = request.getContextPath();
		final String urlPrefix = RequestUtils.getUrlPrefix(request);
		final String template = super.getPasswordTipTemplate();
		
		new Thread() {
			public void run() {
				try {
					// 發送郵件提醒
					String notify_content = MessageFormat.format(template,
							new String[]{ubean.getName(),ubean.getPassword(),urlPrefix});
					Parser html = new Parser();
					html.setEncoding(Globals.ENC_8859_1);
					html.setInputHTML(notify_content);
					Node[] nodes = html.extractAllNodesThatMatch(
							HtmlNodeFilters.titleFilter).toNodeArray();
					String title = nodes[0].toPlainTextString();
					MailSender sender = MailSender.getHtmlMailSender(null, 25,
							null, null);
					sender.setSubject(title);
					sender.setSendDate(new Date());
					sender.setMailContent(notify_content);
					sender.setMailTo(new String[] { ubean
							.getContactInfo().getEmail() }, "to");
					MailTransportQueue queue = (MailTransportQueue) getServlet()
							.getServletContext().getAttribute(
									Globals.MAIL_QUEUE);
					// 寫入待發送郵件隊列
					queue.write(site_id, sender.getMimeMessage());
					if(log.isDebugEnabled())
						log.debug("Notification mail was written to the sending queue.");
				} catch (Exception e) {
					log.error("send notification mail failed.", e);
				}
			}
		}.start();
	}
	
	/**
	 * 添加好友
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @usage http://localhost/dlog/user.do?sid=1&uid=223&eventSubmit_AddFriend&fromPage=xxxx
	 * @ajax_enabled
	 */
	protected ActionForward doAddFriend(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		FormBean fbean = (FormBean) form;
		validateClientId(request, fbean);
		String msg = null;
		//判斷用戶是否登錄
		SessionUserObject loginUser = super.getLoginUser(request, response, false);
		if(loginUser != null){
			int friendId = RequestUtils.getParam(request, "uid", -1);
			UserBean friend = UserDAO.getUserByID(friendId);
			if(friend==null)
				msg = getMessage(request,null,"error.user_not_found", new Integer(friendId));
			else if(friendId == loginUser.getId())
				msg = getMessage(request,null,"error.cannot_add_myself");
			else{
				FriendBean fb = new FriendBean();
				fb.setAddTime(new Date());
				fb.setFriend(friend);
				fb.setOwner(loginUser.getId());
				fb.setType(FriendBean.TYPE_GENERAL);
				fb.setRole(FriendBean.ROLE_GENERAL);
				UserDAO.addFriend(fb);
				msg = getMessage(request,null,"error.friend_added", new Integer(friendId));
			}
		}
		else
			msg = getMessage(request,null,"error.user_not_login");
		return msgbox(mapping,form,request,response,msg,fbean.getFromPage());
	}
	
	/**
	 * 阻止用戶(加入黑名單)
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @param s_other_id
	 * @return
	 * @throws Exception
	 * @ajax_enabled
	 */
	protected ActionForward doBlockUser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		UserForm fbean = (UserForm)form;
		super.validateClientId(request, fbean);
		String msg = null;
		//判斷用戶是否登錄
		SessionUserObject loginUser = super.getLoginUser(request, response, false);
		if(loginUser!=null){
			String s_id = String.valueOf(fbean.getId());
			if(UserDAO.isUserInBlackList(loginUser.getId(), fbean.getId())){
				msg = getMessage(request,null,"error.user_already_in_block", s_id);
			}
			else{
				UserDAO.addBlackList(loginUser.getId(), fbean.getId(), 0);
				msg = getMessage(request,null,"error.user_added_to_block", s_id);
			}
		}
		else
			msg = getMessage(request,null,"error.user_not_login");
		request.setAttribute("msg", msg);
		return makeForward(mapping.findForward("blacklist"),fbean.getSid());
	}

	/**
	 * 取消阻止(從黑名單中刪除)
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * http://localhost/dlog/user.do?sid=1&uid=223&eventSubmit_DelFriend
	 */
	protected ActionForward doUnblockUser(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		FormBean fbean = (FormBean) form;
		validateClientId(request, fbean);
		String msg = null;
		//判斷用戶是否登錄
		SessionUserObject loginUser = super.getLoginUser(request, response, false);
		if(loginUser != null){
			String[] uids = request.getParameterValues("uid");
			UserDAO.deleteBlacklist(loginUser.getId(), uids);
			msg = getMessage(request,null,"error.user_delete_from_block", "");
		}
		else
			msg = getMessage(request,null,"error.user_not_login");
		return msgbox(mapping,form,request,response,msg,fbean.getFromPage());
	}
	
	/**
	 * 刪除好友
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * http://localhost/dlog/user.do?sid=1&uid=223&eventSubmit_DelFriend
	 */
	protected ActionForward doDelFriend(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		FormBean fbean = (FormBean) form;
		validateClientId(request, fbean);
		String msg = null;
		//判斷用戶是否登錄
		SessionUserObject loginUser = super.getLoginUser(request, response, false);
		if(loginUser != null){
			String[] uids = request.getParameterValues("uid");
			int er = UserDAO.deleteFriend(loginUser.getId(), uids);
			if(er>0)
				msg = getMessage(request,null,"error.friend_deleted");
		}
		else
			msg = getMessage(request,null,"error.user_not_login");
		return msgbox(mapping,form,request,response,msg,fbean.getFromPage());
	}
	
	/**
	 * 用戶登錄并注冊個人網記
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 * @see com.liusoft.dlog4j.action.UserAction#doLogin(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)
	 */
	protected ActionForward doLogin(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		int own_site_id = -1;
		UserForm user = (UserForm) form;
		validateClientId(request, user);
		ActionMessages msgs = new ActionMessages();
		if (StringUtils.isEmpty(user.getName()))
			msgs.add("username", new ActionMessage("error.username_empty"));
		else if (StringUtils.isEmpty(user.getPassword()))
			msgs.add("password", new ActionMessage("error.password_empty"));
		else {
			UserBean ubean = DLOGUserManager.getUserByName(user.getName());
			if (ubean == null
					|| !StringUtils.equals(ubean.getPassword(), user
							.getPassword()))
				msgs.add("password",
						new ActionMessage("error.user_auth_failed"));
			else if (ubean.getStatus() != UserBean.STATUS_NORMAL) {
				msgs.add("password", new ActionMessage("error.user_disabled"));
			} else {
				// 執行登錄過程
				UserLoginManager.loginUser(request, response, ubean, user.getKeepDays());
				own_site_id = ubean.getOwnSiteId();
			}
		}

		if (!msgs.isEmpty()) {
			saveMessages(request, msgs);
			return mapping.findForward("login");
		}
		
		String fromPage = user.getFromPage();
		
		if (StringUtils.isNotEmpty(fromPage))
			return new ActionForward(fromPage, true);
		
		if(user.getSid()>0)
			return makeForward(mapping.findForward("main"), user.getSid());
		
		if(own_site_id < 1)
			return mapping.findForward("home");

		return makeForward(mapping.findForward("home"), own_site_id);
		
	}

	/**
	 * 用戶注銷,清除COOKIE
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	protected ActionForward doLogout(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			String fromPage) throws Exception {
		
		//執行注銷過程
		UserLoginManager.logoutUser(request, response);

		if (StringUtils.isNotEmpty(fromPage))
			return new ActionForward(fromPage, true);
		return mapping.findForward("home");
	}
	
	private static String g_portrait_path;
	private static String g_portrait_uri;
	
	/**
	 * 獲取頭像的存放路徑
	 */
	private synchronized void initPortraitPath(){
		if(g_portrait_uri!=null)
			return;
		g_portrait_uri = getServlet().getInitParameter("portrait_base_uri");
		String portrait_path = this.getServlet().getInitParameter("portrait_base_path");

		if(portrait_path.startsWith(Globals.LOCAL_PATH_PREFIX))
			g_portrait_path = portrait_path.substring(Globals.LOCAL_PATH_PREFIX.length());		
		else if(portrait_path.startsWith("/"))
			g_portrait_path = getServlet().getServletContext().getRealPath(portrait_path);
		else
			g_portrait_path = portrait_path;
		if(!g_portrait_path.endsWith(File.separator))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品成人网| 国产精品资源网| 亚洲三级在线观看| 中文av一区特黄| 国产欧美日韩亚州综合| 国产偷国产偷亚洲高清人白洁| 日韩欧美国产综合| 日韩欧美国产wwwww| 精品国产免费一区二区三区香蕉| 日韩免费视频线观看| 日韩三级在线免费观看| 337p亚洲精品色噜噜狠狠| 欧美另类z0zxhd电影| 7777女厕盗摄久久久| 日韩欧美一二三| 日韩免费在线观看| 国产日韩v精品一区二区| 国产日韩一级二级三级| 亚洲国产电影在线观看| 日本一区二区久久| 亚洲三级视频在线观看| 亚洲成人自拍网| 日韩avvvv在线播放| 久久国产日韩欧美精品| 国产自产v一区二区三区c| 国产成人午夜片在线观看高清观看| 国产盗摄女厕一区二区三区| 成人黄色网址在线观看| 色综合久久久久| 欧美精品日日鲁夜夜添| 日韩久久久精品| 欧美激情综合在线| 夜夜精品视频一区二区| 日本不卡一区二区| 国产精品888| 在线观看国产精品网站| 日韩欧美色综合| 国产精品国产a| 天天色图综合网| 国产一区二区在线看| 99re8在线精品视频免费播放| 欧美制服丝袜第一页| 日韩女优毛片在线| 综合电影一区二区三区 | 精品福利一区二区三区免费视频| 久久亚洲捆绑美女| 亚洲综合无码一区二区| 久久狠狠亚洲综合| 一本大道av一区二区在线播放 | 亚洲高清免费一级二级三级| 裸体在线国模精品偷拍| 成人av在线资源网站| 777午夜精品视频在线播放| 欧美激情一区二区三区全黄| 午夜国产不卡在线观看视频| 国产盗摄精品一区二区三区在线 | 99久久国产综合精品色伊| 欧美老女人在线| 中文字幕亚洲在| 免费欧美日韩国产三级电影| 成人va在线观看| 日韩视频免费直播| 玉米视频成人免费看| 国产一区二区看久久| 欧美精品在欧美一区二区少妇| 国产欧美精品在线观看| 日韩精品电影在线| 91视频xxxx| 久久这里只有精品6| 五月婷婷欧美视频| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 91在线免费视频观看| 日韩一区二区三区观看| 亚洲一区二区美女| 91亚洲精品久久久蜜桃网站 | 首页亚洲欧美制服丝腿| 94-欧美-setu| 国产日韩v精品一区二区| 六月丁香婷婷久久| 91精品国产麻豆国产自产在线| 亚洲欧洲综合另类在线| 国产精品一区二区三区乱码| 欧美电影影音先锋| 亚洲国产精品天堂| 在线精品视频免费观看| 亚洲欧洲精品一区二区三区不卡| 狠狠色狠狠色综合日日91app| 欧美乱妇15p| 亚洲图片欧美色图| 972aa.com艺术欧美| 国产精品美女久久久久高潮| 国产不卡在线一区| 久久男人中文字幕资源站| 久草热8精品视频在线观看| 91精品国产综合久久久久| 亚洲国产精品精华液网站| 色网站国产精品| 日韩毛片在线免费观看| 91视频观看免费| 日韩理论片中文av| 99久久精品国产一区二区三区| 国产精品狼人久久影院观看方式| 国产.欧美.日韩| 国产精品女主播av| 91视频国产观看| 亚洲激情网站免费观看| 91丨九色丨蝌蚪富婆spa| 亚洲视频在线一区二区| 91美女在线看| 一区二区三区免费在线观看| 色婷婷综合久色| 亚洲一区中文在线| 欧美日韩五月天| 日韩有码一区二区三区| 精品日韩99亚洲| 国产精品综合在线视频| 国产喷白浆一区二区三区| 成人激情电影免费在线观看| 亚洲欧美在线aaa| 日本黄色一区二区| 亚洲成人av一区二区三区| 欧美一级理论性理论a| 美国av一区二区| 久久久精品tv| 91亚洲男人天堂| 三级欧美韩日大片在线看| 日韩欧美一区电影| 国产91露脸合集magnet| 亚洲视频在线观看一区| 欧美色偷偷大香| 久久精品国产亚洲高清剧情介绍 | 免费在线观看不卡| 国产欧美一区视频| 91丨九色丨蝌蚪富婆spa| 亚洲成av人在线观看| 日韩天堂在线观看| 粉嫩高潮美女一区二区三区| 亚洲免费三区一区二区| 91精品午夜视频| 国产福利一区二区三区在线视频| 中文字幕一区二区三区在线观看| 欧美性一区二区| 久久www免费人成看片高清| 中文一区一区三区高中清不卡| 欧美中文字幕一区| 九九在线精品视频| 1区2区3区国产精品| 欧美性三三影院| 国产一区二区三区国产| 一区二区久久久| xnxx国产精品| 日本韩国精品一区二区在线观看| 日本成人超碰在线观看| 中文字幕一区二区三区不卡在线| 91精品综合久久久久久| 99久久久久免费精品国产| 久久精品国产成人一区二区三区| 国产精品成人在线观看| 日韩精品一区二区三区视频 | 欧美日韩免费一区二区三区视频| 国产乱人伦偷精品视频不卡| 亚洲国产日韩a在线播放| 久久久亚洲国产美女国产盗摄| 欧美午夜免费电影| 不卡一二三区首页| 久久se这里有精品| 亚洲高清三级视频| 国产精品福利一区| 欧美成人video| 欧美性受xxxx黑人xyx| 成人黄色国产精品网站大全在线免费观看| 亚洲一级二级在线| 国产精品美女久久久久久| 日韩欧美二区三区| 欧美日韩一区国产| 97精品国产露脸对白| 国产福利视频一区二区三区| 日产精品久久久久久久性色| 综合激情成人伊人| 中国色在线观看另类| 日韩免费看的电影| 欧洲一区二区三区在线| 99视频一区二区| 国产成人自拍高清视频在线免费播放| 亚洲成av人片在线| 亚洲综合色网站| 亚洲欧美视频在线观看视频| 中文字幕欧美日韩一区| 欧美一区二区三区四区在线观看 | 欧美一级一区二区| 欧美亚洲一区二区在线| 91丨九色porny丨蝌蚪| 国产成人亚洲精品青草天美| 国产一区二区三区四| 久久国产精品99精品国产 | 欧美性受xxxx黑人xyx性爽| 91麻豆6部合集magnet| 成人午夜大片免费观看| 国产99久久久国产精品免费看| 国产在线国偷精品免费看|