<%@language=vbscript codepage=936 %>
<%
'|-----------------------------------------------------------------------|
'|---------飞越软件信息采集器v1.0 for 动易网站管理系统2005/2006 ---------|
'|-------------------------- 作者:科技创造自由 --------------------------|
'|------------------ 飞越快乐家园  http://www.fy66.net/ -----------------|
'|--动易版主Top在本插件的编写过程中给予了大力支持,特此表示诚恳的感谢!----|
'|------ 本插件多处代码参考了SNA新闻采集系统for动易4.03,特此声明! -------|
'|----- 转载请保留版权信息,手下留情,留下的是对别人的尊重,谢谢! ----------|
'|-----------------------------------------------------------------------|
option explicit
response.buffer=true	
Const PurviewLevel=1
%>
<!--#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"-->
<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 showset(thisform)
{
		if(thisform.FilterType.selectedIndex==1)
		{
        	FilterType1.style.display = "none";
			FilterType2.style.display = "";
		}
		else
		{
        	FilterType1.style.display = "";
			FilterType2.style.display = "none";
	    }

}
</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_Filters.asp">管理首页</a> | <a href="Admin_ST_FilterAdd.asp">添加新项目</a></td>
	</tr>
</table><br>
<%

Dim stAction,stFoundErr,stErrMsg
Dim FilterName,ItemID,FilterObject,FilterType,FilterContent,FisString,FioString,FilterRep,FilterID,sType,Flag
Dim rrs,SqlItemR


Flag=True
sType=Trim(Request("Type"))
FilterID=Trim(Request("FilterID"))
If sType="modify" then
	Set rrs=server.createobject("adodb.recordset")
	SqlItemR="Select * from Filters Where FilterID=" & FilterID
	rrs.open SqlItemR,ConnItem,1,1	
	ItemID=rrs("ItemID")
	FilterName=rrs("FilterName")
	FilterObject=rrs("FilterObject")
	FilterType=rrs("FilterType")
	FilterContent=rrs("FilterContent")
	FisString=rrs("FisString")
	FioString=rrs("FioString")
	FilterRep=rrs("FilterRep")
	Flag=rrs("Flag")
	
	rrs.close
	set rrs=nothing
Else

End if

stAction=Trim(Request("Action"))

If stAction="SaveAdd" Then
   Call Save()
Else
   Call Main()
End If
'关闭数据库链接
Call CloseConn()
Call CloseConn_User()
Call CloseConnItem()
%>
<%Sub Main%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" ><form method="post" action="Admin_ST_FilterAdd.asp" name="form1"> 
	<tr>                                 
		<td height="22" colspan="2" class="title"> <div align="center"><strong>添 加 新 过 滤</strong></div></td>
	</tr>
	<tr class="tdbg">
		<td width="150" class="tdbg" align=center><strong> 过滤名称：</strong></td>
		<td class="tdbg"><input name="FilterName" type="text" id="FilterName" size="25" maxlength="30" value="<%=FilterName%>">&nbsp;</td>
	</tr>                                
	<tr class="tdbg">                                 
		<td width="150" class="tdbg" align=center><strong> 所属项目：</strong></td>                                
		<td class="tdbg"><%Call ShowItem_Option(ItemID)%></td>                                
	</tr>                                
	<tr class="tdbg">                                 
		<td width="150" class="tdbg" align=center><strong> 过滤对象：<strong></td>                               
		<td class="tdbg"><select name="FilterObject" id="FilterObject"><option value="1"<%if FilterObject=1 or FilterObject="" then Response.write " selected"%>>标题过滤</option><option value="2"<%if FilterObject=2 then Response.write " selected"%>>正文过滤</option></select></td>                               
	</tr>                               
	<tr class="tdbg">                                
		<td width="150" class="tdbg" align=center><strong> 过滤类型：</strong></td>                               
		<td class="tdbg"><select name="FilterType" id="FilterType" onchange=showset(this.form)><option value="1"<%if FilterType=1 or FilterType="" then Response.write " selected"%> >简单替换</option><option value="2"<%if FilterType=2 then Response.write " selected"%>>高级过滤</option></select></td>                                
	</tr>                                
	<tr class="tdbg" class="border" id="FilterType1" style="display:<%if FilterType=2 then Response.write "none"%>">                                 
      <td width="150" class="tdbg" align=center><strong> 内容：</strong></td>                               
      <td class="tdbg"><textarea name="FilterContent" cols="49" rows="5"><%=FilterContent%></textarea></td>                               
	</tr>                            
	<tr class="tdbg" class="border" id="FilterType2" style="display:<%if FilterType=1 or FilterType="" then Response.write "none"%>">                               
      <td width="150" class="tdbg" align=center><strong> 开始标记：</strong><br><br><br><br><br><strong> 结束标记：</strong></td>                              
      <td class="tdbg">
      	<textarea name="FisString" cols="49" rows="5"><%=FisString%></textarea><br>
      	<textarea name="FioString" cols="49" rows="5"><%=FioString%></textarea>&nbsp;
      </td>                                
	</tr>                                
	<tr class="tdbg" id="FilterRep">                                 
      <td width="150" class="tdbg" align=center><strong> 替换：</strong></td>                                
      <td class="tdbg"><textarea name="FilterRep" cols="49" rows="5"><%=FilterRep%></textarea>&nbsp;</td>                               
	</tr>   
	<tr class='tdbg'>
		<td align='center' width="150"><b>是否启用：</b></td><td>&nbsp;&nbsp;<input name='Flag' type='checkbox' id='Flag' value='Yes'<%if Flag<>False then response.write "Checked"%>></td>
	</tr> 
	<tr class="tdbg">                                
		<td colspan="2" align="center" class="tdbg"><input name="FilterID" type="hidden" id="FilterID" value="<%=FilterID%>"><input name="Action" type="hidden" id="Action" value="SaveAdd"><input  type="submit" name="Submit" value="确&nbsp;&nbsp;定" >&nbsp;&nbsp;&nbsp;&nbsp;<input name="Cancel" type="button" id="Cancel" value="取&nbsp;&nbsp;消" onClick="window.location.href='Admin_ST_Filters.asp'"></td>                               
	</tr>                               
