<% Option Explicit %>
<!--#include file="inc/Cls_DB.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<%
'==============================================================================
'软件名称：风讯新闻采集系统V1.0
'最新更新：2004.12
'==============================================================================
'商业注册联系：028-85098980-601,602 技术支持：028-85098980-606、607,客户支持：608
'产品咨询QQ：159410,655071,66252421
'技术支持:所有程序使用问题，请提问到bbs.foosun.net我们将及时回答您
'程序开发：风讯开发组 & 风讯插件开发组
'论坛支持：风讯在线论坛(http://bbs.foosun.net)
'官方网站：www.Foosun.net  演示站点：test.cooin.com    
'网站建设专区：www.cooin.com
'==============================================================================
'免费版本请在新闻首页保留版权信息，并做上本站LOGO友情连接
'==============================================================================
Dim DBC,Conn,CollectConn
Set DBC = New DataBaseClass
Set CollectConn = DBC.OpenConnection()
DBC.ConnStr = "DBQ=" + Server.MapPath(DataBaseConnectStr) + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
'判断权限
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P1402") then Call ReturnError1()
'判断权限结束
if Request("action") = "Del" then
	CollectConn.Execute("delete from Rule where id=" & Request("id") & "")
	Response.Redirect("Rule.asp")
	Response.End
end if

if Request.Form("Result") = "add" then
    Dim Sql,RsEditObj
	Set RsEditObj = Server.CreateObject ("ADODB.RecordSet")
	Sql = "Select * from Rule"
	RsEditObj.Open Sql,CollectConn,1,3
	RsEditObj.AddNew
	RsEditObj("RuleName") = Request.Form("RuleName")
	RsEditObj("SiteId") = Request.Form("SiteId")
	RsEditObj("HeadSeting") = Request.Form("HeadSeting")
	RsEditObj("FootSeting") = Request.Form("FootSeting")
	RsEditObj("ReContent") = Request.Form("ReContent")
	RsEditObj("AddDate") = Now()
	RsEditObj.update
	RsEditObj.close
	Set RsEditObj = Nothing
	Response.Redirect("Rule.asp")
	Response.End
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>自动替换规则设置</title>
</head>
<link href="inc/Collect.css" rel="stylesheet">
<body leftmargin="0" topmargin="0">
<%
if Request("action") = "AddRule" then
	Call Add()
else
	Call Main()
end if
Sub Main()
	Dim RsSite,Sitesql,CheckInfo,StrPage,Select_Count,Select_PageCount,i,ApplyStation,RsTempObj
	StrPage = Request.QueryString("Page")
	if StrPage <= 1 or StrPage = "" then 
		StrPage = 1
	else 
		StrPage = CInt(StrPage)
	end if
	Set RsSite = Server.CreateObject ("ADODB.RecordSet")
	SiteSql = "select * from Rule order by id desc"
	RsSite.Open SiteSql,CollectConn,1,1
	if RsSite.eof then
		RsSite.close
		Set RsSite = Nothing
		CollectConn.close
		Set CollectConn = Nothing
		Response.Write"没有规则,请<a href=?Action=AddRule>添加</a>。"
		Response.End
	end if
	RsSite.PageSize = 12
	Select_Count = RsSite.RecordCount
	Select_PageCount = RsSite.PageCount
	if StrPage > Select_PageCount then StrPage = Select_PageCount
	RsSite.AbsolutePage = CInt(StrPage)
%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  <tr> 
    <td width="19%" height="30" bgcolor="#FFFFFF" class="ButtonList"> 
      <div align="center">规则名称</div></td>
    <td width="20%" height="30" bgcolor="#FFFFFF" class="ButtonList"> 
      <div align="center">应用站点</div></td>
    <td width="20%" height="30" bgcolor="#FFFFFF" class="ButtonList"> 
      <div align="center">时间</div></td>
    <td width="11%" height="30" class="ButtonList"> 
      <div align="center">操作</div></td>
  </tr>
<%
		for i=1 to RsSite.PageSize
			if RsSite.Eof then Exit For
			if Not ISNull(RsSite("Siteid")) then
				Sql = "Select ID,SiteName from Site where ID=" & RsSite("Siteid")
				Set RsTempObj = CollectConn.Execute(Sql)
				if Not RsTempObj.Eof then
					ApplyStation = RsTempObj("SiteName")
				else
					ApplyStation = "站点不存在"
				end if
				Set RsTempObj = Nothing
			else
				ApplyStation = "站点不存在"
			end if
