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

📄 sysconfig.java

📁 天乙虚拟社区8.05版本。只支持Mysql
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package com.laoer.bbscs.service.config;

import java.util.*;

import org.apache.commons.lang.*;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.logging.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.exception.*;
import com.laoer.bbscs.service.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.apache.commons.io.FilenameUtils;

/**
 * <p>
 * Title: Tianyi BBS
 * </p>
 *
 * <p>
 * Description: BBSCS
 * </p>
 *
 * <p>
 * Copyright: Copyright (c) 2006
 * </p>
 *
 * <p>
 * Company: Laoer.com
 * </p>
 *
 * @author Gong Tianyi
 * @version 7.0
 */
public class SysConfig {

	private static final Log logger = LogFactory.getLog(SysConfig.class);

	private HashMap<String, Config> configs;

	private ConfigService configService;

	private boolean isLoad = false;

	public SysConfig(ConfigService configService) {
		this.configs = new HashMap<String, Config>();
		this.configService = configService;
		this.loadConfigs();
	}

	public void loadConfigs() {
		logger.info("Load sys config...");
		List l = this.getConfigService().findConfigs();
		for (int i = 0; i < l.size(); i++) {
			Config config = (Config) l.get(i);
			this.configs.put(config.getId(), config);
		}
		logger.info("Load sys config complete," + l.size() + " items is loaded.");
	}

	public Config getConfigContext(String key) {
		return (Config) this.configs.get(key);
	}

	public void setConfigContext(String key, String confContext) {
		Config config = this.getConfigContext(key);
		config.setConfContext(confContext);
		this.configs.put(key, config);
	}

	public void saveConfigs() throws SysConfigException {
		try {
			this.getConfigService().updateAllConfigs(this.configs);
		} catch (BbscsException ex) {
			logger.error(ex);
			throw new SysConfigException(ex);
		}
	}

	public int getIntValue(String key, int defaultValue) {
		Config config = this.getConfigContext(key);
		return NumberUtils.toInt(config.getConfContext(), defaultValue);
	}

	public String getStringValue(String key) {
		Config config = this.getConfigContext(key);
		return StringUtils.trimToEmpty(config.getConfContext());
	}

	public float getFloatValue(String key, float defaultValue) {
		Config config = this.getConfigContext(key);
		return NumberUtils.toFloat(config.getConfContext(), defaultValue);
	}

	public int getIsOpen() {
		return this.getIntValue("IsOpen", 1);
	}

	public void setIsOpen(int isOpen) {
		this.setConfigContext("IsOpen", String.valueOf(isOpen));
	}

	public boolean isOpen() {
		return (this.getIsOpen() == 1);
	}

	public String getCloseReson() {
		return this.getStringValue("CloseReson");
	}

	public void setCloseReson(String closeReson) {
		this.setConfigContext("CloseReson", closeReson);
	}

	public String getForumName() {
		return this.getStringValue("ForumName");
	}

	public void setForumName(String forumName) {
		this.setConfigContext("ForumName", forumName);
	}

	public String getForumUrl() {
		return this.getStringValue("ForumUrl");
	}

	public void setForumUrl(String forumUrl) {
		this.setConfigContext("ForumUrl", forumUrl);
	}

	public String getWebName() {
		return this.getStringValue("WebName");
	}

	public void setWebName(String webName) {
		this.setConfigContext("WebName", webName);
	}

	public String getWebUrl() {
		return this.getStringValue("WebUrl");
	}

	public void setWebUrl(String webUrl) {
		this.setConfigContext("WebUrl", webUrl);
	}

	public String getWebmasterEmail() {
		return this.getStringValue("WebmasterEmail");
	}

	public void setWebmasterEmail(String webmasterEmail) {
		this.setConfigContext("WebmasterEmail", webmasterEmail);
	}

	public String getPrivacyUrl() {
		return this.getStringValue("PrivacyUrl");
	}

	public void setPrivacyUrl(String privacyUrl) {
		this.setConfigContext("PrivacyUrl", privacyUrl);
	}

	public String getCopyRightMsg() {
		return this.getStringValue("CopyRightMsg");
	}

	public void setCopyRightMsg(String copyRightMsg) {
		this.setConfigContext("CopyRightMsg", copyRightMsg);
	}

	public String getMetaKeywords() {
		return this.getStringValue("MetaKeywords");
	}

	public void setMetaKeywords(String metaKeywords) {
		this.setConfigContext("MetaKeywords", metaKeywords);
	}

	public String getMetaDescription() {
		return this.getStringValue("MetaDescription");
	}

	public void setMetaDescription(String metaDescription) {
		this.setConfigContext("MetaDescription", metaDescription);
	}

	public int getCanSeePageNum() {
		return this.getIntValue("CanSeePageNum", 10);
	}

	public void setCanSeePageNum(int canSeePageNum) {
		this.setConfigContext("CanSeePageNum", String.valueOf(canSeePageNum));
	}

	public int getUseSafeLogin() {
		return this.getIntValue("UseSafeLogin", 0);
	}

	public void setUseSafeLogin(int useSafeLogin) {
		this.setConfigContext("UseSafeLogin", String.valueOf(useSafeLogin));
	}

	public boolean isUseSafeLogin() {
		return (getUseSafeLogin() == 1);
	}

	public int getUseAuthCode() {
		return this.getIntValue("UseAuthCode", 1);
	}

	public void setUseAuthCode(int useAuthCode) {
		this.setConfigContext("UseAuthCode", String.valueOf(useAuthCode));
	}

