<% 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 SiteID
SiteID = Request("SiteID")
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"),"P1404") then Call ReturnError1()
'判断权限结束
Dim NewsSql,RsNewsObj,CurrPage,AllPageNum,RecordNum,i,SysClassCName,SiteName,RsTempObj
CurrPage = Request("CurrPage")
NewsSql = "Select * from News where History=true Order by ID Desc"
Set RsNewsObj = Server.CreateObject("ADODB.RecordSet")
RsNewsObj.Open NewsSql,CollectConn,1,1
%>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>新闻采集</TITLE>
</HEAD>
<link href="Inc/Collect.css" rel="stylesheet">
<script language="JavaScript" src="JS/Public.js"></script>
<BODY topmargin="0" leftmargin="0" oncontextmenu="//return false;">
<table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <tr bgcolor="#F3F3F3"> 
    <td width="10%" height="24" nowrap class="ButtonList"> <div align="center">状态</div></td>
    <td height="24" nowrap class="ButtonList"> <div align="center">标题</div></td>
    <td width="10%" height="24" nowrap class="ButtonList"> <div align="center">新闻长度</div></td>
    <td width="10%" height="24" nowrap class="ButtonList"> <div align="center">目标栏目</div></td>
    <td width="10%" height="24" nowrap class="ButtonList"> <div align="center">采集站点</div></td>
    <td width="10%" height="24" nowrap class="ButtonList"> <div align="center">添加日期</div></td>
  </tr>
  <%
if Not RsNewsObj.Eof then
	if CurrPage = "" then
		CurrPage = 1
	else
		CurrPage = CInt(CurrPage)
	end if
	RsNewsObj.PageSize = 18
	RecordNum = RsNewsObj.RecordCount
	AllPageNum = RsNewsObj.PageCount
	if CurrPage > AllPageNum then CurrPage = AllPageNum
	RsNewsObj.AbsolutePage = Cint(CurrPage)
	for i = 1 to RsNewsObj.PageSize
		if RsNewsObj.Eof then Exit For
		Set RsTempObj = Conn.Execute("Select ClassCName from NewsClass where ClassID='" & RsNewsObj("ClassID") & "'")
		if Not RsTempObj.Eof then
			SysClassCName = RsTempObj("ClassCName")
		else
			SysClassCName = "栏目不存在"
		end if
		RsTempObj.Close
		Set RsTempObj = Nothing
		Set RsTempObj = CollectConn.Execute("Select SiteName from Site where ID=" & RsNewsObj("SiteID"))
		if Not RsTempObj.Eof then
			SiteName = RsTempObj("SiteName")
		else
			SiteName = "未知"
		end if
		RsTempObj.Close
		Set RsTempObj = Nothing
%>
  <tr bgcolor="#F3F3F3"> 
    <td nowrap><div align="center"> 
        <input type="checkbox" value="<% = RsNewsObj("ID") %>" name="SelectFlag">
      </div></td>
    <td nowrap><span <%if JudgePopedomTF(Session("Name"),"P1408") then%> style="cursor:hand;" title="单击修改此新闻" onClick="ClickEditNews('<% = RsNewsObj("ID") %>');" onMouseOver="this.className='Selected';" onMouseOut="this.className='';"<%end if%>> 
        <% = RsNewsObj("Title") %>
      </span></td>
    <td nowrap><div align="center"> 
        <% = Len(RsNewsObj("Content")) %>
        字符</div></td>
    <td nowrap><div align="center"> 
        <% = SysClassCName %>
      </div></td>
    <td nowrap><div align="center"> 
        <% = SiteName %>
      </div></td>
    <td nowrap><div align="center"> 
        <% = RsNewsObj("AddDate") %>
      </div></td>
  </tr>
  <%
		RsNewsObj.MoveNext
	next
%>
  <tr bgcolor="#F3F3F3"> 
    <td height="30" colspan="6" nowrap background="images/Collect_bg.gif"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="40%">
