/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package guestbook;

import java.sql.Timestamp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import database.DBConn;
import filter.FaceFilter;
import filter.HTMLFilter;
import filter.UbbCode;

/** 
 * MyEclipse Struts
 * Creation date: 05-23-2008
 * 
 * XDoclet definition:
 * @struts.action path="/addGuest" name="addFrom" scope="request" validate="true"
 * @struts.action-forward name="buhao" path="buhao.jsp"
 * @struts.action-forward name="hao" path="/hao.jsp"
 */
public class AddGuest extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		AddFrom addFrom = (AddFrom) form;// TODO Auto-generated method stub
		DBConn db = new DBConn();
		FaceFilter ff = new FaceFilter();
		HTMLFilter html = new HTMLFilter();
		UbbCode uc = new UbbCode();
		GuestBook gb = new GuestBook();
		html.setSource(addFrom.getContent());
		html.run();
		gb.setName(addFrom.getName());
		gb.setFace(addFrom.getFace());
		gb.setMail(addFrom.getMail());
		gb.setQq(addFrom.getQq());
		gb.setUsertitle(addFrom.getUsertitle());
		gb.setContent(html.getResult());
		ff.setSource(gb.getContent());
		ff.run();
		gb.setContent(ff.getResult());
		uc.setSource(gb.getContent());
		uc.run();
		gb.setContent(uc.getResult());
		java.util.Date date=new java.util.Date();
		String datetime=new Timestamp(date.getTime()).toString();
		gb.setMydate(datetime);
		db.addGuest(gb);
		return mapping.findForward("hao");
	}
}