<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<%
Dim ItemID
Dim RsItem,SqlItem,FoundErr,ErrMsg
Dim ListStr,LsString,LoString
Dim  ListPaingType,LPsString,LPoString,ListPaingStr1,ListPaingStr2,ListPaingID1,ListPaingID2,ListPaingStr3,HsString,HoString,HttpUrlType,HttpUrlStr
Dim  ListUrl,ListCode,NewsArrayCode,NewsArray,UrlTest,NewsCode
dim Testi
ItemID=Trim(Request("ItemID"))
HsString=Request.Form("HsString")
HoString=Request.Form("HoString")
HttpUrlType=Trim(Request.Form("HttpUrlType"))
HttpUrlStr=Trim(Request.Form("HttpUrlStr"))


If ItemID="" Then
   FoundErr=True
   ErrMsg=ErrMsg & "<br><li>参数错误，请从有效链接进入</li>"
Else
   ItemID=Clng(ItemID)
End If
If HsString="" Then
   FoundErr=True
   ErrMsg=ErrMsg & "<br><li>链接开始标记不能为空</li>"
End If
If HoString="" Then
   FoundErr=True
   ErrMsg=ErrMsg & "<br><li>链接结束标记不能为空</li>" 
End If
If HttpUrlType="" Then
   FoundErr=True
   ErrMsg=ErrMsg & "<br><li>请选择链接处理类型</li>"
Else
   HttpUrlType=Clng(HttpUrlType)
   If HttpUrlType=1 Then
      If HttpUrlStr="" Then
         FoundErr=True
         ErrMsg=ErrMsg & "<br><li>绝对链接字符设置不能为空</li>"
      Else
            If  Len(HttpUrlStr)<15  Then
               FoundErr=True
               ErrMsg=ErrMsg & "<br><li>绝对链接字符设置不正确(15个字符以上)</li>"
            End  If      
      End If
   End If
End If


If FoundErr<>True Then
   SqlItem="Select ListStr,LsString,LoString,ListPaingType,LPsString,LPoString,ListPaingStr1,ListPaingStr2,ListPaingID1,ListPaingID2,ListPaingStr3,HsString,HoString,HttpUrlType,HttpUrlStr from Item Where ItemID=" & ItemID
   Set RsItem=server.CreateObject("adodb.recordset")
   RsItem.Open SqlItem,ConnItem,2,3

   RsItem("HsString")=HsString
   RsItem("HoString")=HoString
   RsItem("HttpUrlType")=HttpUrlType
   If HttpUrlType=1 Then
      RsItem("HttpUrlStr")=HttpUrlStr
   End If
   ListStr=RsItem("ListStr")
   LsString=RsItem("LsString")
   LoString=RsItem("LoString")
   ListPaingType=RsItem("ListPaingType")
   LPsString=RsItem("LPsString")
   ListPaingStr1=RsItem("ListPaingStr1")
   ListPaingStr2=RsItem("ListPaingStr2")
   ListPaingID1=RsItem("ListPaingID1")
   ListPaingID2=RsItem("ListPaingID2")
   ListPaingStr3=RsItem("ListPaingStr3")

   RsItem.UpDate
   RsItem.Close
   Set RsItem=Nothing
   
   Select  Case  ListPaingType
   Case  0,1
         ListUrl=ListStr
   Case  2
         ListUrl=Replace(ListPaingStr2,"{$ID}",CStr(ListPaingID1))
   Case  3
         If  Instr(ListPaingStr3,"|")>0  Then
         ListUrl=Left(ListPaingStr3,Instr(ListPaingStr3,"|")-1)
      Else
         ListUrl=NewsArray(1)
      End  If
   End  Select

   ListCode=GetHttpPage(ListUrl)
   If ListCode<>"$False$" Then
      ListCode=GetBody(ListCode,LsString,LoString,False,False)
      If ListCode<>"$False$" Then 
         NewsArrayCode=GetArray(ListCode,HsString,HoString,False,False)
         If NewsArrayCode<>"$False$" Then
               NewsArray=Split(NewsArrayCode,"$Array$")
               For Testi=0 To Ubound(NewsArray)
                  If HttpUrlType=1 Then
                     NewsArray(Testi)=Replace(HttpUrlStr,"{$ID}",NewsArray(Testi))
                  Else
                     NewsArray(Testi)=DefiniteUrl(NewsArray(Testi),ListUrl)
                  End If
               Next
               UrlTest=NewsArray(0)
               NewsCode=GetHttpPage(UrlTest)
         Else
            FoundErr=True
            ErrMsg=ErrMsg & "<br><li>在获取链接列表时出错。</li>"
         End If   
      Else
         FoundErr=True
         ErrMsg=ErrMsg & "<br><li>在截取列表时发生错误。</li>"
      End If
   Else
      FoundErr=True
      ErrMsg=ErrMsg & "<br><li>在获取:" & ListUrl & "网页源码时发生错误。</li>"
   End If
