<% 
	Dim ShowErr,action
	if Request("action") = "s" Then 
	conn.Execute("Update ClassLink_skweb Set oid=oid+1 where ID="&request("id"))
    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
	response.end
else 
end if 
   
if Request("action") = "x" Then 
	conn.Execute("Update ClassLink_skweb Set oid=oid-1 where ID="&request("id"))
    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
	response.end
else 
end if 

if Request("action") = "sortsave" Then 
 	Call skweboa.FSOSaveASP( ""  & skweboa.HTMLCode(Request.Form("content")) &"",""&MyDbPath&"SKCMS/skconfig/list.cs")	
    Call skweboa.SK_window("设置成功",""&MyDbPath&"SKCMS/dialog.asp?action=closmain","2","3") 
else 
end if  

	action = Request("action")
	Select Case action
 
			Case "SaveAdd"
				Call SaveAdd
			Case "del"
				Call Del()
			Case "Classmain"
				Call Classmain()
	
			Case "addlink","Editlink"
				Call addlink()
	
			Case "Saveaddlink"
				Call Saveaddlink()
			Case "SaveEditlink"
				Call SaveEditlink()
	
			Case "linkdel"
				Call linkdel()
										
			Case "sh"
				Call sh()
			Case "qxsh"
				Call qxsh()		
				
			Case "sd"
				Call sd()
			Case "qxsd"
				Call qxsd()	
					
			Case Else
				Call Main()
	End Select
	

