<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<%
Response.Charset = "gb2312"
If Request("checksubmit")="yes" Then
	Select Case Request("action")
		Case "checkusername"
			Call checkusername
		Case "checkseccode"
			Call checkseccode
		Case "checkemail"
			Call checkemail
		Case "smilies"
			Call smilies
		Case "loadtopics"
			loadtopics
	End Select

	Sub loadtopics
		Dim Gs,tid,uName,tmp
		tid = CID(Request("tid"))
		uName = HtmlEncode(Request("uname"))
		Set Gs = team.execute("Select Top 5 ID,Topic,UserName,Views,Replies,Lasttime From ["&Isforum&"Forum] Where deltopic=0 and UserName='"& uName &"' and Not (ID="& tID &") order By Posttime Desc")
		If Gs.Eof And Gs.Bof Then
			Exit sub
		Else
			tmp = "<div class=""textdiv""><ul>"
			Do While not Gs.Eof
				tmp = tmp & IIF(CID(team.Forum_setting(65))=1,",<li><a href=""thread-"&Gs(0)&".html"" target=""_blank"">"& Gs(1) &"</a></li> ","<li><a href=""thread.asp?tid="&Gs(0)&""" target=""_blank"">"& Gs(1) &"</a></li> ")
				Gs.MoveNext
			Loop
			tmp = tmp & " </ul></div> "
		End If
		Echo tmp
	End Sub 

	Sub smilies
		Dim i,page,AllSmNum,u,NextM,NextP,iNum,PNum
		page = CID(Request("page"))
		If page < 1 Then page = 1
		PNum		= 87								'总表情数
		iNum		= CID(Request("inum"))				'分页数
		AllSmNum	= Abs(int(-Abs(PNum/iNum)))			'总分页数
		If Page = 1 Then
			NextP = 1
			NextM = iNum
		Else
			NextM = iNum * Page
			NextP = (NextM - (NextM/Page))+1
			If NextM > PNum Then NextM = PNum
		End If
		Echo "<div class=""smdiv""><ul>"
		For i = NextP To NextM
			Echo "<img src=""images/Emotions/"& i &".gif"" alt=""[em"& i &"]"" id=""smilie_"& i &""" border=""0"" onClick=""insertSmiley("& i &")"" width=""33"" onMouseover=""this.style.cursor = 'hand'""/>"
		Next
		Echo "</ul></div>"
		Echo "<div class=""smpages"">"
		For i =1 To AllSmNum
			Echo "<a onclick=""loadsmile("& iNum &","& i &")"" style=""cursor:hand"">"& i &"</a>"
		Next 
		Echo "</div>"
	End Sub 

	Sub checkusername
		dim username,Rs,SQL
		UserName=HRF(1,1,"username")
		Set Rs =team.execute( "Select * from [user] where username='"&UserName&"'")
		if rs.eof and rs.bof then
			Echo "<script>"
			Echo "	parent.document.getElementById('checkusername').innerHTML ='  <img src=""images/success.gif"" align=""absmiddle"">恭喜，您输入的用户名 "&UserName&" 可以使用，请继续填写其他选项。' "
			Echo "	parent.document.getElementById('checkusername').style.color = 'red'	"
			Echo "	parent.document.register.regsubmit.disabled=false;	"
			Echo "</script>"
		else
			Echo "<script>"
			Echo "	parent.document.getElementById('checkusername').innerHTML =' 对不起，您输入的用户名 "&UserName&" 已经被他人使用，请选择其他名字后再试。' "
			Echo "	parent.document.getElementById('checkusername').style.color = 'green'	"
			Echo "	parent.document.register.regsubmit.disabled=true;	"
			Echo "</script>"
		end if
		rs.close:set rs=nothing
	End Sub

	Sub checkemail
		dim UserMail,Rs
		UserMail=HRF(1,1,"email")
		Set Rs =team.execute( "Select * from [user] where usermail='"&UserMail&"'")
		if rs.eof and rs.bof then
			Echo "<script>"
			Echo "	parent.document.getElementById('checkemail').innerHTML ='  <img src=""images/success.gif"" align=""absmiddle""> 恭喜，您输入的邮件地址 "&UserMail&" 可以使用，请继续填写其他选项。' "
			Echo "	parent.document.getElementById('checkemail').style.color = 'red'	"
			Echo "	parent.document.register.regsubmit.disabled=false;	"
			Echo "</script>"
		else
			Echo "<script>"
			Echo "	parent.document.getElementById('checkemail').innerHTML =' 对不起，您输入的邮件地址 "&UserMail&" 已经被他人使用，请选择其他邮件地址后再试。' "
			Echo "	parent.document.getElementById('checkemail').style.color = 'green'	"
			Echo "	parent.document.register.regsubmit.disabled=true;	"
			Echo "</script>"
		end if
		rs.close
		set rs=nothing
	End Sub

	Sub checkseccode
		Dim Code
		If team.Forum_setting(48)>=1 Then
			Code=HRF(1,1,"seccodeverify")
			if CodeIsTrue(Code) Then
				Echo "<script>"
				Echo "	parent.document.getElementById('checkseccode').innerHTML =' <img src=""images/success.gif"" align=""absmiddle""> ' "
				Echo "	parent.document.getElementById('checkseccode').style.color = 'red'	"
				Echo "</script>"
			Else
				Echo "<script>"
				Echo "	parent.document.getElementById('checkseccode').innerHTML =' 验证码错误,请刷新后重新填写 ' "
				Echo "	parent.document.getElementById('checkseccode').style.color = 'green'	"
				Echo "</script>"
			End if
		End If
	End Sub

	Function CodeIsTrue(a)
		Dim CodeStr
		CodeStr=Trim(a)
		If CStr(Session("GetCode"))=CStr(CodeStr) And CodeStr<>""  Then
			CodeIsTrue=True
		Else
			CodeIsTrue=False
		End If	
	End Function

End If
%>