<!--#include file="QvodCms_Conn.asp"-->
<!--#include file="QvodCms_Check.asp"-->
<%
dim action,reurl,elite_id,maxid,name_id,class_id,server_id,data_name,data_actor,data_director,data_erea,data_elite,data_hits,data_status,data_picurl,data_intro,data_inputer,data_lastdate,data_color,data_picsmall,LianZai,data_vip,data_cu,dataping,data_playpath,data_playurl,data_year,data_language,data_continu
reurl=Request.ServerVariables("Http_Referer")'来源地址
If reurl="" Then reurl="qvodcms_data.asp"
action=Trim(Request.QueryString("action"))
name_id=Clng(Request.QueryString("name_id"))&Trim(Request.QueryString("data_id"))'影片ID
class_id=Cint(Request.form("class_id")) '所属栏目
data_name=Left(Request.form("data_name"),255)'影片名称
data_actor=Left(Request.form("data_actor"),255)'领衔主演
data_director=Left(Request.form("data_director"),255)'影片导演
data_inputer=Left(Request.form("data_skin"),255)'影片模板
data_erea=Trim(Request.form("data_erea"))'影片产地
data_elite=Cint(Request.form("data_elite"))'影片推荐,0,1
data_lastdate=Cint(Request.form("data_lastdate"))'是否更新时间,0,1
data_hits=Clng(Request.form("data_hits"))'影片热门
data_status=Cint(Request.form("data_status"))'影片审核,0,1
data_picurl=Trim(Request.form("data_bigpic"))'影片大图片
data_picsmall=Trim(Request.form("data_smallpic"))'影片大图片
data_intro=Trim(Request.form("data_intro"))'影片简介
elite_id=Cint(Request.QueryString("elite_id"))'是否推荐或是否审核值1,0
data_year=Clng(Request.form("data_year")) '影片年份
data_language=Trim(request.form("data_language")) '影片语种
LianZai=Trim(Request.form("LianZai")) '是否连载(0/1)
data_color=Trim(Request.form("data_color")) '标题颜色
data_vip=Cint(Request.form("data_vip"))'会员影片,0,1
data_cu=Cint(Request.form("data_cu"))'标题加粗,0,1
dataping=Left(Trim(Request.form("dataping")),10)'汉字拼音转换
data_playpath=Trim(Request.Form("data_playpath"))'所有播放来源组
data_playurl=Trim(Request.Form("data_playurl"))'所有播放地址
data_playurl=transferUrl(data_playpath,data_playurl)
data_playpath=trimOuterStr(data_playpath,",")
data_playpath = Replace(data_playpath,", ","$$")

Call OpenConn()
Select Case action
Case "add"
	Call Data_Add
Case "edit"
	Call Data_Edit
Case "del"
    Call Data_Del
Case "elite"
    Call Data_Eli
Case "status"
    Call Data_Sta
Case Else
    Call QvodCms_Err("参数不正确！")	
End Select
Call CloseConn()

Sub Data_Add '作用:入库新的影片信息
    If data_name=""  Then 
	    Call QvodCms_Err("影片名称不能为空！")
	    Response.End
    ElseIf data_actor=""  Then
	    Call QvodCms_Err("主演不能为空！")
	    Response.End	
    End if
	Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from qvodcms_name "
	rs.Open sql, Conn, 1, 3
	rs.AddNew
	rs("class_id")=class_id
	rs("data_name")=data_name
	rs("data_actor")=data_actor
	rs("data_director")=data_director
	rs("data_inputer")=data_inputer
	rs("data_erea")=data_erea
	If Cint(AdminId(4))=1 And Instr(data_picurl,"http://")>0 Then'判断远程图片本地化
		rs("data_picbig")=GetPicurl(data_picurl,"../"&AdminId(13))
		If Cint(AdminId(6))=1 Then 
		rs("data_picsmall")=GetPicurll(data_picsmall,"../"&AdminId(13))
		End if
	Else
	    rs("data_picbig")=data_picurl
		rs("data_picsmall")=data_picsmall
	End If
	rs("data_intro")=data_intro
	rs("data_lastdate")=now()
	rs("data_hits")=10
	rs("data_status")="1"
	rs("data_elite")=data_elite
	rs("data_year")=data_year
	rs("data_language")=data_language
	rs("data_continu")=data_continu
	rs("data_color")=data_color
	rs("data_vip")=data_vip
	rs("data_cu")=data_cu
	rs("data_ping")=dataping
	rs("data_py")=getpyin(data_name)'汉字拼音转换
	rs("data_playpath")=Trim(data_playpath)
	rs("data_playurl")=data_playurl
	rs.update
	rs.Close:Set rs=nothing
	'Call QvodCms_Err_Url("影片信息录入成功，确定返回数据列表！","qvodcms_data.asp")
	Response.Redirect("qvodcms_data.asp")

