<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="conn.asp"-->
<!--#include file="md5.asp"-->
<!--#include file="common.asp"-->
<%
dim SiteName
dim SiteURL
dim MasterName
dim Email
dim PageWidth
dim Unit

sql="select * from setting"
set rs=conn.execute (sql)
if not rs.eof then
	SiteName=rs("SiteName")
	SiteURL=rs("SiteURL")
	MasterName=rs("MasterName")
	Email=rs("Email")
	
	PageWidth=rs("PageWidth")
	Unit=rs("Unit")
	rs.close
end if

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%response.write SiteName&"-自助友情链接系统 V1.7 - Power By DATA100.NET"%></title>
<LINK href="css.css" type=text/css rel=stylesheet>
</head>

<body>
<%
if request("submit")=" 确 定 " then
	dim username
	dim passsword
	dim repasssword
	dim verify
	
	username=trim(replace(request("username"),"'",""))
	passsword=trim(replace(request("passsword"),"'",""))
	repasssword=trim(replace(request("repasssword"),"'",""))
	verify=trim(replace(request("verify"),"'",""))
		
	if username="" or passsword="" or verify="" then
		Errmsg = Errmsg+"<li>请填写全部信息。"
		Call ErrList(Errmsg)
		response.end
	elseif session("pSN")="" then
		Errmsg = Errmsg+"<li>请不要重复提交，如需重新登陆请返回登陆页面。<li>返回后请刷新登陆页面后重新输入正确的信息。"
		Call ErrList(Errmsg)
		response.end
	elseif Trim(Request("verify"))<>session("pSN") then
		Errmsg = Errmsg+"<li>你输入的附加码和系统产生的不符。"
		Call ErrList(Errmsg)
		response.end
	end if
	
	s=cint(request("s"))
	if s=1 then
		sql="select ID,passsword from link where username='"&username&"'"
	elseif s=2 then
		sql="select ID,MasterPSW from setting where MasterName='"&username&"'"
	end if

	rs.open sql,conn,1,3
	if not rs.eof then
		if rs(1)<>md5(passsword) then
			Errmsg = Errmsg+"<li>用户名或密码错误。"
			Call ErrList(Errmsg)
			response.end
		else
			if s=1 then
				session("L_username")=username
				session("L_userid")=rs(0)
				response.Redirect("useradmin.asp")
			else
				session("S_username")=username
				session("S_userid")=rs(0)
				session("pSN")=""
				response.Redirect("admin.asp")
			end if
		end if
	else
		Errmsg = Errmsg+"<li>用户名或密码错误1。"
		Call ErrList(Errmsg)
		response.end
	end if
end if
%>

<%
dim s
s=cint(request("s"))
if s=1 then
	if session("L_username")<>"" and session("L_userid")<>"" then
		response.Redirect("useradmin.asp")
		response.end
	end if
elseif s=2 then
	if session("S_username")<>"" and session("S_userid")<>"" then
		response.Redirect("admin.asp")
		response.end
	end if
end if
%>
<table  border="0" align="center" cellpadding="0" cellspacing="0" width="<%=PageWidth&Unit%>">
  <tr>
    <td>
<table width="530" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#698CC3">
  <form id="form1" name="form1" method="post">
    <tr>
      <td bgcolor="#FFFFFF"><table width="100%" height="2"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td></td>
          </tr>
        </table>
          <table width="99%" height="30"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="698cc3" class="title">
            <tr>
              <td><%response.write "&nbsp;<a class=""atitle"" href="""&SiteURL&""" target=_blank>"&SiteName&"</a>-自助友情链接系统 V1.7-管理入口"%></td>
              <td align="right">&nbsp;</td>
            </tr>
          </table>
          <table width="100%" height="2"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td></td>
            </tr>
          </table>
          <!--显示与隐藏的表格-->
          <table width="99%"  border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="d6e0ef" style="display:" id="Tab3">
            <tr bgcolor="#FFFFFF">
              <td height="20" colspan="2">&nbsp;</td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="35%" height="20">用户名:</td>
              <td><input name="username" type="text" id="username" size="50" maxlength="50"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td height="20">密码:</td>
              <td><input name="passsword" type="password" id="passsword" size="50" maxlength="20"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td height="20">附加码:</td>
              <td><input name="verify" type="text" id="verify" size="16" maxlength="20">
                <input name="s" type="hidden" id="s" value="<%=s%>">
                请照此输入附加码 -> <img src="getcode.asp"></td>
            </tr>
            <tr align="center" bgcolor="#FFFFFF">
              <td height="20" colspan="2">
			  <input type="submit" name="Submit" value=" 确 定 ">&nbsp;
              <input type="reset" name="Submit" value=" 重 设 "></td>
            </tr>
          </table>
          <!--显示与隐藏的表格-->
          <table width="100%" height="2"  border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td></td>
            </tr>
        </table></td>
    </tr>
  </form>
</table>
</td></tr></table>
</body>
</html>
