<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--#include file="conn.asp" -->
<!--#include file="md5.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登陆</title>
<link href="images/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
if request.QueryString("action")="check" then
if trim(request.form("pwds"))<>trim(session("pwdt")) then
response.Write("验证码错误")
response.Write("<meta http-equiv='refresh' content='1;URL=login.asp'>")
else
username=replace(replace(request.Form("username"),chr(34),"%22"),chr(39),"%26")
password=request.Form("password")
Set rs=server.createobject("ADODB.RECORDSET")
sql="select * from user where username='"&username&"' and password='"&md5(password)&"'"
rs.open sql,conn,3,3
if rs.bof and rs.eof then
response.Write("错误的用户名或者密码")
response.Write("<meta http-equiv='refresh' content='1;URL=login.asp'>")
else
session("username")=username
response.Cookies("username")=username
ip=request.servervariables("http_x_forwarded_for")
if ip="" then
ip=request.servervariables("remote_addr")
end if
rs("ip")=ip
rs("dateandtime")=now()
rs.update
Response.Write("<center>登陆成功<br>")
response.Write("<a href='index.asp' target='_top'>返回首页</a><br>")
response.Write("<a href='"&request.servervariables("HTTP_REFERER")&"'>返回上一页</a><br></center>")
end if
rs.close
set rs=nothing
end if
else
Private Function EncryptString(strString)
Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSet
Randomize Timer
intKey = Round((RND * 1000000) + 1000000)
intOffSet = Round((RND * 1000000) + 1000000)
If IsNull(strString) = False Then
strRAW = strString
intStringLen = Len(strRAW)
For i = 0 to intStringLen - 1
strTemp = Left(strRAW, 1)
strRAW = Right(strRAW, Len(strRAW) - 1)
CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey)
Next
EncryptString = CharHexSet & "|" & Hex(intOffSet + intKey) & "|" & Hex(intOffSet)
Else
EncryptString = ""
End If
End Function
Private Function DeCryptString(strCryptString)
Dim strRAW, arHexCharSet, i, intKey, intOffSet, strRawKey, strHexCrypData
For i=0 to UBound(arHexCharSet)
strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)
Next
DeCryptString = strRAW
End Function
Private Function HexConv(hexVar)
Dim hxx, hxx_var, multiply
IF hexVar <> "" THEN
hexVar = UCASE(hexVar)
hexVar = StrReverse(hexVar)
DIM hx()
REDIM hx(LEN(hexVar))
hxx = 0
hxx_var = 0
FOR hxx = 1 TO LEN(hexVar)
IF multiply = "" THEN multiply = 1
hx(hxx) = mid(hexVar,hxx,1)
hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var
multiply = (multiply * 16)
NEXT
hexVar = hxx_var
HexConv = hexVar
END IF
End Function
Private Function get_hxno(ghx)
If ghx = "A" Then
ghx = 10
ElseIf ghx = "B" Then
ghx = 11
ElseIf ghx = "C" Then
ghx = 12
ElseIf ghx = "D" Then
ghx = 13
ElseIf ghx = "E" Then
ghx = 14
ElseIf ghx = "F" Then
ghx = 15
End If
get_hxno = ghx
End Function