// 激活账号
 @RequestMapping(value = "/active.jspx", method = RequestMethod.GET)
 public String active(
     String username,
     String key,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   WebErrors errors = validateActive(username, key, request, response);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   UnifiedUser user = unifiedUserMng.active(username, key);
   BbsUser bbsUser = bbsUserMng.findById(user.getId());
   String ip = RequestUtils.getIpAddr(request);
   authMng.activeLogin(user, ip, request, response, session);
   // 登录记录
   BbsLoginLog loginLog = new BbsLoginLog();
   loginLog.setIp(RequestUtils.getIpAddr(request));
   Calendar calendar = Calendar.getInstance();
   loginLog.setLoginTime(calendar.getTime());
   loginLog.setUser(bbsUser);
   bbsLoginMng.save(loginLog);
   // 在线时长统计
   BbsUserOnline online = bbsUser.getUserOnline();
   // 首次登陆
   online = new BbsUserOnline();
   online.setUser(bbsUser);
   online.initial();
   userOnlineMng.save(online);
   FrontUtils.frontData(request, model, site);
   return FrontUtils.getTplPath(
       request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_ACTIVE_SUCCESS);
 }
示例#2
0
 @RequestMapping(value = "/topic/search*.jhtml")
 public String searchSubmit(Integer pageNo, HttpServletRequest request, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   FrontUtils.frontData(request, model, site);
   String keywords = RequestUtils.getQueryParam(request, "keywords");
   String forumIdStr = RequestUtils.getQueryParam(request, "forumId");
   Integer forumId = 0;
   if (forumIdStr != null && StringUtils.isNotBlank(forumIdStr)) {
     forumId = Integer.parseInt(forumIdStr);
   }
   model.put("keywords", keywords);
   model.put("forumId", forumId);
   FrontUtils.frontPageData(request, model);
   return FrontUtils.getTplPath(request, site, TPLDIR_SPECIAL, SEARCH_RESULT);
 }
示例#3
0
 @RequestMapping(value = "/data/v_rename.do")
 public String renameInput(HttpServletRequest request, ModelMap model) {
   String name = RequestUtils.getQueryParam(request, "name");
   String origName = name.substring(Constants.BACKUP_PATH.length());
   model.addAttribute("origName", origName);
   return "data/rename";
 }
示例#4
0
 @RequestMapping(value = "/register.jspx", method = RequestMethod.POST)
 public String submit(
     String username,
     String email,
     String password,
     CmsUserExt userExt,
     String captcha,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   WebErrors errors = validateSubmit(username, email, password, captcha, site, request, response);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   String ip = RequestUtils.getIpAddr(request);
   cmsUserMng.registerMember(username, email, password, ip, null, userExt);
   log.info("member register success. username={}", username);
   if (!StringUtils.isBlank(nextUrl)) {
     response.sendRedirect(nextUrl);
     return null;
   } else {
     return FrontUtils.showMessage(request, model, "global.success");
   }
 }
示例#5
0
 @RequestMapping("/data/o_delete_single.do")
 public String deleteSingle(
     HttpServletRequest request, ModelMap model, HttpServletResponse response) {
   // TODO 输入验证
   String name = RequestUtils.getQueryParam(request, "name");
   int count = resourceMng.delete(new String[] {name});
   log.info("delete Resource {}, count {}", name, count);
   cmsLogMng.operating(request, "resource.log.delete", "filename=" + name);
   return listBackUpFiles(model, request, response);
 }
示例#6
0
 @RequiresPermissions("data:o_delete_single")
 @RequestMapping("/mysql/data/o_delete_single.do")
 public String deleteSingle(
     HttpServletRequest request, ModelMap model, HttpServletResponse response) {
   String name = RequestUtils.getQueryParam(request, "name");
   WebErrors errors = validateDelete(new String[] {name}, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   int count = resourceMng.delete(new String[] {name});
   log.info("delete Resource {}, count {}", name, count);
   cmsLogMng.operating(request, "resource.log.delete", "filename=" + name);
   return listBackUpFiles(model, request, response);
 }
示例#7
0
  @RequestMapping(value = "/vote.jspx", method = RequestMethod.POST)
  public String submit(
      Integer voteId,
      Integer[] subIds,
      String[] reply,
      HttpServletRequest request,
      HttpServletResponse response,
      ModelMap model) {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    String ip = RequestUtils.getIpAddr(request);
    String cookieName = VOTE_COOKIE_PREFIX + voteId;
    Cookie cookie = CookieUtils.getCookie(request, cookieName);
    String cookieValue;
    if (cookie != null && !StringUtils.isBlank(cookie.getValue())) {
      cookieValue = cookie.getValue();
    } else {
      cookieValue = null;
    }
    List<Integer[]> itemIds = getItemIdsParam(request, subIds);
    Integer[] subTxtIds = null;
    if (reply != null && reply.length > 0) {
      subTxtIds = new Integer[reply.length];
      List<Integer> subTxtIdList = new ArrayList<Integer>();
      for (int i = 0; i < itemIds.size(); i++) {
        if (itemIds.get(i) == null) {
          subTxtIdList.add(subIds[i]);
        }
      }
      // 投票文本选项和题目id数组对应相同大小
      subTxtIds = (Integer[]) subTxtIdList.toArray(subTxtIds);
    }
    if (!validateSubmit(voteId, subIds, itemIds, user, ip, cookieValue, model)) {
      if (cookieValue == null) {
        // 随机cookie
        cookieValue = StringUtils.remove(UUID.randomUUID().toString(), "-");
        // 写cookie
        CookieUtils.addCookie(request, response, cookieName, cookieValue, Integer.MAX_VALUE, null);
      }
      CmsVoteTopic vote =
          cmsVoteTopicMng.vote(voteId, subTxtIds, itemIds, reply, user, ip, cookieValue);
      model.addAttribute("status", 0);
      model.addAttribute("vote", vote);

      log.info("vote CmsVote id={}, name={}", vote.getId(), vote.getTitle());
    }
    FrontUtils.frontData(request, model, site);
    return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_SPECIAL, VOTE_RESULT);
  }
