<!--#include file="inc/inc_syssite.asp"-->
<!--#include file="inc/inc_antispam.asp"-->
<!--#include file="inc/class_blog.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/upiconfig.asp"-->
<%
'*********Design By Jackie For HoWaveV4.05_Oblog4.0_0905*****
dim UserName,UserPassword,hl_rs,hl_sql
Dim rsreg, sql, ajax, buttonface, rearr
Dim regusername, regpassword, sex, question, answer, email, reguserlevel, userispass, blogname, usertype, nickname
Dim re_regpassword, user_domain, user_domainroot
Dim ErrMessages
Dim userRegfloder  
UserName=Request.Cookies("Howave_GBUserName")
UserPassword=Request.Cookies("Howave_UserPassword")
    If UserName="" or UserPassword="" then 
       Response.Write "读取用户名和密码为空，激活失败"
       Response.End()
	Else
	   If Len(UserPassword) = 32 Then UserPassword = Mid(UserPassword,9,16)   
    end if
    email=UserName&"@jsp163.com"
	question="Your Password"
	answer=Trim(UserPassword)

   
   ' chk_regtime()  '屏蔽注册时间限制
	ErrMessages=""
    regusername = oblog.filt_badstr(UserName)
    regpassword = UserPassword     
    blogname = UserName&"的博客"
    usertype =1	
  
	user_domain = ""
    user_domainroot = ""
    If regusername = "" Or oblog.strLength(regusername) > 14 Or oblog.strLength(regusername) < 4 Then ErrMessages= "用户名不能为空(不能大于14小于4)！"
'    If oblog.chk_regname(regusername) Then ErrMessages="用户名已经存在或系统不允许注册！"
    If oblog.chk_badword(regusername) > 0 Then ErrMessages="用户名中含有系统不允许的字符！"	
    If en_nameisnum = 0 And IsNumeric(regusername) Then ErrMessages="用户名不允许全部为数字！"
