?? configurationwebhandler.java
字號:
/*
* $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/ConfigurationWebHandler.java,v 1.7 2004/02/03 19:07:22 minhnn Exp $
* $Author: minhnn $
* $Revision: 1.7 $
* $Date: 2004/02/03 19:07:22 $
*
* ====================================================================
*
* 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
*/
package com.mvnforum.admin;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.*;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import net.myvietnam.mvncore.exception.BadInputException;
import net.myvietnam.mvncore.util.FileUtil;
import net.myvietnam.mvncore.util.ParamUtil;
public class ConfigurationWebHandler
{
private static Log log = LogFactory.getLog(ConfigurationWebHandler.class);
public ConfigurationWebHandler() {
}
public void updateConfigStepOne(HttpServletRequest request)
throws BadInputException, DocumentException, IOException {
String MvnforumHome, WebmasterEmail, LogoUrl, SupportedLocales, DefaultLocaleName, DefaultGuestName, DisablePasswordlessAuth,
RequireActivation, EnableLoginInfoInCookie, EnableLoginInfoInSession, EnableLoginInfoInRealm, EnableLoginInfoInCustomization,
EnableNewMember, EnableRss, EnableWatch, EnableNewPost, EnableAttachment, EnableAvatar, EnableEmoticon, EnableModeration;
MvnforumHome = ParamUtil.getParameter(request, "MvnforumHome");
WebmasterEmail = ParamUtil.getParameter(request, "WebmasterEmail");
LogoUrl = ParamUtil.getParameter(request, "LogoUrl");
SupportedLocales = ParamUtil.getParameter(request, "SupportedLocales");
DefaultLocaleName = ParamUtil.getParameter(request, "DefaultLocaleName");
DefaultGuestName = ParamUtil.getParameter(request, "DefaultGuestName");
DisablePasswordlessAuth = ParamUtil.getParameter(request, "DisablePasswordlessAuth");
RequireActivation = ParamUtil.getParameter(request, "RequireActivation");
EnableLoginInfoInCookie = ParamUtil.getParameter(request, "EnableLoginInfoInCookie");
EnableLoginInfoInSession = ParamUtil.getParameter(request, "EnableLoginInfoInSession");
EnableLoginInfoInRealm = ParamUtil.getParameter(request, "EnableLoginInfoInRealm");
EnableLoginInfoInCustomization = ParamUtil.getParameter(request, "EnableLoginInfoInCustomization");
EnableNewMember = ParamUtil.getParameter(request, "EnableNewMember");
EnableNewPost = ParamUtil.getParameter(request, "EnableNewPost");
EnableAttachment = ParamUtil.getParameter(request, "EnableAttachment");
EnableAvatar = ParamUtil.getParameter(request, "EnableAvatar");
EnableEmoticon = ParamUtil.getParameter(request, "EnableModeration");
EnableModeration = ParamUtil.getParameter(request, "EnableModeration");
EnableRss = ParamUtil.getParameter(request, "EnableRss");
EnableWatch = ParamUtil.getParameter(request, "EnableWatch");
String strPathName = FileUtil.getServletClassesPath();
SAXReader reader = new SAXReader();
Document document = reader.read(strPathName + "mvnforum.xml");
Element root = document.getRootElement();
// iterate through child elements of root
for (Iterator i = root.elementIterator("mvnforumconfig"); i.hasNext(); ) {
Element element = (Element) i.next();
for (int j = 0, size = element.nodeCount(); j < size; j++) {
Node node = element.node(j);
if (node.getNodeTypeName().equals("Element")) {
//System.out.println(node.getName() +"=" + node.getText());
if (node.getName().equals("mvnforum_home")) {
node.setText(MvnforumHome);
} else if (node.getName().equals("webmaster_email")) {
node.setText(WebmasterEmail);
} else if (node.getName().equals("logo_url")) {
node.setText(LogoUrl);
} else if (node.getName().equals("supported_locales")) {
node.setText(SupportedLocales);
} else if (node.getName().equals("default_locale_name")) {
node.setText(DefaultLocaleName);
} else if (node.getName().equals("default_guest_name")) {
node.setText(DefaultGuestName);
} else if (node.getName().equals("disable_passwordless_auth")) {
node.setText(DisablePasswordlessAuth);
} else if (node.getName().equals("enable_login_info_in_cookie")) {
node.setText(EnableLoginInfoInCookie);
} else if (node.getName().equals("enable_login_info_in_session")) {
node.setText(EnableLoginInfoInSession);
} else if (node.getName().equals("enable_login_info_in_realm")) {
node.setText(EnableLoginInfoInRealm);
} else if (node.getName().equals("enable_login_info_in_customization")) {
node.setText(EnableLoginInfoInCustomization);
} else if (node.getName().equals("require_activation")) {
node.setText(RequireActivation);
} else if (node.getName().equals("enable_new_member")) {
node.setText(EnableNewMember);
} else if (node.getName().equals("enable_new_post")) {
node.setText(EnableNewPost);
} else if (node.getName().equals("enable_rss")) {
node.setText(EnableRss);
} else if (node.getName().equals("enable_watch")) {
node.setText(EnableWatch);
} else if (node.getName().equals("enable_attachment")) {
node.setText(EnableAttachment);
} else if (node.getName().equals("enable_avatar")) {
node.setText(EnableAvatar);
} else if (node.getName().equals("enable_emoticon")) {
node.setText(EnableEmoticon);
} else if (node.getName().equals("enable_moderation")) {
node.setText(EnableModeration);
}
}
}
}
saveDocument(document, strPathName + "mvnforum.xml");
}
public void updateConfigStepTwo(HttpServletRequest request)
throws BadInputException, DocumentException, IOException {
String maxAttachmentSize, maxFavoriteThread, maxEditDays, maxAttachDays, maxDeleteDays, rowsPerPage, rowsPerRSS,
hotTopicThreshold, maxPostsPerHour, maxMembersPerHour, enableBackupOnServer, maxImportSize;
maxAttachmentSize = ParamUtil.getParameter(request, "MaxAttachmentSize");
maxFavoriteThread = ParamUtil.getParameter(request, "MaxFavoriteThread");
maxEditDays = ParamUtil.getParameter(request, "MaxEditDays");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -