📄 mvnforumconfig.java
字号:
/*
* Copyright (C) 2002 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
*/
package net.myvietnam.mvnplugin.mvnforum;
import java.util.ResourceBundle;
import java.io.*;
import net.myvietnam.mvncore.util.FileUtil;
import net.myvietnam.mvncore.util.DateUtil;
public final class MVNForumConfig {
private MVNForumConfig() {
}
private static final String OPTION_FILE_NAME = "mvnplugin_mvnforum_MVNForumConfig";
private static boolean shouldRun = true;
public static boolean isShouldRun() {
return shouldRun;
}
private static String reason = "Normal System";
public static String getReason() {
return reason;
}
private static String tempDir = "";
private static String searchIndexDir = "";
private static String logDir = "";
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 + "tempfile.tmp";
//System.out.println("temp file = " + tempFilename);
File tempFile = new File(tempFilename);
//System.out.println("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);
logDir = MVNFORUM_HOME + File.separatorChar + "log";
FileUtil.createDirs(logDir, true);
} catch (IOException ex) {
ex.printStackTrace();
shouldRun = false;
reason = "Check your MVNForumHome. detail = " + ex.getMessage();
}
}
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 getLogDir() {
return logDir;
}
static String WEBMASTER_EMAIL = "webmaster@MyVietnam.net";
public static String getWebMasterEmail() {
return WEBMASTER_EMAIL;
}
static String LOGO_URL = "http://www.mvnForum.com";
public static String getLogoUrl() {
return LOGO_URL;
}
public final static boolean PRINT_STACK_TRACE = true;
public final static int SESSION_DURATION = 30 * DateUtil.MINUTE;// SHOULD NOT less than 15 minutes
public static final boolean DEFAULT_MESSAGE_ENABLE = true;
public static final boolean DEFAULT_MEMBER_ENABLE = true;
public static final int ROWS_IN_ADMINS = 20;
/**
* This is the number of rows returned when list topics
* in MessageWebHandler.listThreads()
* /forum/listthreads
*/
public static final int ROWS_IN_THREADS = 20;
/**
* This is the number of rows returned when list recent topics of any Forum
* /forum/listrecentthreads
*/
public static final int ROWS_IN_RECENT_THREADS = 20;
/**
* This is the number of reply rows returned when viewthread
* /forum/viewthread
*/
public static final int ROWS_IN_REPLIES = 10;
/**
* This is the number of reply rows returned when addpost (reply to a topic)
* /forum/addpost
*/
public static final int ROWS_IN_LAST_REPLIES = 5;
/**
* This is the number of rows returned when list recent messages in the Message table
* /admin/listdisablemessageprocess
*/
public static final int ROWS_IN_RECENT_MESSAGES = 20;
/**
* This is the number of rows returned when list members in the Member table
*/
public static final int ROWS_IN_MEMBERS = 20;
static {
try {
ResourceBundle res = ResourceBundle.getBundle(OPTION_FILE_NAME);
MVNFORUM_HOME = res.getString("MVNFORUM_HOME").trim();
setMVNForumHome(MVNFORUM_HOME);
WEBMASTER_EMAIL = res.getString("WEBMASTER_EMAIL").trim();
LOGO_URL = res.getString("LOGO_URL").trim();
} catch (Exception e) {
e.printStackTrace();
System.out.println("net.myvietnam.webplugin.mvnforum.MVNForumConfig: Can't read the properties file: '" + OPTION_FILE_NAME + ".properties'. Make sure the file is in your CLASSPATH");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -