<!--#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 help_id from jins_help_list where help_id in ("&ids&") ")
	do while not rs_t.eof
		if fso.FolderExists(server.mappath("../HELPPIC/"&rs_t("help_id"))) then fso.deletefolder server.mappath("../HELPPIC/"&rs_t("help_id")),true
	rs_t.movenext
	loop

	conn.execute("delete from jins_help_list where help_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_help_list "
	else
	    sql="select * from jins_help_list where help_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_help_list.asp?order_name=help_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 conn.execute("select sort_id from jins_help_sort where sort_id="&request("sort_id")&" ").eof and request("sort_id")>0  then
		MySys.error.info="您选择的帮助分类不存在！"
		MySys.error.location="back"
		MySys.error.err()
	end if

	if request("sort_id")="" or request("help_title")="" or request("help_writer")=""  then 	
		MySys.error.info="请完整填写相关项目！"
		MySys.error.location="back"
		MySys.error.err()
	end if
	
	'/////普通项
	rs("sort_id")=int(request("sort_id"))
	if request("help_title")<>"" then rs("help_title")=trim(request("help_title"))
	if request("help_open")<>"" then rs("help_open")=int(request("help_open"))	
	if request("help_content")<>"" then rs("help_content")=trim(request("help_content"))
	if request("help_writer")<>"" then rs("help_writer")=trim(request("help_writer"))	
	if request("help_addtime")<>"" then rs("help_addtime")=trim(request("help_addtime")) else rs("help_addtime")=now
	rs("help_clicknum")=request("help_clicknum")
	rs("help_num")=0
	
	rs.update
	
	if request("action")="add" then
	
		if fso.folderExists(server.mappath("../helpPIC/$_TEMP_$")) then
			fso.copyfolder server.mappath("../helpPIC/$_TEMP_$"),server.mappath("../helpPIC/"&rs("help_id"))
			fso.deletefolder server.mappath("../helpPIC/$_TEMP_$"),true
			fso.createfolder server.mappath("../helpPIC/$_TEMP_$")
		end if
		
	    if rs("help_content")<>"" then rs("help_content")=replace(rs("help_content"),"HELPPIC/$_TEMP_$","HELPPIC/"&rs("help_id"))
					
	    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"-->