End If

If FoundErr=True Then
   Call WriteErrMsg(ErrMsg)
Else
   Call Main()
End If 
'关闭数据库链接
Call CloseConn()
Call CloseConnItem()
%>
<%Sub Main()%>
<html>
<head>
<title>采集系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../css/Admin_Style.css">

<script language="VBScript">
 Private Sub ceshi(Num)
    Dim content
    Content=document.form1.Content.value
    Select Case Num   
    Case 1
        huoqv=document.form1.LsString.value
    Case 2
        huoqv=document.form1.LoString.value
    Case 3
        huoqv=document.form1.LPsString.value
    Case 4
        huoqv=document.form1.LPoString.value
    Case 5
        huoqv=document.form1.TsString.value
    Case 6
        huoqv=document.form1.ToString.value
    Case 7
        huoqv=document.form1.CsString.value
    Case 8
        huoqv=document.form1.CoString.value
    Case 9
        huoqv=document.form1.AsString.value
    Case 10
        huoqv=document.form1.AoString.value
    Case 11
        huoqv=document.form1.FsString.value
    Case 12
        huoqv=document.form1.FoString.value
    Case 13
        huoqv=document.form1.KsString.value
    Case 14
        huoqv=document.form1.KoString.value
    Case 15
        huoqv=document.form1.NPsString.value
    Case 16
        huoqv=document.form1.NPsString.value
    Case 17
        huoqv=document.form1.DsString.value
    Case 18
        huoqv=document.form1.DoString.value
    Case Else
        Exit sub
    End Select
    if huoqv="" then 
       alert("测试无效！代码为空！")
       exit Sub
    End if 
    If InStr(Content,huoqv) = 0 Then
       alert("测试无效！网页没有这些代码。")
    Else
       If InStr(Mid(Content,InStr(Content,huoqv)+LenB(huoqv),LenB(Content)),huoqv) = 0 Then
          alert("测试成功！代码在页面是唯一的。")
       Else
          alert("测试失败！代码有重复,开始或结束至少有一处代码是唯一才有效！")
       End if
    End if
 End Sub
 Private Sub Analyse()
    Dim AnalyseString,AnalyseString2
    Dim content,Analysetemp
    Content=document.form1.Content.value
    AnalyseString=document.form1.AnalyseString.value
    if AnalyseString="" then 
        alert("分析无效！分析代码为空！")
        Exit Sub
    End if
    if isNumeric(document.form1.AnalyseNum.value)=false then 
        alert("分析字符数不是有效数字！")
        Exit Sub
    End if
    AnalyseString2=LenB(AnalyseString)
    If InStr(Content,AnalyseString) = 0 Then
        alert("分析无效！网页没有这些代码。")
    Else
        if InStr(Content,AnalyseString)-document.form1.AnalyseNum.value <= 0 then
            Analysetemp = 1
        Else
            Analysetemp =InStr(Content,AnalyseString)-document.form1.AnalyseNum.value
        End if
        If InStr(Mid(Content,InStr(Content,AnalyseString)+AnalyseString2, LenB(Content)),AnalyseString) = 0 Then
            if document.form1.AnalyseWay(0).checked=true Then
                document.form1.AnalyseContent.value=Mid(Content,Analysetemp,Len(AnalyseString)+document.form1.AnalyseNum.value)
            elseif document.form1.AnalyseWay(1).checked=true then
                document.form1.AnalyseContent.value=Mid(Content,InStr(Content,AnalyseString),Len(AnalyseString)+document.form1.AnalyseNum.value)
            elseif document.form1.AnalyseWay(2).checked=true then
                document.form1.AnalyseContent.value=Mid(Content,Analysetemp,document.form1.AnalyseNum.value)+Mid(Content,InStr(Content,AnalyseString),Len(AnalyseString)+document.form1.AnalyseNum.value)
            End if
        Else
            alert("分析失败！分析代码有重复,要确认为一的字符。")
            Exit Sub
        End if
    End if
 End Sub
 </script>