	public boolean isUseAuthCode() {
		return (getUseAuthCode() == 1);
	}

	public int getUseRegAuthCode() {
		return this.getIntValue("UseRegAuthCode", 1);
	}

	public void setUseRegAuthCode(int useRegAuthCode) {
		this.setConfigContext("UseRegAuthCode", String.valueOf(useRegAuthCode));
	}

	public boolean isUseRegAuthCode() {
		return (getUseRegAuthCode() == 1);
	}

	public String getLogoutUrl() {
		return this.getStringValue("LogoutUrl");
	}

	public void setLogoutUrl(String logoutUrl) {
		this.setConfigContext("LogoutUrl", logoutUrl);
	}

	public int getDateShowType() {
		return this.getIntValue("DateShowType", 0);
	}

	public void setDateShowType(int dateShowType) {
		this.setConfigContext("DateShowType", String.valueOf(dateShowType));
	}

	public int getDefaultTimeZone() {
		return this.getIntValue("DefaultTimeZone", 0);
	}

	public void setDefaultTimeZone(int defaultTimeZone) {
		this.setConfigContext("DefaultTimeZone", String.valueOf(defaultTimeZone));
	}

	public String getForumDateTimeFormat() {
		return this.getStringValue("ForumDateTimeFormat");
	}

	public void setForumDateTimeFormat(String forumDateTimeFormat) {
		this.setConfigContext("ForumDateTimeFormat", forumDateTimeFormat);
	}

	public String getPostDateTimeFormat() {
		return this.getStringValue("PostDateTimeFormat");
	}

	public void setPostDateTimeFormat(String postDateTimeFormat) {
		this.setConfigContext("PostDateTimeFormat", postDateTimeFormat);
	}

	public String getOtherDateTimeFormat() {
		return this.getStringValue("OtherDateTimeFormat");
	}

	public void setOtherDateTimeFormat(String otherDateTimeFormat) {
		this.setConfigContext("OtherDateTimeFormat", otherDateTimeFormat);
	}

	public String getRegDateTimeFormat() {
		return this.getStringValue("RegDateTimeFormat");
	}

	public void setRegDateTimeFormat(String regDateTimeFormat) {
		this.setConfigContext("RegDateTimeFormat", regDateTimeFormat);
	}

	public String getBirthDateTimeFormat() {
		return this.getStringValue("BirthDateTimeFormat");
	}

	public void setBirthDateTimeFormat(String birthDateTimeFormat) {
		this.setConfigContext("BirthDateTimeFormat", birthDateTimeFormat);
	}

	public String getTimeFormat() {
		return this.getStringValue("TimeFormat");
	}

	public void setTimeFormat(String timeFormat) {
		this.setConfigContext("TimeFormat", timeFormat);
	}

	public String getCookiePath() {
		return this.getStringValue("CookiePath");
	}

	public void setCookiePath(String cookiePath) {
		this.setConfigContext("CookiePath", cookiePath);
	}

	public String getCookieDomain() {
		return this.getStringValue("CookieDomain");
	}

	public void setCookieDomain(String cookieDomain) {
		this.setConfigContext("CookieDomain", cookieDomain);
	}

	public String getCookieKey() {
		return this.getStringValue("CookieKey");
	}

	public void setCookieKey(String cookieKey) {
		this.setConfigContext("CookieKey", cookieKey);
	}

	public int getUsePass() {
		return this.getIntValue("UsePass", 0);
	}

	public void setUsePass(int usePass) {
		this.setConfigContext("UsePass", String.valueOf(usePass));
	}

	public boolean isUsePass() {
		return (getUsePass() == 1);
	}

	public String getPassUrl() {
		return this.getStringValue("PassUrl");
	}

	public void setPassUrl(String passUrl) {
		this.setConfigContext("PassUrl", passUrl);
	}

	public String getPassRegUrl() {
		return this.getStringValue("PassRegUrl");
	}

	public void setPassRegUrl(String passRegUrl) {
		this.setConfigContext("PassRegUrl", passRegUrl);
	}

	public String getPassChangeUrl() {
		return this.getStringValue("PassChangeUrl");
	}

	public void setPassChangeUrl(String passChangeUrl) {
		this.setConfigContext("PassChangeUrl", passChangeUrl);
	}

	public int getUseScreen() {
		return this.getIntValue("UseScreen", 1);
	}

	public void setUseScreen(int useScreen) {
		this.setConfigContext("UseScreen", String.valueOf(useScreen));
	}

	public String getBestrowScreen() {
		return this.getStringValue("BestrowScreen");
	}

	public void setBestrowScreen(String bestrowScreen) {
		this.setConfigContext("BestrowScreen", bestrowScreen);
	}

	public String getScreenWord() {
		return this.getStringValue("ScreenWord");
	}

	public void setScreenWord(String screenWord) {
		this.setConfigContext("ScreenWord", screenWord);
	}

	public int getUseEmail() {
		return this.getIntValue("UseEmail", 1);
	}

	public void setUseEmail(int useEmail) {
		this.setConfigContext("UseEmail", String.valueOf(useEmail));
	}

	public int getSmtpAuth() {
		return this.getIntValue("SmtpAuth", 1);
	}

	public void setSmtpAuth(int smtpAuth) {
		this.setConfigContext("SmtpAuth", String.valueOf(smtpAuth));
	}

	public String getSenderEmail() {
		return this.getStringValue("SenderEmail");
	}

	public void setSenderEmail(String senderEmail) {

⌨️ 快捷键说明

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