You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
10 KiB

package com.action;
/**
* <EFBFBD><EFBFBD>Աע<EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>
* @author Administrator
*
*/
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.bean.MemberBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;
import com.util.MD5;
public class MemberAction extends HttpServlet {
/**
* Constructor of the object.
*/
public MemberAction() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
HttpSession session = request.getSession();
MemberBean memberBean = new MemberBean();
String method = Filter.escapeHTMLTags(request.getParameter("method").trim());
/*********************************************
* <EFBFBD><EFBFBD>Աע<EFBFBD><EFBFBD>ͨ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD> <EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> reg2.jspҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
*********************************************/
if(method.equals("reg2")){//<2F><>Աע<D4B1><D7A2> reg2.jsp
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim());
request.setAttribute("username", username);
request.setAttribute("password", password);
request.setAttribute("reg_type", reg_type);
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
if(reg_type.equals("person")){//<2F><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8>˻<EFBFBD>Ա
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
else if(reg_type.equals("co")){//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5>Ա
request.getRequestDispatcher("coreg.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "<22>Բ<EFBFBD><D4B2>𣬸<EFBFBD><F0A3ACB8>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
request.setAttribute("message", "ϵͳά<CDB3><CEAC><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԣ<EFBFBD>");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("checksame")){//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
request.setAttribute("username", username);
request.setAttribute("message", "<22><>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD>ʹ<EFBFBD>ã<EFBFBD>");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "<22>Բ<EFBFBD><D4B2>𣬸<EFBFBD><F0A3ACB8>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
request.setAttribute("message", "ϵͳά<CDB3><CEAC><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԣ<EFBFBD>");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("Editpwd")){//<2F><>Ա<EFBFBD>޸ĵ<DEB8>½<EFBFBD><C2BD><EFBFBD><EFBFBD>
String member=(String)session.getAttribute("member");
String type=(String)session.getAttribute("type");
if(member==null||type==null){
response.sendRedirect("error.jsp");
}
else{
String oldpwd = MD5.MD5(request.getParameter("oldpwd").trim());
String newpwd = MD5.MD5(request.getParameter("newpwd").trim());
int flag = memberBean.editPassword(member, oldpwd, newpwd);
switch (flag){
case Constant.SUCCESS:
request.setAttribute("message", "<22><><EFBFBD><EFBFBD><EFBFBD>޸ijɹ<C4B3><C9B9><EFBFBD>");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", ʼ<D4AD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>Ȩ<EFBFBD>ޣ<EFBFBD>");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
case Constant.SYSTEM_ERROR:
request.setAttribute("message", "ϵͳά<CDB3><CEAC><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԣ<EFBFBD>");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
}
}
}
/*********************************************
* <EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>Աע<EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*********************************************/
else if(method.equals("PREG")){//<2F><><EFBFBD>˻<EFBFBD>Ա<EFBFBD><D4B1>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String type = "person";
String realname = Filter.escapeHTMLTags(request.getParameter("realname").trim());
String sex = Filter.escapeHTMLTags(request.getParameter("sex").trim());
String sheng = Filter.escapeHTMLTags(request.getParameter("sheng").trim());
String city = Filter.escapeHTMLTags(request.getParameter("city").trim());
String bir = Filter.escapeHTMLTags(request.getParameter("bir").trim());
String telphone = Filter.escapeHTMLTags(request.getParameter("telphone").trim());
String email = Filter.escapeHTMLTags(request.getParameter("email").trim());
String question = Filter.escapeHTMLTags(request.getParameter("question").trim());
String answer = Filter.escapeHTMLTags(request.getParameter("answer").trim());
String address = Filter.escapeHTMLTags(request.getParameter("address").trim());
String lastip = request.getRemoteAddr();
int off = 1;
int flag = memberBean.personReg(username, password, type, realname, sex, bir,sheng,city, telphone, email, question, answer, lastip, off,address);
if(flag == Constant.SUCCESS){
List siteList = new SystemBean().getSiteInfo();
String sitename = siteList.get(0).toString();
request.setAttribute("message", <><D7A2><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>Ϊ"+sitename+"<22><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else{
request.setAttribute("message", "ϵͳά<CDB3><CEAC><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԣ<EFBFBD>");
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
}
else if(method.equals("UPREGINFO")){//<2F><><EFBFBD>˻<EFBFBD>Ա<EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
String member=(String)session.getAttribute("member");
String type=(String)session.getAttribute("type");
if(member==null||type==null){
response.sendRedirect("error.jsp");
}
else{
String realname = Filter.escapeHTMLTags(request.getParameter("realname").trim());
String sex = Filter.escapeHTMLTags(request.getParameter("sex").trim());
String sheng = Filter.escapeHTMLTags(request.getParameter("sheng").trim());
String city = Filter.escapeHTMLTags(request.getParameter("city").trim());
String bir = Filter.escapeHTMLTags(request.getParameter("bir").trim());
String telphone = Filter.escapeHTMLTags(request.getParameter("telphone").trim());
String email = Filter.escapeHTMLTags(request.getParameter("email").trim());
String question = Filter.escapeHTMLTags(request.getParameter("question").trim());
String answer = Filter.escapeHTMLTags(request.getParameter("answer").trim());
String address = Filter.escapeHTMLTags(request.getParameter("address").trim());
int flag = memberBean.uppersonReg(member, realname, sex, bir, sheng, city, telphone, email, question, answer,address);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>");
request.getRequestDispatcher("member/info/info.jsp").forward(request, response);
}
else{
request.setAttribute("message", "ϵͳά<CDB3><CEAC><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD>ԣ<EFBFBD>");
request.getRequestDispatcher("member/info/info.jsp").forward(request, response);
}
}
}
else if(method.equals("lostpwd")){
String username=request.getParameter("username");
String question=request.getParameter("question");
String answer=request.getParameter("answer");
String reg_type=request.getParameter("reg_type");
String info=memberBean.returnPwd(username, question, answer, reg_type);
if(info.trim().equals("error")){
request.setAttribute("message", "<22><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else{
request.setAttribute("message", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ"+info+"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>޸ģ<DEB8>");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
else{
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}