End sub

Sub Data_Edit '作用:编辑影片信息
    If data_name=""  Then 
	    Call QvodCms_Err("影片名称不能为空！")
	    Response.End
    ElseIf data_actor=""  Then
	    Call QvodCms_Err("主演不能为空！")
	    Response.End	
    End if
    Set rs = Server.CreateObject("adodb.recordset")
	sql = " select * from qvodcms_name where name_id="&name_id&" "
	rs.Open sql, Conn, 1, 3
	If Not (rs.bof And rs.eof) Then 
		rs("class_id")=class_id
		rs("data_name")=data_name
		rs("data_actor")=data_actor
		rs("data_director")=data_director
		rs("data_inputer")=data_inputer
		rs("data_erea")=data_erea	
	    rs("data_picbig")=data_picurl
		If Cint(AdminId(6))=1 Then
	    rs("data_picsmall")=data_picsmall
		End If
		rs("data_intro")=data_intro
		rs("data_status")=data_status
		If data_lastdate=1 Then
		rs("data_lastdate")=now()
		End If
		If data_hits>0 Then
		rs("data_hits")=data_hits
		End If
		if LianZai<>"" Then
		rs("data_reurl")=LianZai
		End If
		rs("data_year")=data_year
		rs("data_language")=data_language
		rs("data_continu")=data_continu		
		rs("data_color")=data_color
		rs("data_elite")=data_elite
		rs("data_vip")=data_vip
	    rs("data_cu")=data_cu
		rs("data_ping")=dataping
		rs("data_py")=getpyin(data_name)'汉字拼音转换
		rs("data_playpath")=Trim(data_playpath)
	    rs("data_playurl")=data_playurl
		rs.update
	End if
	rs.Close:set rs=nothing
	'Call QvodCms_Err_Url("修改成功，确定返回数据列表！","qvodcms_data.asp")
	Response.Redirect("qvodcms_data.asp")
End Sub

Sub Data_Del '作用:删除影片信息 
    Set rs_d=conn.execute(" select class_id,name_id,data_picbig,data_picsmall,data_py from qvodcms_name where name_id="&name_id&" ")
	If Not(rs_d.bof and rs_d.eof)  Then
		If Not(rs_d.bof and rs_d.eof)  Then
		
		      If Not(Instr(rs_d("data_picbig"),"http://")>0 Or LCase(rs_d("data_picbig"))="images/nopic.gif") Then Call DelHtml ("../"&rs_d("data_picbig")&""):Call DelHtml ("../"&rs_d("data_picsmall")&"")'删除图片
		  
		      If Config(17)="html" Then
		     StrPath=GetDataLink(rs_d("class_id"),rs_d("name_id"),rs_d("data_py")):If Config(0)<>"/" Then StrPath=Replace(StrPath,Config(0),"/")
		      If Config(23)="4" Then Call DelFolder(".."&StrPath) Else Call DelHtml(".."&StrPath) End If
		      End If
			  
	    End If
	End If
    rs_d.close:Set rs_d=Nothing
    conn.execute(" delete from qvodcms_name where name_id="&name_id&" ")'删除影片信息
	Call CloseConn
	Response.Redirect(reurl)
End Sub

Sub Data_Eli '作用:推荐影片
    If elite_id<>1 then elite_id=0  
    Set rs = Server.CreateObject("adodb.recordset")
	sql = " select name_id,data_elite from qvodcms_name where name_id="&name_id&" "
	rs.Open sql, Conn, 1, 3
	If Not (rs.bof And rs.eof) Then 
		rs("data_elite")=elite_id
		rs.update
	Else
	    Call QvodCms_Err_Url("没有查询到你要编辑的影片！")
		Response.End
	End if
	rs.Close
	set rs=nothing
	response.Redirect(reurl)
End Sub

Sub Data_Sta '作用:审核影片
    If elite_id<>1 then elite_id=0  
    Set rs = Server.CreateObject("adodb.recordset")
	sql = " select name_id,data_status from qvodcms_name where name_id="&name_id&" "
	rs.Open sql, Conn, 1, 3
	If Not (rs.bof And rs.eof) Then 
		rs("data_status")=elite_id
		rs.update
	Else
	    Call QvodCms_Err_Url("没有查询到你要编辑的影片！")
		Response.End
	End if
	rs.Close
	set rs=nothing
	response.Redirect(reurl)
End Sub

%>