<!--#include file="../../../../p_inc/Include_func.asp"-->
<!--#include file="../../../../p_inc/openconn.asp"-->
<!--#include file="../../../../Members/config.asp"-->

<%
Dim kkkks
kkkks="3,8,9,10,11,12,13,14,16,18,19,20,21,22,23,24,7,25,27"
kkkks_a=Split(kkkks,",")

IF Not ChkPost() Then
	response.Redirect G_error_page_1
	response.End()
End IF
'输出数组,去掉重复的字段
Function PrintArrayx(str,s)
	Dim str2,i,str3,str3_t
	str=ForMatStr(str,s)
	str2=split(str,s)
	For i=Lbound(str2) To Ubound(str2)
		str3_t=str2(i)
		IF instr(s&str3&s,s&str3_t&s)=0 Then
			str3=str3&str3_t&s
		End IF
	Next
	PrintArrayx=ForMatStr(str3,s)
End Function

Response.Buffer=True
response.contenttype="x-javascript;charset=gb2312"
v=request("callback")
IF v="cbadd" Then '增加一个应用
	Uid=Bint(Request.Cookies(G_u_Cookies)("soojs_id"))
	IF Uid=0 Then Response.Write "":Response.End()
	sappId=Request("appId")
	sappId=Replace(sappId,"'","")
	sappId=Bint(sappId)
	str=""
	Set oRs=Server.CreateObject(G_RS)
	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,3
	IF Not oRs.Eof Then
		t1=GetRp(oRs(0))
		t1=FormatNumSerial(t1)
		k1=","&t1&","
		k1=Replace(t1,","&sappId&",",",")
		t1=k1&","&sappId
		t1=FormatNumSerial(t1)
		t1=PrintArrayx(t1,",")
		'Response.Write t1
		oRs("soojs_1616_manager")=t1
		oRs.update()
		str="cbadd(1)"
	Else
		str="cbadd(0)"
	End IF
	oRs.close
	Response.Write Str
ElseIF v="cbup" Then '向上移动
	Uid=Bint(Request.Cookies(G_u_Cookies)("soojs_id"))
	IF Uid=0 Then Response.Write "":Response.End()
	sappId=Request("appId")
	sappId=Replace(sappId,"'","")
	sappId=Bint(sappId)
	str=""
	str2=""
	str3=""
	Set oRs=Server.CreateObject(G_RS)
	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,3
	IF Not oRs.Eof Then
		t1=GetRp(oRs(0))
		t1=FormatNumSerial(t1)
		t1_a=Split(t1,",")
		n1=""
		n2=0
		For i=0 To Ubound(t1_a)
			m1=Bint(t1_a(i))
			IF m1=sappId Then
				n2=i
			End IF
		Next
		IF n2=0 Then
			str="cbup(0)"
			Response.End()
		End IF
		For k=0 To Ubound(t1_a)
			s12=t1_a(k)
			IF n2=k+1 Then
				s12=t1_a(k+1)
			ElseIF n2=k Then
				s12=t1_a(k-1)
			End IF
			str3=str3&s12&","
		Next
		str3=PrintArrayx(str3,",")
		'Response.Write t1&"<br>"
		'Response.Write n2&"<br>"
		'Response.Write str3&"<br>"
		oRs("soojs_1616_manager")=str3
		oRs.update()
		str="cbup(1)"
	Else
		str="cbup(0)"
	End IF
	oRs.close
	Response.Write Str		
ElseIF v="cbreset" Then '恢复默认应用
	Set oRs=Server.CreateObject(G_RS)
	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,3
	IF Not oRs.Eof Then
		oRs("soojs_1616_manager")=kkkks
		oRs.update()		
		Response.Write "cbreset(1)"
	Else
		Response.Write "cbreset(0)"
	End IF
	oRs.close		
ElseIF v="cbdel" Then '删除一个应用
	Uid=Bint(Request.Cookies(G_u_Cookies)("soojs_id"))
	IF Uid=0 Then Response.Write "":Response.End()
	sappId=Request("appId")
	sappId=Replace(sappId,"'","")
	sappId=Bint(sappId)
	str=""
	Set oRs=Server.CreateObject(G_RS)
	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,3
	IF Not oRs.Eof Then
		t1=GetRp(oRs(0))
		t1=FormatNumSerial(t1)
		k1=","&t1&","
		k1=Replace(k1,","&sappId&",",",")
		t1=FormatNumSerial(k1)
		t1=PrintArrayx(t1,",")
		'Response.Write t1
		oRs("soojs_1616_manager")=t1
		oRs.update()
		str="cbdel(1)"
	Else
		str="cbdel(0)"
	End IF
	oRs.close
	Response.Write Str	
