<%@language=vbscript codepage=936 %>
<%
'|-----------------------------------------------------------------------|
'|---------飞越软件信息采集器v1.0 for 动易网站管理系统2005/2006 ---------|
'|-------------------------- 作者:科技创造自由 --------------------------|
'|------------------ 飞越快乐家园  http://www.fy66.net/ -----------------|
'|--动易版主Top在本插件的编写过程中给予了大力支持,特此表示诚恳的感谢!----|
'|------ 本插件多处代码参考了SNA新闻采集系统for动易4.03,特此声明! -------|
'|----- 转载请保留版权信息,手下留情,留下的是对别人的尊重,谢谢! ----------|
'|-----------------------------------------------------------------------|
option explicit
response.buffer=true	
'Const AdminPurview=1
'Response.Buffer = False
Const PurviewLevel = 1
Const PurviewLevel_Channel = 0
Const PurviewLevel_Others = ""
Server.ScriptTimeOut = 99999999


'Dim ComeUrl,Site_Sn



%>
<!--#include file="../Conn.asp"-->
<!--#include file="../inc/Function.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<!--#include file="Admin_ST_Conn.asp"-->
<!--#include file="Admin_ST_Function.asp"-->


<%



Dim SqlItem,RsItem
Dim tAction,tFoundErr,tErrMsg
Dim ItemID,ItemName,tChannelID,ClassID,SpecialID
Dim ListStr,ListPaingType,ListPaingStr2,ListPaingID1,ListPaingID2,ListPaingStr3,Flag,WebName,LastTimeStr,iChannelID
Dim ListUrl
Dim CurrentPage,AllPage,iItem,MaxPerPage
MaxPerPage=Clng(Trim(Request("MaxPerPage")))
if MaxPerPage="" then
	MaxPerPage=20
End if
tAction=Request("Action")
iChannelID=Request("iChannelID")
if iChannelID="" then iChannelID=0
If tAction="Del" Then
   Call Del()
End If
If tFoundErr=True Then
   Call WriteErrMsg()
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="Admin_Style.css">
<SCRIPT language=javascript>
function unselectall(thisform)
{
    if(thisform.chkAll.checked)
	{
		thisform.chkAll.checked = thisform.chkAll.checked&0;
    } 	
}

    function CheckAll(thisform){
        for (var i=0;i<thisform.elements.length;i++){
            var e = thisform.elements[i];
            if (e.Name != "chkAll"&&e.disabled!=true&&e.zzz!=1)
                e.checked = thisform.chkAll.checked;
        }
    }
function ConfirmDel(thisform)
{
	if(thisform.Action.value=="Del")
	{
		if(confirm("确定要删除选中的项目吗？"))
		    return true;
		else
			return false;
	}
}
function showsetting(thisform)
{
	for (var j=0;j<6;j++)
	{
		var tab = eval("document.all.settable"+j);
		if(thisform.ADType.selectedIndex==j)
			tab.style.display = "";
		else
			tab.style.display = "none";
	}
	if(thisform.ADType.selectedIndex==6)
	{
		nocodead.style.display = "none";
		iscodead.style.display = "";
	}
	else
	{
		nocodead.style.display = "";
		iscodead.style.display = "none";
	}
}

    function mysub()
    {
        esave.style.visibility="visible";
    }
