<!--#include file="inc/function.asp" -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>采集管理 - 采集项目管理 - 126电影程序CMS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="../images/css_body.css" type=text/css rel=stylesheet>
<script language="javascript" src="../images/admin.js"></script>
<style type="text/css">
<!--
.RefreshLen {
	MARGIN-top: 10px;MARGIN-BOTTOM: 5px;WIDTH: 400px; BORDER: #99CBEE 1px solid; HEIGHT: 20px; TEXT-ALIGN: left; background-color:#CAE4F7;
}
-->
</style>

</head>
<body>
<%

sub WriteJD()
'IF Not CheckFlag("03") Then:Call MB("对不起，您没有资源采集管理权限！","",0):Response.End():End IF
Response.Write"<div class=""container"" id=""cpcontainer""><TABLE width=""96%"" border=0 align=center cellpadding=""5"" cellSpacing=1 class=tbtitle style=""BACKGROUND: #cad9ea;"">" &vbcrlf
Response.Write"<TBODY>" &vbcrlf
Response.Write"<TR bgColor=""#f5fafe"">" &vbcrlf
Response.Write"<Th align=""center"">视 频 入 库 进 度</Th>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"<TR bgcolor=""#FFFFFF"">" &vbcrlf
Response.Write"<TD><div class=""RefreshLen""><span id=""RefreshLenx""></span></div></TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"<TR bgcolor=""#FFFFFF"">" &vbcrlf
Response.Write"<TD><font color='red'>总共要入库&nbsp;<b><span id=""MovieNum"">0</span></b>&nbsp;个影片,已经入库&nbsp;<b><span id=""MovieHtmlNum"">0</span></b>&nbsp;个影片</font></TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"<TR bgcolor=""#FFFFFF"">" &vbcrlf
Response.Write"<TD><input type='button' class='btn' value='返回列表' onclick=""location.href='admin_intolib.asp'""></TD>" &vbcrlf
Response.Write"</TR>" &vbcrlf
Response.Write"</TBODY>" &vbcrlf
Response.Write"</TABLE></div>" &vbcrlf
End Sub

sub EditSave()
		dim rs,sql,i
		
		Set Rs=Server.CreateObject(recordsStr)
		sql="select * from movie where ID="&NoSqlHack(Request.Form("ID"))
		Rs.open sql,connc,1,3
		RS("title")=NoSqlHack(Request.Form("MovieName"))
		RS("Server")=NoSqlHack(Request.Form("Server"))
		RS("ClassID")=NoSqlHack(Request.Form("ClassID"))
		RS("Area")=NoSqlHack(Request.Form("Area"))
		RS("name")=NoSqlHack(Request.Form("MovieActor"))
		RS("Timea")=NoSqlHack(Request.Form("Timea3"))
		RS("tupian")=NoSqlHack(Request.Form("MoviePic"))
		RS("CollectZT")=NoSqlHack(Request.Form("CollectZT"))
		RS("content")=NoSqlHack(Request.Form("Content"))
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Set Rs = server.CreateObject(recordsStr)
		sql="select * from url where movieid="&NoSqlHack(Request.Form("ID"))
		Rs.open sql,connc,1,3
		do while not Rs.eof
		i=i+1
		RS("url")=NoSqlHack(Request.Form("Url"&i))
		Rs.update
		Rs.movenext
		loop
		Rs.close
		set Rs=nothing
		
		call Admin_ShowErr("<li>修改影片成功</li>","admin_intolib.asp",1)
end sub
sub Del()
	
	connc.execute "delete from movie WHERE ID in ("&NoSqlHack(Request("ID"))&")"
	connc.execute "delete from url WHERE movieid in ("&NoSqlHack(Request("ID"))&")"
	
	call Admin_ShowErr("<li>删除影片成功！</li>","admin_intolib.asp",1)
end sub

sub DelUrl()
	connc.execute "delete from url WHERE ID="&NoSqlHack(Request.QueryString("ID"))&""
	response.redirect Request.ServerVariables("HTTP_REFERER")
end sub

sub IDInflow()	
	call Inflow("IDX",NoSqlHack(Request.Form("ID")))
end sub

sub AllInflow()
	call Inflow("All","")
end sub

sub IDX()
	dim MovieNumW,Sql_Collect
	Call WriteJD()
    MovieNumW=connc.Execute("Select count(ID) from movie where ID in ("&NoSqlHack(replace(Request.Form("ID")," ",""))&")")(0)
	Sql_Collect="select * from movie Where id in ("&NoSqlHack(replace(Request.Form("ID")," ",""))&")"
	Call MovieInflow(Sql_Collect,MovieNumW)  
	connc.Execute("update movie set CollectZT=1 Where id in ("&NoSqlHack(replace(Request.Form("ID")," ",""))&")") 
end sub
sub All()
	dim MovieNumW,Sql_Collect
	Call WriteJD()
    MovieNumW=connc.Execute("Select count(ID) from movie")(0)
	Sql_Collect="select * from movie"
	Call MovieInflow(Sql_Collect,MovieNumW)
	connc.execute("update movie set CollectZT=1") 
end sub
sub noInflow()
	dim MovieNumW,Sql_Collect
	Call WriteJD()
    MovieNumW=connc.Execute("Select count(ID) from movie where CollectZT=0")(0)
	Sql_Collect="select * from movie where CollectZT=0"
	Call MovieInflow(Sql_Collect,MovieNumW)
	connc.execute("update movie set CollectZT=1 where CollectZT=0") 
end sub

Rem 修改MovieInflow过程来进行数据入库 
sub MovieInflow(Sql_Collect,MovieNumW)
dim iscover,RS_Collect,flag,RS_MOVIE,sql_MOVIE,area,rs,MovieID,MovieInflowNum
 
