<!--#include file="conn.asp" -->
<!--#include file="inc/char.inc" -->
<%
response.buffer=true
dim errmsg,founderr

username=trim(replace(request("username"),"'",""))
password=trim(replace(request("password"),"'",""))
savecookie=request("savecookie")

call chkinput
call chkuser
if founderr=true then 
	call error() 
else 
	call adlogin()
end if

sub chkinput()
	if chkpost=false then
   		ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从外部提交发言。"
   		FoundErr=True
	end if

	if len(username) > 20 then
		errmsg=errmsg+"<br>"+"<li>请输入您的用户名过长！"
		founderr=true
	else
		username=username
	end if
	
	if Instr(request("username"),"=")>0 or Instr(request("username"),"%")>0 or Instr(request("username"),chr(32))>0 or Instr(request("username"),"?")>0 or Instr(request("username"),"&")>0 or Instr(request("username"),";")>0 or Instr(request("username"),",")>0 or Instr(request("username"),"'")>0 or Instr(request("username"),",")>0 or Instr(request("username"),chr(34))>0 or Instr(request("username"),chr(9))>0 or Instr(request("username"),"")>0 then
	errmsg=errmsg+"<br>"+"<li>用户名中含有非法字符。"
		founderr=true
	else
		username=trim(request("username"))
	end if
	
		if password="" or len(password) > 20 then
		errmsg=errmsg+"<br>"+"<li>请输入您的密码过长！"
		founderr=true
	else
		password=trim(request("password"))
	end if
end sub


sub chkuser
	sql = "Select username,password From admin Where username='"&Username&"' And password='"&Password&"'"	
	set rs=conn.execute (sql)
	If rs.EOF Then
		errmsg=errmsg+"<br>"+"<li>用户名和密码不正确 !"
		founderr=true
	end if	
	
end sub


sub adlogin()

	if savecookie=1 then
		response.Cookies("soonlink").Expires=Date+365
	end if
	session("ad_selluser")="passed"
	response.Cookies("soonlink")("username")=username
	response.Cookies("soonlink")("password")=password
	subidtype="ad_view.asp"	
	response.redirect (subidtype)
end sub

conn.close
set conn=nothing
'==========================================
'程序制做:迅捷网络.    http://www.soonhost.com
'迅捷主机网 -- 域名注册、主机租用、网站建设、脚本开发
'网址：http://www.soonhost.com
'msn:soonhost@hotmail.com
'请保留以上版权信息，谢谢合作！
'==========================================
%>