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

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>126oo影视数据同步程序</title>
<link rel="stylesheet" href="Images/css.css" type="text/css" media="all"  />
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 
<%
response.Charset="GBK"
Dim url 
Response.Buffer = true
Server.ScriptTimeOut=10000
Url="http://vip.126oo.com/"

Function Geturl(url)
    
	Dim Http
	Set Http=server.createobject("MSXML2.XMLHTTP")
	'set Http=server.createobject("Microsoft.Xmlhttp")
	Http.open "GET",url,false
	Http.send()
	If Http.readystate<>4 then
		Exit function
	End if
		Geturl=bytesToBSTR(Http.responseBody,"gb2312")
	Set http=Nothing
	'if err.number<>0 then err.Clear
End Function

Function BytesToBstr(body,Cset)
	dim objstream,s
	s="stream"
	set objstream = Server.CreateObject("adodb."&s)
	objstream.Type = 1
	objstream.Mode =3
	objstream.Open
	objstream.Write body
	objstream.Position = 0
	objstream.Type = 2
	objstream.Charset = Cset
	BytesToBstr = objstream.ReadText
	objstream.Close
	set objstream = nothing
End Function

Function HostName()
dim HostUrl
HostUrl=Lcase(Request.Servervariables("HTTP_HOST"))
HostUrl=Split(HostUrl,".")
If Ubound(HostUrl)=1 then '1级
       HostName=HostUrl(0)&chr(46)&HostUrl(1)
Elseif Ubound(HostUrl)=2 then '2级
       HostName=HostUrl(1)&chr(46)&HostUrl(2)
Elseif Ubound(HostUrl)=3 then '3级
       HostName=HostUrl(1)&chr(46)&HostUrl(2)&chr(46)&HostUrl(3)
End if
End function

Function cut(str,start,start_num,over,over_num)
cut=mid(str,Instr(str,start)+start_num,Instr(str,over)+over_num-Instr(str,start)-start_num)
End Function


Dim action,maxz_url,maxz_cn_update_url

action = Request.QueryString ("action")

Select Case Lcase(action)
Case "res_list"
res_list
Case "update"
res_update
Case "res_left"
res_left
Case "res_right"
res_right
Case Else
main:end Select

Function main

Response.Write Geturl(url&"index.asp"):end Function

Function res_left
Response.Write Geturl(url&"index.asp?action=res_left")
end Function

Function res_right
Response.Write Geturl(url&"index.asp?action=res_right")
end Function

Function res_update
dim zt_key,zt_id,maxz_urll,maxz_cn_str,maxz_cn_array,i
dim PicURL,zt_name,zt_type,zt_zy,zt_pic,zt_dy,zt_Area,zt_Year,zt_Language,zt_url,zt_content
dim CJ_Source,CJ_ID,pic_array,TP,ZJ,rs,sql,PathMov_Image,unionplayurl

zt_key=request("key")

IF zt_key="0" OR zt_key=""  Then
Response.Write("<script language='javascript'>alert('对不起,请选择您要入库的分类！');history.back();</script>")  
Response.End
End IF

maxz_url=request.Form("maxz_url")
zt_id=Replace(request.Form("zt_id"),", ",",")
IF zt_id=""  Then
Response.Write("<script language='javascript'>alert('对不起,您没有选择您要入库的数据！');history.back();</script>")
Response.End 
End IF

maxz_urll=maxz_url&"?action=add&zt_id="&zt_id
maxz_urll=maxz_urll&"&a="&HostName

maxz_cn_str=Geturl(maxz_urll)
If InStr(maxz_cn_str,"<!--1:s-->")<=1 Then 
Response.Write maxz_cn_str
Response.End 
end If 


maxz_cn_array=Split(maxz_cn_str,"|||||")
Response.Write"<table  width=100% height=30 border=0 align=center cellpadding=0 cellspacing=1 class=table><td colspan=2 class=xingmu align=center>数 据 采 集 结 果</th>"
For i=0 To UBound(maxz_cn_array)-1

PicURL=cut(maxz_cn_array(i),"<!--0:s-->",10,"<!--0:e-->",0)
zt_name=cut(maxz_cn_array(i),"<!--1:s-->",10,"<!--1:e-->",0)
zt_type=cut(maxz_cn_array(i),"<!--2:s-->",10,"<!--2:e-->",0)
zt_zy=cut(maxz_cn_array(i),"<!--3:s-->",10,"<!--3:e-->",0)
zt_pic=cut(maxz_cn_array(i),"<!--4:s-->",10,"<!--4:e-->",0)
zt_dy=cut(maxz_cn_array(i),"<!--5:s-->",10,"<!--5:e-->",0)
zt_Area = cut(maxz_cn_array(i),"<!--6:s-->",10,"<!--6:e-->",0)
zt_Year =  cut(maxz_cn_array(i),"<!--7:s-->",10,"<!--7:e-->",0)
zt_Language = cut(maxz_cn_array(i),"<!--8:s-->",10,"<!--8:e-->",0)
zt_url= cut(maxz_cn_array(i),"<!--9:s-->",10,"<!--9:e-->",0)
zt_content=  cut(maxz_cn_array(i),"<!--10:s-->",11,"<!--10:e-->",0)
CJ_Source = cut(maxz_cn_array(i),"<!--11:s-->",11,"<!--11:e-->",0)
CJ_ID = cut(maxz_cn_array(i),"<!--12:s-->",11,"<!--12:e-->",0)

zt_zy = Replace(zt_zy,"'","''")
zt_content = Replace(zt_content,"'","''")

if CJ_Source = "57ooflv" or CJ_Source = "126ooflv" then CJ_Source = "unionflv"
unionplayurl = GetUnionPlayUrl("CJ_Source")

Set rs = Database.GetRecordDetail("Tbl_Area","A_Name like '%" & zt_Area &"%'")  
if rs.eof then zt_Area =0 else zt_Area = rs("A_ID") : zt_Area=clng(zt_Area)

Set rs = Database.GetRecordDetail("Tbl_Language","L_Name like '%" & zt_Language &"%'")  
if rs.eof then zt_Language =0 else zt_Language = rs("L_ID") : zt_Language=clng(zt_Language)

dim fileName
fileName=mid(zt_pic,instrrev(zt_pic,"/")+1)
PathMov_Image = "uploadimg/"& getSavePicPath & "/" & fileName
PathMov_Image = replace(PathMov_Image,"//","/")

TP=Request("TP") '强制更新
ZJ=Trim(Request("ZJ")) '追加地址

dim strtemp
strtemp=""
if CJ_ID <> "" then 
	strtemp = " or CJ_ID= '"&CJ_ID&"' "
end if

Set Rs=server.CreateObject("ADODB.RecordSet")
Sql="Select * from Tbl_Datas Where D_Name ='"&zt_name&"' " & strtemp

'set rs = Database.GetRecordBySQL(Sql)
Rs.Open Sql,Database.dbConn,1,2
If Rs.Eof Or Rs.Bof Then
IF ZJ=1 OR ZJ=2  Then '
Database.dbConn.execute("insert into Tbl_Datas(D_Type,D_Name,D_PlayUrl1,D_Content,D_Pic,D_Level,D_Hits,D_AddTime,D_Source1,D_Starring,D_Year,D_Area,D_Language,CJ_Source,CJ_ID) values("&zt_key&",'"&zt_name&"','"&zt_url&"','"&zt_content&"','"&PathMov_Image&"',0,0,'"&now()&"','"&zt_dy&"','"&zt_zy&"','"&zt_Year&"','"&zt_Area&"','"&zt_Language&"','"&CJ_Source&"','"&CJ_ID&"')")

Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Response.flush
End IF

IF ZJ=3 Then
Database.dbConn("insert into Tbl_Datas(D_Type,D_Name,D_PlayUrl2,D_Content,D_Pic,D_Level,D_Hits,D_AddTime,D_Source2,D_Starring,D_Year,D_Area,D_Language,CJ_Source,CJ_ID) values("&zt_key&",'"&zt_name&"','"&zt_url&"','"&zt_content&"','"&PathMov_Image&"',0,0,'"&now()&"','"&zt_dy&"','"&zt_zy&"','"&zt_Year&"','"&zt_Area&"','"&zt_Language&"','"&CJ_Source&"','"&CJ_ID&"')")

Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Response.flush
End IF

Else


IF TP="TP" Then
RS("D_Pic")= PathMov_Image
Rs("D_Content")= zt_content
Rs("D_Starring")= zt_zy
Rs("D_Year")=zt_Year
Rs("D_Language")=zt_Language
Rs("D_Area")=zt_Area
Rs("D_AddTime")=Now
RS.Update
Response.flush
End IF

