<%
Class CCAPI_CCUnion
	Private p_sitename,p_siteurl,p_sitelogo,p_sitetype,p_sitemail,p_ccuserid,p_cckey,p_ccpwd
	
	Private urlreturn,result,configstr

	Private Sub Class_Initialize()
	End Sub
	
	Private Sub Class_terminate()
		p_sitename=""
		p_siteurl=""
		p_sitelogo=""
		p_sitetype=""
		p_sitemail=""
		p_ccuserid=""
		p_cckey=""
		p_ccpwd=""
		urlreturn=""
		result=""
		configstr=""
	End Sub
	
	Public Property Get sitename
		sitename=p_sitename
	End Property
	Public Property Let sitename(str_name)
		p_sitename=str_name
	End Property
	
	Public Property Get siteurl
		siteurl=p_siteurl
	End Property
	Public Property Let siteurl(str_url)
		p_siteurl=str_url
	End Property
	
	Public Property Get sitelogo
		sitelogo=p_sitelogo
	End Property
	Public Property Let sitelogo(str_logo)
		p_sitelogo=str_logo
	End Property
	
	Public Property Get sitetype
		sitetype=p_sitetype
	End Property
	Public Property Let sitetype(int_type)
		p_sitetype=int_type
	End Property
	
	Public Property Get sitemail
		sitemail=p_sitemail
	End Property
	Public Property Let sitemail(str_mail)
		p_sitemail=str_mail
	End Property
	
	Public Property Get ccuserid
		ccuserid=p_ccuserid
	End Property
	Public Property Let ccuserid(str_userid)
		p_ccuserid=str_userid
	End Property
	
	Public Property Get cckey
		cckey=p_ccuserid
	End Property
	Public Property Let cckey(str_cckey)
		p_cckey=str_cckey
	End Property
	
	Public Property Get ccpwd
		ccpwd=p_ccpwd
	End Property
	Public Property Let ccpwd(str_ccpwd)
		p_ccpwd=str_ccpwd
	End Property
	
	Public Function regist()
		urlreturn = openUrl("http://union.bokecc.com/maxz/reg.bo?siteName="&server.urlencode(server.urlencode(p_sitename))&"&siteUrl="&server.urlencode(p_siteurl)&"&siteLogo="&server.urlencode(p_sitelogo)&"&siteType="&p_sitetype&"&siteEmail="&server.urlencode(p_sitemail),1) 
		If Not IsNumeric(urlreturn) Then
			result = replace(urlreturn, " ", "")
			result = Split(result, ",")
			configstr="<"&"%"&chr(13)&chr(10)&"dim union_config_array"&chr(13)&chr(10)&"union_config_array=array("""&p_sitename&""","""&p_siteurl&""","""&p_sitelogo&""","&p_sitetype&","""&p_sitemail&""","""&result(0)&""","""&result(2)&""","""&result(1)&""")"&chr(13)&chr(10)&"%"&">"
			call createHtml("configs/union_config.asp",configstr)
			echo lang_regist_array(0)&result(1)
		Else
			Select Case urlreturn
				  Case "-1"
				  	echo lang_regist_array(1)
				  Case "-2"
					echo lang_regist_array(2)
				  Case "-3"
					echo lang_regist_array(3)
				  Case "-4"
					echo lang_regist_array(4)
				  Case "-5"
					echo lang_regist_array(5)
			 End Select
		End If
	End Function
	
	Private Function judgeBind()
		If Not IsNumeric(urlreturn) Then
			result = replace(urlreturn, " ", "")
			result = Split(result, ",")
			if result(3)="" then 
				sitetype=0
			else
				sitetype=result(3)
			end if
			configstr="<"&"%"&chr(13)&"dim union_config_array"&chr(13)&"union_config_array=array("""&result(4)&""","""&URLDecode(result(2))&""","""&result(5)&""","&p_sitetype&","""&p_sitemail&""","""&result(0)&""","""&result(1)&""","""&p_ccpwd&""")"&chr(13)&"%"&">"
			call createHtml("configs/union_config.asp",configstr)
			If result(6) = 1 Then
			 	alertMsg lang_bind_array(0),account
			ElseIf result(6) = 2 Then
			  	alertMsg lang_bind_array(1),account 
			End If
		Else
			Select Case urlreturn
				  Case "-1"
					echo lang_bind_array(2)
				  Case "-2"
					echo lang_bind_array(3)
				  Case "-3"
					echo lang_bind_array(4)
				  Case "-4"
					echo lang_bind_array(5)
				  Case "-5"
					echo lang_bind_array(6)
			End Select
		End If
	End Function
	
	Public Function bind()
		urlreturn = openUrl("http://union.bokecc.com/maxz/bind.bo?password="&server.urlencode(p_ccpwd)&"&siteEmail="&server.urlencode(p_sitemail)&"&siteUrl="&server.urlencode(p_siteurl),1)
		judgeBind()
	End Function
	
	Public Function comparevars(str1,str2)
		if str1=str2 then
			comparevars=true
		else
			comparevars=false
		end if
	End Function
	
	Private Function judgeModify()
		If IsNumeric(urlreturn) Then
			result = CInt(urlreturn)
			Select Case result
				Case 1
					configstr="<"&"%"&chr(13)&"dim union_config_array"&chr(13)&"union_config_array=array("""&p_sitename&""","""&p_siteurl&""","""&p_sitelogo&""","&p_sitetype&","""&union_config_array(4)&""","""&union_config_array(5)&""","""&union_config_array(6)&""","""&p_ccpwd&""")"&chr(13)&"%"&">"
					call createHtml("configs/union_config.asp",configstr)
					echo "<script language=javascript>alert('"&lang_modify_array(0)&"');location.href='?';</script>"
				Case 0
					echo lang_modify_array(1)
				Case -1
					echo lang_modify_array(2)
				Case -2
					echo lang_modify_array(3)
				Case -3
					echo lang_modify_array(4)
				Case -4
					echo lang_modify_array(5)
				Case -5
					echo lang_modify_array(6)
				Case -6
					echo lang_modify_array(7)
				Case -7
					echo lang_modify_array(8)
				Case -8
					echo lang_modify_array(9)
			End Select
		Else
			echo lang_modify_array(10)
		End If
	End Function
	
	Public Function modify(oldpassword,newpassword)
		dim code,cc_key
		cc_key=union_config_array(6)
		code = server.urlencode(auth_code("password="&server.urlencode(newpassword)&"&oldPassword="&server.urlencode(oldpassword)&"&siteName="&server.urlencode(p_sitename)&"&oldSiteUrl="&server.urlencode(union_config_array(1))&"&siteUrl="&server.urlencode(p_siteurl)&"&siteLogo="&server.urlencode(p_sitelogo)&"&siteType="&CInt(p_sitetype),"encode", cc_key))
		urlreturn = openUrl("http://union.bokecc.com/maxz/edit.bo?siteid="&union_config_array(5)&"&code="&code,1)		
		judgeModify()
	End Function
	
	Function unBind()
		configstr="<"&"%"&chr(13)&"dim union_config_array"&chr(13)&"union_config_array=array("""","""","""",0,"""","""","""","""")"&chr(13)&"%"&">"
		call createHtml("configs/union_config.asp",configstr)
		response.redirect account
	End Function
End Class
%>