<!--#include file="../Conn.asp" -->
<!--#include file="Admin10_Inc.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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {font-size: 12px;}
h1{font-size: 14px;}
body {
	margin-left: 0px;
	margin-top: 0px;
}
-->
</style></head>
<body>
<%
Call OpenConn()
Dim action,selecttime,selectmonth,xmlurl,m,d,loading
Dim data_id,class_id,softtype,server_id,data_name,data_erea,data_elite,data_hits,data_status,data_picurl,data_intro,data_inputer,url_intro,main_class_id
action=Trim(Request.QueryString("action"))'共用参数
selecttime=Trim(Request.Form("selecttime"))
selectmonth=Trim(Request.Form("selectmonth"))
If action="one" Then
    If selecttime="" Then 
	admin_err_a("请先选择日期!")
	Response.End()
    Else
	If Month(selecttime)<10 Then 
	    m="0"&Month(selecttime)
	Else
	    m=Month(selecttime)
	End If
	If Day(selecttime)<10 Then 
	    d="0"&Day(selecttime)
	Else
	    d=Day(selecttime)
	End If
	xmlurl=Year(selecttime)&m&d
	loading="数据正在加载中...."
	Call karqisave
    End If
ElseIf action="two" Then
    If selectmonth="" Then 
	admin_err_a("请先选择月份!")
	Response.End()
    Else
	If Month(selectmonth)<10 Then 
	    m="0"&Month(selectmonth)
	Else
	    m=Month(selectmonth)
	End If
	xmlurl=Year(selectmonth)&m
	loading="数据正在加载中...."
	Call karqisave
    End If
Else
    Call karqiother
End If

Sub karqiother
    Response.Write("<div style='margin-top:80px; text-align:center'>提示："&date()-1&" 的数据请在 "&date()&"-10:00 后采集！<br><br>如遇周末，卡奇电影片库更新延迟1天！</div>")
End Sub

Sub karqisave
	Response.buffer=true '开启缓存
	Response.Write "<div id='loading' style='margin-top:80px; text-align:center'><img src='loading.gif'/>"&loading&"</div>" '先写入提示
	Response.flush() '输出缓存
	Response.clear()
		  
	Set http=Server.CreateObject("Microsoft.XMLHTTP")
	http.Open "GET","http://www.karqi.com/xml/"&xmlurl&".xml",False
	http.send
	Set xml=Server.CreateObject("Microsoft.XMLDOM")
	xml.Async=False
	xml.ValidateOnParse=False
	xml.Load(http.ResponseXML)
	
    '对XML数据做判断是否是我们需要的
	If xml.Load(http.ResponseXML)=False Then
	    Call Loadjava
	    Response.Write("<div style='border:2px solid #CCCCCC;height:160px;line-height:160px;text-align:center'>该"&xmlurl&"日期的数据，卡奇电影暂未提供，请稍后再试！</div>")
	    Response.End
	End If	
	
	Response.flush() '再次输出缓存
    Response.clear()
    Call Loadjava
    ''''''''''''''''''''''''''''''''''''''''''''	
	If xml.ReadyState>2 Then
		'Response.Write("文档已经准备就绪。状态："& xml.ReadyState &"<br>")
		'搜索根结点
		Dim cNode 
		Set cNode = xml.documentElement.selectSingleNode("/movie_list")
		'取得根节点个数
	    Maxlbid = cNode.childNodes.length - 1
		'搜索二级结点（以根节点为参照,故//）
		Dim SearchChildNote 
		Set SearchChildNote = xml.selectnodes("//movie")
		'开始对影片属性进行处理
		Dim j,m,n,i
		Response.Write("<h1>本次更新需要处理<font color='red'>"&Maxlbid+1&"</font>部影片！</h1>")
		For i = 0 to Maxlbid		
			'取得第3级节点个数（以2级节点为参照）
			m=SearchChildNote.item(i).childNodes.length-1
			'取得第4级节点个数（以2级节点为参照）
			n=SearchChildNote.item(i).childNodes(m).childNodes.length-1
			'循环取得第4级节点的值（以2级节点为参照）
			url_intro=""
			For j=0 to n
				if j=0 then
					url=SearchChildNote.item(i).childNodes(m).childNodes(j).selectsinglenode("name").text&"|"&SearchChildNote.item(i).childNodes(m).childNodes(j).selectsinglenode("params").text
				else
					url="$$$"&SearchChildNote.item(i).childNodes(m).childNodes(j).selectsinglenode("name").text&"|"&SearchChildNote.item(i).childNodes(m).childNodes(j).selectsinglenode("params").text
				end if
				url_intro=url_intro&url
			Next
			url_intro="〓P2P高速播放|QvodPlayer↓$$$"&url_intro
			'取二级节点属性＿卡奇影片ID，影片分类
			main_class_id=cNode.childNodes.item(i).getAttribute("main_type")
			class_id=cNode.childNodes.item(i).getAttribute("sub_type")
			data_inputer=cNode.childNodes.item(i).getAttribute("id")
			'取三级节点值（通过2级节点来获取其属性）
			data_name=SearchChildNote.item(i).selectsinglenode("name").text
			data_intro=SearchChildNote.item(i).selectsinglenode("description").text
			data_picurl=SearchChildNote.item(i).selectsinglenode("pic").text
			Response.Write("第<font color='red'>"&i+1&"个→"&data_name&"</font>&nbsp;")
			Call Admin10_Save()
			If i=Maxlbid Then Response.Write("<font color='red'><h1>此次数据更新采集完成！</font></h1>")		
		Next
	Else
	    Response.Write("文档还未准备就绪。状态："& xml.ReadyState &"<br>")
	End If
	Set http=Nothing
	Set xml=Nothing	
End Sub

Call CloseConn()
%>

<%Sub Loadjava%>
	<script type="text/javascript">
	//去掉之前的提示
	var oLoading=document.getElementById("loading");
	var parent=oLoading.parentNode;
	parent.removeChild(oLoading);
	</script>
<%End Sub%>
</body>
</html>