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

📄 register.java

📁 天乙社区6.0是一套基于JAVA技术的网络虚拟社区
💻 JAVA
字号:
package com.laoer.bbscs.web.action;

import com.laoer.bbscs.web.form.*;
import com.laoer.bbscs.business.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.sys.*;
import com.laoer.comm.util.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;

/**
 * <p>Title: TianYi BBS</p>
 * <p>Description: TianYi BBS System</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: LAOER.COM/TIANYISOFT.NET</p>
 * @author laoer
 * @version 6.0
 */

public class Register
    extends TopBaseAction {

  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest httpServletRequest,
                               HttpServletResponse httpServletResponse) {

    ActionErrors errors = new ActionErrors();
    RegForm form = (RegForm) actionForm;

    if (SysInfo.getInstance().getOpen().equals("n")) {

      errors.add("error.reg.notallowreg",
                 new ActionError("error.reg.notallowreg"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }

    if (form.getAction().equals("add")) {

      if (SysInfo.getInstance().getUsepass().equals("y")) {
        ActionForward f = new ActionForward(SysInfo.getInstance().getPassregurl(), true);
        return f;
      }
      else {
        form.setAction("new");
        form.setSex( (short) 0);
        form.setHomePage("http://");
        form.setForumPerNum( (short) 20);
        form.setPostPerNum( (short) 10);
        form.setTimeZone("GMT+08:00");
        httpServletRequest.setAttribute("regForm", form);
        return actionMapping.findForward("reg");
      }
    }
    if (form.getAction().equals("new")) {
      if (!SysInfo.getInstance().getUsepass().equals("y")) {
        IUserInfoService uiService = this.getUserInfoService();
        IUserDetailService udService = this.getUserDetailService();
        UserInfo ui = new UserInfo();
        ui.setAnswer(form.getAnswer());
        ui.setArticleNum(0);
        ui.setBoard( (short) 0);
        ui.setBoardMaster( (short) 0);
        ui.setBoardSave("");
        ui.setBulletin( (short) 0);
        ui.setCanInBoards("");
        ui.setEmail(form.getEmail());
        ui.setExp(0);
        ui.setExpression(0);
        ui.setForumPerNum(form.getForumPerNum());
        ui.setFriend("");
        ui.setHavePic( (short) 0);
        ui.setHpower( (short) 0);
        ui.setLastLoginTime(SysUtil.getLongTime());
        ui.setLoginTime(SysUtil.getLongTime());
        ui.setLoginTimes(0);
        ui.setLogoutTime(SysUtil.getLongTime() - 24 * 3600 * 1000);
        ui.setManager( (short) 0);
        ui.setNickname(form.getNickname());
        ui.setPasswd(form.getPasswd());
        ui.setPicFileName("");
        ui.setPost( (short) 0);
        ui.setPostPerNum(form.getPostPerNum());
        ui.setPower( (short) 10);
        ui.setQuestion(form.getQuestion());
        ui.setRegTime(SysUtil.getLongTime());
        ui.setRepasswd(Util.hash(form.getPasswd()));
        ui.setSignDetail1("");
        ui.setSignDetail2("");
        ui.setSignDetail3("");
        ui.setSignName1("");
        ui.setSignName2("");
        ui.setSignName3("");
        ui.setStayTime(0);
        ui.setStyle(0);
        ui.setSuperAdmin( (short) 0);
        ui.setTimeZone(form.getTimeZone());
        ui.setUserAdmin( (short) 0);
        ui.setUserFrom(form.getUserFrom());
        ui.setUsername(form.getUsername());
        Result r = uiService.regUser(ui);
        if (r.isRight()) {
          ui = (UserInfo) r.getObject();
          UserDetail ud = new UserDetail();
          ud.setBrief(form.getBrief());
          ud.setIcqNo(form.getIcqNo());
          ud.setOicqNo(form.getOicqNo());
          ud.setMsn(form.getMsn());
          ud.setYahoo(form.getYahoo());
          ud.setUserID(ui.getId().longValue());
          udService.saveUserDetail(ud);
          uiService.createUserFileInPost(ui);
          SysStat.getInstance().setAllUserNum(uiService.getAllUserNum(),
                                              form.getUsername());
          ActionForward f = new ActionForward(SysUtil.getResultUrl(r.getMsg(),
              "index.jsp"), true);
          return f;
        }
        else {
          errors.add(r.getMsg(), new ActionError(r.getMsg()));
          saveErrors(httpServletRequest, errors);
          return actionMapping.findForward("reg");
        }
      }
    }
    return actionMapping.findForward("error");
  }
}

⌨️ 快捷键说明

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