<!-- #include file="../conn.asp" -->
<!-- #include file="admin.asp" -->
<%call ling()
Call Head()

		IF  Request.QueryString("Action")="view" Then
			call view
		elseiF  Request.QueryString("Action")="del" Then
			call del
		elseiF  Request.QueryString("Action")="edit" Then
			call edit
		elseiF  Request.QueryString("Action")="add" Then
			call add
		elseiF  Request.QueryString("Action")="save" Then
			call save
		else

			call index
		end if
Function index

Call saycardd("采集模板管理")


Set Rs = Server.CreateObject("Adodb.Recordset")
Sql = "SELECT * FROM cjbook order by id desc"
Rs.Open Sql,conn,1,1
If Not rs.eof	Then
	Dim PageSize,i
	PageSize=10							
	Dim Count,page,pagecount,gopage,parent			
	gopage="cjbook.asp?sid="&sid&"&amp;saytk="&saytk&"&amp;"
	Count=rs.recordcount
	page=int(request.QueryString ("page"))
	if page<=0 or page="" then page=1		
	pagecount=(count+pagesize-1)\pagesize	
        if page>pagecount then page=pagecount	
	rs.move(pagesize*(page-1))				
	For i=1 To PageSize       						
	If rs.eof Then Exit For				
%><%=i+(page-1)*PageSize%>.<a href='cjbook.asp?sid=<%=sid%>&amp;Action=view&amp;id=<%=ubb(rs("id"))%>&amp;saytk=<%=saytk%>'><%=ubb(rs("name"))%></a><br/>
<%     
	rs.moveNext						
	Next
	if page-pagecount<0 then response.write "<a href="""&gopage&"page="&page+1&""">下页</a>"
	if page>1 then response.write "<a href="""&gopage&"page="&page-1&""">上页</a>"
	if pagecount>1 then response.write "<br/><b>"&page&"</b>/"&pagecount&"页"
if saytk=1 then
response.write "<input name=""page"" format=""*N"" value="""&page&""" type=""text"" maxlength=""5"" emptyok=""true"" size=""3""/><a href="""&gopage&"page=$(page)"">>></a>"
end if
Else
%>
	(没有模板)

<%end if%>
		<%
		Rs.close
		set rs=nothing
		Response.Write("<br/><a href='cjbook.asp?sid="&sid&"&amp;Action=add&amp;saytk="&saytk&"'>[添加模板]</a><br/>")
end Function
Function add
Call saycardd("添加采集模板")

if saytk>1 then
Response.write "<form name=""form"" method=""post"" action=""cjbook.asp?sid="&sid&"&amp;Action=save&amp;edit=add&amp;saytk="&saytk&""">"
end if%>
		模板名称:<br/><input name="name" maxlength="255" /><br/>
		开始位置:<br/><input name="starwml" value=""/><br/> 
		结束位置:<br/><input name="overwml" value=""/><br/> 
        网页编码: <select name="ubm" value="1">
		<option value="utf-8">utf-8</option>
		<option value="GB2312">GB2312</option>
		</select><br/>
		图片相对地址:<input name="addurl" value="http://"/><br/> 
<%if saytk>1 then
response.write "<input type=""submit"" name=""Submit"" value=""发布""></form><br/>"
else%>
		<anchor>发布
		<go href="cjbook.asp?sid=<%=sid%>&amp;Action=save&amp;edit=add&amp;saytk=<%=saytk%>" method="post">
		<postfield name="name" value="$(name:n)" />
		<postfield name="addurl" value="$(addurl:n)" />
		<postfield name="starwml" value="$(starwml)" />
		<postfield name="overwml" value="$(overwml)" />
		<postfield name="ubm" value="$(ubm)" />
		</go>
		</anchor><br/><%end if%>
<a href="cjbook.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[模板管理]</a><br/>
	<%
end Function
Function edit
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
	if id=""  then
	call error("ID无效")
else
			Set Rs = Server.CreateObject("Adodb.Recordset")
			Sql = "SELECT * FROM cjbook where id="&id
			Rs.Open Sql,conn,1,1
if not (rs.bof and rs.eof)  then 
Call saycardd("修改模板")

if saytk>1 then
Response.write "<form name=""form"" method=""post"" action=""cjbook.asp?sid="&sid&"&amp;Action=save&amp;edit=edit&amp;saytk="&saytk&""">"%>
		模板名称:<br/><input name="name" value="<%=UBB1(rs("name"))%>"/><br/>
		开始位置:<br/><input name="starwml" value="<%=UBB1(rs("starwml"))%>"/><br/> 
		结束位置:<br/><input name="overwml" value="<%=UBB1(rs("overwml"))%>"/><br/> 
        网页编码: <select name="ubm" value="<%=UBB1(rs("ubm"))%>">
		<option value="utf-8">utf-8</option>
		<option value="GB2312">GB2312</option>
		</select><br/>
		图片相对地址:<input name="addurl" value="<%=UBB1(rs("addurl"))%>"/><br/> 
<input type="submit" name="Submit" value="修改"></form><br/>
<%else%>
		模板名称:<br/><input name="name<%=tt%>" value="<%=UBB1(rs("name"))%>"/><br/>
		开始位置:<br/><input name="starwml<%=tt%>" value="<%=UBB1(rs("starwml"))%>"/><br/> 
		结束位置:<br/><input name="overwml<%=tt%>" value="<%=UBB1(rs("overwml"))%>"/><br/> 
        网页编码: <select name="ubm<%=tt%>" value="<%=UBB1(rs("ubm"))%>">
		<option value="utf-8">utf-8</option>
		<option value="GB2312">GB2312</option>
		</select><br/>
		图片相对地址:<input name="addurl<%=tt%>" value="<%=UBB1(rs("addurl"))%>"/><br/> 
	<anchor>修改
<go href="cjbook.asp?sid=<%=sid%>&amp;Action=save&amp;edit=edit&amp;saytk=<%=saytk%>" method="post">
		<postfield name="name" value="$(name<%=tt%>)" />
		<postfield name="addurl" value="$(addurl<%=tt%>)" />
		<postfield name="starwml" value="$(starwml<%=tt%>)" />
		<postfield name="overwml" value="$(overwml<%=tt%>)" />
		<postfield name="ubm" value="$(ubm<%=tt%>)" />
		<postfield name="id" value="<%=id%>" />
			</go>
			</anchor><%end if%><br/>
<a href="cjbook.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[模板管理]</a><br/>
			<%else
if saytk>1 then
Response.write "<title>出错啦</title></head><body><body bgcolor="""&yanse1&"""><p>没有该模板!<br/>"
else%>
			<card id="index" title="出错啦"><p>没有该模板!<br/>
			<%end if
end if
			Rs.close
			set rs=nothing
		end if
end Function
Function view
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
		if id=""  then
if saytk>1 then
Response.write "<title>出错啦</title></head><body><body bgcolor="""&yanse1&"""><p>ID无效.<br/>"
else%>
	<card id="index" title="出错啦"><p>ID无效.<br/>
<%end if%>
		<%Else
Call saycardd("模板管理")

			Set Rs = Server.CreateObject("Adodb.Recordset")
			Sql = "SELECT * FROM cjbook where id="&id
			Rs.Open Sql,conn,1,1
			if not (rs.bof and rs.eof)  then %>
				模板名称:<%=ubb1(rs("name"))%><br/>
				开始位置:<%=ubb1(rs("starwml"))%><br/>
				结束位置:<%=ubb1(rs("overwml"))%><br/>
				网页编码:<%=ubb1(rs("ubm"))%><br/>
				相对地址:<%=ubb1(rs("addurl"))%><br/>
				<a href='cjbook.asp?sid=<%=sid%>&amp;Action=edit&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[编辑]</a> <a href='cjbook.asp?sid=<%=sid%>&amp;Action=del&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[删除]</a><br/>
<a href="cjbook.asp?sid=<%=sid%>">[模板管理]</a><br/>
			<%else%>
				暂无模板!<br/>
			<%end if
			Rs.close
			set rs=nothing
		end if
end Function
Function  del
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
 		if id=""  then
if saytk>1 then
Response.write "<title>出错啦</title></head><body><body bgcolor="""&yanse1&"""><p>ID无效.<br/>"
else%>
	<card id="index" title="出错啦"><p>ID无效.<br/>
		<%end if
else
			if Request("del")="true" then
				set rs=server.CreateObject("adodb.recordset")
				Sql = "SELECT * FROM cjbook where id="&id
				rs.open sql,conn,1,3
				if not (rs.bof and rs.eof)  then
				rs.delete
				end if
				Rs.close
				set rs=Nothing
Call saycardd("删除模板")
%>
		已成功删除该模板!<br/>
<a href="cjbook.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[模板管理]</a><br/>
			<%Else
	Call saycardd("删除模板")		
%>
			是否要删除该模板?<br/>
			<a href='cjbook.asp?sid=<%=sid%>&amp;Action=del&amp;del=true&amp;id=<%=id%>&amp;saytk=<%=saytk%>'>[确定删除]</a><br/><anchor>返回上页<prev/></anchor><br/>
<a href="cjbook.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[模板管理]</a><br/>
<%end if
end if
end Function
Function save
	name=Trim(Request("name"))
	addurl=Trim(Request("addurl"))
	starwml=Trim(Request("starwml"))
	overwml=Trim(Request("overwml"))
	ubm=Trim(Request("ubm"))
	id=TRim(Request("id"))
	if not isnumeric(id) then id=""
		if name=""  then errmsg=errmsg&"模板标题不能为空<br/>":flag=0
		if starwml=""  then errmsg=errmsg&"开始位置不能为空<br/>":flag=0
		if overwml=""  then errmsg=errmsg&"结束位置不能为空<br/>":flag=0
		if ubm=""  then errmsg=errmsg&"网页编码不能为空<br/>":flag=0
		if Request("edit")="edit" then
		if id=""  then errmsg=errmsg&"ID无效<br/>":flag=0
		if flag<>"0" then
				set rs=server.CreateObject("adodb.recordset")
				sql="select * from cjbook where id="&id
				rs.open sql,conn,1,3
				rs("name")=name
				rs("addurl")=addurl
				rs("starwml")=starwml
				rs("overwml")=overwml
				rs("ubm")=ubm
				rs.update()
				Rs.close
				set rs=Nothing
Call cardz("修改模板","cjbook.asp?sid="&sid&"&amp;saytk="&saytk&"")
%>
修改模板成功<br/><br/>
<a href="cjbook.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[模板管理]</a><br/>
<%else
call saycardd("添加模板出错")
Response.Write(""&errmsg&"<br/><anchor>[返回修改]<prev/></anchor><br/>") 		
		end if
		else
			if flag<>"0" then
				set rs=server.CreateObject("adodb.recordset")
				sql="select * from cjbook"
				rs.open sql,conn,1,3
				rs.addnew()
				rs("name")=name
				if addurl<>"" then rs("addurl")=addurl
				rs("starwml")=starwml
				rs("overwml")=overwml
				rs("ubm")=ubm
				rs.update()
				Rs.close
				set rs=Nothing
Call cardz("修改模板","cjbook.asp?sid="&sid&"&amp;saytk="&saytk&"")
%>
添加模板成功<br/><br/>
<a href="cjbook.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[模板管理]</a><br/>
<%Else
Call saycardd("添加模板出错")


Response.Write(""&errmsg&"<br/><anchor>[返回修改]<prev/></anchor><br/>") 	
		end if
		END IF
end Function%>
<a href="index.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[图片管理]</a><br/>
<a href="../index.asp?sid=<%=sid%>&amp;saytk=<%=saytk%>">[后台管理]</a><br/>

报时: <%=String(2-Len(hour(now)),"0") & hour(now) %>:<%=String(2-len(minute(now)),"0") & minute(now) %>
<%call head3()%>