setup5.jsp

来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· JSP 代码 · 共 235 行

JSP
235
字号
<%/** * $RCSfile: setup5.jsp,v $ * $Revision: 1.3 $ * $Date: 2002/04/30 19:35:33 $ * * Copyright (C) 1999-2002 CoolServlets, Inc. All rights reserved. * * This software is the proprietary information of CoolServlets, Inc. * Use is subject to license terms. */%><%@ page import="java.io.*,                 java.util.*,                 java.lang.reflect.*,                 com.jivesoftware.forum.*,				 com.jivesoftware.forum.util.*,				 com.jivesoftware.util.*"%><% 	Locale locale = JiveGlobals.getLocale();	// Set the JSP page to use the Jive locale	response.setLocale(locale);	// Load the appropriate resource bundle to display the page.	ResourceBundle bundle = SkinUtils.getResourceBundle("skin_admin_setup", locale);%><%	// get parameters    boolean setupCompleted = false;    Object completed = session.getAttribute("setupCompleted");    if (completed != null) {        setupCompleted = ((Boolean)completed).booleanValue();    }	boolean updateAdmin = ParamUtils.getBooleanParameter(request,"updateAdmin");    boolean skip = ParamUtils.getBooleanParameter(request,"skip");	String currentPassword = ParamUtils.getParameter(request, "currentPassword");	String password = ParamUtils.getParameter(request,"password");	if (password == null) {		password = "";	}	String confirmPassword = ParamUtils.getParameter(request,"confirmPassword");	if (confirmPassword == null) {		confirmPassword = "";	}	String email = ParamUtils.getParameter(request,"email");		boolean errors = false;	String errorMessage = "";	if (!setupCompleted && updateAdmin) {		if (!password.equals(confirmPassword)) {			errors = true;			errorMessage = "The passwords you supplied did not match. Please retype them carefully below.";		}		if (password.equals("")) {			errors = true;			errorMessage = "You can not specify a blank password.";		}		else {			Authorization auth = null;			try {				auth = AuthorizationFactory.getAuthorization("admin", currentPassword);			}			catch (UnauthorizedException ue) {				errors = true;				errorMessage = "The value you supplied for the current password field does not " +					"appear to be the valid password for the admin account. Try again with the " +					"correct password.";			}			if (!errors) {				try {					ForumFactory forumFactory = ForumFactory.getInstance(auth);					UserManager userManager = forumFactory.getUserManager();					User admin = userManager.getUser("admin");					admin.setPassword(password);					if (email != null) {						admin.setEmail(email);					}					Date now = new Date();					admin.setCreationDate(now);					admin.setModifiedDate(now);                    					// Everything seems to have worked!                    session.setAttribute("setupCompleted",new Boolean(true));                    session.setAttribute("sidebar.3.light", GREEN);					response.sendRedirect("setup5.jsp");					return;				}				catch (Exception e) {					e.printStackTrace();					errors = true;					errorMessage = "There was an unexpected error encountered when setting the new " +						"admin information. Please check your error logs and attempt to remedy the problem.";				}			}		}	}    if (skip) {        session.setAttribute("setupCompleted",new Boolean(true));        session.setAttribute("sidebar.3.light", GREEN);        response.sendRedirect("setup5.jsp");    }%><%@ include file="global.jsp" %><%@ include file="header.jsp" %><table cellpadding="6" cellspacing="0" border="0" width="100%"><tr><td width="1%" valign="top"><%  // set sidebar properties    if (!GREEN.equals(getSessionString(session,"sidebar.3.light"))) {        session.setAttribute("sidebar.3.light", YELLOW);    }%><%@ include file="sidebar.jsp" %></td><td width="99%" valign="top">    <b>Administrator Account Setup</b>    <hr size="0"><%  if (!setupCompleted) { %>    	<font size="-1">	The Jive Forums database schemas include a default admin account password of "admin" which must be changed	for security reasons. You should also provide a valid email address so that you can be alerted of system	errors.    <p>    <%  if (errors) { %>        <font color="#cc3300">        <i><%= errorMessage %></i>        <p>        </font>    <%  } %>        <font size="-1">    You can skip this step if you already have an administrator defined    or are using a custom user implementation: (not recommended)    </font>    <ul>        <form action="setup5.jsp">            <input type="hidden" name="skip" value="true">            <input type="submit" value="Skip This Step">        </form>    </ul>    <font size="-1">    Or, continue with the standard admin user setup.    </font>	<ul>	<form action="setup5.jsp" mode="post" name="f">	<input type="hidden" name="updateAdmin" value="true">	<table cellpadding="3" cellspacing="0" border="0">	<tr>		<td><font size="-1">Email Address</font></td>		<td><input type="text" size="40" name="email" value=""></td>	</tr>	<tr>		<td colspan="2"><img src="images/blank.gif" width="1" height="3" border="0"></td>	</tr>	<tr>		<td><font size="-1">Current Password</font></td>		<td><input type="text" size="20" name="currentPassword" value="admin"></td>	</tr>	<tr>		<td><font size="-1">New Password</font></td>		<td><input type="password" size="20" name="password" value=""></td>	</tr>	<tr>		<td><font size="-1">Confirm New Password</font></td>		<td><input type="password" size="20" name="confirmPassword" value=""></td>	</tr>	</table>    </ul>    <script language="JavaScript" type="text/javascript">    <!--        document.f.email.focus();    //-->    </script>    <hr size="0">    <center>    <input type="submit" value="Update Admin Account">    </center>    </form><p><%  } %><%  if (setupCompleted) {        // set "setup" property equal to true        JiveGlobals.setJiveProperty("setup","true");        // Remove all the setup attributes from the session        List deletables = new ArrayList(10);        for (Enumeration enum = session.getAttributeNames(); enum.hasMoreElements();) {            String attribName = (String)enum.nextElement();            if (attribName.startsWith("")) {                deletables.add(attribName);            }        }        for (int i=0; i<deletables.size(); i++) {            String attribName = (String)deletables.get(i);            session.removeAttribute(attribName);        }%>    <font size="-1">    Jive Forums setup is now complete! To continue, click the button below    to login to the Jive admin tool.    <p>    </font>        <form action="../index.jsp">    <hr size="0">    <center>    <input type="submit" value="Login to Jive">    </center>    </form><%  } %><%@ include file="footer.jsp" %></td></tr></table>

⌨️ 快捷键说明

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