<script language="JavaScript">
 <!--
 function CheckForm(){
    if (document.form1.Content.value.length > 200000){
        document.form1.Content.value="";
    }
 }
 function setFileFileds(weburl){   
    str="<iframe id='IFrame1' marginwidth=0 marginheight=0 frameborder=0  width='800' height='300' src="+weburl+"></iframe>";
    objFiles.innerHTML=str;
 }
//-->
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr> 
    <td height="22" colspan="2" align="center" class="topbg"><strong>采&nbsp;&nbsp;集&nbsp;&nbsp;系&nbsp;&nbsp;统&nbsp;&nbsp;项&nbsp;&nbsp;目&nbsp;&nbsp;管&nbsp;&nbsp;理</strong></td>
  </tr>
  <tr class="tdbg"> 

    <td width="65" height="30"><strong>管理导航：</strong></td>
    <td height="30"><a href="Admin_ItemAddNew.asp">添加项目</a> >> <a href="Admin_ItemModify.asp?ItemID=<%=ItemID%>">基本设置</a> >> <a href="Admin_ItemModify2.asp?ItemID=<%=ItemID%>">列表设置</a> >> <a href="Admin_ItemModify3.asp?ItemID=<%=ItemID%>">链接设置</a> >> <font color=red>正文设置</font> >> 采样测试 >> 属性设置 >> 完成</td>         
  </tr>         
</table> 
<br>
<form method="post" action="Admin_ItemAddNew5.asp" name="form1">
<table class=border cellSpacing=1 cellPadding=0 width="100%" align=center border=0>
  <tr> 
    <td height="22" colspan="2" class="title"> <div align="center"><strong> 项 目 编 辑--采集目标网页 </strong>      <Input type="radio" value="0" name="page" onClick="javascript:ShowPage.style.display='none';" checked>不查看
      <Input type="radio" value="1" name="page" onClick="javascript:ShowPage.style.display='';javascript:setFileFileds('<%=NewsArray(0)%>');" >查看网页
</div></td>
  </tr>
  <tr class="tdbg" id="ShowPage" style="display:'none'"> 
    <td class="tdbg" colspan='2' align='center' id='objFiles'></td>
  </tr>
  <tr> 
    <td height="22" colspan="2" class="title"> <div align="center"><strong> 项 目 编 辑--采集目标源码 </strong>      <Input type="radio" value="0" name="code" onClick="javascript:Content.style.height='1';" >不查看
      <Input type="radio" value="1" name="code" onClick="javascript:Content.style.height='300';" checked>查看源码
</div></td>
  </tr>
  <tr class="tdbg"> 
    <td class="tdbg" colspan='2' align='center'>     <TEXTAREA NAME='Content' ROWS='' COLS='' style='width:800px;height:300px'>
  	 	<%=Replace(Replace(NewsCode, "</textarea>", "<&#47textarea>"),"</TEXTAREA>","<&#47TEXTAREA>")%>
 </TEXTAREA></td>
  </tr>
</table>
<table class=border cellSpacing=1 cellPadding=0 width="100%" height='30' align=center border=0>
  <tr>
    <td class=tdbg colSpan=2 height=22>&nbsp;&nbsp;这是分析后所得到的新闻绝对链接地址：<A href=<%=NewsArray(0)%> target="_blank"><FONT color=red><%=NewsArray(0)%></FONT></A>&nbsp;&nbsp;请查看是否正确。</td>
    <input type='hidden' name='Testi' value='0'>
  </tr>
