<!--#include file="conn.asp"-->
<!--#include file=../md5.asp-->
<%
'-------------------------------------
'功能：管理员登陆
'天天智能友情链接管理系统
'天天DV网制作 http://www.ttdv.cn
'博大网址库http://www.ip126.com

'可自由传播和免费使用，但必须保留此完整版权信息
'本程序撷取了ITlearner、博大网址库等优秀程序中的源代码，对他们的作者表示感谢
'-------------------------------------

dim action,closedb,adminname,Password,rs,sql,myname,pass,rank
action=request("action")

if action="chklogin" then
	myname=replace(trim(request("myname")),"'","‘")
	pass=md5(replace(trim(request("pass")),"'","‘"))	
	dim server_v1,server_v2
        server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
        server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
        If mid(server_v1,8,len(server_v2))<>server_v2 then
                Response.write "远程提交，不合法"
                Response.End
        End If
        
        if myname="" or pass="" then
	response.write "<center><b>密码不能为空！请<a href=admin_login.asp><b><font color=#Ff0000>重新登陆</font></b></a></b>"
	response.end
	end if
	set rs=server.createobject("adodb.recordset")
	sql="select * from [admin] where Password='"&Pass&"' and adminname='"&myName&"'"
	rs.open sql,conn,1,1
	if not rs.bof and not rs.eof then 
	adminname=rs("adminname")
	password=rs("password")
	rank=rs("rank")
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing	       
	if myname=adminname and pass=password then
		session(hxCacheName&"_admin")="OK"
		Response.cookies(hxCacheName&"_ttlink")("administrator")=adminname
		Response.cookies(hxCacheName&"_rank")("rank")=rank
		response.redirect "index.asp"
	else
		response.redirect "admin_login.asp"
	end if
	else
            response.write " <center><b>身份确认失败！请<a href=admin_login.asp><b><font color=#Ff0000>重新登陆</font></b></a></b> "
            session("dick_err")=session("dick_err")+1
            response.end
	end if
end if
if action="exit" then
session(hxCacheName&"_admin")=""
end if
%>
<html>
<head>
<link href="../style.css" rel="stylesheet" type="text/css">
<title>管理员登陆_<%=WebName & ChannelName%> - Powered By ttdv</title>
</head>
<body>
<p>&nbsp;</p>
<p>&nbsp;</p>


<table width="300" border="0" align="center" cellPadding="0" cellSpacing="0">
  <tr>
    <td bgColor="#ADAED6"><table cellSpacing="1" cellPadding="0" width="100%" border="0" height="145">
      <tr>
        <td align="middle" bgColor="#BDBEDE" height="28" sytle="line-height:150%"><div align="center" ><%=WebName & ChannelName%>管理系统管理员登陆</div></td>
      </tr>
      <tr>
        <td align="middle" bgColor="#ffffff" height="123"><table cellSpacing="0" cellPadding="0" width="95%" border="0" height="108">
            <tr>
              <td align="middle" height="91">
              <form method="post" action="?action=chklogin" name="f1">
                  <table cellSpacing="0" cellPadding="0" width="100%" border="0" height="73">
                    <tr>
                      <td width="35%" align="right" height="38"><font face="Arial, Helvetica, sans-serif" color="#999999"> adminname&nbsp;&nbsp;&nbsp;&nbsp; </font></td>
                      <td width="65%" height="38"><input type="text" class="editbox4" size="19" name="myname">                      </td>
                    </tr>
                    <tr>
                      <td align="right" height="35" width="35%"><font face="Arial, Helvetica, sans-serif" color="#999999">Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
                      <td height="35" width="65%"><input class="editbox4" type="password" size="20" name="pass"></td>
                    </tr>
                  </table>
                  <br>
                  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td><div align="center">
                        <input class="button" type="submit" value="确认登陆" name="Submit">
                      </div></td>
                      <td><div align="center">
                        <input class="button" type="reset" value="取消登陆" name="Submit">
                      </div></td>
                    </tr>
                  </table>
                  </form></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>

</body></html>