ElseIF v="cblist"  Then '显示所有管理应用
	Uid=Bint(Request.Cookies(G_u_Cookies)("soojs_id"))
	IF Uid=0 Then Response.Write "":Response.End()
	Pstr=N_Fso.ReadAllTextFile(Add_Root_Dir("/template/"&G_moban&"/images/manager/js/config.js"))
	PFlag=False
	Set oRs=Server.CreateObject(G_RS)
	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,3
	IF Not oRs.Eof Then	
		t1=GetRp(oRs(0))
		IF t1="" Then
			PFlag=True
		End IF
		t1=FormatNumSerial(t1)
		t1_a=Split(t1,",")
		For i=0 To Ubound(t1_a)
			n1=t1_a(i)
			IF n1<>0 Then
				Pstr=Replace(Pstr,"{added"&n1&"}","yes")
			End IF
		Next		
	End IF
	IF PFlag Then
		oRs("soojs_1616_manager")=kkkks
		oRs.update()
		For i=0 To Ubound(kkkks_a)
			kki=kkkks_a(i)
			Pstr=Replace(Pstr,"{added"&kki&"}","yes")	
		Next		
	Else
		For i=1 To 100
			Pstr=Replace(Pstr,"{added"&i&"}","no")	
		Next
	End IF
	oRs.close
	Response.Write Pstr
ElseIF v="cbgetadded" Then '显示自己在用的所有应用
	Uid=Bint(Request.Cookies(G_u_Cookies)("soojs_id"))
	IF Uid=0 Then Response.Write "":Response.End()
	Pstr=N_Fso.ReadAllTextFile(Add_Root_Dir("/template/"&G_moban&"/images/manager/js/self.js"))
	kstr=""
	kstr2=""
	kstr3=""
	PFlag=False
	Set oRs=Server.CreateObject(G_RS)
	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,1
	IF Not oRs.Eof Then	
		t1=GetRp(oRs(0))
		IF t1="" Then
			PFlag=True
		End IF
		t1=FormatNumSerial(t1)
		t1_a=Split(t1,",")
		For i=0 To Ubound(t1_a)
			n1=t1_a(i)
			IF n1<>0 Then
				kstr2=N_Fso.ReadAllTextFile(Add_Root_Dir("/template/"&G_moban&"/images/manager/myjs/"&n1&".js"))
				IF kstr2<>"" Then 
					kstr3=kstr3&kstr2&","
				End IF
			End IF
		Next	
		IF kstr3<>"" Then
			kstr3=mid(kstr3,1,len(kstr3)-1)
		End IF			
	End IF	
	IF PFlag Then
		oRs("soojs_1616_manager")=kkkks
		oRs.update()
		For i=1 To 100
			kstr2=N_Fso.ReadAllTextFile(Add_Root_Dir("/template/"&G_moban&"/images/manager/myjs/"&n1&".js"))
			IF kstr2<>"" Then 
				kstr3=kstr3&kstr2&","
			End IF
		Next	
		IF kstr3<>"" Then
			kstr3=mid(kstr3,1,len(kstr3)-1)
		End IF				
	Else

	End IF	
	kstr=kstr&"cbgetadded(["&kstr3&"]);"
	Response.Write kstr
ElseIF v="cbgetaddedlist" Then '显示自己在用的所有应用--首页
	Uid=Bint(Request.Cookies(G_u_Cookies)("soojs_id"))
	IF Uid=0 Then Response.Write "":Response.End()
	kstr=""
	kstr2=""
	kstr3=""
	PFlag=False
	Set oRs=Server.CreateObject(G_RS)
	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,1
	IF Not oRs.Eof Then	
		t1=GetRp(oRs(0))
		IF t1="" Then
			t1=kkkks
		End IF
		t1=FormatNumSerial(t1)
		kstr=t1			
	End IF	
	Response.Write kstr	

'	Pstr=N_Fso.ReadAllTextFile(Add_Root_Dir("/template/"&G_moban&"/images/manager/js/self.js"))
'	kstr=""
'	kstr2=""
'	kstr3=""
'	PFlag=False
'	Set oRs=Server.CreateObject(G_RS)
'	oRs.open "Select soojs_1616_manager From soojs_un Where Id="&Request.Cookies(G_u_Cookies)("soojs_id"),Conn,1,1
'	IF Not oRs.Eof Then	
'		t1=GetRp(oRs(0))
'		IF t1="" Then
'			PFlag=True
'		End IF
'		t1=FormatNumSerial(t1)
'		t1_a=Split(t1,",")
'		For i=0 To Ubound(t1_a)
'			n1=t1_a(i)
'			IF n1<>0 Then
'				kstr2=N_Fso.ReadAllTextFile(Add_Root_Dir("/template/"&G_moban&"/images/manager/myjs/"&n1&".js"))
'				IF kstr2<>"" Then 
'					kstr3=kstr3&kstr2&","
'				End IF
'			End IF
'		Next	
'		IF kstr3<>"" Then
'			kstr3=mid(kstr3,1,len(kstr3)-1)
'		End IF			
'	End IF	
'	IF PFlag Then
'		oRs("soojs_1616_manager")="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30"
'		oRs.update()
'		For i=1 To 30
'			kstr2=N_Fso.ReadAllTextFile(Add_Root_Dir("/template/"&G_moban&"/images/manager/myjs/"&n1&".js"))
'			IF kstr2<>"" Then 
'				kstr3=kstr3&kstr2&","
'			End IF
'		Next	
'		IF kstr3<>"" Then
'			kstr3=mid(kstr3,1,len(kstr3)-1)
'		End IF				
'	Else
'
'	End IF	
'	kstr=kstr&"["&kstr3&"]"
'	Response.Write kstr
End IF

%>