'    If oblog.CacheConfig(4) <>"" And oblog.CacheConfig(5) = 1 Then
'        If user_domain = "" Or oblog.strLength(user_domain) > 14 Then oblog.adderrstr  ("域名不能为空(不能大于14个字符)！")
'        If user_domain <> request("old_userdomain") And oblog.strLength(user_domain) < 4 Then oblog.adderrstr  ("域名不能小于4个字符！")
'        If oblog.chk_regname(user_domain) Then oblog.adderrstr  ("此域名系统不允许注册！")
'        If oblog.chk_badword(user_domain) > 0 Then oblog.adderrstr  ("域名中含有系统不允许的字符！")
'        If oblog.chkdomain(user_domain) = False Then oblog.adderrstr  ("域名不合规范，只能使用小写字母，数字！")
'        If user_domainroot = "" Then oblog.adderrstr  ("域名根不能为空！")
'		If oblog.CheckDomainRoot(user_domainroot) = False Then oblog.adderrstr  ("域名根不合法！")
'    End If
'    If regpassword = "" Or oblog.strLength(regpassword) > 14 Or oblog.strLength(regpassword) < 4 Then oblog.adderrstr  ("密码不能为空(不能大于14小于4)！")
'    If question = "" Or oblog.strLength(question) > 50 Then oblog.adderrstr  ("找回密码提示问题不能为空(不能大于50)！")
'    If answer = "" Or oblog.strLength(answer) > 50 Then oblog.adderrstr  ("找回密码问题答案不能为空(不能大于50)！")
    If blogname = "" Or oblog.strLength(blogname) > 50 Then ErrMessages="blog名不能为空(不能大于50字符)！"
    If oblog.chk_badword(blogname) > 0 Then ErrMessages="blog名中含有系统不允许的字符！"
    If InStr(regusername, "=") > 0 Or InStr(regusername, "%") > 0 Or InStr(regusername, Chr(32)) > 0 Or InStr(regusername, "?") > 0 Or InStr(regusername, "&") > 0 Or InStr(regusername, ";") > 0 Or InStr(regusername, ",") > 0 Or InStr(regusername, "'") > 0 Or InStr(regusername, ",") > 0 Or InStr(regusername, Chr(34)) > 0 Or InStr(regusername, Chr(9)) > 0 Or InStr(regusername, "") > 0 Or InStr(regusername, "$") > 0 Then ErrMessages="用户名中含有非法字符！"
    '进行重复性判断22/47/25
    If oblog.CacheConfig(22)="1" Then
    	Set rsreg=oblog.execute("select Count(userid) From oblog_user Where useremail='" & email & "'")
    	If rsreg(0)>0 Then
    		ErrMessages="您使用的Email: " & email & " 已被他人使用，请更换其他Email"
    	End If
    	rsreg.Close
	End If
	If oblog.CacheConfig(25)="1" Then
		Set rsreg=oblog.execute("select Count(userid) From oblog_user Where blogname='" & blogname & "'")
    	If rsreg(0)>0 Then
    		ErrMessages="您使用的博客名称: " & blogname & " 已被他人使用，请更换博客名称"
    	End If
    	rsreg.Close
	End If
    '进行IP控制
	Dim sIP
    sIP=oblog.userip
    If oblog.CacheConfig(21)>"0" Then
	    sql="select Count(userid) from oblog_user where regip='"& sIP &"' And "
	    If Is_sqldata = 1 Then
	        sql = sql & " Datediff(hour,adddate,getdate())<=1"
	    Else
	        sql = sql & " Datediff('h',adddate,Now())<=1"
	    End If
	    Set rsreg = oblog.execute(sql)
	    If rsreg(0) > CInt(oblog.CacheConfig(21)) Then 
	    	oblog.KillIP(sIP)
	    	ErrMessages="您的IP因为恶意注册被临时禁止"
			rsreg.Close			
			Response.Write ErrMessages
			response.end
	    End If
    	rsreg.Close
    End If
    If oblog.CacheConfig(14) > "0"  Then
        sql="select Count(userid) from oblog_user where regip='"& sIP &"' And "
        If Is_sqldata = 1 Then
            sql = sql & " Datediff(hour,adddate,getdate())<=24"
        Else
            sql = sql & " Datediff('h',adddate,Now())<=24"
        End If
        Set rsreg = oblog.execute(sql)
        If rsreg(0) > CInt(oblog.CacheConfig(14)) Then
           '进行IP屏蔽
           	oblog.KillIP(sIP)
			'进行批量屏蔽
           oblog.execute("Update [oblog_user] Set user_level=6 Where regip='"&oblog.userip&"'")
            ErrMessages="您的IP因为恶意注册而被系统禁止"
			rsreg.Close
			Response.Write ErrMessages
			response.end
        End If
        rsreg.Close
    End If
