<%@ page contentType="text/html;charset=GBK" %>
<%
/**
 *	$RCSfile: login.jsp,v $
 *	$Revision: 1.3 $
 *	$Date: 2002/10/07 07:50:53 $
 */
%>

<%@ page import="java.net.*,
                 java.util.*,
                 com.jivesoftware.forum.*,
                 com.jivesoftware.forum.util.*"
    errorPage="error.jsp"
%>

<%@ include file="global.jsp" %>

<%  // Get parameters
    String username = ParamUtils.getParameter(request,"username");
    if(username!=null && !username.equals(""))
     username=username+"-user-web-"+web_account;
    
    String password = ParamUtils.getParameter(request,"password");
    String referrer = ParamUtils.getParameter(request,"referrer");
    boolean login = ParamUtils.getBooleanParameter(request,"login");
    boolean logout = ParamUtils.getBooleanParameter(request,"logout");
    boolean autoLogin = ParamUtils.getBooleanParameter(request,"autoLogin");
    String loginButton = ParamUtils.getParameter(request,"loginButton");
    boolean unauth = ParamUtils.getBooleanParameter(request, "unauth");

    if ("Cancel".equals(loginButton)) {
        if (referrer == null) {
            referrer = "index.jsp";
        }
        response.sendRedirect(referrer);
        return;
    }

    if ("null".equals(referrer)) {
        referrer = null;
    }
    if (referrer == null) {
        referrer = request.getHeader("REFERER");
    }

    // Error variables
    boolean errors = false;
    String errorMessage = "";

    // logout if requested
    if (logout) {
        SkinUtils.logout(request,response);
        response.sendRedirect("index.jsp");
        return;
    }
  
    // login if requested
    if (login) {
		if (username == null || password == null) {
			errors = true;
			errorMessage = "请输入用户名和密码.";
		}
		if (!errors) {
			try {
				SkinUtils.login(
					request,response,username,password,autoLogin
				);
				// at this point if no exceptions were thrown, the user is
				// logged in, so redirect to the page that sent us here:
				response.sendRedirect(referrer);
				return;
			}
			catch (UnauthorizedException ue) {
				errors = true;
				errorMessage = "不正确的用户名或密码.";
			}
		}
    }
%>

<%  String title = "论坛 - 登陆"; %>
<%@ include file="header.jsp" %>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
    <td>

    <%-- breadcrumbs --%>

    <font face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
     color="<%= JiveGlobals.getJiveProperty("skin.default.linkColor") %>">
    <b>
    <a href="<%= JiveGlobals.getJiveProperty("skin.default.homeURL") %>"
     >首页</a>
    &raquo;
    <a href="index.jsp" title="返回论坛列表"
     >论坛</a>
    &raquo;
    <a href="login.jsp" class="header" title="登录到论坛"
    >登陆</a>
    </b>
    </font>

    </td>
</tr>
</table>

<p>

<%  if (unauth) { %>
    <b><font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
    color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>">
    <%  if (isGuest) { %>
    客人身份没有权限完成此操作
    <%  } else { %>
    您没有权限完成此操作.
    <%  } %>
    </font></b>
    <p>
<%  } %>

<font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>">
请使用下面的表单登陆. 如果您还没有任何帐号,
您可以
<a href="account.jsp?referrer=<%= URLEncoder.encode(referrer) %>">创建一个新帐号</a>.
</font>

<%  if (errors) { %>
    <p>
    <font size="-1" color="#ff0000" face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>">
    <%= errorMessage %>
    </font>
<%  } %>

<form action="login.jsp" method="post" name="loginForm">
<input type="hidden" name="login" value="true">
<input type="hidden" name="referrer" value="<%= referrer %>">

<center>

<table cellpadding="2" cellspacing="0" border="0">
<tr>
    <td>
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
        color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>">
        用户名:
        </font>
    </td>
    <td>
    <input type="text" name="username" size="20" maxlength="30">
    </td>
</tr>
<tr>
    <td>
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
        color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>">
        密　码:
        </font>
    </td>
    <td>
    <input type="password" name="password" size="20" maxlength="30">
    </td>
</tr>
<tr>
    <td align="right">
    <input type="checkbox" name="autoLogin" id="cb01">
    </td>
    <td>
        <font class=p2 face="<%= JiveGlobals.getJiveProperty("skin.default.fontFace") %>"
        color="<%= JiveGlobals.getJiveProperty("skin.default.textColor") %>">
        <label for="cb01">自动登录</label>
        </font>
    </td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
    <td colspan="2" align="center">
    <input type="submit" name="loginButton" value="登 陆">
    <input type="submit" name="loginButton" value="取 消">
    </td>
</tr>
</table>
</form>

<p>

</center>

<script language="JavaScript" type="text/javascript">
<!--
document.loginForm.username.focus();
//-->
</script>

<%@ include file="footer.jsp" %>