<!--#include file="admin_start.asp"-->

<%
dim id
dim ids
dim n_ids

id=request("id")
ids=request("ids")
ids=replace(ids," ","")
n_ids=""

Set fso = CreateObject("Scripting.FileSystemObject")

if not MySys.check.isInteger(id) and request("action")="edit" then
MySys.error.info="请选择您要操作的项目！"
MySys.error.location="back"
MySys.error.err()
end if

select case request("action")
case "delete"

	if ids="" then
		MySys.error.info="请选择你要删除的友情链接！"
		MySys.error.location="back"
		MySys.error.err()
	end if		

	set rs_t=conn.execute("select links_id from jins_links_list where links_id in ("&ids&") ")
	do while not rs_t.eof
		if fso.FolderExists(server.mappath("../LINKSPIC/"&rs_t("links_id"))) then fso.deletefolder server.mappath("../LINKSPIC/"&rs_t("links_id")),true
	rs_t.movenext
	loop

	conn.execute("delete from jins_links_list where links_id in ("&ids&") ")
	
	session("FB_EM_1_SQL_uppath")=""

	MySys.error.info="删除友情链接成功！"
	MySys.error.location="back"
	MySys.error.suc()
	
case else

	if request("action")="add" then
	    sql="select * from jins_links_list "
	else
	    sql="select * from jins_links_list where links_id="&id&" "
	end if
	
	rs.open sql,conn,1,3
	
	'/////////////////////////////////////////////检测
	
	if request("action")="add" then
	    rs.addnew
		MySys.error.info="友情链接添加成功！"
	    MySys.error.location="admin/admin_info_links_list.asp?order_name=links_addtime&order_action=desc&s_n=6,sort_id,0&sort_id="&request("sort_id")
	else
		MySys.error.info="友情链接编辑成功！"
	    MySys.error.location="back"
	end if

	if request("action")="edit" and rs.eof then
		MySys.error.info="您选择的友情链接不存在！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	

	if request("links_name")="" or request("links_url")=""  then 	
		MySys.error.info="请完整填写相关项目！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	'/////普通项
	rs("sort_id")=0
	if request("links_name")<>"" then rs("links_name")=trim(request("links_name"))
	if request("links_open")<>"" then rs("links_open")=int(request("links_open"))	
	if request("links_url")<>"" then rs("links_url")=trim(request("links_url"))
	if request("links_info")<>"" then rs("links_info")=trim(request("links_info"))	
	'if request("links_num")<>"" then rs("links_addtime")=trim(request("links_addtime")) else rs("links_addtime")=now
	'rs("links_clicknum")=request("links_clicknum")
	
	if request("action")="edit" then
	
		'////////////图片处理
		if rs("links_img")<>"" then 
			if request("links_img")<>rs("links_img") then 
				 if fso.FileExists(server.mappath("../"&rs("links_img"))) then fso.deletefile server.mappath("../"&rs("links_img")),true
			end if
		end if
		
		rs("links_img")=trim(request("links_img"))
		
		'////////////图片处理end
		
		rs("links_addtime")=trim(request("links_addtime"))	
		
	end if	
	rs.update
	
	if request("action")="add" then
	
		'////////////图片处理
		if request("links_img")<>"" then
		    if fso.FileExists(server.mappath("../"&request("links_img"))) then
		        filename=server.mappath("../"&replace(request("links_img"),"$_TEMP_$",rs("links_id")))
				MySys.check.MakeNewsDir(filename)
				'response.write filename&"<br>"
				fso.copyfile server.mappath("../"&request("links_img")),filename
				fso.deletefile server.mappath("../"&request("links_img")),true
				
			    'ims=im.showimage(filename,90,90)
				
			    rs("links_img")=replace(request("links_img"),"$_TEMP_$",rs("links_id"))
			end if
		end if

		'////////////图片处理end
		rs("links_addtime")=now()	
	    rs.update
	end if
	
	rs.close
	
	session("FB_EM_1_SQL_uppath")=""

	MySys.error.suc()

	'/////////////////////////////////////////////
end select
Set fso = nothing

%>
<!--#include file="admin_end.asp"-->
