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

📄 post.java

📁 天乙虚拟社区8.05版本。只支持Mysql
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		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(this.getUserBlog());
		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(this.boolean2int(this.getPreviewAttach()));

		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"));
				this.setNeedsAttribute(true);
				return INPUT;
			}

			f = this.getForumService().createReForum(f, mainForum, this.getBoard(), ui, uploadFile, isQuote);
			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"));
			this.setNeedsAttribute(true);
			return INPUT;
		}
	}

	public String upfile() {
		Forum f = this.getForumService().findForumByID(this.getId(), this.getBid());
		if (f == null) {
			this.addActionError(this.getText("error.post.getpost"));
			return RESULT_HTMLERROR;
		}
		if (!this.getUserSession().getId().equals(f.getUserID())) {

			this.addActionError(this.getText("error.post.upfile.user1", new String[] { this.getId() }));
			return RESULT_HTMLERROR;
		}
		this.setUpfileIframeUrl(this.getBasePath()
				+ BBSCSUtil.getActionMappingURLWithoutPrefix("post?action=upfileinput&id=" + this.getId() + "&bid="
						+ this.getBid()));
		return "upfileInPost";
	}

	public String upfileinput() {
		return "upfileInput";
	}

	public String upfiledo() {

		Forum f = this.getForumService().findForumByID(this.getId(), this.getBid());

		if (this.getSysConfig().getAttachmentNum() == 0) {
			if (f.getAttachFileName().size() >= 20) {
				this.setAjaxCodeid("2");
				this.setAjaxMsg(this.getText("error.post.upfile.num", new String[] { "20" }));
				return "forumUpComponent";
			}
		} else if (this.getSysConfig().getAttachmentNum() > 0
				&& f.getAttachFileName().size() >= this.getSysConfig().getAttachmentNum()) {

			this.setAjaxCodeid("2");
			this.setAjaxMsg(this.getText("error.post.upfile.num", new String[] { String.valueOf(this.getSysConfig()
					.getAttachmentNum()) }));
			return "forumUpComponent";
		}

		if (!this.getUserSession().getId().equals(f.getUserID())) {
			this.setAjaxCodeid("4");
			this.setAjaxMsg(this.getText("error.post.upfile.user"));
			return "forumUpComponent";
		}

		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.setAjaxCodeid("1");
				this.setAjaxMsg(this.getText("post.upnotice", new String[] {
						String.valueOf(this.getSysConfig().getAttachFileSize()),
						this.getSysConfig().getAttachFileType() }));

				return "forumUpComponent";

			}
			try {
				uploadFile = new UploadFile();
				uploadFile.setFileName(this.getUploadFileName().toLowerCase());
				uploadFile.setInputStream(new FileInputStream(this.getUpload()));
			} catch (FileNotFoundException ex2) {
				uploadFile = null;
				this.setAjaxCodeid("3");
				this.setAjaxMsg(this.getText("error.post.upfile.error"));
				return "forumUpComponent";

			}
		}

		try {
			if (this.getBoard().getAuditAttach() == 1) {
				f.setAuditingAttachFile(1);
			}
			f = this.getForumService().createForumUpFile(f, uploadFile);
			if (this.getBoard().getAuditAttach() == 0) {

				this.setAjaxCodeid("0");
				this.setAjaxMsg(this.getText("post.upfile.upok"));

			} else {
				this.setAjaxCodeid("99");
				this.setAjaxMsg(this.getText("post.upfile.upok1"));
			}

			// this.setAjaxCodeid("0");
			// this.setAjaxMsg(this.getText("post.upfile.upok"));
			return "forumUpComponent";
		} catch (BbscsException ex3) {
			this.setAjaxCodeid("3");
			this.setAjaxMsg(this.getText("error.post.upfile.error"));
			return "forumUpComponent";
		}
	}

	public String showdelattachpage() {
		Forum f = this.getForumService().findForumByID(this.getId(), this.getBid());
		if (f == null) {
			this.addActionError(this.getText("error.post.getpost"));
			return RESULT_HTMLERROR;
		}
		if (f.getAttachFileName() == null || f.getAttachFileName().isEmpty()) {
			this.addActionError(this.getText("error.post.upfile.notexist", new String[] { this.getId() }));
			return RESULT_HTMLERROR;
		}
		if (!(this.getUserSession().getId().equals(f.getUserID()) || this.getUserSession()
				.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_DELATTACH))) {
			this.addActionError(this.getText("error.post.upfile.user2", new String[] { this.getId() }));
			return RESULT_HTMLERROR;
		}
		this.setAttachFiles(f.getAttachFileName());
		return "attachFiles";
	}

	public String edit() {
		Forum f = this.getForumService().findForumByID(this.getId(), this.getBid());
		if (f == null) {
			this.addActionError(this.getText("error.post.getpost"));
			return ERROR;
		}
		if (!(f.getUserID().equals(this.getUserSession().getId()) || this.getUserSession()
				.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST))) {
			this.addActionError(this.getText("error.noPermission"));
			return ERROR;
		}

		if (this.getSysConfig().getEditPostLimit() > 0) {
			if (!(this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST) || (System
					.currentTimeMillis() - f.getPostTime()) < this.getSysConfig().getEditPostLimit() * 60000)) {
				this.addActionError(this.getText("error.post.edit.timeout"));
				return ERROR;
			}
		}

		this.setAction("editdo");
		this.setTitle(f.getTitle());
		//this.setDetail(f.getDetail());#### change at 2007.5.1
		this.setDetail(this.getForumService().getForumDetail(f,true));

		this.setTitleColor(f.getTitleColor());
		this.setPostType(f.getPostType());
		this.setFace(f.getFace());
		this.setEditType(f.getEditType());
		this.setSign(3);
		this.setEmailInform(this.int2boolean(f.getEmailInform()));
		this.setMsgInform(this.int2boolean(f.getMsgInform()));
		setNeedsAttributeEdit(f.getIsNew());
		return INPUT;
	}

	public String editdo() {
		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 f = this.getForumService().findForumByID(this.getId(), this.getBid());
		if (f == null) {
			this.addActionError(this.getText("error.post.getpost"));
			return ERROR;
		}
		if (!(f.getUserID().equals(this.getUserSession().getId()) || this.getUserSession()
				.isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_EDITPOST))) {
			this.addActionError(this.getText("error.noPermission"));
			return ERROR;
		}

		String IP = this.getUserRemoteAddr().substring(0, this.getUserRemoteAddr().lastIndexOf(".")) + ".*";
		f.setArtSize(BBSCSUtil.getSysCharsetStrLength(this.getDetail()));

		String amend = this.getText("change.text", new String[] { this.getUserSession().getUserName(),
				Util.formatDateTime(new Date()), IP });
		f.setAmend(amend);

		f.setEditType(this.getEditType());
		f.setFace(this.getFace());
		f.setPostType(this.getPostType());
		if (this.getSign() != 3) {
			if (this.getSign() == -1) {
				f.setSign("");
			} else {
				f.setSign(this.getUserSession().getSignDetail()[this.getSign()]);
			}
		}
		f.setTitle(title);
		f.setTitleColor(this.getTitleColor());
		f.setDetail(detail);
		if (f.getIndexStatus() == Constant.INDEX_STATUS_INDEXED) {
			f.setIndexStatus(Constant.INDEX_STATUS_NEED_UPDTAE);
		}

		try {
			f = this.getForumService().saveEditForum(f);
			if (Constant.USE_URL_REWRITE) {
				this.setForwardUrl(this.getBasePath() + "read-topic-" + this.getBid() + "-" + this.getMainID() + "-"
						+ this.getTagId() + "-" + this.getFcpage() + "-index-" + this.getInpages() + ".html");
			} else {
				this.setForwardUrl(this.getBasePath()
						+ BBSCSUtil.getActionMappingURLWithoutPrefix("read?action=topic&id=" + this.getMainID()
								+ "&bid=" + this.getBid() + "&fcpage=" + this.getFcpage() + "&inpages="
								+ this.getInpages() + "&tagId=" + this.getTagId()));
			}
			return SUCCESS;
		} catch (BbscsException ex4) {
			return ERROR;
		}
	}

	public String buy() {
		Forum f = this.getForumService().findForumByID(this.getId(), this.getBid());
		if (f == null) {
			this.addActionError(this.getText("error.post.getpost"));
			return ERROR;
		}

		UserInfo ui = this.getUserService().findUserInfoById(this.getUserSession().getId());
		if (ui == null) {
			this.addActionError(this.getText("error.post.guest"));
			return ERROR;
		}

		if (ui.getCoin() < f.getIsHiddenValue()) {
			this.addActionError(this.getText("error.post.buy.coin"));
			return ERROR;
		}
		try {
			this.getForumService().saveForumBuy(this.getBid(), this.getId(), f, ui);
			if (Constant.USE_URL_REWRITE) {
				this.setForwardUrl(this.getBasePath() + "/read-topic-" + this.getBid() + "-" + this.getId() + "-"
						+ this.getTagId() + "-1-index-1.html");
			} else {
				this.setForwardUrl(this.getBasePath()
						+ BBSCSUtil.getActionMappingURLWithoutPrefix("read?action=topic&id=" + this.getId() + "&bid="
								+ this.getBid() + "&fcpage=" + 1 + "&fcaction=index" + "&inpages=" + 1 + "&tagId="
								+ this.getTagId()));
			}
			return SUCCESS;
		} catch (BbscsException ex5) {
			this.addActionError(this.getText("error.post.buy.error"));
			return ERROR;
		}
	}

	private String checkBeforePost() {
		if (this.getSysConfig().getPostCheckTime() > 0
				&& !this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_NOT_POSTCHECKTIME)) {
			if ((System.currentTimeMillis() - this.getUserCookie().getLastPostTime()) <= (this.getSysConfig()
					.getPostCheckTime() * 1000)) {
				this.addActionError(this.getText("error.post.checktime", new String[] { String.valueOf(this
						.getSysConfig().getPostCheckTime()) }));
				return ERROR;
			}
		}
		if (this.getSysConfig().getUseForbid() == 1) {
			if (this.getSysConfig().isForbidIP(this.getUserRemoteAddr())) {
				this.addActionError(this.getText("error.reg.ipforbid", new String[] { this.getUserRemoteAddr() }));
				return ERROR;
			}
		}
		if (this.getSysConfig().isUsePostPeriodOfTime()) {
			long onwtime = System.currentTimeMillis();
			if (!this.getSysConfig().isInPostPeriodOfTime(onwtime)) {
				this.addActionError(this.getText("error.post.isnotinperiodoftime", new String[] {
						String.valueOf(this.getSysConfig().getPostPeriodOfTimeStart()),
						String.valueOf(this.getSysConfig().getPostPeriodOfTimeEnd()) }));
				return ERROR;
			}
		}
		return SUCCESS;
	}

	private void setNeedsAttribute(boolean isRe) {
		this.setPostHiddenTypeRe(this.getSysConfig().getPostHiddenTypeRe());
		this.setPostHiddenTypeMoney(this.getSysConfig().getPostHiddenTypeMoney());
		this.setPostHiddenTypeArtNum(this.getSysConfig().getPostHiddenTypeArtNum());

		int canUseTitleColor = 0;
		if (!isRe) {
			if (this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_USE_TITLECOLOR)) {
				canUseTitleColor = 1;
			}
		}

		this.setTitleColorOptions(this.getSysOptionsValues().getTitleColorValues(canUseTitleColor, this.getLocale()));
		this.setPostPriceValues(this.getSysOptionsValues().getPostPriceValues(this.getSysConfig().getPostPriceLists()));
		this.tagValues.add(new OptionsString("0", this.getBoard().getBoardName()));
		Iterator it = this.getBoard().getBoardTag().iterator();
		BoardTag bt = null;
		while (it.hasNext()) {
			bt = (BoardTag) it.next();
			this.tagValues.add(new OptionsString(bt.getId(), bt.getTagName()));
		}
	}

	private void setNeedsAttributeEdit(int isNew) {
		this.setPostHiddenTypeRe(this.getSysConfig().getPostHiddenTypeRe());
		this.setPostHiddenTypeMoney(this.getSysConfig().getPostHiddenTypeMoney());
		this.setPostHiddenTypeArtNum(this.getSysConfig().getPostHiddenTypeArtNum());

		int canUseTitleColor = 0;
		if (isNew == 1) {
			if (this.getUserSession().isHaveBoardSpecialPermission(Constant.SPERMISSION_CAN_USE_TITLECOLOR)) {
				canUseTitleColor = 1;
			}
		}

		this.setTitleColorOptions(this.getSysOptionsValues().getTitleColorValues(canUseTitleColor, this.getLocale()));
		this.setPostPriceValues(this.getSysOptionsValues().getPostPriceValues(this.getSysConfig().getPostPriceLists()));
		this.tagValues.add(new OptionsString("0", this.getBoard().getBoardName()));
		Iterator it = this.getBoard().getBoardTag().iterator();
		BoardTag bt = null;
		while (it.hasNext()) {
			bt = (BoardTag) it.next();
			this.tagValues.add(new OptionsString(bt.getId(), bt.getTagName()));
		}
	}

	private int getUserPostPerNum(int userNum, int sysNum) {
		if (userNum == 0) {
			return sysNum;
		} else {
			return userNum;
		}
	}

	public String getUpfileIframeUrl() {
		return upfileIframeUrl;
	}

	public void setUpfileIframeUrl(String upfileIframeUrl) {
		this.upfileIframeUrl = upfileIframeUrl;
	}

	public String getAjaxCodeid() {
		return ajaxCodeid;
	}

	public void setAjaxCodeid(String ajaxCodeid) {
		this.ajaxCodeid = ajaxCodeid;
	}

	public String getAjaxMsg() {
		return ajaxMsg;
	}

	public void setAjaxMsg(String ajaxMsg) {
		this.ajaxMsg = ajaxMsg;
	}

	public List getAttachFiles() {
		return attachFiles;
	}

	public void setAttachFiles(List attachFiles) {
		this.attachFiles = attachFiles;
	}

}

⌨️ 快捷键说明

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