<div align="right"><span onClick="SelectNews(true);" class="SpanStyle">全选</span>&nbsp;&nbsp;<span onClick="SelectNews(false);" class="SpanStyle">取消选择</span>&nbsp;&nbsp;<%if JudgePopedomTF(Session("Name"),"P1408") then%><span onClick="EditNews();" class="SpanStyle">修改</span>&nbsp;&nbsp;<%end if%><%if JudgePopedomTF(Session("Name"),"P1409") then%><span onClick="DelNews();" class="SpanStyle">删除</span>&nbsp;&nbsp;<%end if%><%if JudgePopedomTF(Session("Name"),"P1410") then%><span onClick="MoveNewsToSystem();" class="SpanStyle">入库</span><%end if%></div></td>
          <td> <div align="right"> 
              <%
			Response.Write"&nbsp;共<b>"& AllPageNum & "</b>页<b>" & RecordNum & "</b>条记录，每页<b>" & RsNewsObj.pagesize & "</b>条，本页是第<b>"& CurrPage &"</b>页"
			if Int(CurrPage) > 1 then
				Response.Write"&nbsp;<a href=?CurrPage=1>首页</a>&nbsp;"
				Response.Write"&nbsp;<a href=?CurrPage=" & Cstr(CInt(CurrPage)-1) & ">上页</a>&nbsp;"
			end if
			if Int(CurrPage) < AllPageNum then
				Response.Write"&nbsp;<a href=?CurrPage=" & Cstr(Cint(CurrPage)+1) & ">下页</a>"
				Response.Write"&nbsp;<a href=?CurrPage=" & AllPageNum & ">末页</a>&nbsp;"
			end if
			Response.Write"<br>"
		%>
            </div></td>
        </tr>
      </table></td>
  </tr>
  <%
end if
%>
</table>
</BODY>
</HTML>
<%
Set CollectConn = Nothing
Set Conn = Nothing
Set RsNewsObj = Nothing
%>
<script language="JavaScript">
function SelectNews(Flag)
{
	if (typeof(document.all.SelectFlag.length)=='undefined') document.all.SelectFlag.checked=Flag;
	else
	{
		for (var i=0;i<=document.all.SelectFlag.length-1;i++)
		{
			document.all.SelectFlag(i).checked=Flag;
		}
	}
}
function DelNews()
{
	var NewsIDStr=AlreadySelectNews();
	if (NewsIDStr=='')
	{
		alert('没有选择新闻');
		return;
	}
	else
	if (confirm('确定要删除吗？')==true)
	{
		SendDataToServer('DelNews.asp?NewsIDStr='+NewsIDStr);
		window.location.reload();
	}
}
function AlreadySelectNews()
{
	var TempStr='';
	if (typeof(document.all.SelectFlag.length)=='undefined')
	{
		if (document.all.SelectFlag.checked==true)	TempStr=document.all.SelectFlag.value;
		else TempStr='';
	}
	else
	{
		for (var i=0;i<=document.all.SelectFlag.length-1;i++)
		{
			if (document.all.SelectFlag(i).checked==true)
			{
				if (TempStr=='') TempStr=TempStr+document.all.SelectFlag(i).value;
				else TempStr=TempStr+'*'+document.all.SelectFlag(i).value;
			}
		}
	}
	return TempStr;
}
function EditNews()
{
	var NewsIDStr=AlreadySelectNews();
	if (NewsIDStr=='') {alert('请选择要修改的新闻');return;}
	if (NewsIDStr.indexOf('*')==-1) OpenWindow('Frame.asp?FileName=EditNews.asp&NewsIDStr='+NewsIDStr,560,400,window);
	else alert('一次只能修改一条新闻');
}
function ClickEditNews(NewsID)
{
	var NewsIDStr=NewsID;
	if (NewsIDStr=='') {alert('请选择要修改的新闻');return;}
	if (NewsIDStr.indexOf('*')==-1) OpenWindow('Frame.asp?FileName=EditNews.asp&NewsIDStr='+NewsIDStr,560,400,window);
	else alert('一次只能修改一条新闻');
}
function MoveNewsToSystem()
{
	var NewsIDStr=AlreadySelectNews();
	if (NewsIDStr=='') {alert('请选择要修改的新闻');return;}
	else OpenWindow('Frame.asp?FileName=MoveNewsToSystem.asp&DelNews=true&NewsIDStr='+NewsIDStr,160,80,window);
}
</script>