</form> 
</table>
<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 Save()                                
                                
Dim SqlItem,RsItem                                
Dim FilterName,ItemID,FilterObject,FilterType,FilterContent,FisString,FioString,FilterRep,Flag                           
FilterName=Trim(Request.Form("FilterName"))                                
ItemID=Trim(Request.Form("ItemID"))     
FilterObject=Request.Form("FilterObject")                              
FilterType=Clng(Request.Form("FilterType"))                                
FilterContent=Request.Form("FilterContent")                                
FisString=Request.Form("FisString")                                
FioString=Request.Form("FioString")                                
FilterRep=Request.Form("FilterRep") 
Flag=Request.Form("Flag") 

                              
If FilterName="" Then                                
   stFoundErr=True                                
   stErrMsg=stErrMsg & "<br><li>过滤名称不能为空</li>"                                 
End If                                
If ItemID="" Then                                
   stFoundErr=True                                
   stErrMsg=stErrMsg & "<br><li>请选择过滤所属项目</li>"                                 
Else                                
   ItemID=Clng(ItemID)  
   If ItemID="" Then  
      stFoundErr=True                                
      stErrMsg=stErrMsg & "<br><li>请选择过滤所属项目</li>"   
   End If                                
End If       
If FilterObject="" Then                                
   stFoundErr=True                                
   stErrMsg=stErrMsg & "<br><li>请选择过滤对象</li>"                                 
Else                                
   FilterObject=Clng(FilterObject)   
End If                                
                            
If FilterType="" Then                                
   stFoundErr=True                                
   stErrMsg=stErrMsg & "<br><li>请选择过滤类型</li>"                                 
Else                                
   FilterType=Clng(FilterType)                                
   If FilterType=1 Then     
      If FilterContent="" Then                              
         stFoundErr=True                                
         stErrMsg=stErrMsg & "<br><li>过滤的内容不能为空</li>"   
      End If   
   ElseIf FilterType=2 Then   
      If FisString="" or FioString="" Then   
         stFoundErr=True                                
         stErrMsg=stErrMsg & "<br><li>开始/结束标记不能为空</li>"   
      End If   
   Else   
      stFoundErr=True                                
      stErrMsg=stErrMsg & "<br><li>参数错误，请从有效链接进入</li>"   
   End If   
End If                                
                                
If stFoundErr<>True Then                                
   SqlItem ="select top 1 *  from Filters"
   if FilterID<>"" then
   	  SqlItem=SqlItem&" where FilterID="&FilterID&""
   End if    
   Set RsItem=server.CreateObject("adodb.recordset")                                
   RsItem.open SqlItem,ConnItem,1,3
  
   if FilterID="" then
   	  RsItem.AddNew
   End if
   RsItem("FilterName")=FilterName                                
   RsItem("ItemID")=ItemID   
   RsItem("FilterObject")=FilterObject
   RsItem("FilterType")=FilterType                                
   If FilterType=1 Then                                
      RsItem("FilterContent")=FilterContent                                
   ElseIf FilterType=2 Then                                
      RsItem("FisString")=FisString                                
      RsItem("FioString")=FioString                                
   End If                                                
   RsItem("FilterRep")=FilterRep    
   
if Flag="Yes" then  
   RsItem("Flag")=True
Else
   RsItem("Flag")=False
End if
   

   RsItem.Update                                
   RsItem.Close                                
   Set RsItem=Nothing                                
   Response.Redirect "Admin_ST_Filters.asp"                                
Else     
Response.write stErrmsg                           
   Call WriteErrMsg()                                
End If                                
                                
End Sub                                
%>