</script>
<style type="text/css">
<!--
.style1 {color: #555555}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr class='topbg'> 
    <td height="22" colspan="2" align="center" ><strong>采 集 系 统 项 目 管 理</strong></td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border">
  <tr class="tdbg"> 
    <td width="70" height="30"><strong>管理导航：</strong></td>
    <td height="30"><a href="Admin_ST_Collectino.asp">管理首页</a> | <a href="Admin_ST_Add.asp">添加新项目</a></td>
  </tr>
</table><br>
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
	<tr class='title'>
		<td colspan='2'><%Call ShowChannelList(iChannelID)%> | <a href='Admin_ST_Collectino.asp'><FONT style='font-size:12px'<%if iChannelID=0 then Response.write "color='red'"%>> 所有频道 </FONT></a> | </td>
	</tr>
</table><br>

  
<%            
If Request("page")<>"" then
    CurrentPage=Cint(Request("Page"))
Else
    CurrentPage=1
End if                 
Set RsItem=server.createobject("adodb.recordset")         
SqlItem="select ItemID,ItemName,WebName,ListStr,ListPaingType,ListPaingStr2,ListPaingID1,ListPaingID2,ListPaingStr3,ChannelID,ClassID,SpecialID,LastTimeStr,Flag from Item "  
if iChannelID<>0 then
	SqlItem=SqlItem&"Where ChannelID="&iChannelID&""
End if       
SqlItem=SqlItem&" order by ItemID DESC"         
RsItem.open SqlItem,ConnItem,1,1

if RsItem.Eof and RsItem.Bof then%>
   <table cellpadding="0" cellspacing="1" border="0" width="100%" class="border" align=center>
      <tr class='tdbg'><td align='center' colspan='2'><br>无任何记录!<br></td></tr>
   </table>
<%
Else
   RsItem.PageSize=MaxPerPage
   Allpage=RsItem.PageCount
   RsItem.MoveFirst
   RsItem.AbsolutePage=CurrentPage
   iItem=0
%>         
  <table class="border" border="0" cellspacing="1" width="100%" cellpadding="0">         
   <form name="form1" method="POST" action="Admin_ST_Collecting.asp?ItemNum=1&ListNum=1&SuccNum=0&FailNum=0&ListPaingNext=$False$">         
     <tr class="title" style="padding: 0px 2px;">         
      <td width="30" height="22" align="center"><strong>选择</strong></td>                 
      <td align="center"><strong>项目名称</strong></td>         
      <td width="80" align="center"><strong>采集地址</strong></td>
      <td width="80" height="22" align="center"><strong>所属频道</strong></td> 
      <td width="80" height="22" align="center"><strong>所属栏目</strong></td> 
      <td width="80" align="center"><strong>所属专题</strong></td>   
      <td width="40" align="center"><strong>状态</strong></td>
      <td width="130" align="center"><strong>上次采集</strong></td>           
      <td width="100" height="22" align="center"><strong>历史记录</strong></td>         
     </tr>         
<%         

   Do While Not RsItem.Eof 
      ItemID=RsItem("ItemID")
      ItemName=RsItem("ItemName")  
      WebName=RsItem("WebName")
      tChannelID=RsItem("ChannelID")
      ClassID=RsItem("ClassID")
      SpecialID=RsItem("SpecialID")
      ListStr=RsItem("ListStr")
      ListPaingType=RsItem("ListPaingType")
      ListPaingStr2=RsItem("ListPaingStr2")
      ListPaingID1=RsItem("ListPaingID1")
      ListPaingID2=RsItem("ListPaingID2")
      ListPaingStr3=RsItem("ListPaingStr3")
      Flag=RsItem("Flag")
      If  ListPaingType=0  Or ListPaingType=1  Then
            ListUrl=ListStr
      ElseIf  ListPaingType=2  Then
            ListUrl=Replace(ListPaingStr2,"{$ID}",CStr(ListPaingID1))
      ElseIf  ListPaingType=3  Then
            If  Instr(ListPaingStr3,"|")>0  Then
            ListUrl=Left(ListPaingStr3,Instr(ListPaingStr3,"|"))
         Else
               ListUrl=ListPaingStr3
         End  If
      End  If
%>         
	<tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'" style="padding: 0px 2px;">          
		<td width="30" align="center"><input type="checkbox" value=<%=ItemID%> name="ItemStr" onclick="unselectall(this.form)" <%If Flag<>True Then Response.Write "disabled"%>></td>               
		<td align="center"><a href="Admin_ST_Add.asp?ItemID=<%=ItemID%>&Type=modify" title="编辑此项目"><%=ItemName%></a></td>         
		<td align="center"><a href="<%=ListUrl%>" target="_bank"><%=WebName%></a></td>
		<td align="center"><%Call ShowName(1,tChannelID)%></td>  
		<td align="center"><%Call ShowName(2,ClassID)%></td>
		<td align="center"><%Call ShowName(3,SpecialID)%></td> 
		<td align="center"><%If Flag=True Then Response.Write "√"%><%If Flag<>True Then Response.Write "<font color=red>×</font>"%></td>    
		<td align="center"><%ShowcollecDate(ItemID)%></td>    
		<td align="center">成功&nbsp;<font color="blue"><%ShowSuccNum(ItemID)%></font>&nbsp;失败&nbsp;<font color="green"><%ShowFailNum(ItemID)%></font></td>         
	</tr>         
<%         
   iItem=iItem+1
   If iItem >= MaxPerPage Then Exit Do
   RsItem.Movenext         
   Loop         
%>        
	<tr class="tdbg">          
		<td colspan=9 height="30" >
			&nbsp;<input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">全选<input type="hidden" name="Action" value="Del">　　　&nbsp;&nbsp;         
是否为更新模式 <INPUT TYPE='radio' NAME='InputType' value='1' zzz='1'> 是 
    <INPUT TYPE='radio' NAME='InputType' value='0' zzz='1' checked>否
	　　<INPUT TYPE='checkbox' NAME='CollecTest' value='1' zzz='1'> 测试采集	</td>         
	</tr>   
		<tr class="tdbg">          
		<td colspan=9 height="30" align=center >
<input type="submit" value="开 始 采 集" name="submit" onclick="javascript:mysub()" >		</td>         
		</td>         
	</tr>      
	</form>         
</table>  

<table align='center'>
	<tr>          
		<td colspan=9 height="30" align="center">          
                 共 <b> <%=RsItem.recordcount%></b> 个项目记录&nbsp;&nbsp;<a href="Admin_ST_Collectino.asp?iChannelID=<%=iChannelID%>">首页</a>&nbsp;<%if currentPage>1 then %><a href="Admin_ST_Collectino.asp?MaxPerPage=<%=MaxPerPage%>&iChannelID=<%=iChannelID%>&page=<%=currentPage-1%>">上一页</a><%else%>上一页<%end if%>&nbsp;<%if currentPage<allpage then%><a href="Admin_ST_Collectino.asp?MaxPerPage=<%=MaxPerPage%>&iChannelID=<%=iChannelID%>&page=<%=currentPage+1%>">下一页</a><%else%>下一页<%end if%> <a href="Admin_ST_Collectino.asp?MaxPerPage=<%=MaxPerPage%>&page=<%=allPage%>">尾页</a>&nbsp;&nbsp;&nbsp;页次 <b><font color=red><%=currentPage%></font>/<%=allpage%></b> &nbsp;&nbsp;<input type='text' name='MaxPerPage' size='3' maxlength='4' value='<%=MaxPerPage%>' onKeyPress="if (event.keyCode==13) window.location='Admin_ST_Collectino.asp?iChannelID=<%=iChannelID%>&page=<%=currentPage%>&MaxPerPage='+this.value;"> 转到第 <select onchange="window.location='Admin_ST_Collectino.asp?MaxPerPage=<%=MaxPerPage%>&iChannelID=<%=iChannelID%>&page='+this.value" name="gopage"> <%for iItem=1 to allpage%><option <%if iItem=currentPage then%>selected<%end if%> value="<%=iItem%>"><%=iItem%></option><%next%> </select>
		</td>         
	</tr>   
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="border" >
  <tr>
   <td colspan='2' height="20" align="center"><font color=#ff6600><strong>注：采集所引起的任何纠纷均与本系统开发商无关，特此说明！</strong></font></td>
  </tr>
</table>
 <div id="esave" style="position:absolute; top:50px; left:200px; z-index:1;visibility:hidden"> 
    <TABLE WIDTH=400 BORDER=0 CELLSPACING=0 CELLPADDING=0>
      <TR><td width="20%"></td>
    <TD width="60%"> 
    <TABLE WIDTH=100% height=100 BORDER=0 CELLSPACING=1 CELLPADDING=0>
    <TR> 
      <td bgcolor="#0033FF" align=center><b><marquee align="middle" behavior="alternate" scrollamount="5"><font color=#FFFFFF>正在加载采集项目,请稍候...</font></marquee></b></td>
    </tr>
    </table>
    </td><td width='20%'></td>
    </tr>
    </table>
  </div>
   <%
End If   
RsItem.Close         
Set RsItem=nothing         
%> 
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="border" >
  <tr>
   <td colspan='2' height="20" align="center"><a href='http://www.fy66.net/' target=_blank style='color:#449AE8'>插件作者:飞越快乐家园站长-科技创造自由</a></td>
  </tr>
</table> 
</body>         
</html>
<%End Sub%>
<%Sub Del
ItemID=Trim(Request("ItemID"))
If ItemID="" Then
   tFoundErr=True
   tErrMsg=tErrMsg & "<br><li>请选择要删除的项目！</li>"
Else
   If Instr(ItemID,",")>0 Then
      ItemID=Replace(ItemID," ","")   
      ConnItem.Execute("Delete From [Item] Where ItemID In(" & ItemID & ")")
      ConnItem.Execute("Delete From [Filters] Where ItemID In(" & ItemID & ")")
      ConnItem.Execute("Delete From [Histroly] Where ItemID In(" & ItemID & ")")
      ConnItem.Execute("Delete From [HistrolyNews] Where ItemID In(" & ItemID & ")")
   Else
      ItemID=Clng(ItemID)
      ConnItem.Execute("Delete From [Item] Where ItemID=" & ItemID)
      ConnItem.Execute("Delete From [Filters] Where ItemID=" & ItemID)
      ConnItem.Execute("Delete From [Histroly] Where ItemID=" & ItemID)
      ConnItem.Execute("Delete From [HistrolyNews] Where ItemID=" & ItemID)
   End If
End If
End Sub
%>
<%


Sub ShowChannelList(ChannelID)
	dim rrs,rsql,rrs1,rsql1
	set rrs=server.createobject("adodb.recordset")
	rsql="select * from PE_Channel where ModuleType=2 and Disabled=0"
	rrs.open rsql,Conn,1,1
	Do While not rrs.eof
			set rrs1=server.createobject("adodb.recordset")
			rsql1="select ChannelID from Item where ChannelID="&rrs("ChannelID")&""
			rrs1.open rsql1,ConnItem,1,1
			if not rrs1.eof then
				if rrs("ChannelID")=Clng(ChannelID) then
					Response.Write " | <a href='Admin_ST_Collectino.asp?iChannelID="&rrs("ChannelID")&"'><FONT style='font-size:12px;color:red'>"&rrs("ChannelName")&"</font></a>"
				Else
					Response.Write " | <a href='Admin_ST_Collectino.asp?iChannelID="&rrs("ChannelID")&"'><FONT style='font-size:12px'>"&rrs("ChannelName")&"</font></a>"
				End if
			end if
			rrs1.close
			set rrs1=nothing
		rrs.movenext
	Loop
	rrs.close
	set rrs=nothing
End Sub
%>