<!--#include file="conn.asp"-->
<!--#include file="../../inc/filter.asp"-->
<%
Rem 获得友情链接列表
sub get_link_list()
	dim list
	list=""
	set rs_list=Server.CreateObject("ADODB.RecordSet")
	rs_list.open "select * from [fksf_link]",conn,1,1
	for i=1 to rs_list.recordcount
%>
		<tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#cccccc'" style="padding: 0px 2px;">
			<td align="center"><a href="<%=rs_list("linkurl")%>" target="_blank"><%=rs_list("linkname")%></a></td>
			<td align="center"><a href="<%=rs_list("linkurl")%>" target="_blank"><%=rs_list("linkurl")%></a></td>
			<td align="center"><a href="link_update_form.asp?id=<%=rs_list("id")%>">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="link_delete.asp?id=<%=rs_list("id")%>">删除</a></td></tr>
<%
		rs_list.movenext()
	next
	rs_list.close()
	set rs_list=nothing
	response.write(list)
end sub
%>

<%
Rem 友情链接管理入口
sub link_access()
	action=trim(request("action"))
	if(action="") then
		response.Write("<script language=javascript>")
		response.Write("alert('传递判断参数不能为空');")
		response.Write("history.go(-1);")
		response.Write("</script>")
	else
		if(ChkBadWord(action)<>0) then
			response.Write("<script language=javascript>")
			response.Write("alert('传递判断参数包含非法字符');")
			response.Write("history.go(-1);")
			response.Write("</script>")
		else
			if(action="update") then
				call link_update()'操作友情链接更新
			else
				if(action="insert") then
					call link_insert()'操作友情链接添加
				else
					if(action="delete") then
						call link_delete()'操作友情链接删除
					end if
				end if
			end if
		end if
	end if
end sub
%>

<%
Rem 友情链接更新
sub link_update()
	id=trim(request("id"))
	linkname=trim(request("webname"))
	linkurl=trim(request("weburl"))
	
	if(id="" or linkname="" or linkurl="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("history.go(-1);")
		response.Write("</script>")
	else
		if(ChkBadWord(id)<>0 or ChkBadWord(linkname)<>0 or ChkBadWord(linkurl)<>0) then
			response.Write("<script language=javascript>")
			response.Write("alert('参数包含非法字符');")
			response.Write("history.go(-1);")
			response.Write("</script>")
		else
			set rs_link=Server.CreateObject("ADODB.RecordSet")
			rs_link.open "select * from [fksf_link] where id="&id,conn,1,3
			if(rs_link.eof) then
				rs_link.close()
				set rs_link=nothing
				response.Write("<script language=javascript>")
				response.Write("alert('本系统无该友情链接');")
				response.Write("window.location='main_body.asp';")
				response.Write("</script>")
			else
				rs_link("linkname")=linkname
				rs_link("linkurl")=linkurl
				rs_link.update()
				rs_link.close()
				set rs_link=nothing
				response.Write("<script language=javascript>")
				response.Write("alert('友情链接更新成功');")
				response.Write("window.location='main_body.asp';")
				response.Write("</script>")
			end if
		end if
	end if
end sub
%>

<%
Rem 友情链接添加
sub link_insert()
	linkname=trim(request("webname"))
	linkurl=trim(request("weburl"))
	
	if(linkname="" or linkurl="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("history.go(-1);")
		response.Write("</script>")
	else
		if(ChkBadWord(linkname)<>0 or ChkBadWord(linkurl)<>0) then
			response.Write("<script language=javascript>")
			response.Write("alert('参数包含非法字符');")
			response.Write("history.go(-1);")
			response.Write("</script>")
		else
			set rs_link=Server.CreateObject("ADODB.RecordSet")
			rs_link.open "select * from [fksf_link] where linkname='"&linkname&"'",conn,1,3
			if(not rs_link.eof) then
				rs_link.close()
				set rs_link=nothing
				response.Write("<script language=javascript>")
				response.Write("alert('该友情链接已存在');")
				response.Write("window.location='main_body.asp';")
				response.Write("</script>")
			else
				rs_link.addnew()
				rs_link("linkname")=linkname
				rs_link("linkurl")=linkurl
				rs_link.update()
				rs_link.close()
				set rs_link=nothing
				response.Write("<script language=javascript>")
				response.Write("alert('友情链接添加成功');")
				response.Write("window.location='main_body.asp';")
				response.Write("</script>")
			end if
		end if
	end if
end sub
%>

<%
Rem 友情链接删除
sub link_delete()
	id=trim(request("id"))
	
	if(id="") then
		response.Write("<script language=javascript>")
		response.Write("alert('参数不能为空');")
		response.Write("history.go(-1);")
		response.Write("</script>")
	else
		if(ChkBadWord(id)<>0) then
			response.Write("<script language=javascript>")
			response.Write("alert('参数包含非法字符');")
			response.Write("history.go(-1);")
			response.Write("</script>")
		else
			conn.execute("delete from [fksf_link] where id="&id)
			response.Write("<script language=javascript>")
			response.Write("alert('友情链接删除成功');")
			response.Write("window.location='main_body.asp';")
			response.Write("</script>")
		end if
	end if
end sub
%>