<%

Dim RsTemp_v()
Redim RsTemp_v(ubound(RsTemp_name))
id=request.QueryString("id")
call admin_master(0,0)
call admin_cid_sid()
call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='admin_<% response.write index_url%>_module.asp'>模块列表</a></td>
  <td width=10></td>
  <td><a href='admin_<% response.write index_url%>_module.asp?action=add'<%if action="add" then response.write " class=red"%>>添加模块</a></td>
  <td width=10></td>
  <td><a href='admin_<% response.write index_url%>_module.asp?action=mInput'<%if action="mInput" then response.write " class=red"%>>导入模块</a></td>
  <td width=10></td>
  <td><a href='admin_<% response.write index_url%>_module.asp?action=mExport'<%if action="mExport" then response.write " class=red"%>>导出模块</a></td>
  <td width=10></td>
  <td><a href='admin_<% response.write index_url%>_gather.asp'>数据采集</a></td>
  </tr>
  </table>
</td></tr>
</table>
<%
if id<>"" and isnumeric(id) then
  dim startime,FromUrl,ItemName,PicPath,PicValue,FalshPath,FalshValue,MusicPath,MusicValue,OtherPath,OtherValue,Articlelist1,Articlelist2,Addresslist1,Addresslist2,ManyPage,ManyFirst1,ManyFirst2,ManyNext1,ManyNext2,PicType,FalshType,MusicType,OtherType,Manys,Addresslist
  startime=timer()
  dim Pic_count,Pic_Err
  dim Swf_count,Swf_Err
  dim Mp3_count,Mp3_Err
  dim Other_count,Other_err
  dim webstr,web_str
  dim Pages,save_count
  Dim Tempurl,bs_counts
  bs_counts=0
  id=Isform(request.QueryString("id"),"数字","数据传递")

  sql="select * from [DB_Item] where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if rs.eof then
    Response.Write("<script language='JavaScript'>alert('数据传递出错！');history.go(-1);</script>")
    response.End()
  else
    FromUrl=rs("FromUrl")
    ItemName=rs("ItemName")
    CID=rs("C_ID")
    sID=rs("s_ID")
    PicPath=rs("PicPath")
    PicValue=rs("PicValue")
    FalshPath=rs("FalshPath")
    FalshValue=rs("FalshValue")
    MusicPath=rs("MusicPath")
    MusicValue=rs("MusicValue")
    OtherPath=rs("OtherPath")
    OtherValue=rs("OtherValue")
    Articlelist1=rs("Articlelist1")
    Articlelist2=rs("Articlelist2")
    Addresslist1=rs("Addresslist1")
    Addresslist2=rs("Addresslist2")
    ManyPage=rs("ManyPage")
    ManyFirst1=rs("ManyFirst1")
    ManyFirst2=rs("ManyFirst2")
    ManyNext1=rs("ManyNext1")
    ManyNext2=rs("ManyNext2")
    PicType=rs("PicType")
    FalshType=rs("FalshType")
    MusicType=rs("MusicType")
    OtherType=rs("OtherType")
    Manys=rs("Manys")
    Addresslist=rs("Addresslist")
  end if
  rs.close

  if chk() then
    dim Date_Form1,Date_Form2,Count_Form,Page_Form1,Page_Form2,Show_Form,Html_form,div_Form,a_Form,span_Form,font_Form,class_Form,style_Form,img_Form,OBJECT_Form,IFRAME_Form,SCRIPT_Form,IFileName,Match_Form,Pic_Form,Swf_Form,Mp3_Form,Other_Form,FirstRecord_Form,FirstPage_Form

    csid=trim(request.form("c_id"))
    FromUrl=request.Form("FromUrl")
    Date_Form1=request.Form("date1")
    Date_Form2=request.Form("date2")
    Count_Form=request.Form("Count")
    Page_Form1=request.Form("page1")
    Page_Form2=request.Form("page2")
    Show_Form=request.Form("show")
    Html_form=request.Form("Html")
    div_Form=request.Form("c_div")
    a_Form=request.Form("c_a")
    span_Form=request.Form("c_span")
    font_Form=request.Form("c_font")
    class_Form=request.Form("c_class")
    style_Form=request.Form("c_style")
    img_Form=request.Form("c_img")
    OBJECT_Form=request.Form("c_OBJECT")
    IFRAME_Form=request.Form("c_IFRAME")
    SCRIPT_Form=request.Form("c_SCRIPT")
    IFileName=request.Form("FileName")
    Match_Form=request.Form("Match")
    if Match_Form=1 then
      Match_Form=true
    else
      Match_Form=false
    end if
    Pic_Form=request.Form("picsave")
    Swf_Form=request.Form("falshsave")
    Mp3_Form=request.Form("midsave")
    Other_Form=request.Form("othersave")
    FirstRecord_Form=request.Form("FirstRecord")
    FirstPage_Form=request.Form("FirstPage")
    call testdome()
  else
    call savedome()
  end if
