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

📄 post.java

📁 天乙虚拟社区8.05版本。只支持Mysql
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		String detail = StringUtils.trimToEmpty(this.getDetail());
		if (StringUtils.isBlank(title) || BBSCSUtil.getSysCharsetStrLength(title) > 90) {
			this.addActionError(this.getText("error.post.titletoolong"));
			this.setNeedsAttribute(false);
			return INPUT;
		}
		title = this.getSysConfig().bestrowScreen(title);
		if (StringUtils.isBlank(detail)) {
			this.addActionError(this.getText("error.post.nodetail"));
			this.setNeedsAttribute(false);
			return INPUT;
		}

		if (BBSCSUtil.getSysCharsetStrLength(detail) < this.getSysConfig().getPostMinSize()
				|| BBSCSUtil.getSysCharsetStrLength(detail) > this.getSysConfig().getPostMaxSize()) {
			this.addActionError(this.getText("error.post.texttoolong", new String[] {
					String.valueOf(this.getSysConfig().getPostMinSize()),
					String.valueOf(this.getSysConfig().getPostMaxSize()) }));
			this.setNeedsAttribute(false);
			return INPUT;
		}
		detail = this.getSysConfig().bestrowScreen(detail);
		UploadFile uploadFile = null;
		if (this.getUpload() != null && StringUtils.isNotBlank(this.getUploadFileName())
				&& this.getUpload().length() > 0) {
			if (!this.getSysConfig().isAllowAttachFileType(this.getUploadFileName().toLowerCase())
					|| this.getUpload().length() > (this.getSysConfig().getAttachFileSize() * 1024)) {
				this.addActionError(this.getText("post.upnotice", new String[] {
						String.valueOf(this.getSysConfig().getAttachFileSize()),
						this.getSysConfig().getAttachFileType() }));
				this.setNeedsAttribute(false);
				return INPUT;
			}

			try {
				uploadFile = new UploadFile();
				uploadFile.setFileName(this.getUploadFileName().toLowerCase());
				uploadFile.setInputStream(new FileInputStream(this.getUpload()));
			} catch (FileNotFoundException e) {
				logger.error(e);
				uploadFile = null;
			}
		}

		long nowtime = System.currentTimeMillis();
		Forum f = new ForumMain();
		f.setAgree(0);
		f.setAmend("");
		f.setArtSize(BBSCSUtil.getSysCharsetStrLength(detail));
		f.setAttachFileName(new ArrayList());
		f.setAuditing(this.getBoard().getAuditPost());
		if (this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_POST_NOT_AUDITING)){
			f.setAuditing(0);
		}
		if (this.getBoard().getAuditAttach() == 1 && uploadFile != null) {
			f.setAuditingAttachFile(this.getBoard().getAuditAttach());
		} else {
			f.setAuditingAttachFile(0);
		}
		f.setBeAgainst(0);
		f.setBoardID(this.getBid());
		f.setBoardName(this.getBoard().getBoardName());
		f.setCanNotDel(0);
		f.setCanNotRe(0);
		f.setClick(0);
		f.setCommend(0);
		f.setDelIP("");
		f.setDelSign(0);
		f.setDelTime(0);
		f.setDelUserID("");
		f.setDelUserName("");
		f.setDetail(detail);
		f.setDoEliteName("");
		f.setDoEliteTime(0);
		f.setEditType(this.getEditType());
		f.setElite(0);
		f.setEliteID(0);
		f.setFace(this.getFace());
		f.setHaveAttachFile(0);
		f.setIpAddress(this.getUserRemoteAddr());
		f.setIsHidden(this.getIsHidden());
		if (this.getIsHidden() == 2) {
			f.setIsHiddenValue(this.getUseCoin());
		} else if (this.getIsHidden() == 3) {
			f.setIsHiddenValue(this.getNeedArtNum());
		} else {
			f.setIsHiddenValue(0);
		}
		f.setIsLock(0);
		f.setIsNew(1);
		f.setIsTop(0);
		f.setIsVote(0);
		f.setLastPostNickName("---");
		f.setLastPostTitle("");
		f.setLastPostUserName("---");
		f.setLastTime(nowtime);
		f.setMainID("");
		f.setNickName(this.getUserSession().getNickName());
		f.setParentID("");
		f.setPostTime(nowtime);
		f.setPostType(this.getPostType());
		f.setQuoteText("");
		f.setReNum(0);
		if (this.getSign() == -1) {
			f.setSign("");
		} else {
			f.setSign(this.getUserSession().getSignDetail()[this.getSign()]);
		}
		f.setTitle(title);
		f.setTitleColor(this.getTitleColor());
		f.setUserID(this.getUserSession().getId());
		f.setUserName(this.getUserSession().getUserName());
		f.setEmailInform(this.boolean2int(this.getEmailInform()));
		f.setMsgInform(this.boolean2int(this.getMsgInform()));
		f.setUserBlog(this.getUserBlog());
		if (this.getBoard().getAuditPost() == 0) {
			f.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
		} else {
			f.setIndexStatus(Constant.INDEX_STATUS_AUDIT);
		}

		f.setTagID(this.getTagId());
		if (this.getTagId().equals("0")) {
			f.setTagName("");
		} else {
			f.setTagName(this.getBoard().getBoardTagById(this.getTagId()).getTagName());
		}
		// f.setIsGuest(0);
		f.setPreviewAttach(this.boolean2int(this.getPreviewAttach()));
		try {
			UserInfo ui = this.getUserService().findUserInfoById(this.getUserSession().getId());
			if (ui == null) {
				this.addActionError(this.getText("error.post.guest"));
				this.setNeedsAttribute(false);
				return INPUT;
			}

			f = this.getForumService().createForum(f, this.getBoard(), ui, uploadFile);
			this.getUserCookie().addLastPostTime();
			if (this.getBoard().getAuditPost() == 0 || this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_POST_NOT_AUDITING)) {
				if (Constant.USE_URL_REWRITE) {
					this.setForwardUrl(this.getBasePath() + "forum-index-" + this.getBid() + "-" + this.getTagId()
							+ "-1-0.html");
				} else {
					this.setForwardUrl(BBSCSUtil.getActionMappingURLWithoutPrefix("forum?action=index&bid="
							+ this.getBid() + "&tagId=" + this.getTagId()));
				}
			} else {
				this.setForwardUrl(BBSCSUtil.getActionMappingURLWithoutPrefix("postWaitAudit?bid=" + this.getBid()));
			}
			return SUCCESS;
		} catch (BbscsException ex) {
			this.addActionError(this.getText("error.post.add"));
			this.setNeedsAttribute(false);
			return INPUT;
		}
	}

	public String re() {
		if (this.checkBeforePost().equals(ERROR)) {
			return ERROR;
		}
		this.setAction("addre");

		if (this.getUserCookie().getEditType() == -1) {
			if (this.getSysConfig().getEditInterface() == 0) {
				this.setEditType(0);
			} else if (this.getSysConfig().getEditInterface() == 1) {
				this.setEditType(1);
			} else {
				this.setEditType(2);
			}
		} else {
			this.setEditType(this.getUserCookie().getEditType());
		}
		this.setTitleColor(0);
		this.setPostType(0);
		this.setSign(-1);
		this.setUserBlog(0);
		this.setTitle(Constant.RE);
		this.setPreviewAttach(true);
		this.setNeedsAttribute(true);
		return INPUT;
	}

	public String requote() {
		if (this.checkBeforePost().equals(ERROR)) {
			return ERROR;
		}
		this.setAction("addrequote");

		if (this.getUserCookie().getEditType() == -1) {
			if (this.getSysConfig().getEditInterface() == 0) {
				this.setEditType(0);
			} else if (this.getSysConfig().getEditInterface() == 1) {
				this.setEditType(1);
			} else {
				this.setEditType(2);
			}
		} else {
			this.setEditType(this.getUserCookie().getEditType());
		}
		this.setTitleColor(0);
		this.setPostType(0);
		this.setSign(-1);
		this.setUserBlog(0);
		this.setTitle(Constant.RE);
		this.setPreviewAttach(true);
		this.setNeedsAttribute(true);
		return INPUT;
	}

	public String addqre() {
		if (this.checkBeforePost().equals(ERROR)) {
			return ERROR;
		}
		String title = StringUtils.trimToEmpty(this.getTitle());
		String detail = StringUtils.trimToEmpty(this.getDetail());
		if (StringUtils.isBlank(title) || BBSCSUtil.getSysCharsetStrLength(title) > 90) {
			this.addActionError(this.getText("error.post.titletoolong"));
			return ERROR;
		}
		title = this.getSysConfig().bestrowScreen(title);
		if (StringUtils.isBlank(detail)) {
			this.addActionError(this.getText("error.post.nodetail"));
			return ERROR;
		}

		if (BBSCSUtil.getSysCharsetStrLength(detail) < this.getSysConfig().getPostMinSize()
				|| BBSCSUtil.getSysCharsetStrLength(detail) > this.getSysConfig().getPostMaxSize()) {
			this.addActionError(this.getText("error.post.texttoolong", new String[] {
					String.valueOf(this.getSysConfig().getPostMinSize()),
					String.valueOf(this.getSysConfig().getPostMaxSize()) }));
			return ERROR;
		}
		detail = this.getSysConfig().bestrowScreen(detail);

		Forum mainForum = this.getForumService().findForumByID(this.getMainID(), this.getBid());
		if (mainForum == null) {
			this.addActionError(this.getText("error.post.getpost"));
			return ERROR;
		}
		if (mainForum.getIsLock() == 1) {
			this.addActionError(this.getText("error.post.islock"));
			return ERROR;
		}

		long nowtime = System.currentTimeMillis();
		Forum f = new ForumMain();
		f.setAgree(0);
		f.setAmend("");
		f.setArtSize(BBSCSUtil.getSysCharsetStrLength(detail));
		f.setAttachFileName(new ArrayList());
		f.setAuditing(this.getBoard().getAuditPost());
		if (this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_POST_NOT_AUDITING)){
			f.setAuditing(0);
		}
		// f.setAuditingAttachFile(board.getAuditAttach());
		f.setAuditingAttachFile(0);
		f.setBeAgainst(0);
		f.setBoardID(this.getBid());
		f.setBoardName(this.getBoard().getBoardName());
		f.setCanNotDel(0);
		f.setCanNotRe(0);
		f.setClick(0);
		f.setCommend(0);
		f.setDelIP("");
		f.setDelSign(0);
		f.setDelTime(0);
		f.setDelUserID("");
		f.setDelUserName("");
		f.setDetail(detail);
		f.setDoEliteName("");
		f.setDoEliteTime(0);
		f.setEditType(this.getEditType());
		f.setElite(0);
		f.setEliteID(0);
		f.setFace(this.getFace());
		f.setHaveAttachFile(0);
		f.setIpAddress(this.getUserRemoteAddr());
		f.setIsHidden(this.getIsHidden());
		if (this.getIsHidden() == 2) {
			f.setIsHiddenValue(this.getUseCoin());
		} else if (this.getIsHidden() == 3) {
			f.setIsHiddenValue(this.getNeedArtNum());
		} else {
			f.setIsHiddenValue(0);
		}
		f.setIsLock(0);
		f.setIsNew(0);
		f.setIsTop(0);
		f.setIsVote(0);
		f.setLastPostNickName("---");
		f.setLastPostTitle("");
		f.setLastPostUserName("---");
		f.setLastTime(nowtime);
		f.setMainID(this.getMainID());
		f.setNickName(this.getUserSession().getNickName());
		f.setParentID(this.getParentID());
		f.setPostTime(nowtime);
		f.setPostType(this.getPostType());
		f.setQuoteText("");
		f.setReNum(0);
		if (this.getSign() == -1) {
			f.setSign("");
		} else {
			f.setSign(this.getUserSession().getSignDetail()[this.getSign()]);
		}
		f.setTitle(title);
		f.setTitleColor(this.getTitleColor());
		f.setUserID(this.getUserSession().getId());
		f.setUserName(this.getUserSession().getUserName());
		f.setEmailInform(this.boolean2int(this.getEmailInform()));
		f.setMsgInform(this.boolean2int(this.getMsgInform()));
		f.setUserBlog(0);
		if (this.getBoard().getAuditPost() == 0) {
			f.setIndexStatus(Constant.INDEX_STATUS_NO_INDEX);
		} else {
			f.setIndexStatus(Constant.INDEX_STATUS_AUDIT);
		}

		f.setTagID(mainForum.getTagID());
		f.setTagName(mainForum.getTagName());
		// f.setIsGuest(0);

		f.setPreviewAttach(0);

		int userPostPerNum = this.getUserPostPerNum(this.getUserCookie().getPostPerNum(), this.getSysConfig()
				.getPostPerPage());
		int inpages = (int) Math.ceil((this.getTotalnum() + 1) + userPostPerNum - 1) / userPostPerNum;
		if (mainForum.getIsHidden() == 1) {
			inpages = 1;
		}
		try {
			UserInfo ui = this.getUserService().findUserInfoById(this.getUserSession().getId());
			if (ui == null) {
				this.addActionError(this.getText("error.post.guest"));
				return ERROR;
			}

			f = this.getForumService().createReForum(f, mainForum, this.getBoard(), ui, null, false);
			this.getUserCookie().addLastPostTime();
			if (this.getBoard().getAuditPost() == 0 || this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_POST_NOT_AUDITING)) {
				if (Constant.USE_URL_REWRITE) {
					this.setForwardUrl(this.getBasePath() + "read-topic-" + this.getBid() + "-" + this.getMainID()
							+ "-" + this.getTagId() + "-" + this.getFcpage() + "-index-" + inpages + ".html");
				} else {
					this.setForwardUrl(this.getBasePath()
							+ BBSCSUtil.getActionMappingURLWithoutPrefix("read?action=topic&id=" + this.getMainID()
									+ "&bid=" + this.getBid() + "&tagId=" + this.getTagId() + "&fcpage="
									+ this.getFcpage() + "&inpages=" + inpages));
				}
			} else {
				this.setForwardUrl(this.getBasePath()
						+ BBSCSUtil.getActionMappingURLWithoutPrefix("postWaitAudit?bid=" + this.getBid()));
			}
			return SUCCESS;
		} catch (BbscsException ex1) {
			this.addActionError(this.getText("error.post.add"));
			return ERROR;
		}
	}

	public String addre() {
		return this.addrepro(false);
	}

	public String addrequote() {
		return this.addrepro(true);
	}

	private String addrepro(boolean isQuote) {
		if (this.checkBeforePost().equals(ERROR)) {
			return ERROR;
		}
		String title = StringUtils.trimToEmpty(this.getTitle());
		String detail = StringUtils.trimToEmpty(this.getDetail());
		if (StringUtils.isBlank(title) || BBSCSUtil.getSysCharsetStrLength(title) > 90) {
			this.addActionError(this.getText("error.post.titletoolong"));
			this.setNeedsAttribute(true);
			return INPUT;
		}
		title = this.getSysConfig().bestrowScreen(title);
		if (StringUtils.isBlank(detail)) {
			this.addActionError(this.getText("error.post.nodetail"));
			this.setNeedsAttribute(true);
			return INPUT;
		}

		if (BBSCSUtil.getSysCharsetStrLength(detail) < this.getSysConfig().getPostMinSize()
				|| BBSCSUtil.getSysCharsetStrLength(detail) > this.getSysConfig().getPostMaxSize()) {
			this.addActionError(this.getText("error.post.texttoolong", new String[] {
					String.valueOf(this.getSysConfig().getPostMinSize()),
					String.valueOf(this.getSysConfig().getPostMaxSize()) }));
			this.setNeedsAttribute(true);
			return INPUT;
		}
		detail = this.getSysConfig().bestrowScreen(detail);

		UploadFile uploadFile = null;
		if (this.getUpload() != null && StringUtils.isNotBlank(this.getUploadFileName())
				&& this.getUpload().length() > 0) {
			if (!this.getSysConfig().isAllowAttachFileType(this.getUploadFileName().toLowerCase())
					|| this.getUpload().length() > (this.getSysConfig().getAttachFileSize() * 1024)) {
				this.addActionError(this.getText("post.upnotice", new String[] {
						String.valueOf(this.getSysConfig().getAttachFileSize()),
						this.getSysConfig().getAttachFileType() }));
				this.setNeedsAttribute(true);
				return INPUT;
			}

			try {
				uploadFile = new UploadFile();
				uploadFile.setFileName(this.getUploadFileName().toLowerCase());
				uploadFile.setInputStream(new FileInputStream(this.getUpload()));
			} catch (FileNotFoundException e) {
				logger.error(e);
				uploadFile = null;
			}
		}

		Forum mainForum = this.getForumService().findForumByID(this.getMainID(), this.getBid());
		if (mainForum == null) {
			this.addActionError(this.getText("error.post.getpost"));
			this.setNeedsAttribute(true);
			return INPUT;
		}
		if (mainForum.getIsLock() == 1) {
			this.addActionError(this.getText("error.post.islock"));
			this.setNeedsAttribute(true);
			return INPUT;
		}

		long nowtime = System.currentTimeMillis();
		Forum f = new ForumMain();
		f.setAgree(0);
		f.setAmend("");
		f.setArtSize(BBSCSUtil.getSysCharsetStrLength(detail));
		f.setAttachFileName(new ArrayList());
		f.setAuditing(this.getBoard().getAuditPost());
		if (this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_POST_NOT_AUDITING)){
			f.setAuditing(0);
		}
		// f.setAuditingAttachFile(board.getAuditAttach());
		if (this.getBoard().getAuditAttach() == 1 && uploadFile != null) {
			f.setAuditingAttachFile(this.getBoard().getAuditAttach());
		} else {
			f.setAuditingAttachFile(0);
		}
		f.setBeAgainst(0);
		f.setBoardID(this.getBid());
		f.setBoardName(this.getBoard().getBoardName());
		f.setCanNotDel(0);
		f.setCanNotRe(0);
		f.setClick(0);
		f.setCommend(0);
		f.setDelIP("");
		f.setDelSign(0);
		f.setDelTime(0);
		f.setDelUserID("");
		f.setDelUserName("");
		f.setDetail(detail);
		f.setDoEliteName("");
		f.setDoEliteTime(0);
		f.setEditType(this.getEditType());
		f.setElite(0);
		f.setEliteID(0);

⌨️ 快捷键说明

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