?? mvnforumconfig.java
字號(hào):
/*
* $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/MVNForumConfig.java,v 1.23 2004/06/29 02:17:34 minhnn Exp $
* $Author: minhnn $
* $Revision: 1.23 $
* $Date: 2004/06/29 02:17:34 $
*
* ====================================================================
*
* Copyright (C) 2002-2004 by MyVietnam.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* All copyright notices regarding mvnForum MUST remain intact
* in the scripts and in the outputted HTML.
* The "powered by" text/logo with a link back to
* http://www.mvnForum.com and http://www.MyVietnam.net in the
* footer of the pages MUST remain visible when the pages
* are viewed on the internet or intranet.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Support can be obtained from support forums at:
* http://www.mvnForum.com/mvnforum/index
*
* Correspondence and Marketing Questions can be sent to:
* info@MyVietnam.net
*
* @author: Minh Nguyen minhnn@MyVietnam.net
* @author: Mai Nguyen mai.nh@MyVietnam.net
* @author: Igor Manic imanic@users.sourceforge.net
*/
package com.mvnforum;
import java.io.*;
import java.util.Locale;
import com.mvnforum.db.DAOFactory;
import freemarker.cache.FileTemplateLoader;
import freemarker.template.Configuration;
import net.myvietnam.mvncore.configuration.DOM4JConfiguration;
import net.myvietnam.mvncore.exception.ObjectNotFoundException;
import net.myvietnam.mvncore.info.DatabaseInfo;
import net.myvietnam.mvncore.security.FloodControl;
import net.myvietnam.mvncore.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public final class MVNForumConfig {
private static Log log = LogFactory.getLog(MVNForumConfig.class);
private MVNForumConfig() {
}
private static final String OPTION_FILE_NAME = "mvnforum.xml";
private static boolean m_shouldRun = true;
public static boolean isShouldRun() {
return m_shouldRun;
}
private static String m_reason = "Normal System";
public static String getReason() {
return m_reason;
}
/**
* This method could be use to stop run the forum in some condition.
* Some use could be a page that immediately stop the forum for security.
* Other usage is to check to run on some environment such as Servlet 2.3 or later
*
* @param shouldRun boolean the new shouldRun
* @param reason String the reason of the action, this reason will
* be shown in the error page
*/
public static void setShouldRun(boolean shouldRun, String reason) {
m_shouldRun = shouldRun;
m_reason = reason;
}
private static boolean m_guestUserInDatabase = false;
public static boolean isGuestUserInDatabase() {
return m_guestUserInDatabase;
}
private static String tempDir = "";
private static String searchIndexDir = "";
private static String attachmentDir = "";
private static String backupDir = "";
private static String templateDir = "";
private static void setMVNForumHome(String home) {
// now check the read/write permission by writing a temp file
try {
// always create a dir, if the dir already exitsted, nothing happen
FileUtil.createDirs(home, true);
String tempFilename = home + File.separatorChar + "mvnforum_tempfile.tmp";
File tempFile = new File(tempFilename);
if (log.isDebugEnabled()) {
log.debug("Temp file = " + tempFilename);
log.debug("Absolute filename of temp file = " + tempFile.getAbsolutePath());
}
FileOutputStream fos = new FileOutputStream(tempFilename);
fos.write(tempFilename.getBytes());
fos.close();
tempFile.delete();
// now create the dirs if not exitst
tempDir = MVNFORUM_HOME + File.separatorChar + "temp";
FileUtil.createDirs(tempDir, true);
searchIndexDir = MVNFORUM_HOME + File.separatorChar + "search";
FileUtil.createDirs(searchIndexDir, true);
attachmentDir = MVNFORUM_HOME + File.separatorChar + "attachment";
FileUtil.createDirs(attachmentDir, true);
backupDir = MVNFORUM_HOME + File.separatorChar + "backup";
FileUtil.createDirs(backupDir, true);
// this dir is created as a recommended folder to store the log files
String logDir = MVNFORUM_HOME + File.separatorChar + "log";
FileUtil.createDirs(logDir, true);
// this dir is created as a recommended folder to store the template files
templateDir = MVNFORUM_HOME + File.separatorChar + "template";
FileUtil.createDirs(templateDir, true);
// now check the database
DatabaseInfo databaseInfo = new DatabaseInfo();
if (databaseInfo.getErrorMessage() != null) {
log.fatal("Cannot get database connection. Please correct it first.");
m_shouldRun = false;
m_reason = "Check your database configuration. Detail : " + databaseInfo.getErrorMessage();
}
} catch (IOException ex) {
log.fatal("Cannot setup the mvnForumHome folder. Please correct it first.", ex);
m_shouldRun = false;
m_reason = "Check your mvnForumHome. Detail : " + ex.getMessage();
}
}
private static Configuration freeMarkerConfiguration;
public static Configuration getFreeMarkerConfiguration() {
return freeMarkerConfiguration;
}
private static String MVNFORUM_HOME = "mvnForumHome";
public static String getMVNForumHome() {
return MVNFORUM_HOME;
}
public static String getTempDir() {
return tempDir;
}
public static String getSearchIndexDir() {
return searchIndexDir;
}
public static String getAttachmentDir() {
return attachmentDir;
}
public static String getTemplateDir() {
return templateDir;
}
public static String getBackupDir() {
return backupDir;
}
private static String WEBMASTER_EMAIL = "youremail@yourdomain.com";
public static String getWebMasterEmail() {
return WEBMASTER_EMAIL;
}
private static String LOGO_URL = "http://www.mvnForum.com";
public static String getLogoUrl() {
return LOGO_URL;
}
private static String[] SUPPORTED_LOCALE_NAMES = new String[0];
private static Locale[] SUPPORTED_LOCALES = new Locale[0];
public static String[] getSupportedLocaleNames() {
return SUPPORTED_LOCALE_NAMES;
}
public static Locale[] getSupportedLocales() {
return SUPPORTED_LOCALES;
}
private static String DEFAULT_LOCALE_NAME = "en";
private static Locale DEFAULT_LOCALE = null;
public static String getDefaultLocaleName() {
return DEFAULT_LOCALE_NAME;
}
public static Locale getDefaultLocale() {
return DEFAULT_LOCALE;
}
/**
* Default username of a virtual Guest user. Will be overriden with the data
* from the database, if it exists (for the Guest user).
* Admin can give him a name he wants, like "Guest", "Anonymous", "Surfer",
* or even use a language different than English.
*/
private static String DEFAULT_GUEST_NAME = "Guest";
public static String getDefaultGuestName() {
return DEFAULT_GUEST_NAME;
}
//public final static boolean PRINT_STACK_TRACE = false;
/**
* By default, mvnForum disable passwordless authentication
* If you want to authenticate user from realm or customized methods,
* then set the variable to false (AT YOUR OWN RISK, authough I have not
* found any security issues until now)
*/
private static boolean DISABLE_PASSWORDLESS_AUTH = true;
public static boolean getDisablePasswordlessAuth() {
return DISABLE_PASSWORDLESS_AUTH;
}
private static boolean REQUIRE_ACTIVATION = false;
public static boolean getRequireActivation() {
return REQUIRE_ACTIVATION;
}
private static boolean ENABLE_LOGIN_INFO_IN_COOKIE = true;
public static boolean getEnableLoginInfoInCookie() {
return ENABLE_LOGIN_INFO_IN_COOKIE;
}
private static boolean ENABLE_LOGIN_INFO_IN_SESSION = true;
public static boolean getEnableLoginInfoInSession() {
return ENABLE_LOGIN_INFO_IN_SESSION;
}
private static boolean ENABLE_LOGIN_INFO_IN_REALM = false;
public static boolean getEnableLoginInfoInRealm() {
return ENABLE_LOGIN_INFO_IN_REALM;
}
private static boolean ENABLE_LOGIN_INFO_IN_CUSTOMIZATION = false;
public static boolean getEnableLoginInfoInCustomization() {
return ENABLE_LOGIN_INFO_IN_CUSTOMIZATION;
}
private static boolean ENABLE_LOGIN = true;
public static boolean getEnableLogin() {
return ENABLE_LOGIN;
}
private static boolean ENABLE_NEW_MEMBER = true;
public static boolean getEnableNewMember() {
return ENABLE_NEW_MEMBER;
}
private static boolean ENABLE_NEW_POST = true;
public static boolean getEnableNewPost() {
return ENABLE_NEW_POST;
}
private static boolean ENABLE_AVATAR = true;
public static boolean getEnableAvatar() {
return ENABLE_AVATAR;
}
private static boolean ENABLE_EMOTICON = true;
public static boolean getEnableEmoticon() {
return ENABLE_EMOTICON;
}
private static boolean ENABLE_RSS = true;
public static boolean getEnableRSS() {
return ENABLE_RSS;
}
private static boolean ENABLE_WATCH = true;
public static boolean getEnableWatch() {
return ENABLE_WATCH;
}
private static boolean ENABLE_ATTACHMENT = true;
public static boolean getEnableAttachment() {
return ENABLE_ATTACHMENT;
}
private static int MAX_ATTACHMENT_SIZE = 1024;
public static int getMaxAttachmentSize() {
return MAX_ATTACHMENT_SIZE;
}
// Default is false, but in KG it should be true
private static boolean ENABLE_AUTO_FORUM_OWNER = false;
public static boolean getEnableAutoForumOwner() {
return ENABLE_AUTO_FORUM_OWNER;
}
private static boolean ENABLE_CAPTCHA = false;
public static boolean getEnableCaptcha() {
return ENABLE_CAPTCHA;
}
private static boolean ENABLE_NEW_INDEX_PAGE = true;
public static boolean getEnableNewIndexPage() {
return ENABLE_NEW_INDEX_PAGE;
}
/**
* This is the maximum number of favorite threads that a user can add
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -