<!--#include file="connart.asp" -->
<%
dim action : action = be("get","action")
dim p_id,p_script,p_name,p_coding,p_pagetype,p_url,p_pagebatchurl,p_manualurl,p_pagebatchid1,p_pagebatchid2,p_authortype,p_authorstart,p_authorend,p_titletype,p_titlestart,p_titleend,p_collecorder,p_savefiles,p_intolib,p_ontime,p_listcodestart,p_listcodeend,p_listlinkstart,p_listlinkend,p_collect_type,p_time,p_timestart,p_timeend,P_AreaStart,P_AreaEnd,p_classtype,p_typestart,p_typeend,p_contentstart,p_contentend,p_hitsstart,p_hitsend,p_showtype,p_cpagecodestart,p_cpagecodeend,p_cpagetype,p_cpagestart,p_cpageend


Select case action
	case "add","edit" : headAdminCollect "文章自定义采集项目编辑" :edit
	case "save","savecs" : save
	case "saveok" : saveok
	case "del" : del
	case "copy" : copynew
	case "delall" : delall
	case "export" : export
	case "upexpsave" : upexpsave
	case "getcode" : getcode
	case "breakpoint" : breakpoint
	case else : clearSessionart : headAdminCollect "文章自定义采集项目管理" :main
End Select

sub export
	dim rs,result,filedName,Filed,fileName,filePath
	set rs = cjdb.db("Select * from tbl_art_project where p_id="&Request.QueryString("p_id"),"rs1")
	if not rs.eof then
		fileName = rs(1)
		For Each Filed In rs.Fields
			filedName=LCase(Filed.name)
			result=result&"<"&filedName&">"&rs(filedName)&"</"&filedName&">"&vbcrlf
	 	Next
	end if
	cjdb.C(rs)
	filePath = "../../upload/export/"&fileName&".txt"
	objFile.createFile filePath,result
	redirect "collect_down.asp?file="&fileName
end sub

sub upexpsave
	dim rs,fileName,stream,str,strsize,Match,matches
	strsize = Request.TotalBytes
	stream = Request.BinaryRead(strsize) 
	str = bytesToBstr(stream,"UTF-8")
	str = getBody(str,"Content-Type: text/plain","-----------------------------")
	set rs = cjdb.db("select * from tbl_art_project","rs3")
	rs.AddNew
	Set Matches= regCollect(str,"<(p_[\s\S]*?)>([\s\S]*?)</\1>")
	For Each Match In Matches
		if Match.SubMatches(0) <> "p_id" Then
			if Match.SubMatches(0)="p_time" Then
				rs("p_time") = Now()
			else
				rs(""&Match.SubMatches(0)&"")=Match.SubMatches(1)
			end if
		end if
	Next
	rs.UpDate
	cjdb.C(rs)
	set Match=nothing
	set Matches=nothing
	showmsg "导入采集规则成功","collect_art_manage.asp"
end sub

sub breakpoint
	writee gBreakpoint("../../upload/artbreakpoint") & "正在载入断点续传数据，请稍后......"
end sub

sub saveok
	showmsg "采集栏目添加成功","collect_art_manage.asp"
end sub

sub copynew
	dim rsCopy,rs,Filed
	Set rsCopy = cjdb.db ("Select * from tbl_art_project where p_id="&Request.QueryString("p_id"),"rs1")
	if not rsCopy.eof then
	set rs = cjdb.db("Select * from tbl_art_project","rs3")
	rs.AddNew
	For Each Filed In rs.Fields
		if LCase(Filed.name) <> "p_id" then
			if LCase(Filed.name) = "p_name" then
				rs(Filed.name) = rsCopy(Filed.name)&"-[复制]"
			else
				rs(Filed.name) = rsCopy(Filed.name)
			end if
		end if
 	Next
	rs.Update
	rs.MoveNext
	cjdb.c(rs)
 end if
 cjdb.c(rsCopy)
 showmsg "复制采集栏目成功！","collect_art_manage.asp"
end sub

sub del()
 cjdb.db "delete from tbl_art_project WHERE p_id="&Request.QueryString("p_id"),"exe"
 showmsg "采集项目删除成功！","collect_art_manage.asp"
end sub

sub delall()
	dim ids:ids=replace(request.Form("p_id")," ","")
	if not isN(ids) then
		cjdb.db "delete from tbl_art_project WHERE p_id in ("&ids&")","exe"
		showmsg "采集项目删除成功！","collect_art_manage.asp"
	else
		showmsg "请选择相应项目！","collect_art_manage.asp"
	end if
end sub

sub getcode
	dim charset,url,html
	charset = be("get","charset")
	url = be("get","url")
	html = getPage(url,charset)
	writeA html
end sub

sub edit
	dim rs,sql
	
	p_id = be("all","p_id")
 	p_pagebatchid1=1
 	p_pagebatchid2=1
 	p_hitsstart=0
 	p_hitsend=0
 	if not isN(p_id) then
 		sql = "select * from tbl_art_project where p_id="&p_id
		set rs = cjdb.db(sql,"rs1")
 		p_id = rs("p_id")
		p_name = rs("p_name") : p_coding = rs("p_coding") : p_coding = lcase(p_coding) : p_pagetype = rs("p_pagetype") : p_url = rs("p_url")
		p_pagebatchurl = rs("p_pagebatchurl") : p_manualurl = rs("p_manualurl") : p_pagebatchid1 = rs("p_pagebatchid1")
		p_pagebatchid2 = rs("p_pagebatchid2") : p_script = rs("p_script") : p_collecorder = rs("p_collecorder")
		p_savefiles = rs("p_savefiles") : p_intolib = rs("p_intolib") : p_ontime = rs("p_ontime")
		p_listcodestart = rs("p_listcodestart") : p_listcodeend =rs("p_listcodeend") : p_classtype = rs("p_classtype")
		p_collect_type = rs("p_collect_type") : p_time = rs("p_time") : p_listlinkstart = rs("p_listlinkstart")
		p_listlinkend = rs("p_listlinkend") : p_authortype = rs("p_authortype") : p_authorstart = rs("p_authorstart")
		p_authorend = rs("p_authorend") : p_titletype = rs("p_titletype") : p_titlestart = rs("p_titlestart")
		p_titleend = rs("p_titleend") : p_timestart = rs("p_timestart") : p_timeend = rs("p_timeend")
		p_typestart = rs("p_typestart") : p_typeend = rs("p_typeend") : p_contentstart = rs("p_contentstart")
		p_contentend = rs("p_contentend") : p_hitsstart = rs("p_hitsstart") : p_hitsend = rs("p_hitsend")
		p_showtype = rs("p_showtype") : p_cpagecodestart = rs("p_cpagecodestart") : p_cpagecodeend = rs("p_cpagecodeend")
		p_cpagetype = rs("p_cpagetype") : p_cpagestart = rs("p_cpagestart") : p_cpageend = rs("p_cpageend")
		cjdb.c(rs)
 	end if