IF ZJ=1 then
If Rs("D_PlayUrl1")= zt_url Then
IF TP="TP" Then
Response.Write "<tr><td class=hback height=27 width=180>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片①号地址无需更新，但强制更新图片信息!</Font><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Response.flush
Else
Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片①号地址暂时不需要更新!</font></td></tr>"
Response.flush
End IF
Else

Rs("D_PlayUrl1")= zt_url
Rs("D_Source1")= zt_dy
Rs("D_AddTime")=Now
Rs.Update
IF TP="TP" Then
Response.Write "<tr><td class=hback height=27 width=180>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback height=27><font color='#FF0000'>&nbsp;重新写入①号数据，并强制更新图片信息!</Font><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Else
Response.flush
Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片①号地址有变动，已重新写入数据!</font></td></tr>"
Response.flush
End IF
End if
End If

IF ZJ=2 then
If Rs("D_PlayUrl1")<>""  Then
IF TP="TP" Then
Response.Write "<tr><td class=hback height=27 width=180>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback height=27><font color='#FF0000'>&nbsp;跳过更新该影片地址,但强制更新图片信息!</Font><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Response.flush
Else
Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"</td><td class=hback height=27><font color='#FF0000'>&nbsp;设置跳过该影片地址,不需要更新!</font></td></tr>"
Response.flush
End IF
End if
End If

IF ZJ=3 then
If Rs("D_PlayUrl2")= zt_url  Then
IF TP="TP" Then
Response.Write "<tr><td class=hback height=27 width=180>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片②号地址无需更新，但强制更新图片信息!</Font><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Response.flush
Else
Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片②号地址暂时不需要更新!</font></td></tr>"
Response.flush
End IF
Else
Rs("D_PlayUrl2")= zt_url
Rs("D_Source2")= zt_dy
Rs("D_AddTime")= Now
Rs.Update
IF TP="TP" Then
Response.Write "<tr><td class=hback height=27 width=180>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback height=27><font color='#FF0000'>&nbsp;追加②号数据,重新写入，并强制更新图片信息!</Font><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Else
Response.flush
Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片地址已追加到②号播放器中!</font></td></tr>"
Response.flush
End IF
End IF
End IF

IF ZJ=4 then
If Rs("D_PlayUrl2")=zt_url  Then
IF TP="TP" Then
Response.Write "<tr><td class=hback height=27 width=180>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片③号地址无需更新，但强制更新图片信息!</Font><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Response.flush
Else
Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片③号地址暂时不需要更新!</font></td></tr>"
Response.flush
End IF
Else
Rs("D_PlayUrl2")= zt_url
Rs("D_Source2")= zt_dy
Rs("D_AddTime")= Now
Rs.Update
IF TP="TP" Then
Response.Write "<tr><td class=hback height=27 width=180>&nbsp;"&zt_name&"(<font color='#FF0000'>OK</font>)</td><td class=hback height=27><font color='#FF0000'>&nbsp;追加③号数据，重新写入，并强制更新图片信息!</Font><iframe border=0 valign=bottom vspace=0 hspace=0 marginwidth=0 marginheight=0 framespacing=0 frameborder=0 scrolling=no width=400 height=15 src=Admin_Upimg.ASP?path=../"&PathMov_Image&"&url="&PicURL&""&zt_pic&"></iframe></td></tr>"
Else
Response.flush
Response.Write "<tr><td class=hback height=27 width=200>&nbsp;"&zt_name&"</td><td class=hback height=27><font color='#FF0000'>&nbsp;该影片地址已追加到③号播放器中!</font></td></tr>"
Response.flush
End IF
End IF
End IF


End IF
Next
Response.Write"<tr><td class=hback height=27  colspan=2><a href=""#"" onclick=""javascript:history.go(-1);"">&nbsp;恭喜，任务完成！返回</a>(图片下载完即可)</td></tr></table>"
Database.c(rs)
Response.End

End Function

Function res_list
dim page,zt_type
page=request("page")
If page="" Or page<1 Then
page=1
End If 
zt_type=request("zt_type")
If zt_type="" Then
zt_type=0
End If 

maxz_url=request("urla")
maxz_cn_update_url= maxz_url &"?zt_type="&zt_type&"&page="&page&"&urla="&request("urla")&"&keyword="&request("keyword")&"&cj_picurl="&request("cj_picurl")

Response.Write Replace(Geturl(maxz_cn_update_url),"<!--分类-->",Getshowselect("Tbl_Type","T_Name","key","请选择栏目","","T_ID","T_Sort"))

End Function
%>
</body>
</html>