account.jsp

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

JSP
346
字号
<%/** *	$RCSfile: account.jsp,v $ *	$Revision: 1.7 $ *	$Date: 2002/04/30 14:41:54 $ */%><%@ page import="java.util.*,                 com.jivesoftware.forum.*,                 com.jivesoftware.forum.util.*"	errorPage="error.jsp"%><%@ include file="global.jsp" %><%	// Figure out if we can make a new account:    boolean newAccounts = !"false".equals(JiveGlobals.getJiveProperty("skin.default.newAccountCreationEnabled"));    // Get parameters    boolean create = ParamUtils.getBooleanParameter(request,"create");	String username = ParamUtils.getParameter(request,"username");	String password = ParamUtils.getParameter(request,"password");	String confirmPassword = ParamUtils.getParameter(request,"confirmPassword");	String email = ParamUtils.getParameter(request,"email");	String name = ParamUtils.getParameter(request,"name");    String location = ParamUtils.getParameter(request,"location");    String occupation = ParamUtils.getParameter(request,"occupation");    String homepage = ParamUtils.getParameter(request,"homepage");	boolean autoLogin = ParamUtils.getBooleanParameter(request,"autoLogin");	String referrer = ParamUtils.getParameter(request,"referrer");    String skinCancel = SkinUtils.getLocalizedString("skin.default.global.cancel",locale);    if ("null".equals(referrer)) {        referrer = null;    }    if (referrer == null) {        referrer = request.getHeader("REFERER");    }    String createButton = ParamUtils.getParameter(request,"createButton");    if (skinCancel.equals(createButton)) {        if (referrer == null) {            referrer = "index.jsp";        }        response.sendRedirect(referrer);        return;    }        // Error variables    boolean errors = false;	boolean errorUsername = false;	boolean errorPassword = false;	boolean errorConfirmPassword = false;	boolean errorEmail = false;	boolean errorName = false;	boolean errorPasswordMatch = false;    // User creation error vars    boolean errorUserAlreadyExists = false;        // Try creating a user account:    if (create && newAccounts) {        // Validate fields        if (username == null || username.length() < 4) {            errorUsername = true;        }        if (password == null || password.length() < 4) {            errorPassword = true;        }        if (confirmPassword == null || confirmPassword.length() < 4) {            errorConfirmPassword = true;        }        if (email == null) {            errorEmail = true;        }        if (name == null) {            errorName = true;        }        if (!errorPassword && !errorConfirmPassword) {            if (!password.equals(confirmPassword)) {                errorPasswordMatch = true;            }        }        errors = errorUsername || errorPassword || errorConfirmPassword                || errorEmail || errorName || errorPasswordMatch;                // create an account if there were no errors        if (!errors) {		    try {                UserManager userManager = forumFactory.getUserManager();                User user = userManager.createUser(username, password, email);                // Set the name			    user.setName( name );                // Set other properties                if (location != null) {                    user.setProperty("jiveLocation", location);                }                if (occupation != null) {                    user.setProperty("jiveOccupation", occupation);                }                if (homepage != null) {                    user.setProperty("jiveHomepage", homepage);                }                // Log this user in                Authorization auth = AuthorizationFactory.getAuthorization(username,password);                session.setAttribute(AuthorizationFactory.SESSION_AUTHORIZATION, auth);                if (autoLogin) {                    SkinUtils.setCookie(response,AuthorizationFactory.COOKIE_AUTOLOGIN,                        AuthorizationFactory.encryptAuthInfo(username, password));                }			    // redirect to main page			    response.sendRedirect("accountSuccess.jsp");			    return;		    }		    catch (UserAlreadyExistsException uaee) {			    errors = true;                errorUserAlreadyExists = true;		    }        }    }    // Get the minimum allowable length of a password & user name:    int minPasswordLength = 4;    int minUsernameLength = 4;    try {        minPasswordLength = Integer.parseInt(                JiveGlobals.getJiveProperty("createAccount.password.minLength"));    } catch (Exception ignored) {}    try {        minUsernameLength = Integer.parseInt(                JiveGlobals.getJiveProperty("createAccount.username.minLength"));    } catch (Exception ignored) {}%><% String title = SkinUtils.getLocalizedString("skin.default.account.title",locale); %><%@ include file="header.jsp" %><% out.flush(); %><%-- Breadcrumbs --%>    <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>" color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>"><b><a href="<%= JiveGlobals.getJiveProperty("skin.default.homeURL") %>"><%= SkinUtils.getLocalizedString("skin.default.global.home",locale) %></a>&raquo;<a href="index.jsp" title="<%= SkinUtils.getLocalizedString("skin.default.global.go_back_to_forum_list",locale) %>"><%= SkinUtils.getLocalizedString("skin.default.global.forums",locale) %></a>&raquo;<a href="account.jsp"><%= SkinUtils.getLocalizedString("skin.default.global.create_account",locale) %></a></b></font><p><%  // Print out a message if new account creation is disabled:    if (!newAccounts) {%>    <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"     face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">    <%= SkinUtils.getLocalizedString("skin.default.account.new_accounts_disabled",locale) %>    </font><p><%  }    else {%><font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"><%= SkinUtils.getLocalizedString("skin.default.account.description",locale) %><b><%= SkinUtils.getLocalizedString("skin.default.account.required",locale) %></b></font><p><%	if (create && errors) { %>	<font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" color="#ff0000" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">    <%  if (errorUserAlreadyExists) { %>        <%= SkinUtils.getLocalizedString("skin.default.account.username_taken",locale) %>    <%  } else if (errorPasswordMatch) { %>        <%= SkinUtils.getLocalizedString("skin.default.account.passwords",locale) %>    <%  } else { %>        <%= SkinUtils.getLocalizedString("skin.default.account.errors",locale) %>    <%  } %>    </font>    <p><%	}%><form action="account.jsp" method="post" name="userForm"><input type="hidden" name="create" value="true"><input type="hidden" name="referrer" value="<%=referrer%>"><table cellpadding="3" cellspacing="0" border="0" align="center"><tr>    <td align="right" nowrap>        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <b><%= SkinUtils.getLocalizedString("skin.default.account.your_name",locale) %></b>        </font>        <%  if (create && errorName) { %>            <br>            <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"             color="#ff0000"             size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>">            <%= SkinUtils.getLocalizedString("skin.default.account.error_your_name",locale) %>            </font>        <%  } %>    </td>    <td valign="top">        <input type="text" name="name" size="30" maxlength="50" value="<%= (name!=null)?name:"" %>">    </td></tr><tr>    <td align="right" nowrap>        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <b><%= SkinUtils.getLocalizedString("skin.default.global.email",locale) %></b>        </font>        <%  if (create && errorEmail) { %>            <br>            <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"             color="#ff0000"             size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>">            <%= SkinUtils.getLocalizedString("skin.default.account.error_email",locale) %>            </font>        <%  } %>    </td>    <td valign="top">        <input type="text" name="email" size="30" maxlength="50" value="<%= (email!=null)?email:"" %>">    </td></tr><tr>    <td align="right" nowrap>        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <b><%= SkinUtils.getLocalizedString("skin.default.account.desired_username",locale) %></b>        </font>        <%  if (create && errorUsername) {            // Display the minimum length of a username:            List usernameLengthDisplay = new ArrayList(1);            usernameLengthDisplay.add(new Integer(minUsernameLength));        %>            <br>            <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"             color="#ff0000"             size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>">            <%= SkinUtils.getLocalizedString("skin.default.account.error_username",locale,usernameLengthDisplay) %>            </font>        <%  } %>    </td>    <td valign="top">        <input type="text" name="username" size="15" maxlength="50" value="<%= (username!=null)?username:"" %>">    </td></tr><tr>    <td align="right" nowrap>        <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>"         face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">        <b><%= SkinUtils.getLocalizedString("skin.default.global.password",locale) %></b>        </font>        <%  if (create && errorPassword) {            // Display the minimum length of a username:            List passwordLengthDisplay = new ArrayList(1);            passwordLengthDisplay.add(new Integer(minPasswordLength));        %>            <br>            <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"             color="#ff0000"             size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>">            <%= SkinUtils.getLocalizedString("skin.default.account.error_password",locale,passwordLengthDisplay) %>            </font>        <%  } %>    </td>    <td valign="top">        <input type="password" name="password" size="15" maxlength="50" value="<%= (password!=null)?password:"" %>">    </td></tr><tr>    <td align="right">        <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"         size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>">        <b><%= SkinUtils.getLocalizedString("skin.default.global.confirm_password",locale) %></b>        </font>        <%  if (create && (errorConfirmPassword || errorPasswordMatch)) { %>            <br>            <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"             color="#ff0000"             size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>">             <%= SkinUtils.getLocalizedString("skin.default.account.passwords",locale) %>             </font>        <%  } %>        </font>    </td>    <td>        <input type="password" name="confirmPassword" size="15" maxlength="50" value="<%= (confirmPassword!=null)?confirmPassword:"" %>">    </td></tr><tr>    <td align="right">    <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">    <%= SkinUtils.getLocalizedString("skin.default.global.location",locale) %>    </font>    </td>    <td>    <input type="text" name="location" size="30" maxlength="50" value="<%= (location!=null)?location:"" %>">    </td></tr><tr>    <td align="right">    <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">    <%= SkinUtils.getLocalizedString("skin.default.global.occupation",locale) %>    </font>    </td>    <td>    <input type="text" name="occupation" size="30" maxlength="50" value="<%= (occupation!=null)?occupation:"" %>">    </td></tr><tr>    <td align="right">    <font size="<%= JiveGlobals.getJiveProperty("skin.default.fontSize") %>" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">    <%= SkinUtils.getLocalizedString("skin.default.global.homepage",locale) %>    </font>    </td>    <td>    <input type="text" name="homepage" size="30" maxlength="50" value="<%= (homepage!=null)?homepage:"" %>">    </td></tr><tr>    <td align="center" colspan="2">    <br>    <input type="submit" name="createButton" value="<%= SkinUtils.getLocalizedString("skin.default.global.create_account",locale) %>">    <input type="submit" name="createButton" value="<%= SkinUtils.getLocalizedString("skin.default.global.cancel",locale) %>">    </td></tr></table><script language="JavaScript" type="text/javascript"><!--document.userForm.name.focus();//--></script></form><%  } // end if can create new accounts %><br><%@ include file="footer.jsp" %>

⌨️ 快捷键说明

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