%>
<script>
$(document).ready(function(){
	$("#loading",window.parent.document).ajaxStart(function(){
		$(this).show();
	});
	$("#loading",window.parent.document).ajaxStop(function(){
    	$(this).hide();
 	});
});

function $$(id){return document.getElementById(id);}
function trim(s){ return (""+s).replace(/(^\s*)|(\s*$)/g,"");}
function isNum(s){
	var r,re;
	if(s==""){ return false; }
	re = /\d*/i;
	r = s.match(re);
	return (r==s);
}
function getBody(str,s1,s2){
	if(s2=='') return false;
	var tstr=str.toLowerCase(),ind=tstr.indexOf(s1.toLowerCase()),sLen=s1.length;
	if(ind==-1) return false;
	ind=sLen>0 ? ind+sLen : 0;
	s1 = s1.replace(/\\t/g,'\u0009').replace(/\\n/g,'\u000a').replace(/\\r/g,'\u000d');
	s2 = s2.replace(/\\t/g,'\u0009').replace(/\\n/g,'\u000a').replace(/\\r/g,'\u000d');
	return str.substr(ind,tstr.slice(ind).indexOf(s2.toLowerCase()));
}

function definiteUrl(ls,curl){
	var b,t,H,i,j,k,siteUrl,rg=/^\s*[\/\\]/i,ab=/^http:\/\//i,qt=/\\([\\\/])/ig;
	curl=trim(curl).replace(qt,"/");
	siteUrl=curl.replace(/(https?\:\/\/)((\w+)(\.\w+)*(:\d+)?)\/.*/i,"$1$2");
	curl=curl.replace(siteUrl,"");
	for(var i=0;i<ls.length;i++){
		H=""+ls[i];
		if(ab.test(H)){
		}else if(rg.test(H)){
			ls[i]=siteUrl+H
		}else{
			j=H.split("../").length,t=curl.split("/"),k=t.length
			t.length=j<k ? k-j : 0
			ls[i]=siteUrl+t.join("/")+"/"+H.replace(/([\.]{2}\/)/g,"")
		}
	}
	return ls;
}

var stepnum=1;
var listurl="",listcode="",listcutcode="",contenturl="",contentcode="";
function prestep(){
	if (stepnum>1){
		if (stepnum==2 ){
			$("#msgurl").html("");
			$("#htmlcode").val("");
			$("#htmltable").hide();
		}
		if ($("input[name='p_pagetype']:checked").val()=="3" && stepnum==3 ){
			stepnum--;
		}
		stepnum--;
		stepshow();
	}
	else{
		if(confirm("确实要离开该页面吗？\n\n这将会导致规则页面上未保存的数据丢失，确定？\n\n按“确定”继续，或按“取消”留在当前页面。")){
			history.go(-1);
		}
	}
}
function nextstep(){
	var rc = true;
	
	if(stepnum==1){
		if($("#p_name").val().trim()==""){
			alert("项目名称不能为空");
			$("#p_name").focus();
			return;
		}
		switch( $("input[name='p_pagetype']:checked").val() )
		{
			case "0":
				listurl = $("#p_url").val().trim();
				if( $("#p_url").val().trim()=="" ){
					rc=false;
					alert("采集地址不能为空");
					$("#p_url").focus();
				}
				break;
			case "1":
			case "3":
				listurl = $("#p_pagebatchurl").val().trim().replace("{ID}",$("#p_pagebatchid1").val());
				if( $("#p_pagebatchurl").val().trim()=="" ){
					rc=false;
					alert("采集地址不能为空");
					$("#p_pagebatchurl").focus();
				}
				if (rc && !isNum($("#p_pagebatchid1").val()) ){
					rc=false;
					alert("请输入数字");
					$("#p_pagebatchid1").focus();
				}
				if (rc && !isNum($("#p_pagebatchid2").val()) ){
					rc=false;
					alert("请输入数字");
					$("#p_pagebatchid2").focus();
				}
				break;
			case "2":
				listurl = $("#p_manualurl").val().trim().split("\r\n")[0];
				if( $("#p_manualurl").val().trim()=="" ){
					rc=false;
					alert("采集地址不能为空");
					$("#p_manualurl").focus();
				}
				break;
		}
		if( rc && !isNum($("#p_hitsstart").val()) ){
			rc=false;
			alert("随机人气必须是数字哦");
			$("#p_hitsstart").focus();
		}
		if( rc && !isNum($("#p_hitsend").val()) ){
			rc=false;
			alert("随机人气必须是数字哦");
			$("#p_hitsend").focus();
		}
		if(!rc){
			return;
		}
		else{
			if ($("input[name='p_pagetype']:checked").val()=="3"){
				stepnum++;
			}
			$("#listurl").val(listurl);
			showurl(listurl);
			$.ajax({ cache: false, dataType: 'html', type: 'GET', url: 'collect_art_manage.asp?action=getcode&charset=' + $("#p_coding").val() + '&url=' + encodeURI(listurl),
				success: function(r){
					if(r!="false"){
						listcode = r;
						if($("#showcode").attr("checked")){
							$("#htmlcode").val(r);
							$("#htmltable").show();
						}
					}
					else{
						alert("获取列表代码出错，请重试");
						return;
					}
				},
				error:function(r){
					alert("err");
				}
			});
		}
	}
	else if(stepnum==2){
		if($("#p_listcodestart").val().trim()==""){
			rc=false;
			alert("列表开始代码不能为空");
			$("#p_listcodestart").focus();
		}
		if(rc && $("#p_listcodeend").val().trim()==""){
			rc=false;
			alert("列表结束代码不能为空");
			$("#p_listcodeend").focus();
		}
		if(rc && $("#p_listlinkstart").val().trim()==""){
			rc=false;
			alert("链接开始代码不能为空");
			$("#p_listlinkstart").focus();
		}
		if(rc && $("#p_listlinkend").val().trim()==""){
			rc=false;
			alert("链接结束代码不能为空");
			$("#p_listlinkend").focus();
		}
		
		if(rc && $("input[name='p_titletype']:checked").val() == "1"){
			if(rc && $("#p_listtitlestart").val().trim()==""){
				rc=false;
				alert("名称开始代码不能为空");
				$("#p_listtitlestart").focus();
			}
			if(rc && $("#p_listtitleend").val().trim()==""){
				rc=false;
				alert("名称结束代码不能为空");
				$("#p_listtitleend").focus();
			}
		}
		if(rc && $("input[name='p_authortype']:checked").val() == "1"){
			if(rc && $("#p_listauthorstart").val().trim()==""){
				rc=false;
				alert("作者开始代码不能为空");
				$("#p_listauthorstart").focus();
			}
			if(rc && $("#p_listauthorend").val().trim()==""){
				rc=false;
				alert("作者结束代码不能为空");
				$("#p_listauthorend").focus();
			}
		}
		if(!rc){
			return;
		}
		else{
			listcutcode=getBody(listcode, $("#p_listcodestart").val(), $("#p_listcodeend").val());
			if(listcutcode==false){if(!confirm("截取 列表开始~列表结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){return;}}
			var mlink=getBody(listcutcode,$("#p_listlinkstart").val(),$("#p_listlinkend").val());
			if(mlink==false){if(!confirm("截取 链接开始~链接结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){return;}}
			if($("input[name='p_titletype']:checked").val()=="1"){
				var title = getBody(listcutcode, $("#p_listtitlestart").val() , $("#p_listtitleend").val());
				if(title==false){if(!confirm("截取 标题开始~标题结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){return;}}
			}
			if($("input[name='p_authortype']:checked").val()=="1"){
				var starring = getBody(listcutcode, $("#p_listauthorstart").val() , $("#p_listauthorend").val());
				if(starring==false){if(!confirm("截取 主演开始~主演结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改")){return;}}
			}
			contenturl = definiteUrl([mlink],listurl);
			
			showurl(contenturl);
			$.ajax({ cache: false, dataType: 'html', type: 'GET', url: 'collect_art_manage.asp?action=getcode&charset=' + $("#p_coding").val() + '&url=' + encodeURI(contenturl),
				success: function(r){
					if(r!="false"){
						contentcode = r;
						if($("#showcode").attr("checked")){
							$("#htmlcode").val(r);
							$("#htmltable").show();
						}
					}
					else{
						alert("获取内容页代码出错，请重试");
						return;
					}
				},
				error:function(r){
					alert("err");
				}
			});
		}
	}
	else if(stepnum==3){
		
		if( $("input[name='p_titletype']:checked").val()=="0" ){
			if( $("#p_titlestart").val()=="" || $("#p_titleend").val()==""){
				alert("截取 名称开始~名称结束 失败\n\n点[确定]忽略这错误提示，[取消]返回修改");
				return;	
			}
		}
		$("#form1").attr("action","?action=savecs")
		$("#form1").submit();
		
	}
	else if(stepnum==4){
		$("#form1").submit();
	}
	stepnum++;
	stepshow();
}
function stepshow()
{
	for(i=1;i<=4;i++){
		if(i==stepnum){
			$("#step"+i).show();
			$("#tabs"+i).attr("class","hover");
		}
		else{
			$("#step"+i).hide();
			$("#tabs"+i).removeClass("hover");
		}
	}
}
function showurl(s){
	$('#msgurl').html("&nbsp;&nbsp;当前采集地址：<font color=red>"+s+"</font>");
}
</script>
<div>
	<ul id="htmltabs" style="padding:0">
		<li id="tabs1" class="hover" style="cursor:pointer">1，采集基本信息</li>
		<li id="tabs2" style="cursor:pointer">2，采集列表信息</li>
		<li id="tabs3" style="cursor:pointer">3，采集内容信息</li>
		<li id="tabs4" style="cursor:pointer">4，采集测试结果</li>
	</ul>
</div>
<table class="tb2">
<tr>
<td>
	<span id="msgurl"></span>
</td>
</tr>
<tr id="htmltable" style="display:none">
	<th colspan="2"><textarea id="htmlcode" style="width:99%;height:200px;font-family:Fixedsys" wrap="off" readonly></textarea></th>
</tr>
</table>

<form action="?action=save" method="post" id="form1" name="form1">
<table class="tb" id="step1">
	<INPUT id="p_id" name="p_id" type="hidden" value="<%=p_id%>" >
	<INPUT id="listurl" name="listurl" type="hidden" value="" >
	<tbody>
	<tr>
	<td width="15%">项目名称：</td>
	<td>
	<input id="p_name" name="p_name" size="50" value="<%=p_name%>" >
	</td>
	</tr>
	<tr>
	<td>采集过程方式：</td>
	<td>
	<input name="p_showtype" type="radio" value="0" <%If p_showtype=0 Then writeA "checked"%>>显示采集一个列表 &nbsp;&nbsp;
	<input name="p_showtype" type="radio" value="1" <%If p_showtype=1 Then writeA "checked"%>>显示采集一条数据 &nbsp;&nbsp;
	</td>
	</tr>
	<tr>
	<td>采集参数：</td>
	<td>
	<input id="p_collecorder" name="p_collecorder" type="checkbox" value="1" <%If p_collecorder=1 Then writeA "checked"%>>倒序采集 &nbsp;&nbsp; 
	</td>
	</tr>
	<tr>
	<td>目标网页编码：</td>
	<td>
	<select id="p_coding" name="p_coding">
	<option value="gb2312" <%if p_coding="gb2312" then writeA"selected"%>>gb2312</option>
	<option value="gbk" <%if p_coding="gbk" then writeA"selected"%>>gbk</option>
	<option value="utf-8" <%if p_coding="utf-8" then writeA"selected"%>>utf-8</option>
	<option value="big5" <%if p_coding="big5" then writeA"selected"%>>big5</option>
	</select>
	</td>
	</tr>
	<tr>
	<td>分页设置：</td>
	<td>
	<input type="radio" value="0" name="p_pagetype" checked="checked" onClick="showpageshow('0');" <% if p_pagetype=0 then writeA "checked" %>>
不分页&nbsp;&nbsp;
<input type="radio" value="1" name="p_pagetype" onClick="showpageshow('1');" <% if p_pagetype=1 then writeA "checked" %>>
批量分页&nbsp;
<input type="radio" value="2" name="p_pagetype" onClick="showpageshow('2');" <% if p_pagetype=2 then writeA "checked" %>>
手动分页&nbsp;
<input type="radio" value="3" name="p_pagetype" onClick="showpageshow('3');" <% if p_pagetype=3 then writeA "checked" %>> 
按ID直接采集内容
	</td>
	</tr>
	<tr id="IndexCutPage" >
	<td>采集地址：</td>
	<td>
	<input id="p_url" name="p_url" size="50" value="<%=p_url%>">
	</td>
	</tr>
	<tr  id="HandCutPage" style="display:none">
	<td><span id="CutPageName"></span>：</td>
	<td><input id="p_pagebatchurl" name="p_pagebatchurl" type="text" value="<%=p_pagebatchurl%>" size="60">
	分页代码 <font color=red>{ID}</font><br>
	标准格式：Http://www.xxxxx.com/list/list_{ID}.html<br>
	采集范围：
	<input id="p_pagebatchid1" name="p_pagebatchid1" type="text" value="<%=p_pagebatchid1%>" size="4">
	To 
	<input id="p_pagebatchid2" name="p_pagebatchid2" type="text" value="<%=p_pagebatchid2%>" size="4">
	例如：1 - 9</td>
	</tr>
	<tr  id="ListContent" style="display:none">
	<td>手动分页：</td>
	<td><textarea id="p_manualurl" name="p_manualurl" cols="60" rows="3"><%=p_manualurl%></textarea></td>
	</tr>
	
	<tr>
	<td>随机人气：</td>
	<td>
	从&nbsp;<input id="p_hitsstart" name="p_hitsstart" type="text" size="4" value="<%=p_hitsstart%>"> 
	到 &nbsp; <input id="p_hitsend" name="p_hitsend" type="text" size="4" value="<%=p_hitsend%>"> 
	之间 (前小后大)
	</td>
	</tr>
	<tr>
	<td>过滤选项：</td>
	<td height=16 >
	<input name="p_script" type="checkbox" value="1" <%If (p_script and 1)>0 Then writeA "checked"%>>
	Iframe
	<input name="p_script" type="checkbox" value="2" <%If (p_script and 2)>0 Then writeA "checked"%>>
	Object
	<input name="p_script" type="checkbox" value="4" <%If (p_script and 4)>0 Then writeA "checked"%>>
	Script
	<input name="p_script" type="checkbox" value="8" <%If (p_script and 8)>0 Then writeA "checked"%>>
	Div
	<input name="p_script" type="checkbox" value="16" <%If (p_script and 16)>0 Then writeA "checked"%>>
	Class
	<input name="p_script" type="checkbox" value="32" <%If (p_script and 32)>0 Then writeA "checked"%>>
	Table
	<br><br>
	<input name="p_script" type="checkbox" value="64" <%If (p_script and 64)>0 Then writeA "checked"%>>
	Span
	<input name="p_script" type="checkbox" value="128" <%If (p_script and 128)>0 Then writeA "checked"%>>
	Img
	<input name="p_script" type="checkbox" value="256" <%If (p_script and 256)>0 Then writeA "checked"%>>
	Font
	<input name="p_script" type="checkbox" value="512" <%If (p_script and 512)>0 Then writeA "checked"%>>
	A
	<input name="p_script" type="checkbox" value="1024" <%If (p_script and 1024)> 0 Then writeA "checked"%>>
	Tr
	<input name="p_script" type="checkbox" value="2048" <%If (p_script and 2048)> 0 Then writeA "checked"%>>
	Td
	<input name="p_script" type="checkbox" value="4096" <%If (p_script and 4096)>0 Then writeA "checked"%>>
	Html
	</td>
	</tr>
</table>


<table class="tb" id="step2" style="display:none">
	<tbody>
	<tr>
	<td width="15%">列表开始代码：</td>
	<td>
	<span onClick="if($$('p_listcodestart').rows>2)$$('p_listcodestart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_listcodestart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea id="p_listcodestart" name="p_listcodestart" cols="70" rows="3"><%=p_listcodestart%></textarea>
	</td>
	</tr>
	<tr>
	<td>列表结束代码：</td>
	<td>
	<span onClick="if($$('p_listcodeend').rows>2)$$('p_listcodeend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_listcodeend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea id="p_listcodeend" name="p_listcodeend" cols="70" rows="3"><%=p_listcodeend%></textarea>
	</td>
    </tr>
    <tr>
	<td>链接开始代码：</td>
	<td>
	<span onClick="if($$('p_listlinkstart').rows>2)$$('p_listlinkstart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_listlinkstart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea id="p_listlinkstart" name="p_listlinkstart" cols="70" rows="3"><%=p_listlinkstart%></textarea>
	</td>
	</tr>
    <tr>
	<td>链接结束代码：</td>
	<td>
	<span onClick="if($$('p_listlinkend').rows>2)$$('p_listlinkend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_listlinkend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea id="p_listlinkend" name="p_listlinkend" cols="70" rows="3"><%=p_listlinkend%></textarea>
	</td>
	</tr>
	<tr>
	<td>列表采集名称：</td>
	<td>
	<input type="radio" value="0" id="p_titletype" name="p_titletype" checked="checked" <%if p_titletype=0 then%>checked="checked"<%end if%> onClick="ChangeCutPara('0','trp_listtitlestart','trp_listtitleend');ChangeCutPara('1','trp_titlestart','trp_titleend');">
否&nbsp;&nbsp;
	<input type="radio" value="1" id="p_titletype" name="p_titletype" <%if p_titletype=1 then%>checked="checked"<%end if%> onClick="ChangeCutPara('1','trp_listtitlestart','trp_listtitleend');ChangeCutPara('0','trp_titlestart','trp_titleend');">
是&nbsp;
	</td>
	</tr>
	<tr id="trp_listtitlestart" <%if p_titletype=0 then%>style="display:none"<%end if%> >
	<td>名称开始代码：</td>
	<td>
	<span onClick="if($$('p_titlestart').rows>2)$$('p_titlestart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_titlestart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea id="p_listtitlestart" name="p_listtitlestart" cols="70" rows="3"><%=p_titlestart%></textarea>
	</td>
	</tr>
	<tr id="trp_listtitleend" <%if p_titletype=0 then%>style="display:none"<%end if%>>
	<td>名称结束代码：</td>
	<td>
	<span onClick="if($$('p_titleend').rows>2)$$('p_titleend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_titleend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea id="p_listtitleend" name="p_listtitleend" cols="70" rows="3"><%=p_titleend%></textarea>
	</td>
	</tr>
	<tr>
	<td>列表采集作者：</td>
	<td>
	<input type="radio" value="0" id="p_authortype" name="p_authortype" checked="checked" <%if p_authortype=0 then%>checked="checked"<%end if%> onClick="ChangeCutPara('0','trp_listauthorstart','trp_listauthorend');ChangeCutPara('1','trp_authorstart','trp_authorend');">
否&nbsp;&nbsp;
<input type="radio" value="1" id="p_authortype" name="p_authortype" <%if p_authortype=1 then%>checked="checked"<%end if%>  onClick="ChangeCutPara('1','trp_listauthorstart','trp_listauthorend');ChangeCutPara('0','trp_authorstart','trp_authorend');">
是&nbsp;
	</td>
	</tr>
	<tr id="trp_listauthorstart" <%if p_authortype=0 then%>style="display:none"<%end if%>>
	<td>作者开始代码：</td>
	<td>
	<span onClick="if($$('p_listauthorstart').rows>2)$$('p_listauthorstart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_listauthorstart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
 <textarea id="p_listauthorstart" name="p_listauthorstart" cols="70" rows="3"><%=p_authorstart%></textarea>
	</td>
	</tr>
	<tr id="trp_listauthorend" <%if p_authortype=0 then%>style="display:none"<%end if%>>
	<td>作者结束代码：</td>
	<td>
<span onClick="if($$('p_listauthorend').rows>2)$$('p_listauthorend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_listauthorend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea id="p_listauthorend" name="p_listauthorend" cols="70" rows="3"><%=p_authorend%></textarea>
	</td>
	</tr>
	</tbody>
</table>

<table class="tb" id="step3" style="display:none">
	<tbody>
	<%if p_titletype = 0 then%>
	<tr id="trp_titlestart">
	<td width="15%">标题开始代码：</td>
	<td>
	<span onClick="if($$('p_titlestart').rows>2)$$('p_titlestart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_titlestart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_titlestart" cols="70" rows="3"><%=p_titlestart%></textarea>
	</td>
	</tr>
	<tr id="trp_titleend">
	<td>标题结束代码：</td>
	<td>
	<span onClick="if($$('p_titleend').rows>2)$$('p_titleend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_titleend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_titleend" cols="70" rows="3"><%=p_titleend%></textarea>
	</td>
	</tr>
    <%end if%>
    <%if p_authortype = 0 then%>
    <tr id="trp_authorstart">
	<td>作者开始代码：</td>
	<td>
	<span onClick="if($$('p_authorstart').rows>2)$$('p_authorstart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_authorstart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_authorstart" cols="70" rows="3"><%=p_authorstart%></textarea>
	</td>
	</tr>
    <tr id="trp_authorend">
	<td>作者结束代码：</td>
	<td>
	<span onClick="if($$('p_authorend').rows>2)$$('p_authorend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_authorend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_authorend" cols="70" rows="3"><%=p_authorend%></textarea>
	</td>
	</tr>
	<%end if%>
	<tr>
	<td><font color="#FF0000">栏目设置：</font></td>
	<td>
	<input type="radio" value="0" name="p_classtype" onClick="$('#trp_typestart').css('display','none');$('#trp_typeend').css('display','none');$('#trp_classtype').css('display','');$('#p_collect_type').css('display','');" <% if p_classtype=0 then writeA "checked" %>>
	固定栏目&nbsp;&nbsp; 
	<input type="radio" value="1" name="p_classtype" onClick="$('#trp_classtype').css('display','none');$('#p_collect_type').css('display','none');$('#trp_typestart').css('display','');$('#trp_typeend').css('display','');" <% if p_classtype=1 then writeA "checked" %>>
按对应栏目自动转换
	</td>
	</tr>
	<tr id="trp_classtype" <% if p_classtype=1 then writeA "style=""display:none""" %>>
	<td><font color="#FF0000">选择入库栏目：</font></td>
	<td id="CollectClassN2" >
	<select name="p_collect_type" id="CollectClass" size="1">
	<option value="0">请选择入库分类</option>
	<%=makeSelectAll("{pre}art_type","t_id","t_name","t_pid","t_sort",0,"","&nbsp;|&nbsp;&nbsp;",p_collect_type)%>
	</select></td>
	</tr>
	<tr  id="trp_typestart" <% if p_classtype <>1 then writeA "style=""display:none""" %>>
	<td><font color="#FF0000">栏目开始代码：</font></td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_typestart').rows>2)$$('p_typestart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_typestart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_typestart" cols="70" rows="3" id="p_typestart"><%=p_typestart%></textarea></td>
	</tr>
	<tr  id="trp_typeend" <% if p_classtype <>1 then writeA "style=""display:none""" %>>
	<td><font color="#FF0000">栏目结束代码：</font></td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_typeend').rows>2)$$('p_typeend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_typeend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_typeend" cols="70" rows="3" id="p_typeend"><%=p_typeend%></textarea></td>
	</tr>
	<tr>
	<td>发布日期开始代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_timestart').rows>2)$$('p_timestart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_timestart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_timestart" cols="70" rows="3" id="p_timestart"><%=p_timestart%></textarea></td>
	</tr>
	<tr>
	<td>发布日期结束代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_timeend').rows>2)$$('p_timeend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_timeend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_timeend" cols="70" rows="3" id="p_timeend"><%=p_timeend%></textarea></td>
	</tr>
	<tr>
	<td>文章内容开始代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_contentstart').rows>2)$$('p_contentstart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_contentstart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_contentstart" cols="70" rows="3" id="p_contentstart"><%=p_contentstart%></textarea></td>
	</tr>
	<tr>
	<td>文章内容结束代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_contentend').rows>2)$$('p_contentend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_contentend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_contentend" cols="70" rows="3" id="p_contentend"><%=p_contentend%></textarea></td>
	</tr>
	<tr>
	<td><font color="#FF0000">文章分页设置：</font></td>
	<td>
	<input type="radio" value="0" name="p_cpagetype" <%if p_cpagetype=0 then writeA "checked" %> onClick="$$('trp_cpagecodestart').style.display='none';$$('trp_cpagecodeend').style.display='none';$$('trp_cpagestart').style.display='none';$$('trp_cpageend').style.display='none'">
	不采分页&nbsp;&nbsp; 
	<input type="radio" value="1" name="p_cpagetype" <%if p_cpagetype=1 then writeA "checked" %> onClick="$$('trp_cpagecodestart').style.display='block';$$('trp_cpagecodeend').style.display='block';$$('trp_cpagestart').style.display='block';$$('trp_cpageend').style.display='block'">
	采集分页
	</td>
	</tr>
	<tr  id="trp_cpagecodestart" <% if p_cpagetype=0 then%>style="display:none"<%end if%>>
	<td>分页列表开始代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_cpagecodestart').rows>2)$$('p_cpagecodestart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_cpagecodestart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_cpagecodestart" cols="70" rows="3" id="p_cpagecodestart"><%=p_cpagecodestart%></textarea></td>
	</tr>
	<tr  id="trp_cpagecodeend" <% if p_cpagetype=0 then%>style="display:none"<%end if%>>
	<td>分页列表结束代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_cpagecodeend').rows>2)$$('p_cpagecodeend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_cpagecodeend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_cpagecodeend" cols="70" rows="3" id="p_cpagecodeend"><%=p_cpagecodeend%></textarea></td>
	</tr>
	<tr  id="trp_cpagestart" <% if p_cpagetype=0 then%>style="display:none"<%end if%>>
	<td>分页链接开始代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_cpagestart').rows>2)$$('p_cpagestart').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_cpagestart').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_cpagestart" cols="70" rows="3" id="p_cpagestart"><%=p_cpagestart%></textarea></td>
	</tr>
	<tr  id="trp_cpageend" <% if p_cpagetype=0 then%>style="display:none"<%end if%>>
	<td>分页链接结束代码：</td>
	<td>&nbsp;&nbsp;输入区域： <span onClick="if($$('p_cpageend').rows>2)$$('p_cpageend').rows-=1" style='cursor:hand'><b>缩小</b></span> <span onClick="$$('p_cpageend').rows+=1" style='cursor:hand'><b>扩大</b></span><br>
	<textarea name="p_cpageend" cols="70" rows="3" id="p_cpageend"><%=p_cpageend%></textarea></td>
	</tr>
	</tbody>
</table>

<table class="tb" id="step4" style="display:none">
	<tbody>
	<tr>
	<td>
	<strong>正在获取数据请稍后...</strong>
	</td>
	</tr>
</table>

<table class="tb2">
<tr>
<td>
	&nbsp;&nbsp;<input type="button" class="btn" name="back" value="上一步" onclick="prestep()" />&nbsp;&nbsp;<input type="button" class="btn" name="next" value="下一步" onclick="nextstep()" />&nbsp;&nbsp;<input type="checkbox" class="checkbox" name="showcode" id="showcode" value="1"/>下一步显示源码 &nbsp;&nbsp;<input type="submit" class="btn" value="保存规则"/>
</td>
</tr>
</table>
</form>
<script language="JavaScript">
var currObj = "uuuu";
function getActiveText(obj)
{
	obj.focus();
	currObj = obj;
}
function addTag(ibTag)
{
	var isClose = false;
	var obj_ta = currObj;
	if (obj_ta.isTextEdit){
		obj_ta.focus();
		var sel = document.selection;
		var rng = sel.createRange();
		rng.colapse;
		if((sel.type == "Text" || sel.type == "None") && rng != null){
			rng.text = ibTag;
		}
		obj_ta.focus();
		return isClose;
	}
	else return false;
}

function ChangeCutPara(flag,e1,e2)
{
	switch (flag)
	{
		case "0" :
		$("#"+e1).css("display","none");
		$("#"+e2).css("display","none");
		break;
	case "1" :
		$("#"+e1).css("display","");
		$("#"+e2).css("display","");
		break;
	}
}
function showpageshow(flag)
{
	switch (flag)
	{
	case "0" :
	$("#IndexCutPage").css("display","");
	$("#HandCutPage").css("display","none");
	$("#ListContent").css("display","none");
	break;
	case "1" :
	$("#IndexCutPage").css("display","none");
	$("#HandCutPage").css("display","");
	$("#ListContent").css("display","none");
	$("#CutPageName").html("批量分页");
	break;
	case "2" :
	$("#IndexCutPage").css("display","none");
	$("#HandCutPage").css("display","none");
	$("#ListContent").css("display","");
	break;
	case "3" :
	$("#IndexCutPage").css("display","none");
	$("#HandCutPage").css("display","");
	$("#ListContent").css("display","none");
	$("#CutPageName").html("按ID采集内容页");
	break;
	default :
	$("#IndexCutPage").css("display","none");
	$("#HandCutPage").css("display","none");
	$("#ListContent").css("display","none");
	break;
	}
}
showpageshow("<%=p_pagetype%>");
</script>
<%
end sub

sub save
	dim sql,rs,strICListCode,strListUrl,strListCode,p_coding,strListCodeCut,linkarr,titlearr,picarr,linkarrcode,titlearrcode,linkcode,titlecode,piccode,UrlTest,authorcode
	dim isadd,sarr,i
	
	'1
	p_id = Request.Form("p_id")
	p_name = Request.Form("p_name") : p_coding = Request.Form("p_coding") 
	p_pagetype = Request.Form("p_pagetype") : p_url = Request.Form("p_url")
	p_pagebatchurl = Request.Form("p_pagebatchurl") : p_manualurl = Request.Form("p_manualurl")
	p_pagebatchid1 = Request.Form("p_pagebatchid1") : p_pagebatchid2 = Request.Form("p_pagebatchid2")
	p_collecorder = Request.Form("p_collecorder") : p_savefiles = Request.Form("p_savefiles")
	p_intolib = Request.Form("p_intolib") : p_ontime = Request.Form("p_ontime")
	p_hitsstart = request.Form("p_hitsstart") :p_hitsend = request.Form("p_hitsend") 
	p_showtype = request.Form("p_showtype")
	p_script = Request.Form("p_script")
	sarr = split(p_script,",")
	p_script=0
	for i=0 to ubound(sarr)
		if not isN(sarr(i)) then
			p_script = p_script or sarr(i)
		end if
	next
	
	if isN(p_collecorder) then p_collecorder = 0
	if isN(p_savefiles) then p_savefiles = 0
	if isN(p_intolib) then p_intolib = 0
	if isN(p_ontime) then p_ontime = 0
	if isN(p_hitsstart) then p_hitsstart = 0
	if isN(p_hitsend) then p_hitsend = 0
	
	'2
	p_listcodestart = request.Form("p_listcodestart") :	p_listcodeend = request.Form("p_listcodeend")
	p_listlinkstart = request.Form("p_listlinkstart") :	p_listlinkend = request.Form("p_listlinkend")
	p_authortype = request.form("p_authortype")
	p_titletype = request.form("p_titletype")
	if isN(p_authortype) then p_authortype = 0 else p_authortype = clng(p_authortype)
	if isN(p_titletype) then p_titletype = 0 else p_titletype = clng(p_titletype)
	
	'3
	p_timestart=  request.Form("p_timestart") 
	p_timeend = request.Form("p_timeend") : p_classtype=  request.Form("p_classtype") 
	p_collect_type = request.Form("p_collect_type")
	p_typestart=  request.Form("p_typestart")  : p_typeend = request.Form("p_typeend") 
	p_contentstart=  request.Form("p_contentstart")  : p_contentend = request.Form("p_contentend")
	if isN(p_collect_type) then p_collect_type=0
	
	if p_authortype =1 then
		p_authorstart = request.form("p_listauthorstart") : p_authorend = request.form("p_listauthorend")
	else
		p_authorstart = request.form("p_authorstart") : p_authorend = request.form("p_authorend")
	end if
	if p_titletype = 1 then
		p_titlestart = request.Form("p_listtitlestart") : 	p_titleend = request.Form("p_listtitleend")
	else
		p_titlestart = request.Form("p_titlestart") : 	p_titleend = request.Form("p_titleend")
	end if
	
	
	p_listcodestart = request.Form("p_listcodestart") :	p_listcodeend = request.Form("p_listcodeend")
	p_listlinkstart = request.Form("p_listlinkstart") :	p_listlinkend = request.Form("p_listlinkend")
	p_cpagetype = request.form("p_cpagetype")
	p_cpagestart = request.form("p_cpagestart") :	p_cpageend = request.form("p_cpageend")
	p_cpagecodestart = request.form("p_cpagecodestart") :	p_cpagecodeend = request.form("p_cpagecodeend")
	strListUrl = request.Form("listurl")
	if isN(p_cpagetype) then p_cpagetype = 0
	
	
	
	
	if isN(p_id) then p_id=0 : isadd = true else isadd= false
	sql="select * from tbl_art_project "
	if not isadd then sql = sql & " where p_id = " &p_id 
	
	set rs = cjdb.DB (sql,"rs3") 
	if isadd then rs.Addnew
	'step1
	rs("p_name") = p_name
	rs("p_coding") = p_coding
	rs("p_pagetype") = p_pagetype
	rs("p_url") = p_url
	rs("p_pagebatchurl") = p_pagebatchurl
	rs("p_manualurl") = p_manualurl
	rs("p_pagebatchid1") = p_pagebatchid1
	rs("p_pagebatchid2") = p_pagebatchid2
	rs("p_script") = p_script
	rs("p_collecorder") = p_collecorder
	rs("p_savefiles") = p_savefiles
	rs("p_intolib") = p_intolib
	rs("p_ontime") = p_ontime
	rs("p_hitsstart")=p_hitsstart
	rs("p_hitsend")=p_hitsend
	rs("p_showtype")=p_showtype
	
	'step2
	rs("p_listcodestart") = p_listcodestart
	rs("p_listcodeend") = p_listcodeend
	rs("p_listlinkstart") = p_listlinkstart
	rs("p_listlinkend") = p_listlinkend
	rs("p_authortype") = p_authortype
	rs("p_titletype") = p_titletype
	
	'step3
	rs("p_titlestart") = p_titlestart
	rs("p_titleend") = p_titleend
	rs("p_authorstart") = p_authorstart
	rs("p_authorend") = p_authorend
	rs("p_timestart") = p_timestart
	rs("p_timeend") = p_timeend
	rs("p_classtype") = p_classtype
	rs("p_collect_type") = p_collect_type
	rs("p_typestart") = p_typestart
	rs("p_typeend") = p_typeend
	rs("p_contentstart") = p_contentstart
	rs("p_contentend") = p_contentend
	rs("p_cpagetype") = p_cpagetype
	rs("p_cpagestart") = p_cpagestart
	rs("p_cpageend") = p_cpageend
	rs("p_cpagecodestart") = p_cpagecodestart
	rs("p_cpagecodeend") = p_cpagecodeend
 	rs.Update
	cjdb.c(rs)
	
	if action="save" then
 	  	alertUrl "保存成功","collect_art_manage.asp"
 	else
 		headAdminCollect "文章自定义采集项目测试"
		if p_pagetype <> 3 then 
			if isN(session("strListCodeart")) then
				strListCode = getPage(strListUrl,p_coding)
				session("strListCodeart") = strListCode
			else
				strListCode = session("strListCodeart")
			end if
			if isN(session("strListCodeCutart")) then
				strListCodeCut = getBody(strListCode,p_listcodestart,p_listcodeend)
				session("strListCodeCutart") = strListCodeCut
			else
				strListCodeCut = session("strListCodeCutart")
			end if
			if isN(session("linkarrcodeart")) then
				linkarrcode = getArray(strListCodeCut,p_listlinkstart,p_listlinkend)
				session("linkarrcodeart") = linkarrcode
			else
				linkarrcode = session("linkarrcodeart")
			end if
			if p_authortype = 1 then
				authorarr = getArray(strListCodeCut,p_authorstart,p_authorend)
			end if
			if p_titletype = 1 then
				titlearrcode = getArray(strListCodeCut,p_titlestart,p_titleend)
			end if
			
			Select Case linkarrcode
			Case False
				errmsg "采集提示","<li>在获取链接列表时出错。</li>"
			Case Else
				linkarr = Split(linkarrcode,"$Array$")
				UrlTest = linkarr(0)
				UrlTest = DefiniteUrl(UrlTest,strListUrl)
				linkcode = getPage(UrlTest,p_coding)
			End Select
		else
			strListUrl = p_pagebatchurl
			p_pagebatchurl = replace(p_pagebatchurl,"{ID}",p_pagebatchid1)
			linkcode = getPage(p_pagebatchurl,p_coding)
		end if
		
		if linkcode = False then 
			errmsg "采集提示","获取内容页失败!"
		    response.End()
		end if
		
		if p_titletype = 1 then
			Select Case titlearrcode
			Case False
				titlecode = "获取失败"
			Case Else
				titlearr = Split(titlearrcode,"$Array$")
				titlecode = titlearr(0)
			End Select
		else
			titlecode = getBody(linkcode,p_titlestart,p_titleend)
		end if
		
		if p_authortype = 1 then
			Select Case titlearrcode
			Case False
				authorcode = "获取失败"
			Case Else
				authorarr = Split(authorarrcode,"$Array$")
				authorcode = authorarr(0)
			End Select
		else
			authorcode = getBody(linkcode,p_authorstart,p_authorend)
		end if
		
		dim timecode,contentcode,typecode,weburl,cpagecode,cpagelinkarr,cpagelinkarrcode,cpagelink,cpagelinkcode,typearr
		
		contentcode = getBody(linkcode,p_contentstart,p_contentend)
		cpagecode = getBody(linkcode,p_cpagecodestart,p_cpagecodeend)
		contentcode = Replace(contentcode,cpagecode,"")
		
		if p_cpagetype=1 then
			cpagelinkarrcode= getArray(cpagecode,p_cpagestart,p_cpageend)
			cpagelinkarr = Split(cpagelinkarrcode,"$Array$")
			for i=0 to ubound(cpagelinkarr)
				cpagelink = cpagelinkarr(i)
				if cpagelink <> "" and cpagelink<>"#" then
					cpagelink = DefiniteUrl(cpagelink,strListUrl)
					cpagelinkcode =  getPage(cpagelink,p_coding)
					if cpagelinkcode <> False then
						cpagecode = getBody(cpagelinkcode,p_cpagecodestart,p_cpagecodeend)
						cpagelinkcode = getBody(cpagelinkcode,p_contentstart,p_contentend)
						cpagelinkcode = replace(cpagelinkcode,cpagecode,"")
						contentcode = contentcode & cpagelinkcode
					end if
				end if
			next
		end if
		contentcode = replaceFilters(contentcode,p_id,2)
		contentcode = Filterscript(contentcode,p_script)
		
		if p_classtype = 1 then
			typecode = getBody(linkcode,p_typestart,p_typeend)
		else
			typecode = p_collect_type
			typearr = getValueByArray(cachearttype, typecode)
			typecode = typearr(1)
		end if
		typecode = Filterscript(typecode,p_script)
		
		titlecode = replaceStr(titlecode,"False","未知")
		titlecode = replaceFilters(titlecode,p_id,1)
		titlecode =	Filterscript(titlecode,p_script)
		
		authorcode = replaceStr(authorcode,"False","未知")
		authorcode = Filterscript(authorcode,p_script)
		
		timecode = getBody(linkcode,p_timestart,p_timeend)
		timecode = replaceStr(timecode,"False",now)
		timecode = Filterscript(timecode,p_script)
	%>
<table class="tb">
	<tbody>
  	<tr>
	<td colspan="2" align="center">保存规则并采集测试结果</td>
  	</tr>
    <tr>
	<td width="15%" >标题：</td><td> <input type="text" size="50" name="d_title" value="<%=titlecode%>" /> </td>
    </tr>
    <tr>
	<td>作者：</td><td> <input type="text" size="50" name="d_author" value="<%=authorcode%>" /> </td>
    </tr>
    <tr>
	<td>日期：</td><td> <input type="text" size="50" name="d_time" value="<%=timecode%>" /> </td>
    </tr>
    <tr>
	<td>栏目：</td><td> <input type="text" size="50" name="d_typename" value="<%=typecode%>" /> </td>
    </tr>
    <tr>
	<td>内容：</td><td> <div style="height:300px;overflow:hidden;overflow-y:auto;"><%=contentcode%></div> </td>
    </tr>
	<tr>
	<td colspan="2"><input type="button" onClick="window.location.href='javascript:history.go(-1)'" value="返回规则">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" onClick="window.location.href='?action=main'" value="返回列表"></td>
	</tr>
	</tbody>
</table>
<%
	end if
end sub 

sub main
	Dim pagenum : pagenum = be("all","page")
	if isN(pagenum) or not isNum(pagenum) then pagenum = 1
	if pagenum < 1 then pagenum = 1
	pagenum = clng(pagenum)
	dim sql,rs
	Sql="Select * from tbl_art_project Order By p_id Desc"
	set rs=cjdb.db(sql,"rs3")
%>
<table width="96%" border="0" align="center" cellpadding="3" cellspacing="1">
	<tr>
	<td>
		菜单：<a href="collect_art_manage.asp?action=add">添加采集规则</a> | <a href="collect_art_change.asp">分类转换</a> | <a href="collect_art_filters.asp">信息过滤</a> 
	</td>
	</tr>
</table>
<form action="" method="post" name="form1">
<table class=tb >
	<tr>
	<td width="4%">&nbsp;</td>
	<td>项目名称</td>
	<td width="25%">入库分类</td>
	<td width="20%">上次采集</td>
	<td width="25%">操作</td>
	</tr>
	<%
		if rs.eof then
	 %>
    <tr><td align="center" colspan="7" >没有任何记录!</td></tr>
    <%
		else
		Dim i,typearr
		rs.PageSize = app_pagenum
	    rs.AbsolutePage = pagenum
	  	for i = 1 to rs.PageSize
	  	if rs.eof then exit for
	%>
    <tr>
	  <td><input name="p_id" type="checkbox" id="p_id" value="<%=rs("p_id")%>" /></td>
      <td><a href="?action=edit&p_id=<%=rs("p_id")%>"><%=rs("p_name")%></a></td>
	  <td>
	  <%
	  	if rs("p_classtype") = 1 Then
	  		writeF "<font color=red>自定义分类</font>"
	  	else
	  		typearr = getValueByArray(cachearttype, rs("p_collect_type"))
	  		if isarray(typearr) then
				writeA typearr(1)
			else
				writeA "未知"
			end if
	  	end if
	  %>
	  </td>
      <td><%=getColorDay(rs("p_time"))%></td>
 	  <td>
 	  <A href="collect_art_cj.asp?p_id=<%= rs("p_id") %>">采集</A>｜
 	  <A href="?action=edit&p_id=<%=rs("p_id")%>">修改</A>｜
 	  <A href="?action=copy&p_id=<%= rs("p_id") %>">复制</A>｜
 	  <A href="?action=export&p_id=<%= rs("p_id") %>">导出</A>｜
 	  <A href="?action=del&p_id=<%=rs("p_id")%>">删除</A>
 	  </td>
    </tr>
	<%
	rs.MoveNext
	next 
	end if
	%>
	<tr>
	<td  colspan="7">
全选<input name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'p_id');"/>&nbsp;
	<input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){form1.action='?action=delall';}else{return false}"  class="input"/>
	<input type="submit" value="批量采集" onClick="if(confirm('确定要批量采集吗')){form1.action='collect_art_cj.asp?action=pl';}else{return false}"  class="input"/>
	<input type="button" value="导入规则" onClick="$('#win1').window('open');" class="input"/>
	</td></tr>
    <tr align="center">
      <td colspan="7">
      <%=pagelist_manage(rs.PageCount,pagenum,rs.RecordCount,app_pagenum,"collect_art_manage.asp?page={p}")%>
      </td>
    </tr>
</table>
</form>

<div id="win1" class="easyui-window" title="窗口" style="padding:5px;width:400px;" closed="true" closable="true" minimizable="false" maximizable="false">
<form enctype="multipart/form-data" action="?action=upexpsave" method="post">
<table class="tb">
  <tbody>
  	<tr>
  		<td colspan="2" align="center">
  		上传采集规则
         <input type="file" id="file1" name="file1">
		<input type="submit" name="submit" value="开始导入">
		</td>
  	</tr>
</table>
</form>
</div>
<%
cjdb.c(rs)
end sub
%>