<!--#include file="../inc/conn.asp" -->
<%
	dim id,query,ID1,ID2,curnum,cursrc
	
	if app_vodplayviewtype=0 or app_vodplayviewtype=2 Then
		query = Request.ServerVariables("QUERY_STRING") 
		ID1 = ReplaceStr(query,"."&app_vodsuffix&"","")
		ID2 = Split(ID1,"-")
		if ubound(ID2)<>2 then showMsg "请勿传递非法参数！","../index.asp"
		id= ID2(0)
		cursrc= ID2(1)
		curnum= ID2(2)
	elseif app_vodplayviewtype=1 then
		id= be("get","id")
		cursrc= be("get","sort")
		curnum= be("get","num")
	else
		
	end if
	
	if not isNum(id) or not isNum(curnum) or not isNum(cursrc)  then  showMsg "请勿传递非法参数！","../"
	
	dim sql,rs,userid,typearr,userpoint
	sql = "SELECT * FROM {pre}vod WHERE d_hide=0 and d_id="& id
	Set rs = objdb.db(sql,"rs1")
	if rs.eof and rs.bof then showMsg "请勿传递非法参数","../"
	curvodid = clng(id)
	curvodtypeid = rs("d_type")
	userid = session("userid")
	
	if app_user=1 then
		if not getUserPopedom(rs("d_type"),"play") then showMsg "您没有权限浏览此栏目下的内容,请联系管理员获取权限!","../user/"
		if rs("d_stint") > 0 and isN(userid) then alertUrl "此为收费数据请先登录再操作","../user/" : writeE ""
		
		if not isN(userid) then
			dim rsuser : Set rsuser = objdb.DB("SELECT * FROM {pre}user where u_id="&userid,"rs1")
			if not (rsuser.eof and rsuser.bof) then
				dim str,playrecords,stat : stat =false
				userpoint = rsuser("u_points")
				if rsuser("u_flag") = 1 then
					if date<=CDate(rsuser("u_start")) and date>=CDate(rsuser("u_end")) then
						str = "对不起,您的会员时间已经到期,请联系管理员续费!"
					end if
				elseif rsuser("u_flag") = 2 then
					dim ip11,ip12,ip13,ip14,ip21,ip22,ip23,ip24,ip31,ip32,ip33,ip34,ip1arr,ip2arr,ip3arr
					ip1arr = split(U_IP,".") : ip2arr=split(rsuser("u_start"),".") : ip3arr=split(rsuser("u_end"),".")
					if ip1arr(0) >= ip2arr(0) and  ip1arr(0) <= ip3arr(0)  then stat = true else stat =false
					if ip1arr(1) >= ip2arr(1) and  ip1arr(1) <= ip3arr(1)  then stat = true else stat =false
					if ip1arr(2) >= ip2arr(2) and  ip1arr(2) <= ip3arr(2)  then stat = true else stat =false
					if ip1arr(3) >= ip2arr(3) and  ip1arr(3) <= ip3arr(3)  then stat = true else stat =false
					if not stat then str =  "对不起,您登录IP段不在受理范围，请联系管理员续费!"
				else
					if rsuser("u_points") < rs("d_stint") then
						if instr(rsuser("u_plays"),","&curvodid & "-" & cursrc & "-" & curnum&",") > 0 then stat = true
						if not stat then str = "对不起,您的积分不够，无法观看收费数据，请推荐本站给您的好友、赚取更多积分"
					end if
					userpoint = rsuser("u_points") - rs("d_stint")
				end if
				
				if not isN(str) then alertUrl str,"../user/" : writeE ""
				if instr(","&rsuser("u_plays"),","&curvodid&",") > 0 then stat = true
				
				if not stat then
					playrecords = "," & rsuser("u_plays") & curvodid & "-" & cursrc & "-" & curnum & ","
					playrecords = replace(playrecords,",,",",")
					objdb.Update "{pre}user" ,Array("u_points","u_plays"),Array(userpoint,playrecords),"u_id="&userid
				end if
				
			end if
			objdb.C(rsuser)
		end if
	end if
	typearr = getValueByArray(cachevodtype, rs("d_type"))
	objTemplate.loadvod rs,typearr,"play"
	writeA objTemplate.html
	dispseObj()
%>