else
  call admin_table(1,0)
  call joekoe_chk_main()
end if

sub testdome()
dim webstr,Page_count,Page_Url,RsMarkingA,RsMarkingB,bs_count,WebstrsTemp,DB_Rs
dim web_str,titlemsg
call admin_table(1,0)

titlemsg = "(采集条件："
If IsNumeric(Count_Form) Then
  titlemsg = titlemsg&"&nbsp;&nbsp;限制采集<font color=""0000ff"">" & Count_Form & "</font>条信息"
End If
  If Date_Form1 <> "" And Date_Form2 > "" Then
  titlemsg = titlemsg&"&nbsp;&nbsp;限制采集<font color=""0000ff"">" & FormatDateTime(Date_Form1, 1) & "<font color=""000000"">到</font>" & FormatDateTime(Date_Form2, 1) & "</font>的信息"
ElseIf Date_Form1 <> "" Then
  titlemsg = titlemsg&"&nbsp;&nbsp;限制采集<font color=""0000ff"">" & FormatDateTime(Date_Form1, 1) & "<font color=""000000"">到</font>" & FormatDateTime(Now(), 1) & "</font>的信息"
ElseIf Date_Form2 <> "" Then
  titlemsg = titlemsg&"&nbsp;&nbsp;限制采集到<font color=""0000ff"">" & FormatDateTime(Date_Form2, 1) & "</font>的信息"
End If
call admin_td("开始采集&nbsp;&nbsp;"&titlemsg&")")
Response.Write ("<tr><td><hr>"):Response.Flush
sql="select * from [DB_Dome] where ItemID="&ID&" and Columnid=1"
call joekoe_cms.exec(sql,-1)
rs.open sql,conn,1,2
if rs.eof then
      rs.close
      call admin_error("你还没有定义采集模块！")
      exit sub
else
  RsMarkingA=rs("MarkingA"):RsMarkingB=rs("MarkingB")
end if
rs.close

bs_count=0
Tempurl = FromUrl
webstr=Cls.BytesToBstr(Cls.getHTTPPage(Tempurl),"GB2312")
webstr=Cls.stripHTML(webstr,Articlelist1,Articlelist2)
webstr=Cls.Manhunt(webstr,Addresslist1,Addresslist2,true,true,false,true)
webstr=Split(webstr,"$url$")
WebstrsTemp=webstr

if FirstRecord_Form=1 then
   for DB_i= 0 to ubound(WebstrsTemp)
       webstr(ubound(WebstrsTemp)-DB_i)=WebstrsTemp(DB_i)
   next
end if
	