示例#8
0
 @RequestMapping(value = "/email_unique.jspx")
 public void emailUnique(HttpServletRequest request, HttpServletResponse response) {
   String email = RequestUtils.getQueryParam(request, "email");
   // email为空,返回false。
   if (StringUtils.isBlank(email)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   // email存在,返回false。
   if (unifiedUserMng.emailExist(email)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   ResponseUtils.renderJson(response, "true");
 }
 @RequestMapping(value = "/username_unique.jspx")
 public void usernameUnique(HttpServletRequest request, HttpServletResponse response) {
   String username = RequestUtils.getQueryParam(request, "username");
   // 用户名为空,返回false。
   if (StringUtils.isBlank(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   // 用户名存在,返回false。
   if (unifiedUserMng.usernameExist(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   ResponseUtils.renderJson(response, "true");
 }
示例#10
0
 @RequestMapping(value = "/username_unique.jspx")
 public void usernameUnique(HttpServletRequest request, HttpServletResponse response) {
   String username = RequestUtils.getQueryParam(request, "username");
   // 用户名为空,返回false。
   if (StringUtils.isBlank(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   CmsSite site = CmsUtils.getSite(request);
   CmsConfig config = site.getConfig();
   // 保留字检查不通过,返回false。
   if (!config.getMemberConfig().checkUsernameReserved(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   // 用户名存在,返回false。
   if (unifiedUserMng.usernameExist(username)) {
     ResponseUtils.renderJson(response, "false");
     return;
   }
   ResponseUtils.renderJson(response, "true");
 }
  @RequestMapping(value = "/register.jspx", method = RequestMethod.POST)
  public String submit(
      String username,
      String email,
      String password,
      BbsUserExt userExt,
      String captcha,
      String nextUrl,
      HttpServletRequest request,
      HttpServletResponse response,
      ModelMap model)
      throws IOException {
    CmsSite site = CmsUtils.getSite(request);
    BbsConfig config = bbsConfigMng.findById(site.getId());
    WebErrors errors = validateSubmit(username, email, password, captcha, site, request, response);
    if (errors.hasErrors()) {
      return FrontUtils.showError(request, response, model, errors);
    }
    String ip = RequestUtils.getIpAddr(request);
    Integer groupId = null;
    BbsUserGroup group = bbsConfigMng.findById(site.getId()).getRegisterGroup();
    if (group != null) {
      groupId = group.getId();
    }
    BbsUser user = null;
    if (config.getEmailValidate()) {
      EmailSender sender = configMng.getEmailSender();
      MessageTemplate msgTpl = configMng.getRegisterMessageTemplate();
      if (sender == null) {
        // 邮件服务器没有设置好
        model.addAttribute("status", 4);
      } else if (msgTpl == null) {
        // 邮件模板没有设置好
        model.addAttribute("status", 5);
      } else {
        try {
          user =
              bbsUserMng.registerMember(
                  username, email, password, ip, groupId, userExt, false, sender, msgTpl);
          bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId());
          model.addAttribute("status", 0);
        } catch (Exception e) {
          // 发送邮件异常
          model.addAttribute("status", 100);
          model.addAttribute("message", e.getMessage());
          log.error("send email exception.", e);
        }
      }
      log.info("member register success. username={}", username);
      if (!StringUtils.isBlank(nextUrl)) {
        response.sendRedirect(nextUrl);
        return null;
      } else {
        FrontUtils.frontData(request, model, site);
        FrontUtils.frontPageData(request, model);
        return FrontUtils.getTplPath(
            request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_RESULT);
      }
    } else {
      user = bbsUserMng.registerMember(username, email, password, ip, groupId, userExt);
      bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId());
      log.info("member register success. username={}", username);
      FrontUtils.frontData(request, model, site);
      FrontUtils.frontPageData(request, model);
      model.addAttribute("success", true);
      return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, LOGIN_INPUT);
    }

    /*
     * BbsUser user = bbsUserMng.registerMember(username, email, password,
     * ip, groupId, userExt);
     */
  }