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

📄 mvnforumconfig.java

📁 解觖java技术中后台无法上传数给的情况
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * Default number of rows (of Guest user) shown per page
     */
    private static int ROWS_PER_PAGE = 10;
    public static int getRowsPerPage() {
        return ROWS_PER_PAGE;
    }

    /**
     * This is the number of rows returned when list threads for RSS
     */
    private static int ROWS_PER_RSS = 15;//RSS 0.91
    public static int getRowsPerRSS() {
        return ROWS_PER_RSS;
    }

    /**
     * This is the default value of watch option
     * @see com.mvnforum.db.WatchBean for the constant values
     */
    private static int DEFAULT_WATCH_OPTION = 0;
    public static int getDefaultWatchOption() {
        return DEFAULT_WATCH_OPTION;
    }

    private static int DEFAULT_MODERATION_OPTION = 0;
    public static int getDefaultModerationOption() {
        return DEFAULT_MODERATION_OPTION;
    }

    private static int MAX_CHARS_IN_SHORT_SUMMARY = 100;
    public static int getMaxCharsInShortSummary() {
        //getMaxCharsInPostInIndex
        return MAX_CHARS_IN_SHORT_SUMMARY;
    }

    private static int MAX_CHARS_IN_LONG_SUMMARY = 1000;
    public static int getMaxCharsInLongSummary() {
        //getMaxCharsInPostInListthreads()
        return MAX_CHARS_IN_LONG_SUMMARY;
    }

    private static int MAX_CHARS_IN_RSS = 500;
    public static int getMaxCharsInRss() {
        return MAX_CHARS_IN_RSS;
    }

    /**
     * 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;

    /*
    private static boolean parseBooleanValue(String propertyValue, boolean defaultValue) {
        String result = "true";
        try {
            result = propertyValue.trim();
            if ((result.equalsIgnoreCase("false")) || (result.equalsIgnoreCase("no"))) {
                return false;
            } else if ((result.equalsIgnoreCase("true")) || (result.equalsIgnoreCase("yes"))) {
                return true;
            } else {
                log.warn("Invalid boolean value in properties file. Should be \"true\", \"false\", \"yes\" or \"no\".");
                return defaultValue;
            }
        } catch (Exception e) {
            log.warn(e.getMessage());
            return defaultValue;
        }
    }

    private static int parseIntValue(String propertyValue, int defaultValue) {
        try {
            return Integer.parseInt(propertyValue.trim());
        } catch (Exception e) {
            log.warn(e.getMessage());
            return defaultValue;
        }
    }
    */
    private static int parseIntSizeValue(String propertyValue, int defaultValue) {
        try {
            String temp = propertyValue.trim();
            if (temp.endsWith("B") || temp.endsWith("b")) {
                temp = temp.substring(0, temp.length() - 1);
            }
            switch (temp.charAt(temp.length()-1)) {
                case 'K': case 'k':
                    //examples (ending 'B' was cut before): "1K", "1KB", "1k", "1kB", "1 K", "1 KB", "1 k", "1 kB"
                    return 1024 * Integer.parseInt(temp.substring(0, temp.length() - 1).trim());
                case 'M': case 'm':
                    //examples (ending 'B' was cut before): "1M", "1MB", "1m", "1mB", "1 M", "1 MB", "1 m", "1 mB"
                    return 1024 * 1024 * Integer.parseInt(temp.substring(0, temp.length() - 1).trim());
                default:
                    //examples (ending 'B' was cut before): "1", "1B", "1 B"
                    return Integer.parseInt(temp.trim());
            }
        } catch (Exception e) {
            log.warn(e.getMessage());
            return defaultValue;
        }
    }

    static {
        try {
            load();

            // now check if Guest user is in database or not
            try {
                DAOFactory.getMemberDAO().getMember_forPublic(MVNForumConstant.MEMBER_ID_OF_GUEST);
                m_guestUserInDatabase = true;
            } catch (ObjectNotFoundException ex) {
                // dont have Guest user in database, just ignore
            } catch (Exception ex) {
                log.info("Error occured when get Guest user.", ex);
            }

            // Load FreeMarker configuration
            freeMarkerConfiguration = new Configuration();
            FileTemplateLoader templateLoader = new FileTemplateLoader(new File(MVNForumConfig.getTemplateDir()));
            log.debug("Template directory = " + MVNForumConfig.getTemplateDir());
            freeMarkerConfiguration.setTemplateLoader(templateLoader);
        } catch (Exception e) {
            String message = "com.mvnforum.MVNForumConfig: Can't read the configuration file: '" + OPTION_FILE_NAME + "'. Make sure the file is in your CLASSPATH";
            log.error(message, e);
            m_shouldRun = false;
            m_reason = message;
        }
    }

    public static void load() {
        reload();
    }

    public static void reload() {

        String strPathName = FileUtil.getServletClassesPath();
        String configFilename = strPathName + OPTION_FILE_NAME;
        try {
            DOM4JConfiguration conf = new DOM4JConfiguration(new File(configFilename));

            ENABLE_PORTLET = conf.getBoolean("mvnforumconfig.enable_portlet", ENABLE_PORTLET);

            MVNFORUM_HOME       = conf.getString("mvnforumconfig.mvnforum_home", "");
            setMVNForumHome(MVNFORUM_HOME);

            WEBMASTER_EMAIL     = conf.getString("mvnforumconfig.webmaster_email", "");

            LOGO_URL            = conf.getString("mvnforumconfig.logo_url", LOGO_URL);

            LOG_FILE = conf.getString("mvnforumconfig.mvnforum_log", "");

            String supportedLocales = conf.getString("mvnforumconfig.supported_locales", "");
            SUPPORTED_LOCALE_NAMES = StringUtil.getStringArray(supportedLocales, ";");

            SUPPORTED_LOCALES = new Locale[SUPPORTED_LOCALE_NAMES.length];
            for (int i = 0; i < SUPPORTED_LOCALE_NAMES.length; i++) {
                String localeName = SUPPORTED_LOCALE_NAMES[i];
                SUPPORTED_LOCALES[i] = MyUtil.getLocale(localeName);
            }

            try {
                DEFAULT_LOCALE_NAME = conf.getString("mvnforumconfig.default_locale_name", "");
                if (DEFAULT_LOCALE_NAME.length() == 0) {
                    DEFAULT_LOCALE_NAME = "en";
                }
            } catch (Exception ex) {
                log.warn(ex.getMessage());
            }
            DEFAULT_LOCALE = MyUtil.getLocale(DEFAULT_LOCALE_NAME);

            try {
                DEFAULT_GUEST_NAME = conf.getString("mvnforumconfig.default_guest_name", DEFAULT_GUEST_NAME);
            } catch (Exception ex) {
                log.warn(ex.getMessage());
            }

            DEFAULT_GUEST_TIMEZONE = conf.getDouble("mvnforumconfig.default_guest_timezone", DEFAULT_GUEST_TIMEZONE);
            if ( Math.abs(DEFAULT_GUEST_TIMEZONE) > 12 ) {
                DEFAULT_GUEST_TIMEZONE = 0;
            }

            REDIRECT_LOGIN_URL = conf.getString("mvnforumconfig.redirect_login_url", REDIRECT_LOGIN_URL);
            LOCALE_PARAMETER_NAME = conf.getString("mvnforumconfig.locale_parameter_name", LOCALE_PARAMETER_NAME);

            ENABLE_PASSWORDLESS_AUTH = conf.getBoolean("mvnforumconfig.enable_passwordless_auth", false);
            REQUIRE_ACTIVATION = conf.getBoolean("mvnforumconfig.require_activation", false);
            ENABLE_LOGIN_INFO_IN_COOKIE = conf.getBoolean("mvnforumconfig.enable_login_info_in_cookie", true);
            ENABLE_LOGIN_INFO_IN_SESSION = conf.getBoolean("mvnforumconfig.enable_login_info_in_session", true);
            ENABLE_LOGIN_INFO_IN_REALM = conf.getBoolean("mvnforumconfig.enable_login_info_in_realm", false);
            ENABLE_LOGIN_INFO_IN_CUSTOMIZATION = conf.getBoolean("mvnforumconfig.enable_login_info_in_customization", false);

            ENABLE_CACHE_MEMBER = conf.getBoolean("mvnforumconfig.enable_cache_member", true);
            ENABLE_CACHE_POST = conf.getBoolean("mvnforumconfig.enable_cache_post", true);
            ENABLE_CACHE_THREAD = conf.getBoolean("mvnforumconfig.enable_cache_thread", true);
            ENABLE_CACHE_FORUM = conf.getBoolean("mvnforumconfig.enable_cache_forum", true);
            ENABLE_CACHE_CATEGORY = conf.getBoolean("mvnforumconfig.enable_cache_category", true);

            ENABLE_LOGIN = conf.getBoolean("mvnforumconfig.enable_login", true);
            ENABLE_NEW_MEMBER = conf.getBoolean("mvnforumconfig.enable_new_member", true);
            ENABLE_NEW_POST = conf.getBoolean("mvnforumconfig.enable_new_post", true);
            ENABLE_AVATAR = conf.getBoolean("mvnforumconfig.enable_avatar", true);
            ENABLE_EMOTICON = conf.getBoolean("mvnforumconfig.enable_emoticon", true);
            ENABLE_RSS = conf.getBoolean("mvnforumconfig.enable_rss", true);
            ENABLE_SEARCH = conf.getBoolean("mvnforumconfig.enable_search", true);
            ENABLE_WATCH = conf.getBoolean("mvnforumconfig.enable_watch", true);
            ENABLE_ATTACHMENT = conf.getBoolean("mvnforumconfig.enable_attachment", true);
            ENABLE_MESSAGE_ATTACHMENT = conf.getBoolean("mvnforumconfig.enable_message_attachment", true);
            ENABLE_CAPTCHA = conf.getBoolean("mvnforumconfig.enable_captcha", false);
            ENABLE_PORTAL_LIKE_INDEX_PAGE = conf.getBoolean("mvnforumconfig.enable_portal_like_index_page", true);
            ENABLE_ADMIN_CAN_CHANGE_PASSWORD = conf.getBoolean("mvnforumconfig.enable_admin_can_change_password", true);
            ENABLE_SHOW_LAST_LOGIN = conf.getBoolean("mvnforumconfig.enable_show_last_login", true);
            ENABLE_ONLINE_USERS = conf.getBoolean("mvnforumconfig.enable_online_users", true);
            ENABLE_LISTMEMBERS = conf.getBoolean("mvnforumconfig.enable_listmembers", true);
            ENABLE_DUPLICATE_ONLINE_USERS = conf.getBoolean("mvnforumconfig.enable_duplicate_onlineusers", true);
            ENABLE_INVISIBLE_USERS = conf.getBoolean("mvnforumconfig.enable_invisible_users", true);
            ENABLE_PRIVATE_MESSAGE = conf.getBoolean("mvnforumconfig.enable_private_message", true);
            ENABLE_PUBLIC_MESSAGE = conf.getBoolean("mvnforumconfig.enable_public_message", false);
            ENABLE_GUEST_VIEW_IMAGE_ATTACHMENT = conf.getBoolean("mvnforumconfig.enable_guest_view_image_attachment", false);
            ENABLE_MOST_ACTIVE_THREADS = conf.getBoolean("mvnforumconfig.enable_most_active_threads", true);
            ENABLE_MOST_ACTIVE_MEMBERS = conf.getBoolean("mvnforumconfig.enable_most_active_members", true);
            ENABLE_SITE_STATISTICS_OVERVIEW = conf.getBoolean("mvnforumconfig.enable_site_statistics_overview", false);

            if (ENABLE_PORTLET) {
                //disable any authentication & user involving features
                ENABLE_PASSWORDLESS_AUTH = false;
                REQUIRE_ACTIVATION = false;
                ENABLE_LOGIN_INFO_IN_COOKIE = false;
                ENABLE_LOGIN_INFO_IN_SESSION = false;
                ENABLE_CAPTCHA = false;
                ENABLE_SHOW_LAST_LOGIN = false;
                ENABLE_NEW_MEMBER = false;
                ENABLE_LOGIN = false;
                ENABLE_ADMIN_CAN_CHANGE_PASSWORD = false;
                ENABLE_LISTMEMBERS = false;

                // we check this feature later, should enable or not ?
                ENABLE_SITE_STATISTICS_OVERVIEW = false;

                // enable these feature to check for satifying to create/update forum-account
                ENABLE_LOGIN_INFO_IN_REALM = true;
                ENABLE_LOGIN_INFO_IN_CUSTOMIZATION = true;

                //String memberImpl = Portal.getMemberImplementation(PORTAL_TYPE);

                // We don't care these features because we prefer to control
                // members accessing my forum than control all
                // of members even the members never click on forum link

                //ENABLE_ONLINE_USERS = false;
                //ENABLE_DUPLICATE_ONLINE_USERS = false;
                //ENABLE_INVISIBLE_USERS = false;
            }
            /*
            // Netmama
            ENABLE_COMPANY = conf.getBoolean("mvnforumconfig.enable_company", false);
            ENABLE_LISTCOMPANIES = conf.getBoolean("mvnforumconfig.enable_listcompanies", false);
            EXPIRE_DATE_TUTOR = conf.getInt("mvnforumconfig.expire_date_tutor", 90);
            EXPIRE_SOON_DATE = conf.getInt("mvnforumconfig.expire_soon_date", 7);
            */
            MAX_ATTACHMENT_SIZE = parseIntSizeValue(conf.getString("mvnforumconfig.max_attachment_size"), 1024);
            if (MAX_ATTACHMENT_SIZE < -1) MAX_ATTACHMENT_SIZE = 0;// -1 is a valid value in common-upload, mean no maximum file size
            MAX_MESSAGE_ATTACHMENT_SIZE = parseIntSizeValue(conf.getString("mvnforumconfig.max_message_attachment_size"), 1024);
            if (MAX_MESSAGE_ATTACHMENT_SIZE < -1) MAX_MESSAGE_ATTACHMENT_SIZE = 0;// -1 is a valid value in common-upload, mean no maximum file size

            MAX_FAVORITE_THREAD = conf.getInt("mvnforumconfig.max_favorite_thread", 128);
            if (MAX_FAVORITE_THREAD < 0) MAX_FAVORITE_THREAD = 0;

            MAX_PRIVATE_MESSAGE = conf.getInt("mvnforumconfig.max_private_message", 128);
            if (MAX_PRIVATE_MESSAGE < 0) MAX_PRIVATE_MESSAGE = 0;

            MAX_EDIT_DAYS = conf.getInt("mvnforumconfig.max_edit_days", 7);
            if (MAX_EDIT_DAYS < 0) MAX_EDIT_DAYS = 0;

            MAX_ATTACH_DAYS = conf.getInt("mvnforumconfig.max_attach_days", 1);
            if (MAX_ATTACH_DAYS < 0) MAX_ATTACH_DAYS = 0;

            MAX_DELETE_DAYS = conf.getInt("mvnforumconfig.max_delete_days", 1);
            if (MAX_DELETE_DAYS < 0) MAX_DELETE_DAYS = 0;

            ROWS_PER_PAGE = conf.getInt("mvnforumconfig.rows_per_page", 10);
            if (ROWS_PER_PAGE < 5) ROWS_PER_PAGE = 5;

            ROWS_PER_RSS = conf.getInt("mvnforumconfig.rows_per_rss", 15);
            if (ROWS_PER_RSS < 5) ROWS_PER_RSS = 5;

            HOT_TOPIC_THRESHOLD = conf.getInt("mvnforumconfig.hot_topic_threshold", 10);
            if (HOT_TOPIC_THRESHOLD < 5) HOT_TOPIC_THRESHOLD = 5;

            MAX_POSTS_PER_HOUR = conf.getInt("mvnforumconfig.max_posts_per_hour", MAX_POSTS_PER_HOUR);
            if (MAX_POSTS_PER_HOUR < 0) MAX_POSTS_PER_HOUR = 0;

            MAX_MEMBERS_PER_HOUR = conf.getInt("mvnforumconfig.max_members_per_hour", MAX_MEMBERS_PER_HOUR);
            if (MAX_MEMBERS_PER_HOUR < 0) MAX_MEMBERS_PER_HOUR = 0;

            MAX_LOGINS_PER_HOUR = conf.getInt("mvnforumconfig.max_logins_per_hour", MAX_LOGINS_PER_HOUR);
            if (MAX_LOGINS_PER_HOUR < 0) MAX_LOGINS_PER_HOUR = 0;

            MAX_MESSAGES_PER_HOUR = conf.getInt("mvnforumconfig.max_messages_per_hour", MAX_MESSAGES_PER_HOUR);
            if (MAX_MESSAGES_PER_HOUR < 0) MAX_MESSAGES_PER_HOUR = 0;

            MAX_CHARS_IN_SHORT_SUMMARY = conf.getInt("mvnforumconfig.max_chars_in_short_summary", MAX_CHARS_IN_SHORT_SUMMARY);
            if (MAX_CHARS_IN_SHORT_SUMMARY <= 0) MAX_CHARS_IN_SHORT_SUMMARY = Integer.MAX_VALUE;

            MAX_CHARS_IN_LONG_SUMMARY = conf.getInt("mvnforumconfig.max_chars_in_long_summary", MAX_CHARS_IN_LONG_SUMMARY);
            if (MAX_CHARS_IN_LONG_SUMMARY <= 0) MAX_CHARS_IN_LONG_SUMMARY = Integer.MAX_VALUE;

            MAX_CHARS_IN_RSS = conf.getInt("mvnforumconfig.max_chars_in_rss", MAX_CHARS_IN_RSS);
            if (MAX_CHARS_IN_RSS <= 0) MAX_CHARS_IN_RSS = Integer.MAX_VALUE;

            ENABLE_BACKUP_ON_SERVER = conf.getBoolean("mvnforumconfig.enable_backup_on_server", true);
            MAX_IMPORT_SIZE = parseIntSizeValue(conf.getString("mvnforumconfig.max_import_size", "4096000"), 4096000 );

            DEFAULT_WATCH_OPTION = conf.getInt("mvnforumconfig.default_watch_option", 0);
            if (DEFAULT_WATCH_OPTION < 0 || DEFAULT_WATCH_OPTION > 4) DEFAULT_WATCH_OPTION = 0;

            DEFAULT_MODERATION_OPTION = conf.getInt("mvnforumconfig.default_moderation_option", 0);
            if (DEFAULT_MODERATION_OPTION < 0 || DEFAULT_MODERATION_OPTION > 4) DEFAULT_MODERATION_OPTION = 0;

            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_NEW_MEMBER, MAX_MEMBERS_PER_HOUR);
            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_NEW_POST, MAX_POSTS_PER_HOUR);
            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_LOGIN, MAX_LOGINS_PER_HOUR);
            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_NEW_MESSAGE, MAX_MESSAGES_PER_HOUR);
        } catch (Exception e) {
            // Please note that for security reason, the full path file name is logged
            // to the log file only. And the reason that show on the web should only
            // show the filename only
            String message = "com.mvnforum.MVNForumConfig: Can't read the configuration file: '" + configFilename + "'. Make sure the file is in your CLASSPATH";
            log.error(message, e);
            m_shouldRun = false;
            m_reason = "com.mvnforum.MVNForumConfig: Can't read the configuration file: '" + OPTION_FILE_NAME + "'. Make sure the file is in your CLASSPATH";
        }
    }

    public static boolean supportLocale(String localeName) {
        if ((localeName == null) || (localeName.length() == 0)) {
            return false;
        }

        String[] supportedLocaleNames = MVNForumConfig.getSupportedLocaleNames();
        if (supportedLocaleNames == null) {
            log.fatal("Assertion in MVNForumConfig: supportedLocales is null. Please check your configuration.");
            return false;
        }

        for (int i = 0; i < supportedLocaleNames.length; i++) {
            if (localeName.equals(supportedLocaleNames[i])) {
                return true;
            }
        }
        return false;
    }
}

⌨️ 快捷键说明

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