dim RsTemp,RsMatch
dim TempWeb
Page_count=0
for Page_count=0 to ubound(webstr)
Page_Url=Cls.HttpUrls(Addresslist&webstr(Page_count),FromUrl)
web_str=Cls.BytesToBstr(Cls.getHTTPPage(Page_Url),"GB2312")
DB_Rs=Cls.SeparateHTML(web_str,RsMarkingA,RsMarkingB)
if DB_Rs<>false then
  DB_Rs=left(DB_Rs,40)
  sql="select * from "&data_name&" where "&mm_topic&"='"&replace(DB_Rs,"'","''")&"'"
  Set RsTemp= Server.CreateObject("ADODB.Recordset") 
  RsTemp.open sql,conn,3,2
  if  Match_Form then
    if RsTemp.eof then
      RsMatch=true
    else
      RsMatch=false
    end if
  else
  RsMatch=true
end if

if RsMatch then

  RsTemp.AddNew
    call RsTemp_mm()
    for i=0 to ubound(RsTemp_name)
      RsTemp(""&RsTemp_name(i)&"")=RsTemp_v(i)
    next
  
  dim ColumnCName,ColumnEName,MarkingA,MarkingB,Marking,ArticleText
  dim ColumnV,ColumnD,ColumnID
  bs_counts= bs_counts+1
  sql="select * from [DB_Dome] where ItemID="&ID&" "
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,2
  do while not rs.eof
    ColumnID=rs("ColumnID")
    ColumnCName=rs("ColumnCName")
    ColumnEName=rs("ColumnEName")
    MarkingA=trim(rs("MarkingA")&" ")
    MarkingB=trim(rs("MarkingB")&" ")
    Marking=trim(rs("Marking")&" ")
    ColumnV=rs("ColumnV")
    ColumnD=rs("ColumnD")
    if ColumnID=1 then
      response.Write("<strong><font color=""#FF0000"">No.")
      response.Write(bs_counts)
      response.Write("&nbsp;&nbsp;</strong></font><br>")
    end if
    response.Write("<strong><font color=""#0000FF"">")
    response.Write(ColumnCName&":</strong></font>")
    if Marking<>"" then
      TempWeb=Marking
    else
      if MarkingA<>"" and MarkingB<>"" then
        TempWeb=Cls.SeparateHTML(web_str,MarkingA,MarkingB)
      else
		TempWeb=""
      end if
    end if
    if ColumnV="longtext" then  
      response.Write(Cls.Cen(TempWeb)&"<br>")
    else
      response.Write(TempWeb&"<br>")
    end if
    
    select case ColumnV
    case "int"
      if TempWeb<>"" then
  	    if not isnumeric(TempWeb) then
  		  if ColumnD<>"" and isnumeric(ColumnD) then
  			TempWeb=ColumnD
          else
  			TempWeb="0"
          end if
        end if
      else
  		if ColumnD<>"" and isnumeric(ColumnD) then
  			TempWeb=ColumnD
  		else
  			TempWeb="0"
  	    end if
      end if
      if int(TempWeb)>0 then
      	RsTemp(""&ColumnEName&"")=int(TempWeb)
      else
      	if RsTemp(""&ColumnEName&"")>0 then
      		RsTemp(""&ColumnEName&"")=RsTemp(""&ColumnEName&"")
      	else
      		RsTemp(""&ColumnEName&"")=0
      	end if
      end if
    case "varchar"
      if ColumnD<>"" and isnumeric(ColumnD) then
        if int(ColumnD)>0 then TempWeb=left(TempWeb,int(ColumnD))
      end if
      if TempWeb<>"" and TempWeb<>"False" then
         RsTemp(""&ColumnEName&"")=joekoe_cms.code_form(TempWeb)
       end if
    case "datetime"
      if TempWeb<>"" then
        if not IsDate(TempWeb) then
          if ColumnD<>"" and IsDate(ColumnD) then
  			TempWeb=ColumnD
          else
  			TempWeb=now()
          end if
        end if
      else
  		if ColumnD<>"" and IsDate(ColumnD) then
  			TempWeb=ColumnD
         	RsTemp(""&ColumnEName&"")=cDate(TempWeb)
  		else
  			TempWeb=now()
  	    end if
      end if
      if not IsDate(RsTemp(""&ColumnEName&"")) then
         RsTemp(""&ColumnEName&"")=cDate(TempWeb)
      end if
    case else
    	if TempWeb<>"" and TempWeb<>"False" then
     		 RsTemp(""&ColumnEName&"")=joekoe_cms.code_form(TempWeb)
     	else
     		RsTemp(""&ColumnEName&"")=RsTemp(""&ColumnEName&"")
     	end if
    end select
    rs.movenext
    loop
    rs.close
    RsTemp.update
    RsTemp.close
    response.Write("</td></tr><tr><td>")

    if Pic_Form<>1 then:Pic_count=0:Pic_Err=0:end if
    if Swf_Form<>1 then:Swf_count=0:Swf_Err=0:end if
    if Mp3_Form<>1 then:Mp3_count=0:Mp3_Err=0:end if
    if Other_Form<>1 then:Other_count=0:Other_err=0:end if:response.Write("<br>"):response.Write("<strong><font color=""#0000FF"">"):response.Write("采集地址：</strong></font><a href="&Page_Url&" target=""_blank"">"&Page_Url&"</a>")
    if Pages<>0 then:response.Write("&nbsp;&nbsp;&nbsp;&nbsp;一共&nbsp;<font color=""#FF0000"">"&Pages+1&"</font>&nbsp;页"):end if:response.Write("<br>"):response.Write("<strong><font color=""#FF0000"">"):response.Write("附件采集："):response.Write("</strong></font>"):response.Write("图片：共："&pic_count&"个&nbsp;&nbsp;错误：")
    if pic_err<>0 then:response.Write("<strong><font color=""#FF0000"">"&pic_err&"</strong></font>"):else:response.Write(pic_err):end if:response.Write("个&nbsp;&nbsp;&nbsp;&nbsp;"):response.Write("动画：共："&Swf_count&"个&nbsp;&nbsp;错误：")
    if Swf_err<>0 then:response.Write("<strong><font color=""#FF0000"">"&Swf_err&"</strong></font>"):else:response.Write(Swf_err):end if:response.Write("个&nbsp;&nbsp;&nbsp;&nbsp;"):response.Write("音乐：共："&mp3_count&"个&nbsp;&nbsp;错误：")
    if Mp3_err<>0 then:response.Write("<strong><font color=""#FF0000"">"&Mp3_err&"</strong></font>"):else:response.Write(Mp3_err):end if:response.Write("个&nbsp;&nbsp;&nbsp;&nbsp;"):response.Write("其它：共："&Other_count&"个&nbsp;&nbsp;错误：")
    if Other_err<>0 then:response.Write("<strong><font color=""#FF0000"">"&Other_err&"</strong></font>"):else:response.Write(Other_err):end if:response.Write("个&nbsp;&nbsp;&nbsp;&nbsp;"):response.Write("<hr>"):response.Flush()

  end if

  if IsNumeric(Count_Form) then
    if bs_counts=clng(Count_Form) then
      response.Write("采集完成,一共采集了&nbsp;<font color=""0000ff"">"&bs_counts&"</font>&nbsp;条"&tit_fir&".&nbsp;&nbsp;一共使用了"&FormatNumber((timer()-startime)*1000,3)&"毫秒<br>")
      response.Flush()
      response.End()
    end if
  end if