Sub Saveaddlink()
		Dim SK_SiteName,Description,SQL,rs,id
		SK_SiteName = Trim(Request.Form("SK_SiteName"))
		Description = skweboa.C_SKCMSSQL(Request.Form("Description"))
		IF 	SK_SiteName = "" Then 
  			Call skweboa.SK_window("网站名称名称不能为空","","","")
 			Response.End
		End IF
		SQL = "Select * From Link_skweb "
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		Rs.addnew
		 Rs("SK_SiteName") = SK_SiteName
		  Rs("Description")=request("Description")
		  Rs("Webadmin")=request("Webadmin")
		  Rs("Email")=request("Email")
		  Rs("url")=request("url")
		  Rs("AddDate")=now
		  Rs("classlinkID")=skweboa.Return_to_numerical(request("ClassLinkID"))
		  Rs("locked")=skweboa.Return_to_numerical(request("locked"))
		  Rs("rec")=skweboa.Return_to_numerical(request("rec"))
		  Rs("sh")=1	
		  Rs("Logo")=request("Logo")
		Rs.update
		Rs.Close:Set Rs=Nothing
		 Call skweboa.SK_window("添加新链接成功",""&MyDbPath&"SKCMS/dialog.asp?action=closmain","","3")
		Response.End
	End Sub	
		
	Sub SaveEditlink()
		Dim SK_SiteName,Description,SQL,rs,id
		SK_SiteName = Trim(Request.Form("SK_SiteName"))
		Description = skweboa.C_SKCMSSQL(Request.Form("Description"))
		ID = skweboa.Return_to_numerical(Request("ID"))
		IF 	SK_SiteName = "" Then 
 			Call skweboa.SK_window("网站名称不能为空","","","")
 			Response.End
		End IF
		SQL = "Select * From Link_skweb Where ID="&ID
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		IF Not (Rs.Eof And Rs.Bof) Then
		 Rs("SK_SiteName") = SK_SiteName
		Rs("Description")=request("Description")
		  Rs("Webadmin")=request("Webadmin")
		  Rs("Email")=request("Email")
		  Rs("url")=request("url")
		  Rs("classlinkID")=skweboa.Return_to_numerical(request("classlinkID"))
		  Rs("locked")=skweboa.Return_to_numerical(request("locked"))
		  Rs("rec")=skweboa.Return_to_numerical(request("rec"))
		  Rs("Logo")=request("Logo")
			Rs.update
		Else
			Call skweboa.SK_window("无此链接，参数传递出错","","","3")
 			Response.End
		End IF
		Rs.Close:Set Rs=Nothing
			 Call skweboa.SK_window("链接修改成功",""&MyDbPath&"SKCMS/dialog.asp?action=closmain","","3")
 		Response.End
	End Sub	
	
	
	
		
	
	Sub SaveAdd()
		Dim ClassLinkName,Description,SQL,rs,id
		ClassLinkName = Trim(Request.Form("ClassLinkName"))
		Description = skweboa.C_SKCMSSQL(Request.Form("Description"))
		IF 	ClassLinkName = "" Then 
 			Call skweboa.SK_window("类别名称不能为空","","1","3")
 			Response.End
		End IF
		SQL = "Select * From ClassLink_skweb Where ClassLinkName='"&ClassLinkName&"'"
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		IF Not (Rs.Eof And Rs.Bof) Then
 			Call skweboa.SK_window("数据库中已经存在此类别名称","","1","3")
 			Response.End
		End IF
		Rs.addnew
		Rs("ClassLinkName")		= ClassLinkName
		Rs("Description")	    = Description
		Rs.update
		Rs.Close:Set Rs=Nothing
        response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
		Response.End
	End Sub	
	


 	Sub linkdel()
      ID = Request("ID") 
	  IF ID = "" Then
			Call skweboa.SK_window("请指定要删除的内容","","1","1")
			End IF
	    If instr(ID,",")>0 then
			ID=replace(ID," ","")
			 
		   Conn.Execute ("Delete from Link_skweb Where ID in (" & ID & ")")		
		Else
			Conn.Execute ("Delete from Link_skweb Where ID=" & skweboa.Return_to_numerical(ID)&" ")
		End if
		Set conn=nothing
 	    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
 		Response.End	
    End Sub
	
		
 	Sub sh()
	conn.Execute("Update  Link_skweb Set sh=1 where ID=" & skweboa.Return_to_numerical(Request.QueryString("ID")))
    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
	response.end
    End Sub

	Sub qxsh()
	conn.Execute("Update Link_skweb Set sh=0 where ID=" & skweboa.Return_to_numerical(Request.QueryString("ID")))
    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
	response.end
    End Sub
	
	Sub sd()
	conn.Execute("Update  Link_skweb Set Locked=1 where ID=" & skweboa.Return_to_numerical(Request.QueryString("ID")))
    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
	response.end
    End Sub

	Sub qxsd()
	conn.Execute("Update Link_skweb Set Locked=0 where ID=" & skweboa.Return_to_numerical(Request.QueryString("ID")))
    response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
	response.end
    End Sub
		
	
	Sub Del()
		Conn.Execute ("Delete from ClassLink_skweb Where ID=" & skweboa.Return_to_numerical(Request.QueryString("ID")))
		Conn.Execute ("Delete from Link_skweb Where ClassLinkID=" & skweboa.Return_to_numerical(Request.QueryString("ID")))		
		Set conn=nothing
        response.Redirect("" & Request.ServerVariables("HTTP_REFERER") & "")
   		Response.End
    End Sub

	
	
	
	
	
		
 Sub Main
 	Select Case Request.QueryString("actype")
		Case "List"
			Sqls = " where classlinkid="&Request.QueryString("classlinkid")&"  "
			
		Case "sh"
			Sqls = "where sh=0 "
			
		Case Else
			Sqls = "  "
 
	End Select
	
	 Set skpagesPages=New skcmspages
     skpagesPages.GetConn=conn
     'Sql语句
     skpagesPages.GetSql= "SELECT [ID], [ClassLinkID], [SK_SiteName], [Locked],  [AddDate], [Rec], [sh], [url], [logo]" & _
		" FROM [Link_skweb]" &Sqls& _
		"ORDER BY [ID] deSC"
  	
      skpagesPages.PageSize=30
	  dim dqpagelist
	  dqpagelist= skweboa.SK_axe("select count(ID) from Link_skweb  "&Sqls&"  ")(0)	
      set skpagers=skpagesPages.GetRs()
		
		
 %>