<!--#include file="inc/conn.asp"-->
<!--#include file="inc/safe.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim f_user,f_pass,chkcode
f_user=trim(ReplaceBadChar(request.Form("userid")))
f_pass=md5(trim(ReplaceBadChar(request.Form("userpass"))))
chkcode=Request.form("chkcode")

if chkcode="" then
  response.Write("<script>alert(""验证码不能为空，请返回重新输入。"");history.go(-1);</script>")
  response.end
end if

if session("checkcode")="" then
  response.Write("<script>alert(""验证码已经失效，请返回重新输入。"");history.go(-1);</script>")
  response.end
end if

if clng(chkcode)<>clng(session("checkcode")) then
  response.Write("<script>alert(""验证码不正确，请返回重新输入。"");history.go(-1);</script>")
  response.end
end if

set rs=server.CreateObject("adodb.recordset")
rs.open"select userid,username,userpass,lastlogin,logintime,logins,email,sex,grade,chengxin,age,birthday from user_info where username='"&f_user&"' and userpass='"&f_pass&"'",conn,1,3
			if  rs.eof and rs.bof then
			response.Write("<script>alert(""用户名或密码错误，请重新确认输入"");history.go(-1);</script>")
			response.end
			end if

If founduser and trim(f_user)<>trim(membername) Then
		Response.Cookies(Forum_sdjy)("username")=""
		Response.Cookies(Forum_sdjy)("password")=""
		Response.Cookies(Forum_sdjy)("userclass")=""
		Response.Cookies(Forum_sdjy)("userid")=""
		Response.Cookies(Forum_sdjy)("usercookies")=""
End If
dim Sd_userid,Sd_userpass,Sd_userclass,Sd_username,Sd_email

Sd_username=rs("username")
Sd_userpass=rs("userpass")
select case rs("grade")
  case 1
    Sd_userclass="注册会员"
  case 2
    Sd_userclass="普通会员"
  case 3
    Sd_userclass="VIP会员"
end select
Sd_userid=rs("userid")
Sd_email=rs("email")
Sd_sex=rs("sex")
Response.Cookies(Forum_sdjy)("usercookies")=0
Response.Cookies(Forum_sdjy)("username")=Sd_username
Response.Cookies(Forum_sdjy)("password")=Sd_userpass
Response.Cookies(Forum_sdjy)("userclass")=Sd_userclass
Response.Cookies(Forum_sdjy)("userid")=Sd_userid

rs("lastlogin")=rs("logintime")
rs("logintime")=now()
rs("logins")=rs("logins")+1
lognum=clng(rs("logins"))\1500 '增加诚信点数
if lognum > clng(rs("chengxin")) then
  rs("chengxin")=lognum
end if
rs("age")=datediff("yyyy",rs("birthday"),now())
rs.update
rs.close
set rs=nothing

conn.execute "delete from sd_online where userid="&Sd_userid
conn.execute("insert into sd_online(userid,username,starttime,starttimebk) values('"& Sd_userid &"','"& Sd_username &"','"& now() &"','"& now() &"')")

'*****************检测论坛用户是否添加
set rs=server.CreateObject("adodb.recordset")
sql1="select * from [Dv_user] where username='"& Sd_username &"'"
rs.open sql1,conn,1,3
if rs.bof and rs.eof then
rs.addnew
        UserJoinTime = Now()
		Rs("UserName")=Sd_username
		Rs("UserPassword")=Sd_userpass
		Rs("UserEmail")=Sd_email
		Rs("Userclass")="新手上路"
		Rs("TitlePic")="level0.gif"				
		Rs("UserIM")="||||||||||||||||||"	
		Rs("UserPost")=0
		Rs("UserGroupID")=9		
		Rs("Lockuser")=0
		if Sd_sex="男" then
		  Rs("UserSex")=1   
		else
		  Rs("UserSex")=0
		end if					
		Rs("JoinDate")=UserJoinTime  
		Rs("UserFace")="Images/userface/image1.gif"		
		Rs("UserWidth")=32
		Rs("Usertoday")="0|0|0|0|0"
		Rs("UserHeight")=32
		Rs("UserLogins")=1		
		Rs("userWealth")=100
		Rs("userEP")=30
		Rs("usercP")=30		
		Rs("UserPower")=0
		Rs("UserDel")=0
		Rs("UserIsbest")=0
		Rs("UserMoney")=0
		Rs("UserTicket")=0
		Rs("UserFav")="陌生人,我的好友,黑名单"
		Rs("IsChallenge")=0
		Rs("UserHidden")=0	
rs.update
end if
rs.close
set rs=nothing

'**********聊天室帐号********
chatpass=trpass(ReplaceBadChar(request.Form("userpass")))
if Sd_sex="男" then
  head="boy2"
  sex1="男生"
else
  head="girl7"  
  sex1="女生"
end if

set rs=server.CreateObject("adodb.recordset")
sql="select * from [user] where username='"& Sd_username &"'"
rs.open sql,conn,1,3
if rs.eof and rs.bof then
conn.execute("insert into [user](username,password,email,aihao,sex,info,head,reg_ip) values('"&Sd_username &"','"& chatpass &"','"& Sd_email &"','* 未注册项 *','"& sex1 &"','* 这家伙很懒，什么都没留下。。。 *','"& head &"','127.0.0.1')")
end if
rs.close
set rs=nothing

conn.close
set conn=nothing

session("checkcode")=""

response.Redirect("bbs/sdjylogin.asp")
%>