end if
response.Write("<br>"):response.Flush()
next
response.Write("采集完成,一共采集了&nbsp;<font color=""0000ff"">"&bs_counts&"</font>&nbsp;条"&tit_fir&".&nbsp;&nbsp;一共使用了"&FormatNumber((timer()-startime)*1000,3)&"毫秒<br>")
response.Flush()
response.Write("</td></tr></table>")
end sub

sub savedome()
call admin_table(1,1)
call admin_td("开始采集")
call form_first()
%>
<form name="add_frm" action="?id=<%response.write id%>" method=post>
<input type=hidden name=chk value='yes'>
<TR> 
<TD>基本设置：</td>
<td>
<input name="Match" type="checkbox" id="Match" value="1" onClick="CheckRenew(this);" >
与本地<%response.write tit_fir%>标题重复时不采集
<input name="Renew" type="checkbox" id="Renew" value="1" onClick="CheckTest(this);">
覆盖已存在的新闻
<input name="Choice" type="checkbox" id="Choice" value="0" onClick="showsubmenu(this);CheckTest(this);">
人工选择采集</td></tr>
<tr>
<td>目 标 页： </td>
<td>
<INPUT name="FromUrl" type="text" id="FromUrl" value="<%=FromUrl%>" size="75" > 
</td></tr>
<tr>
<td><font color="#CCCCCC">采集顺序：</font></td>
<td><font color="#CCCCCC">从第一页开始
<input name="FirstPage" type="checkbox" id="FirstPage"  value="1">
从第一条开始 
<input name="FirstRecord" type="checkbox" id="FirstRecord"  value="1"></font></td>
</tr>
<tr>
<td><font color="#CCCCCC">页 码 段： </font></td>
<td><font color="#CCCCCC"><input name="page1" type="text" id="page1" value="" size="10" >到 <input name="page2" type="text" id="page2" value="" size="10" >页 </font></td>
</tr>
<tr>
<td><font color="#CCCCCC">时 间 段：</font></td>
<td><font color="#CCCCCC"><INPUT name="date1" type="text" id="date1"  size="10" readonly>
<img src="timeOcx/cal.gif" width="16" height="16" align='absmiddle' style="cursor:hand" onClick="return showCalendar('date1', 'y/m/d');"> 到 <INPUT name="date2" type="text" id="date2"  size="10" readonly>
<img src="timeOcx/cal.gif" width="16" height="16" align='absmiddle' style="cursor:hand" onClick="return showCalendar('date2', 'y/m/d');"></font></td></tr>
<tr>
<td>采集数量： </td>
<td><input name="Count" type="text" id="Count"  value="5" size="10">
条 <font color="#0000FF">简洁提示</font> <input name="show" type="checkbox" id="show3" value="1"  > 
<font color="#999999">测试采集</font> <font color="#999999"> 
<input name="Preview" type="checkbox" id="Preview"value="1"  >
&nbsp; </font></TD>
</TR>

