<%@ page contentType="text/html;charset=GBK" %>

<%
/**
 *	$RCSfile: login.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:16 $
 */
%>

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

<%	// get parameters
	String username = ParamUtils.getParameter(request,"username");
	username=username+"-user-web-"+"admin";
	String password = ParamUtils.getParameter(request,"password");

    boolean errors = false;
    String errorMessage = "";

	if (ParamUtils.getBooleanParameter(request,"login")) {
		try {
            Authorization authToken = AuthorizationFactory.getAuthorization(username, password);
            ForumFactory forumFactory = ForumFactory.getInstance(authToken);
            if (!forumFactory.hasPermission(ForumPermissions.SYSTEM_ADMIN)) {
                throw new UnauthorizedException();
            }
            session.setAttribute("jive.admin.authorization", authToken);
			response.sendRedirect("index.jsp");
			return;
		}
		catch (UnauthorizedException ue) {
            errors = true;
            errorMessage = "登录失败: 请确认你的用户名和口令都正确";
		}
	}
%>

<html>
<head>
	<title>Jive论坛管理员登录</title>
	<script language="JavaScript" type="text/javascript">
		<!--
		// break out of frames
		if (self.parent.frames.length != 0) {
			self.parent.location=document.location;
		}
		//-->
	</script>
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">

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

<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<td width="49%"><br></td>
<td width="2%">
	<noscript>
	<table border="0" cellspacing="0" cellpadding="0">
	<td class="error">
        <font size="-1" color="#ff0000">
        <b>错误:</b> JavaScript不可用。这个工具使用JavaScript并且如果JavaScript不可用，其大多功能将不能正常工作。请打开JavaScript并刷新此页面。
        </font>
	</td>
	</table>
	<br><br><br><br>
	</noscript>

    <%  if (errors) { %>
    <font size="-1" face="arial,helvetica,sans-serif" color="#ff0000">
	<span class="error"><%= errorMessage %></span>
    </font>
	<p>
    <%  } %>
    <p>
    <table cellpadding="1" cellspacing="0" border="0" bgcolor="#999999">
	<tr><td>
    <table cellpadding="2" cellspacing="0" border="0" bgcolor="#eeeeee">
	<tr><td colspan="2"><img src="images/blank.gif" width="1" height="5" border="0"></td></tr>
	<tr>
		<td align="right" nowrap><font size="-1" face="arial,helvetica,sans-serif">用户名 &nbsp;</font></td>
		<td><input type="text" name="username" size="15" maxlength="25"></td>
	</tr>
	<tr><td colspan="2"><img src="images/blank.gif" width="230" height="5" border="0"></td></tr>
	<tr>
		<td align="right" nowrap><font size="-1" face="arial,helvetica,sans-serif">口令 &nbsp;</font></td>
		<td><input type="password" name="password" size="15" maxlength="20"></td>
	</tr>
	<tr><td colspan="2"><img src="images/blank.gif" width="1" height="5" border="0"></td></tr>
	<tr>
		<td colspan="2" align="center">
			<input type="submit" value="&nbsp登录&nbsp;">
			<p>
			<font size="-2" face="verdana,arial,helvetica">
			<b>Jive论坛版本: <%= JiveGlobals.getJiveVersion() %></b>
			</font>
		</td>
	</tr>
	<tr><td colspan="2"><img src="images/blank.gif" width="1" height="5" border="0"></td></tr>
    </table>
    </td></tr>
    </table>
</td>
<td width="49%"><br></td>
</table>

</form>

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

</body>
</html>

