<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="UserConn.asp" -->
<%
Call Chkhttp()
Dim UserID,submit,username,password,lname,qq,ask,askok,webcha,userpic,openid,qqid,uqqid,nickpic
reurl=Request.QueryString("reurl")'来源地址
submit=Request.QueryString("submit")
username=NoSqlHack(Request.Form("username"))'用户名
password=NoSqlHack(Request.Form("password2"))'用户密码
lname=NoSqlHack(Request.Form("lname"))'用户昵称
qq=Left(NoSqlHack(Request.Form("qq")),11)'用户QQ
ask=NoSqlHack(Request.Form("ask"))'用户保护问题
askok=NoSqlHack(Request.Form("askok"))'用户保护答案
webcha=NoSqlHack(Request.Form("webcha"))'注册调查
uqqid=md5(Request.Form("uqqid"),32)'QQID
nickpic=Request.Form("nickpic")'QQ头像
userpic=Replace(Replace(Request.Form("userpic"),"../Images/faces/",""),".gif","")'用户头像
UserID=NoSqlHack(Clng(Request.Form("UserID")))'下线ID
openid=Request.QueryString("openid")'QQMD5_ID
qqid=Request.QueryString("qqid")'QQORID
if openid=uqqid and qqid<>"" then
   userpic=nickpic
   webcha="QQ按钮登陆"
End IF
If len(submit)>10 then
    Set rs = Server.CreateObject("adodb.recordset")
    rs.Open"Select * from qvodcms_user where uname='"&username&"'",Conn,1,3
    If rs.Eof And rs.Bof then
	  rs.addnew
	     If username="" or len(username)<2 or len(username)>18 or password="" or lname="" or Not isNumeric(qq) or ask="" or askok="" Then
		 Call QvodCms_Err("请认真填写注册资料！！！")
         response.End()
		 Else
		 rs("uname")=username
		 rs("upass")=md5(password,32)
		 rs("ulc")=lname
		 rs("uqq")=left(qq,15)
		 rs("uwww")=webcha
		 rs("uask")=ask
		 rs("uok")=askok
		 rs("uip")=QvodCms_Ip()
		 rs("upic")=Trim(userpic)
		 rs("uqqid")=uqqid
		 End If
	  rs.update
	  rs.Close
	  If UserID>0 Then
		 Call NextUser()
	  End if
	  if openid=uqqid and qqid<>"" then'验证QQ登陆注册
	     Call RegLogin()
	  Else
	     Call QvodCms_Err_Url("注册成功！！！","UserLogin.Asp")
	  End IF
	  response.End()
    Else
      Call QvodCms_Err("用户已经注册,请更换！！！")
      response.End()
    End If
Else
Call QvodCms_Err("非法操作！！！")
response.End()
End if

Sub NextUser()
  Set nrs=Conn.Execute("Select uid From qvodcms_user order by uid desc")
   If Not(nrs.eof and nrs.bof) Then
     Conn.Execute("Insert into qvodcms_user_jf (jfuid,jfidd) Values('"&UserID&"','"&nrs("uid")&"')")
	 Conn.Execute("update qvodcms_user Set ujf=ujf+"&Cint(AdminId(29))&" Where uid="&UserID&"")
   End If
  nrs.Close:Set nrs=Nothing
End Sub

Sub RegLogin()
    Set qrs = Server.CreateObject("adodb.recordset")
    qsql = "select * from qvodcms_user where upass='" & md5(password,32) & "' and uname='" & username & "'"
    qrs.Open qsql, Conn, 1, 1
    If qrs.bof And qrs.EOF Then
        Call QvodCms_Err("用户名或密码错误！！！")
		Response.End()
    Else
        If md5(password,32) <> qrs("upass") Then
			Call QvodCms_Err("用户名或密码错误！！！")
			Response.End()
        End If
		Response.Cookies("qvodcms")("UserName") =Trim(qrs("uname"))
		Response.Cookies("qvodcms")("Uid") =QvodCms_CLng(qrs("Uid"))
        Response.Cookies("qvodcms")("Ujf") =QvodCms_CLng(qrs("ujf"))
        Response.Cookies("qvodcms")("Ulc") =Trim(qrs("ulc"))
        Response.Cookies("qvodcms")("Uvip") =qrs("uvip")
		Response.Cookies("qvodcms")("UPic") =Trim(qrs("upic"))
        Response.Cookies("qvodcms")("Utime") =Formatdatetime(qrs("utime"),2)
		If addbox=0 then
		Response.Cookies("qvodcms").Expires=dateadd("n",30,now())
		Else
		Response.Cookies("qvodcms").Expires=Date+30
		End if
		qrs.Close:Set qrs=Nothing
		if reurl<>"" then
		Response.Write "<script>window.parent.location.href='"&Reurl&"';</script>"
		Else
		Reurl="UserMian.Asp"
		Response.Write "<script>window.parent.location.href='"&Reurl&"';</script>"
		End if
		Response.End()
    End If
End Sub
Call CloseConn()
%>