%>
  <tr bgcolor="#FFFFFF" onMouseOver="this.style.backgroundColor='#EFEFEF'" onMouseOut="this.style.backgroundColor=''"> 
    <td height="26"> <div align="center"><% = RsSite("RuleName") %> </div></td>
    <td> <div align="center"><% = ApplyStation %></div></td>
    <td> <div align="center"> <% = RsSite("AddDate") %></div></td>
    <td><div align="center"><span class="SpanStyle" title="修改属性" onClick="window.location='Rulemodify.asp?RuleId=<% = RsSite("Id") %>';">属性</span> 
        | <span class="SpanStyle" title="删除" onClick="if (confirm('确定要删除吗？')==true) window.location='?action=Del&Id=<% = RsSite("Id") %>';">删除</span> 
      </div></td>
  </tr>
  <%
			RsSite.MoveNext
		next
%>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="4"> 
      <table background="images/Collect_bg.gif" width="100%" border="0" cellpadding="5" cellspacing="0">
        <tr> 
          <td width="17%" height="30"> 
            <div align="left"><a href="?Action=AddRule"><strong><font color="#FF0000">增加替换规则</font></strong></a></div></td>
          <td width="83%" height="30"> 
            <div align="right"> 
				<%
				Response.Write"&nbsp;共<b>" & Select_PageCount & "</b>页<b>" & Select_Count & "</b>条记录，每页<b>" & RsSite.pagesize & "</b>条，本页是第<b>" & StrPage &"</b>页"
				if Int(StrPage)>1 then
					Response.Write "&nbsp;<a href=?Page=1>第一页</a>&nbsp;"
					Response.Write "&nbsp;<a href=?Page=" & CStr(CInt(StrPage) - 1) & ">上一页</a>&nbsp;"
				end if
				if Int(StrPage) < Select_PageCount then
					Response.Write "&nbsp;<a href=?Page=" & CStr(CInt(StrPage) + 1 ) & ">下一页</a>"
					Response.Write "&nbsp;<a href=?Page="& Select_PageCount &">最后一页</a>&nbsp;"
				end if
				Response.Write"<br>"
				RsSite.close
				Set RsSite = Nothing
				%>
            </div></td>
        </tr>
      </table></td>
  </tr>
</table>
<%End Sub%>
<%
Sub Add()
	Dim SiteList,RsSiteObj
	Set RsSiteObj = Server.CreateObject("Adodb.RecordSet")
	RsSiteObj.Source = "Select ID,SiteName from Site order by id desc"
	RsSiteObj.open RsSiteObj.Source,CollectConn,1,3
	do while Not RsSiteObj.Eof
		SiteList = SiteList & "<option value=" & RsSiteObj("ID") & "" & ">" & RsSiteObj("SiteName") & "</option><br>"
		RsSiteObj.MoveNext	
	loop
	RsSiteObj.Close
	Set RsSiteObj = Nothing
%>
  
<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
  <form name="form1" method="post" action="">
    <tr bgcolor="#FFFFFF" background="images/Collect_bg.gif"> 
      <td background="images/Collect_bg.gif" height="30" colspan="4"><strong><font color="#FF0000">增加规则</font></strong></td>
    </tr>
    <tr bgcolor="#F3F3F3"> 
      <td width="10%"> <div align="right"> 
          <input name="Result" type="hidden" id="Result" value="add">
          规则名称</div></td>
      <td width="40%"> <input style="width:100%;" name="RuleName" type="text" id="RuleName"> 
      </td>
      <td width="10%"> <div align="right">应用到</div></td>
      <td> <select style="width:100%;" name="SiteId" id="SiteId">
          <% = SiteList %>
        </select> </td>
    </tr>
    <tr bgcolor="#F3F3F3"> 
      <td><div align="right">开始标记</div></td>
      <td><textarea name="HeadSeting" rows="3" id="textarea2" style="width:100%;"></textarea></td>
      <td><div align="right">结束标记</div></td>
      <td><textarea name="FootSeting" rows="3" id="textarea3" style="width:100%;"></textarea></td>
    </tr>
    <tr bgcolor="#F3F3F3"> 
      <td><div align="right"> 替换为</div></td>
      <td colspan="3" bgcolor="#F3F3F3"><textarea name="ReContent" rows="5" style="width:100%;"></textarea></td>
    </tr>
    <tr bgcolor="#F3F3F3"> 
      <td height="50" colspan="4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td width="50%">
<div align="center">
                <input type="submit" name="Submit" value=" 增 加 ">
              </div></td>
            <td><div align="center">
                <input type="reset" name="Submit2" value=" 重 填 ">
              </div></td>
          </tr>
        </table> </td>
    </tr>
  </form>
</table>
<%End Sub%>
</body>
</html>
<%
Set CollectConn = Nothing
Set Conn = Nothing
%>