<TR id='submenu0' style="display:"> 
<TD height=30 colspan="2"><font color="#999999"><%response.write tit_fir%>内容过滤设置</font></TD>
</TR>
<TR id='submenu1' style="display:"> 
<TD colspan="2">过滤标签：
<input name="Html" type="checkbox" id="Html2" value="1">去除所有HTML标记 
<input type=checkbox  value=1 name=c_span >SPAN 
<input type=checkbox  value=1 name=c_font >FONT 
<input type=checkbox  value=1 name=c_class >CLASS 
<input type=checkbox value=1 name=c_a >A 
<input type=checkbox  value=1 name=c_div >DIV 
<input type=checkbox  value=1 name=c_style >STYLE 
<input type=checkbox value=1 name=c_img >IMG
<br>
广告过滤： 
<input name="c_OBJECT" type="checkbox" value="1">OBJECT 
<input name="c_IFRAME" type="checkbox" value="1">IFRAME 
<input name="c_SCRIPT" type="checkbox" value="1">SCRIPT
<br>
远程保存：
<input name="picsave" type="checkbox" id="picsave3" value="1"  <%if PicValue=0 then response.Write("disabled")%>>保存图片 
<input name="falshsave" type="checkbox" id="falshsave3" value="1" <%if FalshValue=0 then response.Write("disabled")%>>保存Falsh 
<input name="midsave" type="checkbox" id="midsave3" value="1" <%if MusicValue=0 then response.Write("disabled")%>>保存音乐 
<input name="othersave" type="checkbox" id="othersave3" value="1" <%if OtherValue=0 then response.Write("disabled")%>>保存其它 
</TD>
</TR>