iscover=request.Form("iscover")
Response.Write "<div style=overflow:auto;margin-left:0px;height:350px;width:99%;><center>"
set RS_Collect=Server.CreateObject(recordsStr)
RS_Collect.open Sql_Collect,connc,1,1
do while not RS_Collect.eof
flag=false
Response.Write "<font color=red>"&RS_Collect("title")&"</font>入库成功!<br>"
title=RS_Collect("title")
 set RS_MOVIE=Server.CreateObject("ADODB.RecordSet")
  set rs=Server.CreateObject("ADODB.RecordSet")
 sql_MOVIE = "Select * from tbl_datas where d_name = '"&title&"'"
 RS_MOVIE.open sql_MOVIE,conn,2,3
 If RS_MOVIE.State=0 Then
 Call Admin_ShowErr("<li>电影入库错误:数据库访问失败</li>","admin_intolib.asp",1)
 End If
		If ERR.NUMBER<>0 Then
			Err.Clear 
		End If 
			If RS_MOVIE.EOF or  (not RS_MOVIE.EOF and request("CCTV8")="8") Then
				RS_MOVIE.addnew
				flag=true
				
			
			RS_MOVIE("d_pic") = replace(RS_Collect("tupian"),"'","''")
			RS_MOVIE("d_hits") = 0
			RS_MOVIE("D_AddTime")= Now()
			RS_MOVIE("d_year")=RS_Collect("Timea")
			
				if not isN(RS_Collect("area")) then
				area = replace(RS_Collect("area"),"'","''")
				area = replace(area,"地区","")
				sql = "select * from tbl_area where a_name like '%" & area &"%'"
				
				rs.open sql,conn,1,1
				if not rs.eof then 
					RS_MOVIE("d_area") = rs("a_id")
				end if
				
				end if
			
			if RS_Collect("name")<>"" then
			RS_MOVIE("D_Starring")=replace(replace(replace(RS_Collect("name"),","," ")," "," "),"'","''")
			else 
			RS_MOVIE("D_Starring")=RS_Collect("name")
			end if
			
			end if
			
			RS_MOVIE("D_Source1")=RS_Collect("Server")
			RS_MOVIE("d_type")=RS_Collect("ClassID")
			RS_MOVIE("d_name")=replace(RS_Collect("title"),"'","''")
			
			if request("CCTV2")="2" and RS_Collect("area")<>"" then
				area = replace(RS_Collect("area"),"'","''")
				area = replace(area,"地区","")
				sql = "select * from tbl_area where a_name like '%" & area &"%'"
				
				rs.open sql,conn,1,1
				if not rs.eof then 
					RS_MOVIE("d_area") = rs("a_id")
				end if
			end if
			
			if request("CCTV1")="1"  Then
				RS_MOVIE("d_year")=RS_Collect("Timea")
			end if
			
			if request("CCTV3")="3" and RS_Collect("name")<>"" then
			RS_MOVIE("D_Starring")=replace(replace(replace(RS_Collect("name"),","," ")," "," "),"'","''")
			else 
			RS_MOVIE("D_Starring")=RS_Collect("name")
			end if
			
			if request("CCTV4")="4" and RS_Collect("tupian")<> "" Then
				RS_MOVIE("d_pic") = replace(RS_Collect("tupian"),"'","''")
			end if
			RS_MOVIE("D_AddTime")= Now()
			
			If ERR.NUMBER<>0 Then
				Call Admin_ShowErr("<li>电影入库错误0001:<BR>错误代码:"&Err.Number&"<BR>错误源:"&Err.Source&"<BR>错误描述:"&Err.Description&"</li>","admin_intolib.asp",1)
			End If
		
		
	if request("CCTV")="7" and flag=false then 
		if RS_MOVIE("D_PlayUrl1") <> "" then
			RS_MOVIE("D_PlayUrl2")=HJURL(RS_Collect("ID"))
		else
			RS_MOVIE("D_PlayUrl1")=HJURL(RS_Collect("ID"))
		end if
	end if
	
	if request("CCTV")="6" then
		RS_MOVIE("D_PlayUrl1")=HJURL(RS_Collect("ID"))
	end if
	
	if request("CCTV5")="5" Then
 		RS_MOVIE("D_Content")=RS_Collect("ConTent")	
 	end if
	

			If ERR.NUMBER<>0 Then
				Call Admin_ShowErr("<li>电影入库错误:<BR>错误代码:"&Err.Number&"<BR>错误源:"&Err.Source&"<BR>错误描述:"&Err.Description&"</li>","admin_intolib.asp",1)
			End If
			
			If RS_MOVIE.EOF or  (not RS_MOVIE.EOF and clng(iscover)=3) Then
				RS_MOVIE.update
				RS_MOVIE.close 
				RS_MOVIE.Open "select top 1 d_id from tbl_datas Order by d_id desc",Conn,2,3
				MovieID=RS_MOVIE("d_id")
			else
				MovieID=RS_MOVIE("d_id")
				RS_MOVIE.Update
			end if
			RS_MOVIE.Close
			Set RS_MOVIE = Nothing
	
MovieInflowNum=MovieInflowNum+1
Response.Write "<script type=""text/javascript"" language=""javascript"">" & vbNewLine
Response.Write vbTab & "document.getElementById(""RefreshLenx"").style.width = """&(MovieInflowNum/MovieNumW)*100&"%"&""";" & vbNewLine
Response.Write vbTab & "document.getElementById(""RefreshLenx"").innerHTML = """&Round((MovieInflowNum/MovieNumW)*100)&"%"&""";" & vbNewLine
Response.Write vbTab & "document.getElementById(""MovieHtmlNum"").innerHTML = """ & MovieInflowNum & """;" & vbNewLine
Response.Write vbTab & "document.getElementById(""MovieNum"").innerHTML = """ & MovieNumW & """;" & vbNewLine
Response.Write "</script>" & vbNewLine
Response.Flush
RS_Collect.movenext
loop
RS_Collect.close
set RS_Collect=nothing
Response.Write "</div>"
end sub


Function HJURL(ID)
dim TempUrl,Sql_Collect2,Sql_Collect,Server1,title,RS_Collect2,RS_Collect,NO

TempUrl=""
Sql_Collect2="select * from url where movieid="&ID&""
set RS_Collect2=server.createobject("adodb.recordset")
RS_Collect2.open Sql_Collect2,connc,1,1
Sql_Collect="select Server,title From movie where ID="&ID&""
set RS_Collect=server.createobject("adodb.recordset")
RS_Collect.open Sql_Collect,connc,1,1

	IF Not(RS_Collect.Bof And RS_Collect.Eof) Then
			Server1=RS_Collect("Server")
			title=RS_Collect("title")
	Else
			Server1="qvod"
			title="DVD高清版"
	End IF

	RS_Collect.Close
	Set RS_Collect=Nothing
'编号
NO=1
do while not RS_Collect2.eof
'取得总数

	If NO=1 Then
		TempUrl=TempUrl&title&NO&"$"&RS_Collect2("url")
	Else
		TempUrl=TempUrl& vbcrlf &title&NO&"$"&RS_Collect2("url")
	End If
	NO=NO+1
RS_Collect2.movenext
loop
RS_Collect2.close
set RS_Collect2=nothing
HJURL= TempUrl
End Function



'入库过程结束
dim action
action=Trim(request("action"))
Select Case action
Case "Edit"
 dim rs,sql,id,title,name,timea,tupian,server1,classid,area,CollectZT,content
		Set Rs=Server.CreateObject(recordsStr)
		sql="select * from movie where ID="&NoSqlHack(Request.QueryString("ID"))
		Rs.open sql,connc,1,1
		ID=RS("ID")
		title=RS("Title")  
		name=RS("name")
		Timea=RS("Timea")
		tupian=RS("tupian")
		Server1=RS("Server")
		ClassID=RS("ClassID")
		Area=RS("Area")
		CollectZT=RS("CollectZT")
		content=RS("content")
		RS.close   
      	set RS=nothing
	call Edit()
Case "EditSave"
	call EditSave()
Case "Del"
	call Del()
Case "DelUrl"
	call DelUrl()
Case "AllInflow"
	call All()
Case "IDInflow"
	dim ids:ids=replace(request.Form("ID")," ","")
	if not isNul(ids) then 	
		call IDX()
	else
		call Admin_ShowErr("<li>请选择入库影片！</li>","admin_intolib.asp",0)
	end if
Case "noInflow"
call noInflow()
Case "All"
	call All()
Case "IDX"
	call IDX()	
Case else
	call List()
End Select

sub List()
Dim int_RPP 
dim rs,sql,cPageNo,i
int_RPP=100
%>

<TABLE width="96%" border=0 align=center cellpadding="5" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
  <tbody>
    <TR bgColor="#f5fafe">
      <th  colspan="8" align="center" >采 集 视 频 管 理</th>
    </tr>
    <tr bgcolor="#FFFFFF">
	<form action="admin_intolib.asp" method="post">
      <td height="32" colspan="8" >  &nbsp;<A href="admin_intolib.asp?CollectZT=1">已入库数据</A>　☆　<A href="admin_intolib.asp?CollectZT=0">未入库数据</A>　☆　<A href="admin_intolib.asp">所有采集数据</A><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>影片搜索： 
 
  <input name="MovieName" type="text" id="MovieName" size="30">
   &nbsp; <input type="submit" class="btn" name="Submit2" value="查 询 影 片">	  </td>
   </form>
    </tr>
    <tr bgColor="#f5fafe">
      <td width="10%" height="30" >编号</td>
      <td >影片名称</td>
      <td width="7%" >状态</td>
      <td width="9%" >播放器</td>
      <td width="9%" >栏目分类</td>
      <td width="16%" >采集项目名称</td>
      <td width="15%" >添加时间</td>
      <td width="20%" >操作</td>
    </tr>
<form name="forms" action="admin_intolib.asp" method="post">
<%  Set Rs = server.CreateObject(recordsStr)
		sql="Select * from movie"
		if Request.QueryString("CollectZT")<>"" then
			sql=sql&" where CollectZT="&NoSqlHack(Request.QueryString("CollectZT"))&" Order by TimeDate desc"
		else
		if Request.Form("MovieName")<>"" then
			sql=sql&" where title Like '%"&NoSqlHack(Request.Form("MovieName"))&"%' Order by TimeDate desc"
		else
		    sql=sql&" Order by TimeDate desc"
		end if
		end if
		Rs.open sql,connc,1,1
	if Rs.eof then
	   Response.Write"<TR bgcolor=""#FFFFFF""><TD colspan=""9""  height=""40"">没有记录。</TD></TR>"
	else
		Rs.PageSize=int_RPP
		cPageNo=NoSqlHack(Request.QueryString("Page"))
		If cPageNo="" Then cPageNo = 1
		If not isnumeric(cPageNo) Then cPageNo = 1
		cPageNo = Clng(cPageNo)
		If cPageNo>Rs.PageCount Then cPageNo=Rs.PageCount 
		If cPageNo<=0 Then cPageNo=1
		Rs.AbsolutePage=cPageNo 
	for i=1 to int_RPP
	 if Rs.eof Then exit For %>    
	 <tr bgcolor="#FFFFFF">
      <td><input name="ID" type="checkbox" id="ID" value="<% = RS("ID")%>"> <%=RS("ID")%></td>
      <td><%=RS("title")%></td>
      <td><%IF RS("CollectZT")=1 Then Response.Write"<font color=""#FF0000"">已入库</font>" Else Response.Write"未入库"%></td>
      <td><%=RS("Server")%></td>
      <td><%=Get_ClassCN(RS("ClassID"))%></td>
      <td><%=RS("ClassName")%></td>
      <td title="<%=RS("TimeDate")%>"><%if isDate(RS("TimeDate")) then isCurrentDay(formatdatetime(RS("TimeDate"),2))%></td>
      <td width="10%" ><A href="admin_intolib.asp?action=Edit&ID=<%=RS("ID")%>">修改</A>｜<A href="admin_intolib.asp?action=Del&ID=<%=RS("ID")%>">删除</A></td>
    </tr>
	<%Rs.MoveNext
	next 
	end if%>

    <tr bgcolor="#FFFFFF">
	<td colspan="8" >全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','ID')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','ID')" />&nbsp;&nbsp;&nbsp; <input type="button" class="btn" name="Submit" value="批量删除"  onClick="document.forms.action.value='Del';{if(confirm('确定删除您所选择的影片吗？')){this.document.forms.submit();return true;}return false;}">&nbsp;&nbsp; <input type="button" class="btn" name="Submit" value="入库所选" onClick="document.forms.action.value='IDInflow';{if(confirm('确定入库您所选择的影片吗？')){this.document.forms.submit();return true;}return false;}">
&nbsp; 
        <input type="button" class="btn" name="Submit" value="全部入库" onClick="document.forms.action.value='AllInflow';{if(confirm('全部入库你所采集的影片吗？')){this.document.forms.submit();return true;}return false;}">
        &nbsp; <input type="button" class="btn" name="Submit" value="入库未入库" onClick="document.forms.action.value='noInflow';{if(confirm('确定入库所有未入库的影片吗？')){this.document.forms.submit();return true;}return false;}"></td>
		</tr>
    <tr bgcolor="#FFFFFF">
    <td colspan="8" >影片同名选项：  
	<input type="checkbox" name="CCTV1" value="1">覆盖年份&nbsp;&nbsp;<input type="checkbox" name="CCTV2" value="2">覆盖地区&nbsp;&nbsp;<input type="checkbox" name="CCTV3" value="3">覆盖演员&nbsp;&nbsp;<input type="checkbox" name="CCTV4" value="4">覆盖图片&nbsp;&nbsp;
	<input type="checkbox" name="CCTV5" value="5" />
	覆盖简介&nbsp;&nbsp;
	<input type="checkbox" name="CCTV" value="6">覆盖播放地址&nbsp;&nbsp;<input type="checkbox" name="CCTV" value="7">
	追加播放地址&nbsp;
	<input type="checkbox" name="CCTV8" value="8">新记录<br><br>
	<font color="#FF0000">注意
	：覆盖播放地址和追加播放地址不能同时选上，否则同时无效．选上新记录时前面的所有选项无效．覆盖播放地址是把所有播放地址覆盖．</font></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td  colspan="8"  align="center" >
      &nbsp;       <% response.Write fPageCount(Rs,cPageNo) %>
      <input name="action" type="hidden" id="action">      </td>
    </tr>
   </form>
  </tbody>
</table>

<%end sub
sub Edit()
dim i

%>
<div class="container" id="cpcontainer">
<TABLE width="96%" border=0 align=center cellpadding="5" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
  <tbody>
    <TR bgColor="#f5fafe">
      <th colspan="4" align="center" >采 集 视 频 修 改</th>
    </tr>
  <form action="admin_intolib.asp?action=EditSave" method="post" name="form">
    <tr bgcolor="#FFFFFF">
      <td width="11%"   >影片名称：</td>
      <td width="89%" ><input name="MovieName" type="text" value="<%=title%>" size="40"></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td   >影片演员：</td>
      <td ><input name="MovieActor" type="text" value="<%=name%>" size="40"></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td   >影片日期：</td>
      <td ><input name="Timea3" type="text" value="<%=Timea%>" size="40"></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td   >影片图片：</td>
      <td ><input name="MoviePic" type="text" value="<%=tupian%>" size="40"></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td   >入库状态：</td>
      <td >   <input type="radio" name="CollectZT" value="0" <%IF CollectZT=0 Then Response.Write"checked"%>> 未入库
	  <input name="CollectZT" type="radio" value="1" <%IF CollectZT=1 Then Response.Write"checked"%>> 已入库</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td   >影视类别：</td>
 <td height=7  >
 
<select name="ClassID" id="ClassID"  >
<option value="">请选择数据分类</option>
    <% makeTypeOptionSelected 0,"&nbsp;|&nbsp;&nbsp;",ClassID %>
	</select>
    
&nbsp; 发行地区：  
 <%=Area%>
&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td   >播放类型：</td>
      <td height=7  >

<select name="Server">
 <option value=''>暂没有数据</option>
      <%=Server1&"---qiushi"%> <%=GetShowPlaySelect(Server1)%>
        </select>
</td>
    </tr>

	<tr bgcolor="#FFFFFF"><td  >影片地址：</td>
	<td ><%Set Rs = server.CreateObject(recordsStr)
sql="Select * from url where movieid="&ID&""
Rs.open sql,connc,1,1
do while not RS.eof
i=i+1
Response.Write"<input type=""text"" name=""Url"&i&""" size=80 value="""&RS("url")&""">&nbsp;第"&i&"集&nbsp;&nbsp;&nbsp;<a href=""admin_intolib.asp?action=DelUrl&id="&RS("ID")&"""><font color=""#FF0000"">删除</font></a><br>" &vbcrlf
RS.movenext     
loop
RS.close    
Set RS=Nothing%></td>
	</tr>
    <tr bgcolor="#FFFFFF">
      <td  >影片介绍：</td>
      <td ><textarea name="Content" style="width:70%;height:180px;"><%=Content%></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td  colspan="2" >
        <input type="hidden" name="ID" value="<%=ID%>">
      <input type="submit" class="btn" name="Submit" value="修 改">
      <input  type="button" class="btn" name="button" value="返 回" onClick="window.location.href='javascript:history.go(-1)'">	
      </td>
      
    </tr>
  </form>
  </tbody>
</table>
</div>
<%
end sub
call conncclose()

%>
</BODY></HTML>
