예제 #1
0
 /**
  * 我的留言
  *
  * <p>如果没有登录则跳转到登陆页
  *
  * @param request
  * @param response
  * @param model
  * @return
  */
 @RequestMapping(value = "/member/myguestbook.jspx")
 public String myguestbook(
     Integer pageNo,
     Integer ctgId,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   Pagination pagination =
       guestbookMng.getPage(
           site.getId(),
           ctgId,
           user.getId(),
           null,
           null,
           true,
           false,
           cpn(pageNo),
           CookieUtils.getPageSize(request));
   model.addAttribute("pagination", pagination);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_GUESTBOOK, GUESTBOOK_LIST);
 }
예제 #2
0
 /**
  * 密码修改提交页
  *
  * @param origPwd 原始密码
  * @param newPwd 新密码
  * @param email 邮箱
  * @param nextUrl 下一个页面地址
  * @param request
  * @param response
  * @param model
  * @return
  * @throws IOException
  */
 @RequestMapping(value = "/member/pwd.jspx", method = RequestMethod.POST)
 public String passwordSubmit(
     String origPwd,
     String newPwd,
     String email,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   WebErrors errors = validatePasswordSubmit(user.getId(), origPwd, newPwd, email, request);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   cmsUserMng.updatePwdEmail(user.getId(), newPwd, email);
   return FrontUtils.showSuccess(request, model, nextUrl);
 }
예제 #3
0
 /**
  * 个人资料提交页
  *
  * @param request
  * @param response
  * @param model
  * @return
  * @throws IOException
  */
 @RequestMapping(value = "/member/profile.jspx", method = RequestMethod.POST)
 public String profileSubmit(
     CmsUserExt ext,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   ext.setId(user.getId());
   cmsUserExtMng.update(ext, user);
   log.info("update CmsUserExt success. id={}", user.getId());
   return FrontUtils.showSuccess(request, model, nextUrl);
 }
예제 #4
0
 /**
  * 验证密码是否正确
  *
  * @param origPwd 原密码
  * @param request
  * @param response
  */
 @RequestMapping("/member/checkPwd.jspx")
 public void checkPwd(String origPwd, HttpServletRequest request, HttpServletResponse response) {
   CmsUser user = CmsUtils.getUser(request);
   boolean pass = cmsUserMng.isPasswordValid(user.getId(), origPwd);
   ResponseUtils.renderJson(response, pass ? "true" : "false");
 }
예제 #5
0
  private boolean validateSubmit(
      Integer topicId,
      Integer[] subIds,
      List<Integer[]> itemIds,
      CmsUser user,
      String ip,
      String cookie,
      ModelMap model) {
    // 投票ID不能为空
    if (topicId == null) {
      model.addAttribute("status", 1);
      return true;
    }
    // 投票项不能为空
    if (itemIds == null || itemIds.size() <= 0) {
      model.addAttribute("status", 2);
      return true;
    }
    // 非文本选项 投票项不能为空
    for (int i = 0; i < subIds.length; i++) {
      if (!cmsVoteSubTopicMng.findById(subIds[i]).getIsText()) {
        if (itemIds.get(i) == null) {
          model.addAttribute("status", 2);
          return true;
        }
      }
    }
    CmsVoteTopic topic = cmsVoteTopicMng.findById(topicId);
    // 投票主题不存在
    if (topic == null) {
      model.addAttribute("status", 100);
      return true;
    }
    // 投票项不合法
    List<Integer> itemTotalIds = new ArrayList<Integer>();
    for (Integer[] ids : itemIds) {
      if (ids != null && ids.length > 0) {
        for (Integer id : ids) {
          itemTotalIds.add(id);
        }
      }
    }
    boolean contains;
    for (Integer itemId : itemTotalIds) {
      contains = false;
      for (CmsVoteItem item : topic.getItems()) {
        if (item.getId().equals(itemId)) {
          contains = true;
          break;
        }
      }
      if (!contains) {
        model.addAttribute("status", 101);
        return true;
      }
    }

    // 需要登录才能投票
    if (topic.getRestrictMember() && user == null) {
      model.addAttribute("status", 501);
      return true;
    }

    // 投票主题已经关闭
    if (topic.getDisabled()) {
      model.addAttribute("status", 200);
      return true;
    }
    /*多题目取消下面限制
    // 投票的选项个数大于允许的个数
    if (itemIds.length > topic.getMultiSelect()) {
    	model.addAttribute("status", 201);
    	return true;
    }
    */
    long now = System.currentTimeMillis();
    // 投票还没有开始
    Date start = topic.getStartTime();
    if (start != null && now < start.getTime()) {
      model.addAttribute("status", 202);
      model.addAttribute("startTime", start);
      return true;
    }
    // 投票已经结束
    Date end = topic.getEndTime();
    if (end != null && now > end.getTime()) {
      model.addAttribute("status", 203);
      model.addAttribute("endTime", end);
      return true;
    }
    Integer hour = topic.getRepeateHour();
    if (hour == null || hour > 0) {
      Date vtime;
      // 规定时间内,同一会员不能重复投票
      if (topic.getRestrictMember()) {
        vtime = cmsVoteRecordMng.lastVoteTimeByUserId(user.getId(), topicId);
        if (hour == null || vtime.getTime() + hour * 60 * 60 * 1000 > now) {
          model.addAttribute("status", 204);
          return true;
        }
      }
      // 规定时间内,同一IP不能重复投票
      if (topic.getRestrictIp()) {
        vtime = cmsVoteRecordMng.lastVoteTimeByIp(ip, topicId);
        if (hour == null || vtime.getTime() + hour * 60 * 60 * 1000 > now) {
          model.addAttribute("status", 205);
          return true;
        }
      }
      // 规定时间内,同一COOKIE不能重复投票
      if (topic.getRestrictCookie() && cookie != null) {
        vtime = cmsVoteRecordMng.lastVoteTimeByCookie(cookie, topicId);
        if (hour == null || vtime.getTime() + hour * 60 * 60 * 1000 > now) {
          model.addAttribute("status", 206);
          return true;
        }
      }
    }
    return false;
  }