<TR id='submenu2' style="display:"> 
<TD height=30 colspan="2"><font color="#999999">其他相关设置</font></TD>
</TR>
<%
call other_set()
%>
<tr>
<td></td>
<td height=30><INPUT name="Submit" type="submit" id="Submit" value="开始采集">
<input type="button" name="Submit22" value="<%response.write tit_fir%>内容分页采集设置" onClick="location.href=''" <%if not ManyPage then response.Write("disabled")%>>
<input type="button" name="Submit2" value="高级选项" onClick="location.href=''" disabled> 
</td>
</tr></form>
</table>
<script>
function CheckReview(Obj)
{
if (Obj.!=true)
{
document.add_frm.ShowReview.=false;
document.add_frm.ShowReview.disabled=true;
}
else
{
document.add_frm.ShowReview.disabled=false;
}
}
function CheckRenew(Obj)
{
if (Obj.!=true)
{
document.add_frm.Renew.=false;
document.add_frm.Renew.disabled=true;
}
else
{
document.add_frm.Renew.disabled=false;
}
}
function CheckTest(Obj)
{
if (Obj.!=true)
{
document.add_frm.Preview.=true;
}
else
{
document.add_frm.Preview.=false;
}
}
function showsubmenu(isa)
{
if (isa.value==1)
{
eval("submenu0.style.display=\"\";");
eval("submenu1.style.display=\"\";");
eval("submenu2.style.display=\"\";");
eval("submenu3.style.display=\"\";");
//eval("submenu4.style.display=\"\";");
//eval("submenu5.style.display=\"\";");
//eval("submenu6.style.display=\"\";");
//eval("submenu7.style.display=\"\";");
isa.value=0
}else{
eval("submenu0.style.display=\"none\";");
eval("submenu1.style.display=\"none\";");
eval("submenu2.style.display=\"none\";");
eval("submenu3.style.display=\"none\";");
//eval("submenu4.style.display=\"none\";");
//eval("submenu5.style.display=\"none\";");
//eval("submenu6.style.display=\"none\";");
//eval("submenu7.style.display=\"none\";");
isa.value=1
}
}
</script>
<%
end sub


sub joekoe_chk_main()
  dim name,types,pageurl2
  pageurl2=pageurl
  sql_add=" where nsort='"&index_url&"' "
  call sql_cid_sid(sql_add)
%>
<form name=sel_form action='?jk_mod=<%response.write jk_mod%>&action=handle&c_id=<%response.write cid%>&s_id=<%response.write sid%>' method=post>
<TR align=center> 
<TD width="5%" class=td>编号</TD>
<TD width="25%" class=td>模板名称</TD>
<TD width="15%" class=td>所属栏目</TD>
<TD width="15%" class=td>采集目标</TD>
<TD width="15%" class=td>创建日期</TD>
<TD width="25%" class=td>操作</TD>
</TR>
<%
  sql="select count(id) from [DB_Item]"&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from [DB_Item]"&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    id=rs("id")
%>
<tr align=center>
<td class=tims><%response.write (viewpage-1)*nummer+i%></td>
<td><a href='?action=edit&id=<%response.write id%>'><%=rs("ItemName")%></a></td>
<td>
			  <%
			 dim temprs
			 Set TempRs = Conn.Execute("Select * from jk_Class where C_ID = " & rs("C_ID") & "")
			 if TempRs.eof then
			 else
			 response.Write(TempRs("C_Name"))
			 end if
			  %>
</td>
<td><%response.Write("<A href="""&rs("FromUrl")&""" target=""_blank"">"&rs("FromName")&"</a>")%></td>
<td align=right><font class=tims><%response.write joekoe_cms.time_type(rs("ItemTime"),4)%></font></td>
<td><a href="?id=<%=rs("id")%>">开始采集</a></td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=10>
现有<font class=red><%response.write rssum%></font>个<%response.write tit_fir%>，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
</tr>
</form>
<%
end sub
%>