<!--#include file="conn.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/function.asp"-->
<%
if ChkPost()=false then
	response.write("不允许从外部提交！")
	response.clear
	response.End()
end if
if ot_user then
	response.write("当前用户表设定为外部数据库，不允许使用此页面注册！")
	response.clear
	response.End()
end if
dim rs,rsreg,rsfilt,regbadstr
dim regusername,regpassword,sex,question,answer,email,reguserlevel,userispass,blogname,usertype,nickname
set rs=conn.execute("select lockip from lockip where lockip='"&Request.ServerVariables("REMOTE_ADDR")&"'")
if not (rs.bof or rs.eof) then
	response.write("对不起！你的IP已被锁定,不允许注册！")
	response.clear
	response.End()
end if
regusername=trim(request("username"))
if regusername="" then
	response.Redirect "index.asp"
end if
regpassword=md5(request("password"))
sex=request("sex")
email=trim(request("email"))
question=trim(request("question"))
answer=trim(request("an"))
blogname=trim(request("blogname"))
usertype=clng(request("usertype"))
nickname=trim(request("nickname"))
set rs=conn.execute("select reguserlevel,admincheckreg from bloginfo")
reguserlevel=rs("reguserlevel")
if rs("admincheckreg")="true" then
	reguserlevel=6
end if
set rsreg=server.CreateObject("adodb.recordset")
rsreg.open "select * from [user] where username='"& regusername &"'",conn,1,3
if rsreg.eof then
	set rsfilt=conn.execute("select regFiltrate from filtrate")
	regbadstr=split(rsfilt(0),",")
	dim i,n
	n=0
	for i=0 to ubound(regbadstr)
		if instr(username,regbadstr(i))>0 then
			n = 1
		end if
	next
	if n=0 then
		rsreg.addnew
		rsreg("username")=regusername
		rsreg("userpassword")=regpassword
		rsreg("sex")=sex
		rsreg("question")=question
		rsreg("answer")=answer
		rsreg("useremail")=email
		rsreg("userlevel")=reguserlevel
		rsreg("userispass")=userispass
		rsreg("lockuser")="false"
		rsreg("userisbest")="false"
		rsreg("blogname")=blogname
		rsreg("usertypeid")=usertype
		rsreg("nickname")=nickname
		rsreg("en_blogteam")="true"
		rsreg("adddate")=now()
		rsreg.update
		conn.execute("update bloginfo set usercount=usercount+1")
		call PutApplicationValue()
		if rs("admincheckreg")="true" then
			Response.Write"<script language=JavaScript>"
			Response.Write"alert(""注册成功，但当前系统设置为需要通过审核，您也许没有发贴权限！"");"
			Response.Write"window.location='index.asp'"
			Response.Write"</script>"
			response.End()
		else
			Response.Write"<script language=JavaScript>"
			Response.Write"alert(""恭喜！您已注册成功！请进行登陆！"");"
			Response.Write"window.location='index.asp'"
			Response.Write"</script>"
			response.End()
		end if
	else
		Response.Write"<script language=JavaScript>"
		Response.Write"alert(""您的名字中含有系统不允许的字符，请重新更换再试！"");"
		Response.Write"window.history.go(-1);"
		Response.Write"</script>"
		response.End()
	end if
else
	Response.Write"<script language=JavaScript>"
	Response.Write"alert(""对不起！此用户名已经存在，请更换用户名再进行注册！"");"
	Response.Write"window.history.go(-1);"
	Response.Write"</script>"
	response.End()
end if
set rs=nothing
rsreg.close
set rsreg=nothing
call closeconn()
 %>