</table>
<br>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" >
  <tr>
    <td class=title colSpan=2 height=22>
      <DIV align=center><STRONG> 项 目 编 辑--正 文 设 置</STRONG></DIV></td>
  </tr>
  <tr class="tdbg"> 
     <td width="150" class="tdbg" align='center'><strong>标题开始标记：</strong><br><br><br><br><br><br>
     <strong>标题结束标记：</strong></td>
     <td class="tdbg" >
       <textarea name="TsString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(5)' ><br>
       <textarea name="ToString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(6)' ></td>
  </tr>
  <tr class="tdbg"> 
    <td width="150" class="tdbg" align='center'><strong>正文开始标记：</strong><p>　</p><p>　</p>
      <strong>正文结束标记：</strong></td>
    <td class="tdbg" >
      <textarea name="CsString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(7)' ><br>
      <textarea name="CoString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(8)' ></td>
  </tr>
  <tr class="tdbg"> 
    <td width="150" class="tdbg" align='center'><b>&nbsp;&nbsp;&nbsp;时间设置：</b></td>
    <td class="tdbg" >
      <input type="radio" value="0" name="DateType"checked onClick="javascript:Date1.style.display='none'">不作设置&nbsp;
      <input type="radio" value="1" name="DateType" onClick="javascript:Date1.style.display=''">设置标签&nbsp;</td>
    </tr>
    <tr class="tdbg" id="Date1" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>时间开始标记：</font></strong><br><br><br><br><br><br>
        <strong>时间结束标记：</font></strong></td>
      <td class="tdbg" >
        <textarea name="DsString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(17)' ><br>
        <textarea name="DoString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(18)' ></td>
    </tr>
  <tr class="tdbg"> 
    <td width="150" class="tdbg" align='center'><b>&nbsp;&nbsp;&nbsp;作者设置：</b></td>
    <td class="tdbg" >
      <input type="radio" value="0" name="AuthorType"checked onClick="javascript:Author1.style.display='none';Author2.style.display='none'">不作设置&nbsp;
      <input type="radio" value="1" name="AuthorType" onClick="javascript:Author1.style.display='';Author2.style.display='none'">设置标签&nbsp;
      <input type="radio" value="2" name="AuthorType" onClick="javascript:Author1.style.display='none';Author2.style.display=''">指定作者</td>
    </tr>
    <tr class="tdbg" id="Author1" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>作者开始标记：</font></strong><br><br><br><br><br><br>
        <strong>作者结束标记：</font></strong></td>
      <td class="tdbg" >
        <textarea name="AsString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(9)' ><br>
        <textarea name="AoString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(10)' ></td>
    </tr>
    <tr class="tdbg" id="Author2" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>请指定作者：</font></strong></td>
      <td class="tdbg" >
        <input name="AuthorStr" type="text" id="AuthorStr" value="">
      </td>
    </tr>
    <tr class="tdbg"> 
      <td width="150" class="tdbg" align='center'><b>&nbsp;&nbsp;&nbsp;来源设置：</b></td>
      <td class="tdbg" >
        <input type="radio" value="0" name="CopyFromType"checked onClick="javascript:CopyFrom1.style.display='none';CopyFrom2.style.display='none'">不作设置&nbsp;
        <input type="radio" value="1" name="CopyFromType" onClick="javascript:CopyFrom1.style.display='';CopyFrom2.style.display='none'">设置标签&nbsp;
        <input type="radio" value="2" name="CopyFromType" onClick="javascript:CopyFrom1.style.display='none';CopyFrom2.style.display=''">指定来源</td>
    </tr>
    <tr class="tdbg" id="CopyFrom1" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>来源开始标记：</font></strong><br><br><br><br><br><br>
      <strong>来源结束标记：</font></strong></td>
      <td class="tdbg" >
        <textarea name="FsString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(11)' ><br>
        <textarea name="FoString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(12)' ></td>
    </tr>
    <tr class="tdbg" id="CopyFrom2" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>请指定来源：</font></strong></td>
      <td class="tdbg" >
        <input name="CopyFromStr" type="text" id="CopyFromStr" value="">
      </td>
    </tr>
    <tr class="tdbg"> 
      <td width="150" class="tdbg" align='center'><b>关键字词设置：</b></td>
      <td class="tdbg" >
        <input type="radio" value="0" name="KeyType"checked onClick="javascript:Key1.style.display='none';Key2.style.display='none'">不作设置&nbsp;
        <input type="radio" value="1" name="KeyType" onClick="javascript:Key1.style.display='';Key2.style.display='none'">设置标签&nbsp;
        <input type="radio" value="2" name="KeyType" onClick="javascript:Key1.style.display='none';Key2.style.display=''">指定关键字</td>
    </tr>
    <tr class="tdbg" id="Key1" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>关键词开始标记：</font></strong><br><br><br><br><br><br>
        <strong>关键词结束标记：</font></strong></td>
      <td class="tdbg" >
      <textarea name="KsString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(13)' ><br>
      <textarea name="KoString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(14)' ></td>
    </tr>
    <tr class="tdbg" id="Key2" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>请指定关键：</font></strong></td>
      <td class="tdbg" >
        <input name="KeyStr" type="text" id="KeyStr" value="">
      </td>
    </tr>
    <tr>
      <td width="150" class="tdbg" align='center'><strong>正文分页设置：</strong></td>
      <td class="tdbg" >
        <input type="radio" value="0" name="NewsPaingType"checked onClick="javascript:NewsPaing1.style.display='none';NewsPaing2.style.display='none'">不作设置&nbsp;
        <input type="radio" value="1" name="NewsPaingType" onClick="javascript:NewsPaing1.style.display='';NewsPaing2.style.display='none'">设置标签&nbsp;
       </td>
    </tr>
    <tr class="tdbg" id="NewsPaing1" style="display:'none'">
      <td width="150" class="tdbg" align='center'><strong>下页开始标记：</font></strong><br><br><br><br><br><br>
        <strong>下页结束标记：</font></strong></td>
      <td class="tdbg" >
        <textarea name="NPsString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(15)' ><br>
        <textarea name="NPoString" style='width:450px;height:100px'></textarea>&nbsp;<input TYPE='button' value='测试代码' onCLICK='ceshi(16)' ></td>
    </tr>
    <tr class="tdbg" id="NewsPaing2" style="display:'none'"> 
      <td width="150" class="tdbg" align='center'><strong>手动设置：</font></strong></td>
      <td class="tdbg" >
        <input name="NewsPaingStr2" type="text" value="预留功能" size="51">
      </td>
    </tr>
  <tr class="tdbg">
    <td width="150" class="tdbg" align="center"><strong> 分析代码： </strong></td>
    <td class="tdbg">
     <Input type="radio" value="0" name="analyseType" checked onClick="javascript:analyse.style.display='none';">不作分析&nbsp;
     <Input type="radio" value="1" name="analyseType" onClick="javascript:analyse.style.display='';">启用分析 
    <font color='#0099FF'>注：此功能为辅助功能与采集配置无关</font>    </td>
  </tr>
  <tr class="tdbg" id="analyse" style="display:none">
    <td width="150" class="tdbg" align="right"></strong></td>
    <td class="tdbg">     分析网页字符：
     <Input TYPE='text' NAME='AnalyseString' value='' id='AnalyseString' size='40' maxlength='200'>
     <Input TYPE='button' value=' 分 析 ' NAME='AnalyseStart' onCLICK='Analyse()' ><br>
     <Input TYPE='radio' NAME='AnalyseWay' value='0' checked>向前代码&nbsp;
     <Input TYPE='radio' NAME='AnalyseWay' value='1'>向后代码&nbsp;
     <Input TYPE='radio' NAME='AnalyseWay' value='2'>前后代码&nbsp;
    字符数：
     <Input TYPE='text' NAME='AnalyseNum' value='300' size='5' maxlength='4'>
    <br>
    <TEXTAREA NAME='AnalyseContent' style='width:550px;height:100px'></TEXTAREA>
    </td>
  </tr>
    <tr class=tdbg>
     <td class=tdbg align=middle colSpan=2 height='50'>
<input name="ItemID" type="hidden" value="<%=ItemID%>"> 
        <input  type="button" name="button1" value="上&nbsp;一&nbsp;步" onClick="window.location.href='javascript:history.go(-1)'"  style="cursor: hand;background-color: #cccccc;">
        &nbsp;&nbsp;&nbsp;&nbsp; 
        <input  type="submit" name="Submit" value="下&nbsp;一&nbsp;步" style="cursor: hand;background-color: #cccccc;"></td>
        <input type="hidden" name="UrlTest" id="UrlTest" value="<%=UrlTest%>">    </tr>
   </table>
</form>
<!--#include file="Admin_ItemFoot.asp"-->        
</body>         
</html>
<%End Sub%>