📄 userservice.java
字号:
throw new ErrMsgException(SkinUtil.LoadString(req, "res.label.forum.user", "allowereguser")); } } String[] EAllowAddress = null; String[] EForbidAddress = null; String temp = ""; EAllowAddress = rcfg.getStringArrProperty("EAllowAddress"); EForbidAddress = rcfg.getStringArrProperty("EForbidAddress"); temp = Email.trim().substring(Email.trim().indexOf("@")); if (EAllowAddress == null) { if(EForbidAddress != null) { for (int i = 0; i < EForbidAddress.length; i++) { if (temp.equals(EForbidAddress[i].trim())) { throw new ErrMsgException(SkinUtil.LoadString(req, "res.label.forum.user", "eforbidaddress")); } } } } else { for (int i = 0; i < EAllowAddress.length; i++) { if (!temp.equals(EAllowAddress[i].trim())) { throw new ErrMsgException(SkinUtil.LoadString(req, "res.label.forum.user", "eallowaddress")); } } } String OICQ = pck.getString("OICQ"); String sign = pck.getString("Content"); String ip = pck.getString("ip"); boolean secret = pck.getBoolean("isSecret"); String home = pck.getString("home"); String msn = pck.getString("msn"); String locale = pck.getString("locale"); String fetion = pck.getString("fetion"); Config cfg = Config.getInstance(); if (sign.length() > cfg.getIntProperty("forum.sign_length")) { throw new ErrMsgException(SkinUtil.LoadString(req, "res.label.forum.user", "sign_limit_count") + cfg.getIntProperty("forum.sign_length")); } String tzID = pck.getString("timeZone"); TimeZone tz = TimeZone.getTimeZone(tzID); IPMonitor im = new IPMonitor(); if (!im.isValid(req, ip)) { throw new ErrMsgException(im.getMessage()); } ForumFilter.filterUserName(req, RegName); UserDb user = new UserDb(); user.setNick(RegName); user.setPwdMd5(Password); user.setRawPwd(Password2); user.setQuestion(Question); user.setAnswer(Answer); user.setRealName(RealName); user.setCareer(Career); user.setGender(Gender); user.setJob(Job); try { user.setBirthday(DateUtil.parse(Birthday, "yyyy-MM-dd")); } catch (Exception e) { logger.error("regist:" + e.getMessage()); } user.setMarriage(Marriage); user.setPhone(Phone); user.setMobile(Mobile); user.setState(State); user.setCity(City); user.setAddress(Address); user.setPostCode(PostCode); user.setIDCard(IDCard); user.setRealPic(RealPic); user.setHobbies(Hobbies); user.setEmail(Email); user.setOicq(OICQ); user.setSign(sign); user.setSecret(secret); user.setIp(ip); user.setTimeZone(tz); user.setHome(home); user.setMsn(msn); user.setLocale(locale); user.setFetion(fetion); RegConfig cr = new RegConfig(); int regVerify = cr.getIntProperty("regVerify"); if (regVerify==cr.REGIST_VERIFY_NOT) user.setCheckStatus(user.CHECK_STATUS_PASS); else user.setCheckStatus(user.CHECK_STATUS_NOT); boolean re = user.create(); if (re) { doRegist(req, res, user); } return re; } public boolean editmyinfo(HttpServletRequest req, HttpServletResponse response) throws ErrMsgException { ParamConfig pc = new ParamConfig("form_rule.xml"); ParamChecker pck = new ParamChecker(req); try { pck.doCheck(pc.getFormRule("user_modify")); } catch (CheckErrException e) { throw new ErrMsgException(e.getMessage()); } String name = pck.getString("RegName"); if (name == null || name.trim().equals("")) { throw new ErrMsgException(SkinUtil.LoadString(req, "res.forum.person.userservice", "err_need_name")); } String Password = pck.getString("Password").trim(); String Password2 = pck.getString("Password2").trim(); if (!Password.equals("")) { try { Password = SecurityUtil.MD5(Password); } catch (Exception e) { logger.error("editmyinfo:" + e.getMessage()); } } String Question = pck.getString("Question"); String Answer = pck.getString("Answer"); String RealName = pck.getString("RealName"); String Career = pck.getString("Career"); String Gender = pck.getString("Gender"); String Job = pck.getString("Job"); String BirthYear = pck.getString("BirthYear"); String BirthMonth = pck.getString("BirthMonth"); String BirthDay = pck.getString("BirthDay"); String Birthday = BirthYear + "-" + BirthMonth + "-" + BirthDay; int Marriage = pck.getInt("Marriage"); String Phone = pck.getString("Phone"); String Mobile = pck.getString("Mobile"); String State = pck.getString("State"); String City = pck.getString("City"); String Address = pck.getString("Address"); String PostCode = pck.getString("PostCode"); String IDCard = pck.getString("IDCard"); String RealPic = pck.getString("RealPic"); String Hobbies = pck.getString("Hobbies"); String Email = pck.getString("Email"); String OICQ = pck.getString("OICQ"); String sign = pck.getString("Content"); boolean secret = pck.getBoolean("isSecret"); String tzID = pck.getString("timeZone"); TimeZone tz = TimeZone.getTimeZone(tzID); String home = pck.getString("home"); String msn = pck.getString("msn"); String locale = pck.getString("locale"); String fetion = pck.getString("fetion"); Config cfg = Config.getInstance(); if (sign.length() > cfg.getIntProperty("forum.sign_length")) { throw new ErrMsgException(SkinUtil.LoadString(req, "res.label.forum.user", "sign_limit_count") + cfg.getIntProperty("forum.sign_length")); } UserDb user = new UserDb(); user = user.getUser(name); boolean isRenamed = false; String oldNick = user.getNick(); if (user.isCanRename() && !user.getNick().equals(pck.getString("nick"))) { if (isRegNameExist(req, pck.getString("nick"))) { throw new ErrMsgException(SkinUtil.LoadString(req, "res.label.forum.user", "user_name_exist")); } user.setNick(pck.getString("nick")); user.setCanRename(false); isRenamed = true; } if (!Password.equals("")) user.setPwdMd5(Password); user.setQuestion(Question); user.setAnswer(Answer); user.setRealName(RealName); user.setCareer(Career); user.setGender(Gender); user.setJob(Job); try { user.setBirthday(DateUtil.parse(Birthday, "yyyy-MM-dd")); } catch (Exception e) { logger.error("editmyinfo:" + e.getMessage()); } user.setMarriage(Marriage); user.setPhone(Phone); user.setMobile(Mobile); user.setState(State); user.setCity(City); user.setAddress(Address); user.setPostCode(PostCode); user.setIDCard(IDCard); user.setRealPic(RealPic); user.setEmail(Email); user.setOicq(OICQ); user.setHobbies(Hobbies); user.setSign(sign); if (!Password2.equals("")) { user.setRawPwd(Password2); } user.setSecret(secret); user.setTimeZone(tz); user.setHome(home); user.setMsn(msn); user.setLocale(locale); user.setFetion(fetion); boolean re = user.save(); if (re) { UserPropDb up = new UserPropDb(); up = up.getUserPropDb(name); up.set("faction", pck.getString("faction")); up.set("is_music_autostart", new Integer(pck.getInt("is_music_autostart"))); try { up.save(); if (isRenamed) { cn.js.fan.module.pvg.User u = new cn.js.fan.module.pvg.User(); u = u.getUser(oldNick); if (u.isLoaded() && u.isForegroundUser()) { u.modifyUserName(user.getNick()); } } } catch (ResKeyException e) { throw new ErrMsgException(e.getMessage(req)); } if (!locale.equals("")) { String[] ary = StrUtil.split(locale, "_"); if (ary != null && ary.length == 2) { Locale loc = new Locale(ary[0], ary[1]); HttpSession session = req.getSession(true); session.setAttribute(SkinUtil.SESSION_LOCALE, loc); } } else { HttpSession session = req.getSession(true); session.removeAttribute(SkinUtil.SESSION_LOCALE); } } return re; } public boolean ModifyPWD(HttpServletResponse response, String username, String pwd, String privurl) throws ErrMsgException { String Password = ""; try { Password = SecurityUtil.MD5(pwd); } catch (Exception e) { logger.error(e.getMessage()); } UserDb user = new UserDb(); user = user.getUser(username); user.setPwdMd5(Password); user.setRawPwd(pwd); return user.save(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -