<!--#include file="connvod.asp"-->
<%
Response.Buffer = true
Server.ScriptTimeOut=9999999
headAdminCollect "视频自定义采集"

dim action,p_id,p_ids,num,parrid,parrcount,listnum,viewnum,viewcount,txt,sb,cg

p_ids = be("all","p_id")
action  = be("all","action")
num = be("all","num")
listnum = be("all","listnum")
viewnum = be("all","viewnum")
sb = be("all","sb")
cg = be("all","cg")

if isn(listnum) then listnum=0 else listnum = clng(listnum)
if isn(viewnum) then viewnum=0 else viewnum = clng(viewnum)
if isn(num) then num =0 else num = clng(num)
if  action="pl" Then
	parrid = split(p_ids,",") : parrcount = ubound(parrid) + 1
	if num >= parrcount then 
		dBreakpoint "../../upload/vodbreakpoint"
		showmsg "<font color='red'><b>批量采集完成</b></font>","collect_vod_manage.asp"
	end if
	p_id = parrid(num)
else
	p_id = p_ids
end if
if isN(p_id) then errmsg "采集提示","采集项目ID不能为空!"

dim rs,sql,cjlms
dim p_name,p_coding,p_playtype,p_pagetype,p_url,p_pagebatchurl,p_manualurl,p_pagebatchid1,p_pagebatchid2,p_script,p_showtype,p_collecorder,p_savefiles,p_intolib,p_ontime,p_listcodestart,p_listcodeend,p_classtype,p_collect_type,p_time,p_listlinkstart,p_listlinkend,p_starringtype,p_starringstart,p_starringend,p_titletype,p_titlestart,p_titleend,p_pictype,p_picstart,p_picend,p_timestart,p_timeend,p_areastart,p_areaend,p_typestart,p_typeend,p_contentstart,p_contentend,p_playcodetype,p_playcodestart,p_playcodeend,p_playurlstart,p_playurlend,p_playlinktype,p_playlinkstart,p_playlinkend,p_playspecialtype,p_playspecialrrul,p_playspecialrerul,p_server,p_hitsstart,p_hitsend,p_lzstart,p_lzend,p_colleclinkorder,p_lzcodetype,p_lzcodestart,p_lzcodeend,p_languagestart,p_languageend,p_remarksstart,p_remarksend,p_directedstart,p_directedend,p_setnametype,p_setnamestart,p_setnameend

dim linkarr,linkarrcode,starringarr,starringarrcode,titlearr,titlearrcode,picarr,picarrcode

if sb="" and cg="" then
	cjdb.db "update [tbl_vod_project] set [p_time]='"&now()&"' where [p_id]="&p_id,"exe"
	sb=0 : 	cg=0
end if

sql = "select * from tbl_vod_project where p_id="&p_id
set rs= cjdb.DB(sql,"rs1")
if not rs.Eof then
	p_id = rs("p_id")
	p_name = rs("p_name") : p_coding = rs("p_coding") : p_playtype = rs("p_playtype") : p_pagetype = rs("p_pagetype")
	p_url = rs("p_url") : p_pagebatchurl = rs("p_pagebatchurl") : p_manualurl = rs("p_manualurl") : p_pagebatchid1 = rs("p_pagebatchid1")
	p_pagebatchid2 = rs("p_pagebatchid2") : p_script = rs("p_script") : p_showtype = rs("p_showtype") : p_collecorder = rs("p_collecorder")
	p_savefiles = rs("p_savefiles") : p_intolib = rs("p_intolib") : p_ontime = rs("p_ontime") : p_listcodestart = rs("p_listcodestart")
	p_listcodeend = rs("p_listcodeend") : p_classtype = rs("p_classtype") : p_collect_type = rs("p_collect_type") : p_time = rs("p_time")
	p_listlinkstart = rs("p_listlinkstart") : p_listlinkend = rs("p_listlinkend") : p_starringtype = rs("p_starringtype")
	p_starringstart = rs("p_starringstart") : p_starringend = rs("p_starringend") : p_titletype = rs("p_titletype")
	p_titlestart = rs("p_titlestart") : p_titleend = rs("p_titleend") : p_pictype = rs("p_pictype") : p_picstart = rs("p_picstart")
	p_picend = rs("p_picend") : p_timestart = rs("p_timestart") : p_timeend = rs("p_timeend") : p_areastart = rs("p_areastart")
	p_areaend = rs("p_areaend") : p_typestart = rs("p_typestart") : p_typeend = rs("p_typeend") : p_contentstart = rs("p_contentstart")
	p_contentend = rs("p_contentend") : p_playcodetype = rs("p_playcodetype") : p_playcodestart = rs("p_playcodestart")
	p_playcodeend = rs("p_playcodeend") : p_playurlstart = rs("p_playurlstart") : p_playurlend = rs("p_playurlend")
	p_playlinktype = rs("p_playlinktype") : p_playlinkstart = rs("p_playlinkstart") : p_playlinkend = rs("p_playlinkend")
	p_playspecialtype = rs("p_playspecialtype") : p_playspecialrrul = rs("p_playspecialrrul") : p_playspecialrerul = rs("p_playspecialrerul")
	p_server = rs("p_server") : p_hitsstart = rs("p_hitsstart") : p_hitsend = rs("p_hitsend")
	p_lzstart = rs("p_lzstart") : p_lzend = rs("p_lzend") : p_colleclinkorder = rs("p_colleclinkorder")
	p_lzcodetype = rs("p_lzcodetype") : p_lzcodestart = rs("p_lzcodestart") : p_lzcodeend = rs("p_lzcodeend")
	p_languagestart = rs("p_languagestart") : p_languageend = rs("p_languageend") : p_remarksstart = rs("p_remarksstart")
	p_remarksend = rs("p_remarksend") : p_directedstart = rs("p_directedstart") : p_directedend = rs("p_directedend")
	p_setnametype = rs("p_setnametype") : p_setnamestart = rs("p_setnamestart") : p_setnameend = rs("p_setnameend")
end if
cjdb.C(rs)

dim strListUrl,ListEnd,ListArray,strdstate
p_pagebatchid1 = clng(p_pagebatchid1)
p_pagebatchid2 = clng(p_pagebatchid2)

Select Case p_pagetype
	Case 0 
			If listnum < 1 Then strListUrl = p_Url Else ListEnd = 1
	Case 1,3
          If p_CollecOrder = 1 then
			 If (p_pagebatchid2-(listnum))< p_pagebatchid1 or (p_pagebatchid2-(listnum+1)) < 0 Then
				ListEnd=1
			 Else
				strListUrl=Replace(p_PageBatchUrl,"{ID}",(p_pagebatchid2-listnum))
			 End if
		  Else
			 If (p_pagebatchid1+listnum)> p_pagebatchid2  Then
				ListEnd=1
			 Else
				strListUrl=Replace(p_PageBatchUrl,"{ID}",(p_pagebatchid1+listnum))
			 End If
		  End If
	Case 2
         ListArray=Split(p_ManualUrl,"|")
		  If (listnum)>CInt(Ubound(ListArray)) Then
			 ListEnd=1
		  Else
			 strListUrl = ListArray(listnum)
		  End If  
End Select

writeA "采集中...  第" & listnum+1 & "页， 成功 " & cg & "条，失败" & sb & "条<br>"

Select Case ListEnd
	Case 1
		if action <> "pl" then
			dBreakpoint "../../upload/vodbreakpoint"
			showmsg "采集完成","collect_vod_manage.asp"
		else
			if num >= parrcount then
				dBreakpoint "../../upload/vodbreakpoint"
				showmsg "批量采集完成","collect_vod_manage.asp"
			else
				writeE "数据采集完毕 ---   暂停3秒后继续采集<script language=""javascript"">setTimeout(""makeNextPage();"",3000);function makeNextPage(){location.href='collect_vod_cj.asp?p_id="&p_ids&"&listnum=0&num="&(num+1)&"&action="&action&"';}</script>"
			end if
		end if
	case else
		call cjList()
End Select

sub cjList()
	dim strListCode,strListCodeCut,UrlTest,Url,i,strViewCode,startnum,endnum,j,tempStep,tempPoor
	
	if isN(session("strListCode")) then
		strListCode = getPage(strListUrl,p_Coding)
		session("strListCode") = strListCode
	else
		strListCode = session("strListCode")
	end if
	
	if strListCode = False then
		writeA "<tr><td  colspan=""2"">在获取:"&strListUrl&"网页源码时发生错误！</td></tr>"
		exit sub
	end if
	listnum = listnum+1 : 	tempStep = 1
	
	
	select case p_pagetype
		case 3
			strViewCode = strListCode
			j = 1
			if p_CollecOrder = 1 then 
				startnum = p_pagebatchid2 : endnum = p_pagebatchid1
			else
				startnum = p_pagebatchid1 : endnum = p_pagebatchid2
			end if
			if not indexOf(p_PageBatchUrl,"{ID}") then startnum=0:endnum=0
			call wtablehead
			for i=startnum to endnum
				UrlTest = replaceStr(p_PageBatchUrl,"{ID}",i)
				writeA "<tr><td  colspan=""2""></td>正在采集列表："&UrlTest&"的数据 </tr>"
				call cjView(UrlTest,j)
				writeF ""
				j = j + 1
			next
			call wtablefoot
			clearSession
			writeE "数据采集完毕<script language=""javascript"">setTimeout(""makeNextPage();"",2000);function makeNextPage(){location.href='collect_vod_manage.asp';}</script>"
		case else
			if isN(session("strListCodeCut")) then
				strListCodeCut = getBody(strListCode,p_ListCodeStart,p_ListCodeEnd)
				session("strListCodeCut") = strListCodeCut
			else
				strListCodeCut = session("strListCodeCut")
			end if
			
			if isN(session("linkarrcode")) then
				linkarrcode = getArray(strListCodeCut,p_ListLinkStart,p_ListLinkEnd)
				session("linkarrcode") = linkarrcode
			else
				linkarrcode = session("linkarrcode")
			end if
			
			if p_StarringType = 1 then starringarr = getArray(strListCodeCut,p_StarringStart,p_StarringEnd)
			if p_TitleType = 1 then titlearrcode = getArray(strListCodeCut,p_titlestart,p_titleend)
			if p_PicType = 1 then picarrcode = getArray(strListCodeCut,p_PicStart,p_PicEnd)
			
			if linkarrcode = False then
				writeA "<tr><td  colspan=""2""></td>在获取链接列表时出错！</tr>"
				sb = sb+1
				exit sub
			End If
			
			wBreakpoint "../../upload/vodbreakpoint",geturl()
			
			linkarr = Split(linkarrcode,"$Array$")
			if p_StarringType = 1 then starringarr = Split(starringarrcode,"$Array$")
			if p_TitleType = 1 then titlearr = Split(titlearrcode,"$Array$")
			if p_PicType = 1 then picarr = Split(picarrcode,"$Array$")
			viewcount = ubound(linkarr)
			
			if p_ShowType=1 then
				if viewnum >= viewcount then
					clearSession
					writeE "分页数据采集完毕 ---   暂停2秒后继续采集<script language=""javascript"">setTimeout(""makeNextPage();"",2000);function makeNextPage(){location.href='collect_vod_cj.asp?p_id="&p_ids&"&listnum="&listnum&"&sb="&sb&"&cg="&cg&"&num="&num&"&action="&action&"';}</script>"
				else
					if p_SaveFiles = 1 then strdstate = "false" else strdstate = "true"
					call wtablehead
					call cjView(linkarr(viewnum),viewnum)
					writeF ""
					call wtablefoot
					writeE "数据采集完毕 --- 稍后继续采集<script language=""javascript"">var dstate="&strdstate&";setInterval(""makeNextPage();"",500);function makeNextPage(){if(dstate){dstate=false;location.href='collect_vod_cj.asp?p_id="&p_ids&"&listnum="&listnum-1&"&sb="&sb&"&cg="&cg&"&num="&num&"&viewnum="&viewnum+1&"&action="&action&"';}}</script>"
				end if
			else
				dim forstartnum,forendnum,forstep
				if p_CollecLinkOrder=1 then forstartnum=viewcount:forendnum=0:forstep=-1 else forstartnum=0:forendnum=viewcount:forstep=1
				
				for i=forstartnum to forendnum Step forstep
					'if i <=23 then exit for
					call wtablehead
					if i=forstartnum then
						writeF "<tr><td  colspan=""2""></td>正在采集列表："&strListUrl&"的数据 </tr>"
					end if
					call cjView(linkarr(i),i)
					writeF ""
					call wtablefoot
				next
				clearSession
				writeE "分页数据采集完毕 ---   暂停2秒后继续采集<script language=""javascript"">setTimeout(""makeNextPage();"",2000);function makeNextPage(){location.href='collect_vod_cj.asp?p_id="&p_ids&"&listnum="&listnum&"&sb="&sb&"&cg="&cg&"&num="&num&"&action="&action&"';}</script>"
			end if
	end select
end sub

sub cjView(Byval strlink,Byval num)
	dim strViewCode
	dim titlecode,starringcode,piccode,timecode,areacode,typecode,playcode,contentcode,lzcode,languagecode,remarkscode,lzfwcode,directedcode
    dim weburl,movieid,webArray,i,m_typeid,m_hits,setnames,typecodearr
	
	strlink = DefiniteUrl(strlink,strListUrl)
	strViewCode = getPage(strlink,p_Coding)
	
	if strViewCode = False then
		strdstate="true"
		writeA "<tr><td  colspan=""2"">在获取内容页时出错："&strlink&" </td></tr>"
		sb=sb+1
		exit sub
	Else
		if p_TitleType = 1 then
			if ubound(titlearr) >= num  then titlecode = titlearr(num)
		else
			titlecode = getBody(strViewCode,p_titlestart,p_titleend)
		end if
		titlecode = FilterScript(titlecode,p_script)
		titlecode = replaceFilters(titlecode,p_id,1)
		titlecode = replaceStr(titlecode,"'","")
		
		sql="select m_id,m_name,m_state from [tbl_vod] where m_name='"&titlecode&"'"
		set rs=cjdb.DB(sql,"rs1")
		
		if p_LzCodeType = 1 then
			lzfwcode = getBody(strViewCode,p_LzCodeStart,p_LzCodeEnd)
			lzcode = getBody(lzfwcode,p_LzStart,p_LzEnd)
		else
			lzcode = getBody(strViewCode,p_LzStart,p_LzEnd)
		end if
		lzcode = FilterScript(lzcode,p_script)
		lzcode = ReplaceStr(lzcode,"False","0")
		
		if isN(lzcode) then lzcode = 0
		if not isNum(lzcode) then lzcode=0
		
		if  not (rs.eof and rs.bof) then
			if lzcode = 0 then
				strdstate="true"
				writeA "<tr><td  colspan=""2"">【"&titlecode&"】遇到重复数据跳过采集!</td></tr>"
				exit sub
			end if
		end if
		cjdb.C(rs)
		
		if isN(p_HitsStart) or not isnum(p_HitsStart) then p_HitsStart = 0 
		if isN(p_HitsEnd)  or not isnum(p_HitsEnd) then p_HitsEnd = 0 
		if p_HitsStart =0 and p_HitsEnd = 0 then m_Hits = 0 else m_Hits = rndNum(p_HitsEnd,p_HitsStart)
		
		if p_StarringType = 1 then
			if ubound(starringarr) >= num  then starringcode = starringarr(num) else starringcode="未知"
		else
			starringcode = getBody(strViewCode,p_StarringStart,p_StarringEnd)
		end if
		
		if p_PicType = 1 then
			if ubound(picarr) >= num  then piccode = picarr(num) else piccode=""
		else
			piccode = getBody(strViewCode,p_PicStart,p_PicEnd)
		end if
		piccode = DefiniteUrl(piccode,strlink)
		
		if p_ClassType = 1 then
			typecode = FilterScript(getBody(strViewCode,p_TypeStart,p_TypeEnd),p_script)
			m_typeid = ChangeId(typecode,0,p_id)
		else
			typecode = p_Collect_Type
			m_typeid = p_Collect_Type
			typecodearr = getValueByArray(cachevodtype, typecode)
			typecode = typecodearr(1)
		end if
		if len(typecode) > 50 then typecode = left(typecode,50)
		
		starringcode = replaceStr(starringcode,"False","未知")
		starringcode = FilterScript(starringcode,p_script)
		if len(starringcode) > 255 then starringcode = left(starringcode,254)
		
		directedcode = getBody(strViewCode,p_DirectedStart,p_DirectedEnd)
		directedcode = replaceStr(directedcode,"False","未知")
		directedcode = FilterScript(directedcode,p_script)
		if len(directedcode) > 255 then directedcode = left(directedcode,254)
		
		remarkscode = getBody(strViewCode,p_RemarksStart,p_RemarksEnd)
		remarkscode = ReplaceStr(remarkscode,"False","")
		remarkscode = FilterScript(remarkscode,p_script)
		
		languagecode = getBody(strViewCode,p_LanguageStart,p_LanguageEnd)
		languagecode = ReplaceStr(languagecode,"False","未知")
		languagecode = FilterScript(languagecode,p_script)
		
		timecode = getBody(strViewCode,p_TimeStart,p_TimeEnd)
		timecode = FilterScript(timecode,p_script)
		timecode = trim(ReplaceStr(timecode,"False",now))
		if len(timecode) > 32 then timecode = left(timecode,32)
		
		areacode = getBody(strViewCode,p_AreaStart,p_AreaEnd)
		areacode = ReplaceStr(areacode,"False","未知")
		areacode = FilterScript(areacode,p_script)
		
		contentcode = getBody(strViewCode,p_ContentStart,p_ContentEnd)
		contentcode = ReplaceStr(contentcode,"False","未知")
		contentcode = FilterScript(contentcode,p_script)
		contentcode = replaceFilters(contentcode,p_id,2)
		
		if p_PlayCodeType = 1 then
			playcode = getBody(strViewCode,p_PlayCodeStart,p_PlayCodeEnd)
			if p_PlayLinkType >0 then
				weburl = getArray(playcode,p_PlayLinkStart,p_PlayLinkEnd)
			else
				weburl = getArray(playcode,p_PlayUrlStart,p_PlayUrlEnd)
			end if
			if p_SetNameType=3 then
				setnames = getArray(playcode,p_SetNameStart,p_SetNameEnd)
			end if
		else
			if p_PlayLinkType >0 then
				weburl = getArray(strViewCode,p_PlayLinkStart,p_PlayLinkEnd)
			else
				weburl = getArray(strViewCode,p_PlayUrlStart,p_PlayUrlEnd)
			end if
			if p_SetNameType=3 then
				setnames = getArray(strViewCode,p_SetNameStart,p_SetNameEnd)
			end if
		end if
		
		if p_ShowType=1 then
			writeA "<tr><td  colspan=""2"" align=""center"">此列表中第"&(num+1)&"条数据采集结果</td></tr><tr><td width=""20%"" >来源：</td><td >"&strlink&"</td></tr><tr><td >名称：</td><td >"&titlecode&" 连载:"&lzcode&" 备注:"&remarkscode&"</td></tr><tr><td >演员：</td><td >"&starringcode&"</td></tr><tr><td >时间：</td><td >"&timecode&"</td></tr><tr><td >分类：</td><td >"&typecode&"</td></tr><tr><td >地区：</td><td >"&areacode&"</td></tr><tr><td >语言：</td><td >"&languagecode&"</td></tr><tr><td  >图片：</td><td >"&piccode&"</td></tr><tr><td >介绍：</td><td >"&Left(contentcode,50)&".....</td></tr>"
			if p_SaveFiles = 1 then
				dim fileName,PathMov_Image,ranNum,file_name
				PathMov_Image = piccode
				randomize
				ranNum=int(90000*rnd)+20000
				file_name=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
				filename=file_name&".jpg"
				piccode = "uploadimg/vod/"& getSavePicPath & "/" & filename
				writeF "<tr><td width=""20%"" >自动下载图片：</td><td ><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_pic.asp?action=downpic&wjs=1&path=../"&piccode&"&url="&PathMov_Image&"""></iframe></td></tr>"
			end if
		else
			writeA "<tr><td  colspan=""2"" align=""center"">第"&(num+1)&"条数据采集结果</td></tr><tr><td width=""20%"" >来源：</td><td >"&strlink&"</td></tr><tr><td width=""20%"" >名称：</td><td >"&titlecode&" 连载:"&lzcode&" 备注:"&remarkscode&"</td></tr>"
		end if
		
		writeF ""
		
		
		if weburl = False Then
			writeA "<tr><td  colspan=""2"">在获取播放列表链接时出错</td></tr>"
			sb=sb+1
			exit sub
		else
			sql="select * from tbl_vod where m_urltest='"&strlink&"' "
			set rs=cjdb.DB(sql,"rs3")
		    if not rs.eof then
				cg=cg+1
				rs("m_type") = typecode
				rs("m_area") = areacode	
				rs("m_urlTest") = strlink
				rs("m_name") = titlecode
				rs("m_starring") = starringcode
				rs("m_directed") = directedcode
				rs("m_year")= timecode
				rs("m_content") = contentcode
				rs("m_addtime") = now()
				rs("m_zt") = 0
				rs("m_pid") = p_id
				rs("m_typeid") = m_typeid
				rs("m_playfrom") = p_PlayType
				rs("m_playserver") = p_server
				rs("m_state") = lzcode
				rs("m_remarks") = remarkscode
	            rs.update
				movieid=rs("m_id")
			else
				cg=cg+1
				rs.addnew
				rs("m_type") = typecode
				rs("m_area") = areacode
				rs("m_urlTest") = strlink
				rs("m_name") = titlecode
				rs("m_starring") = starringcode
				rs("m_directed") = directedcode
				rs("m_year")= timecode
				rs("m_pic")= piccode
				rs("m_playfrom") = p_PlayType
				rs("m_content") = contentcode
				rs("m_addtime") = now()
				rs("m_zt") = 0
				rs("m_pid") = p_id
				rs("m_typeid") = m_typeid
				rs("m_playserver") = p_Server
				rs("m_hits")= m_Hits
				rs("m_state") = lzcode
				rs("m_remarks") = remarkscode
				rs.update
				movieid=rs("m_id")
			end if
			cjdb.C(rs)
		
		dim Keyurl,urli,WebTest,WebTestx,url,rsurl,strTempUrl,urlcount,tmpA,tmpB,tmpC,setname,j,setnameArray
		
		webArray=Split(weburl,"$Array$")
		setnameArray=Split(setnames,"$Array$")
		For i=0 To Ubound(webArray)
			if p_PlaySpecialType = 1 and instr(p_PlaySpecialRrul,"[变量]") > 0 then
				WebTest =  SpecialLink(webArray(i),p_PlaySpecialRrul,p_PlaySpecialRerul)
				if WebTest=False then  Exit For
				WebTestx = DefiniteUrl(WebTest,strlink)
			else
				if p_PlayLinkType >0 then
					WebTestx=DefiniteUrl(webArray(i),strlink)
				else
					url=webArray(i)
				end if
			end if
			
			setname=""
			if p_PlayLinkType =1 then
			   playCode = getPage(WebTestx,p_Coding)
			   url = getBody(playCode,p_PlayUrlStart,p_PlayUrlEnd)
			elseif p_PlayLinkType = 2 then
				if isN(p_PlayUrlEnd) then
                	tmpA = InStr(WebTestx, p_PlayUrlStart)
                	url = right(WebTestx,len(WebTestx)-tmpA-len(p_PlayUrlStart)+1)
               	else
                	url = getBody(WebTestx,p_PlayUrlStart,p_PlayUrlEnd)
               	end if
            elseif p_PlayLinkType = 3 then
				playCode = getPage(WebTestx,p_Coding)
				tmpB = getArray(playCode,p_PlayUrlStart,p_PlayUrlEnd)
				tmpC = Split(tmpB,"$Array$")
				For j=0 To Ubound(tmpC)
					url = tmpC(j)
					url = replaceFilters(url,p_id,3)
					sql="SELECT tbl_vod_url.u_Url FROM (tbl_vod_url INNER JOIN tbl_vod ON tbl_vod_url.u_movieid = tbl_vod.m_id)  where tbl_vod_url.u_Url='" & url & "' and tbl_vod.m_pid=" & p_id
     		   		set rsurl= cjdb.DB(sql,"rs1")
			   		if rsurl.bof and rsurl.eof then
			   			strTempUrl = strTempUrl & url & "<br>"
					  	cjdb.DB "insert into tbl_vod_url(u_Url,u_movieid) values('"&url&"','"&movieid&"')","exe"
			   		end if
			   		cjdb.C(rsurl)
				next
				exit for
			end if
			
			   url = replaceFilters(url,p_id,3)
			   if p_SetNameType = 1 then
					setname = getBody(url,p_SetNameStart,p_SetNameEnd)
					url = setname & "$" & url
				elseif p_SetNameType = 2 and p_PlayLinkType = 1 then
					setname = getBody(playCode,p_SetNameStart,p_SetNameEnd)
					url = setname & "$" & url
			   elseif p_SetNameType=3 then
				    if ubound(setnameArray) >=i	then url = setnameArray(i) & "$" & url
			   end if
			   
			   sql="SELECT tbl_vod_url.u_Url FROM (tbl_vod_url INNER JOIN tbl_vod ON tbl_vod_url.u_movieid = tbl_vod.m_id)  where tbl_vod_url.u_Url='" & url & "' and tbl_vod.m_PID=" & p_id
     		   set rsurl= cjdb.DB(sql,"rs1")
			   if rsurl.bof and rsurl.eof then
				   if p_PlayLinkType = 1 then
					  strTempUrl = strTempUrl & url & "<br>"
					  url = replaceStr(url,"'","''")
					  cjdb.DB "insert into tbl_vod_url(u_Url,u_movieid,u_Weburl) values('"&url&"','"&movieid&"','"&WebTestx&"')","exe"
				   else
					  strTempUrl = strTempUrl & url & "<br>"
					  cjdb.DB "insert into tbl_vod_url(u_Url,u_movieid) values('"&url&"','"&movieid&"')","exe"
				   end if
			   end if
			   cjdb.C(rsurl)
		next
	end if

	end if
	
end sub

sub wtablehead
%>
<TABLE width="96%" border=0 align=center cellpadding="4" cellSpacing=1 class=tb>
<TBODY>
<%
end sub

sub wtablefoot
%>
</TBODY>
</TABLE>
<%
end sub

%>