'    If user_domain <> "" Then
'        Set rsreg = oblog.execute("select userid from oblog_user where user_domain='" & oblog.filt_badstr(user_domain) & "' and user_domainroot='" & oblog.filt_badstr(user_domainroot) & "'")
'        If Not rsreg.EOF Or Not rsreg.bof Then oblog.adderrstr  ("系统中已经有这个域名存在，请更改域名！")
'    End If
    If ErrMessages<> "" Then
		Response.Write ErrMessages
	    Response.End()
	end if
    '是否需要审核
    If oblog.CacheConfig(18) = 1 Then reguserlevel = 6 Else reguserlevel = 7	

    If Not IsObject(conn) Then link_database
    Set rsreg = server.CreateObject("adodb.recordset")
    rsreg.open "select * from [oblog_user] where username='" & oblog.filt_badstr(regusername) & "'", conn, 1, 3
    If rsreg.EOF Then
    	rsreg.addnew
        rsreg("username") = regusername
        rsreg("password") = regpassword
        If oblog.CacheConfig(4)<>"" And oblog.CacheConfig(5) = 1 Then
            rsreg("user_domain") = user_domain
            rsreg("user_domainroot") = user_domainroot
        End If
        rsreg("question") = question
        rsreg("answer") = answer
        rsreg("useremail") = email
        rsreg("user_level") = reguserlevel
        rsreg("user_isbest") = 0
        rsreg("blogname") = blogname
        rsreg("user_classid") = usertype
        rsreg("nickname")=UserName
		rsreg("birthday")=ServerDate(Now())
        rsreg("province") = "广东"
        rsreg("city") = "广州"
        rsreg("adddate") = ServerDate(Now())
        rsreg("regip") = oblog.userip
        rsreg("lastloginip") = oblog.userip
        rsreg("lastlogintime") = ServerDate(Now())
        rsreg("user_dir") =oblog.setup(8,0)
        rsreg("user_folder") = regusername
        rsreg("user_group") = oblog.defaultGroup
        rsreg("scores") = oblog.cacheScores(1)
        rsreg("newbie") = 1
		if oblog.CacheConfig(40)=1 then rsreg("comment_isasc")=1
        rsreg.Update
		Session("chk_regtime") = Now()
        oblog.execute ("update oblog_setup set user_count=user_count+1")
        oblog.execute ("update oblog_groups set g_members=g_members+1 WHERE groupid = " &oblog.defaultGroup)
        If is_unamedir = 0 or oblog.chkdomain(regusername) = False Then '如果用户名为中文名则采用该用户的ID为文件夹名
            oblog.execute ("update oblog_user set user_folder=userid where username='" & oblog.filt_badstr(regusername) & "'")
        End If
		 
        If oblog.CacheConfig(17)=1 Then
			Dim tid1,tid2
        	'获取Userid
        	Set rsreg=oblog.Execute("Select userid From oblog_user where username='" & oblog.filt_badstr(regusername) & "'")
			tid1=rsreg(0)
        	oblog.Execute("Update oblog_obcodes Set istate=1,useip='" &oblog.userip & "',usetime='" & Now & "',useuser=" & tid1 & " Where obcode='" &oblog.filt_badstr(request("obcode")) & "'"  )
        	rsreg.Close
			'增加积分
			Set rsreg = oblog.execute ("SELECT creatuser FROM oblog_obcodes Where obcode='" &oblog.filt_badstr(request("obcode")) & "'"  )
			tid2=rsreg(0)
			oblog.GiveScore "",oblog.cacheScores(2),tid2
			rsreg.Close
			'互相加好友
			oblog.execute("insert into [oblog_friend] (userid,friendid,isblack) values ("&tid1&","&tid2&",0)")
			oblog.execute("insert into [oblog_friend] (userid,friendid,isblack) values ("&tid2&","&tid1&",0)")
			dim blog
			set blog=new class_blog
			blog.userid=tid1
			blog.update_friends tid1
			blog.userid=tid2
			blog.update_friends tid2
			set blog=nothing
        End If
        If C_Reg_AutoCreate = 1 Then oblog.CreateUserDir regusername, 1
        If C_Reg_AutoTemplate = 1 Then 
			Set rsreg=oblog.Execute("Select userid From oblog_user where username='" & oblog.filt_badstr(regusername) & "'")			
			rsreg.Close
		End If 
        If oblog.CacheConfig(18) = 1 Then
            rearr=rearr&"注册成功，但当前系统设置为需要通过审核，您暂时没有管理权限！<br />"			
        Else
            oblog.savecookie regusername,regpassword,0,user_domain&"."&user_domainroot
            rearr="恭喜！您已经注册成功！<br />"
            rearr=rearr&"现在将转到管理后台让您选择喜欢的页面风格。</a><br />"	
        End If
		Response.Write rearr
		Response.Redirect("user_setting.asp")
		response.end
    Else
        ErrMessages="系统中已经有这个用户名存在，请更改用户名！"
        Response.Write ErrMessages
		response.end
    End If
    rsreg.Close
    Set rsreg = Nothing
'===================================================
' HoWaveV4.05
'				Powered by HoWave.Net
'===================================================
' Mail: websky888@126.com 
' Q  Q: 18469685, 615939753    Tel:020-88386767
' Web : http://www.HoWave.net, http://www.jsp163.com
' Bbs : http://bbs.HoWave.net, http://bbs.jsp163.com
' Copyright (C) 2005 HoWave.net All Rights Reserved.
'===================================================
%>