<!--#include file="../inc/conn.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电影保留此软件的法律追究权利；
'==========================================================================================
%>

<%
    Dim ID,ID1,ID2,currentid,currentnum,currentsrc
	if app_viewtype=0 or app_makeplay=0 Then
		ID = Request.ServerVariables("QUERY_STRING") 
		ID1 = Replace(ID,"."&app_htmlSuffix&"","")
		ID2 = Split(ID1,",")
		currentid= ID2(0)
		currentsrc= ID2(1)
		currentnum= ID2(2)
	else 
		response.Redirect("../index.asp")
	end if
	
	If isN(currentid) or isN(currentnum) or isN(currentsrc)  then
	  ShowMsg "请勿传递非法参数！","../index.asp"
	end if
	
	If not isNum(currentid) or not isNum(currentnum) or not isNum(currentsrc)  then
	  ShowMsg "请勿传递非法参数！","../index.asp"
	end if
	
Dim rs : Set rs = Database.GetRecordDetail("tbl_datas","D_ID=" & currentid &"")  
if rs.eof then ShowMsg "找不到此ID的影片!","index.asp"
currenttypeid =  rs("d_type")
dim D_Stint : D_Stint = rs("D_Stint")

if D_Stint > 0 then
dim userid
	if app_loginmemory = 1 then
		if md5(session("loginverifycode")&session("username")&session("userid"))<>session("logincheck") then
			alerturl "该影片属于收费影片,需要"&D_Stint&"个积分才能观看，请您先登陆","../user/?action=login&url="&GetUrl()
			writeend ""
		end if
		userid = session("userid")
	else
		if  md5(request.cookies("loginverifycode")&request.cookies("username")&request.cookies("userid"))<>request.cookies("logincheck") then
			alerturl "该影片属于收费影片,需要"&D_Stint&"个积分才能观看，请您先登陆","../user/?action=login&url="&GetUrl()
			writeend ""
		end if
		userid = request.cookies("userid")
	end if
	
Dim rsuser : Set rsuser = Database.GetRecordDetail("Tbl_User",array("U_ID:" & userid))  
if rsuser.eof then 
		alert "用户名或密码不正确!"
else
dim U_Points : U_Points = rsuser("U_Points")
dim U_PlayRecords : U_PlayRecords = rsuser("U_PlayRecords")
dim stat : stat =false

if U_Points < D_Stint then
	if not isN(U_PlayRecords) then
		if instr(U_PlayRecords,","&currentid&",") > 0 then stat = true
	end if
	if not stat then alerturl "对不起,您的积分不够，无法观看收费影片，请推荐本站给您的好友、赚取更多积分","../user/?action=earnpoints":writeend ""
else
 if isN(U_PlayRecords) then
 	 DataBase.UpdateRecord "Tbl_User","U_ID = "& userid ,Array("U_Points:"&U_Points&"-"&D_Stint,"U_PlayRecords:,"&currentid&",")
 else
 	if instr(U_PlayRecords,","&currentid&",") > 0 then stat = true
	if not stat then
		U_PlayRecords = U_PlayRecords & currentid & ","
		DataBase.UpdateRecord  "Tbl_User","U_ID = "& userid ,Array("U_Points:"&U_Points&"-"&D_Stint,"U_PlayRecords:"&U_PlayRecords)
	end if
 end if
end if
Database.C(rsuser)
end if
end if

	Dim Filepath : Filepath= app_installdir&"template/"&app_templatedir&"/"&app_htmldir&"/play.html"
	
	TemplateOBJ.html = CacheOBJ.loadFileOnCache("template_",Filepath)
	TemplateOBJ.replaceLabel()
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:id]",rs("d_id"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typeid]",rs("d_type"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:name]",getData(rs("d_name")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:colorname]",getColorName(getData(rs("d_name")),getData(rs("d_color"))))
	
	Dim d_pic
	d_pic = getData(rs("d_pic"))
	if inStr(d_pic,"http://") <=0 then d_pic = app_installdir&getData(rs("d_pic"))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:pic]",d_pic)
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:starring]",getData(rs("d_starring")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:directed]",getData(rs("d_directed")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:hit]",rs("d_hits"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:des]",getData(rs("D_Content")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:time]",getData(rs("d_AddTime")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:level]",rs("D_Level"))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:state]",getData(rs("D_state")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:year]",getData(rs("D_year")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:source1]",getData(rs("D_Source1")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:source2]",getData(rs("D_Source2")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:stint]",getData(rs("D_Stint")))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[playinfo:num]",currentnum + 1)
	TemplateOBJ.html = replace(TemplateOBJ.html,"[playinfo:info]",getPlayInfo(getData(rs("D_Source1")),getData(rs("D_PlayUrl1")),getData(rs("D_Source2")),getData(rs("D_PlayUrl2"))))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[playinfo:player]",getPlayer())
	TemplateOBJ.html = replace(TemplateOBJ.html,"[playinfo:playerlist]",getPlayerList(currentsrc,getData(rs("D_PlayUrl"&currentsrc)),rs("d_id"),currentnum))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:playurl1]",getPlayUrlList(1,getData(rs("D_PlayUrl1")),rs("d_id")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:playurl2]",getPlayUrlList(2,getData(rs("D_PlayUrl2")),rs("d_id")))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:link]",getViewLink(rs("d_type"),rs("d_id")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typelink]",getTypeLink(rs("d_type")))
	
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:typename]",getDicName("tbl_type","t_name","t_id",rs("d_type")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:language]",getDicName("Tbl_Language","l_name","l_id",rs("D_Language")))
	TemplateOBJ.html = replace(TemplateOBJ.html,"[movieinfo:area]",getDicName("Tbl_Area","a_name","a_id",rs("D_Area")))
	
	Database.C(rs)
	TemplateOBJ.replaceComment(currentid)
	response.Write TemplateOBJ.html
	
%>