<!--#include file="base.asp"-->
<%
''' EYCMS 视频
''' ==================================================================

	sub adddb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
		dim t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,timing
		dim o0,o1,o2,o3
		dim vtype
		dim s0,s1,s2,style,up,frist
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.ffpost("t3",1)
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.enhtml(eycms.fpost("t5",0))
		t6=eycms.enhtml(eycms.fpost("t6",0))
		t7=eycms.enhtml(eycms.fpost("t7",0))
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		t11=eycms.getint(eycms.fpost("t11",0),0)
		t12=eycms.getint(eycms.fpost("t12",0),0)
		t13=eycms.enhtml(eycms.fpost("t13",0))
		t14=eycms.enhtml(eycms.fpost("like",0))
		t15=eycms.enhtml(eycms.fpost("t15",0))
		t16=eycms.enhtml(eycms.fpost("t16",0))
		t17=eycms.enhtml(eycms.fpost("t17",1))
		t18=eycms.getint(eycms.fpost("t18",0),0)
		t19=eycms.enhtml(eycms.fpost("t19",0))
		t20=eycms.getint(eycms.fpost("t20",0),0)
		timing=eycms.getint(eycms.fpost("timing",0),0)
		s0=eycms.enhtml(eycms.fpost("c0",0))
		s1=eycms.enhtml(eycms.fpost("c1",0))
		s2=left(eycms.enhtml(eycms.fpost("s2",0)),7)
		up=eycms.getint(eycms.fpost("up",0),0)
		frist=eycms.getint(eycms.fpost("frist",0),0)
		t13=eycms.iif(isdate(t13),t13,now())
		if eycms.strlen(t14)=0 then t14="0"
		t14=replace(t14," ","")
		imgArr=t2
		o0=""
		o1=eycms.is_pic(t6)
		t6=eycms.iif(o1=0,"",t6)
		o2=t13
		o3=classid
		t1=replace(t1," ",",")
		t1=replace(t1,"　",",")
		t1=replace(t1,"，",",")
		t1=eycms.deal_strmid(t1,",")
		vtype=eycms.is_video(t2)
		if eycms.strlen(s2)>0 then s2="color:"&s2
		style=s0&s1&s2
		if eycms.strlen(style)>0 then style="style="""&style&""""
		if timing=1 then 
			if datediff("h",now(),t13)<1 then eycms.ajaxjson "发布时间必须是1小时之后",0:exit sub
			t9=0
		end if
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26631;&#39064;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t2)=0 then eycms.ajaxjson "&#35270;&#39057;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t19)>0 then
			if not(eycms.checkstr(t19,"urlname")) then
				eycms.ajaxjson "文件名称错误，不能包含特殊字符",0:exit sub
			end if
			if eycms.db.dbcount("ey_content","url='"&t19&"'")>0 then
				eycms.ajaxjson "文件名称已存在，请更换！",0:exit sub
			end if
		end if
		if up=1 then
			t3=eycms.deal_outfile(t3,array(0,1,adminid))
		end if
		if frist=1 and o1=0 then
			t6=eycms.get_frist_pic(t3)
			if t6="" then o1=0 else o1=1
		end If
		If eycms.strlen(t6)>0 Then imgArr=imgArr&","&t6
		if eycms.strlen(t17)=0 then t16=eycms.get_intro(t3) else t17=replace(t17,vbcrlf,"<br>")
		
		dim fstr:fstr=deal_model_field(modeid)
		
		deal_tags "",t1
		data=array(array("title",t0,255,1),array("tags",t1,255,1),array("keyword",t4,255,1),array("description",t5,255,1),array("pic",t6,255,1),array("hits",t8,10,0),array("islock",t9,1,0),array("isnice",t10,1,0),array("ontop",t11,1,0),array("iscomment",t12,1,0),array("createdate",fuckdate(t13),50,1),array("likeid",t14,0,1),array("style",style,0,1),array("ispic",o1,1,0),array("lastupdate",fuckdate(o2),50,1),array("classid",o3,0,0),array("isurl",0,1,0),array("comments",0,0,0),array("adminid",adminid,0,0),array("userid",t20,0,0),array("author",t15,50,1),array("comefrom",t16,50,1),array("intro",t17,0,1),array("timing",timing,1,0),array("point",t18,10,0),array("url",t19,255,1))
		eycms.db.insert "ey_content",data
		dim cid:cid=eycms.db.insertid("id","ey_content")		
		fstr="array(array(""cid"",cid,0,0),array(""content"",t3,0,1),array(""video"",t2,255,1),array(""playtime"",t7,50,1),array(""vtype"",vtype,50,1)"&fstr&")"
		
		eycms.db.insert "ey_model_video",eval(fstr)
		if eycms.strlen(t19)=0 then eycms.deal_content_url cid,o3
		imgArr = imgArr&","&eycms.getfilelist(t3)
		delall imgArr,cid,1
		eycms.ajaxjson cid&":保存成功",1
	end sub
	
	sub editdb()
		dim t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
		dim t10,t11,t12,t13,t14,t1_0,t15,t16,t17,t18,t19,t20,timing
		dim o0,o1,o2
		dim s0,s1,s2,style,up,frist
		dim id:id=eycms.getint(eycms.fget("id",0),0)
		dim vtype
		t0=eycms.enhtml(eycms.fpost("t0",0))
		t1=eycms.enhtml(eycms.fpost("t1",0))
		t1_0=eycms.enhtml(eycms.fpost("t1_0",0))
		t2=eycms.enhtml(eycms.fpost("t2",0))
		t3=eycms.ffpost("t3",1)
		t4=eycms.enhtml(eycms.fpost("t4",0))
		t5=eycms.enhtml(eycms.fpost("t5",0))
		t6=eycms.enhtml(eycms.fpost("t6",0))
		t7=eycms.enhtml(eycms.fpost("t7",0))
		t8=eycms.enhtml(eycms.fpost("t8",0))
		t9=eycms.getint(eycms.fpost("t9",0),0)
		t10=eycms.getint(eycms.fpost("t10",0),0)
		t11=eycms.getint(eycms.fpost("t11",0),0)
		t12=eycms.getint(eycms.fpost("t12",0),0)
		t13=eycms.enhtml(eycms.fpost("t13",0))
		t14=eycms.enhtml(eycms.fpost("like",0))
		t15=eycms.enhtml(eycms.fpost("t15",0))
		t16=eycms.enhtml(eycms.fpost("t16",0))
		t17=eycms.enhtml(eycms.fpost("t17",1))
		t18=eycms.getint(eycms.fpost("t18",0),0)
		t19=eycms.enhtml(eycms.fpost("t19",0))
		t20=eycms.getint(eycms.fpost("t20",0),0)
		timing=eycms.getint(eycms.fpost("timing",0),0)
		s0=eycms.enhtml(eycms.fpost("c0",0))
		s1=eycms.enhtml(eycms.fpost("c1",0))
		s2=left(eycms.enhtml(eycms.fpost("s2",0)),7)
		up=eycms.getint(eycms.fpost("up",0),0)
		frist=eycms.getint(eycms.fpost("frist",0),0)
		t13=eycms.iif(isdate(t13),t13,now())
		if eycms.strlen(t14)=0 then t14="0"
		t14=replace(t14," ","")
		imgArr=t2
		o0=""
		o1=eycms.is_pic(t6)
		t6=eycms.iif(o1=0,"",t6)
		o2=now()
	
		t1=replace(t1," ",",")
		t1=replace(t1,"　",",")
		t1=replace(t1,"，",",")
		t1=eycms.deal_strmid(t1,",")
		vtype=eycms.is_video(t2)
		if eycms.strlen(s2)>0 then s2="color:"&s2
		style=s0&s1&s2
		if eycms.strlen(style)>0 then style="style="""&style&""""
		if timing=1 then 
			if datediff("h",now(),t13)<1 then eycms.ajaxjson "发布时间必须是1小时之后",0:exit sub
			t9=0
		end if 
		if eycms.strlen(t0)=0 then eycms.ajaxjson "&#26631;&#39064;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t2)=0 then eycms.ajaxjson "&#35270;&#39057;&#19981;&#33021;&#20026;&#31354;",0:exit sub
		if eycms.strlen(t14)=0 then t14="0"
		if eycms.strlen(t19)>0 then
			if not(eycms.checkstr(t19,"urlname")) then
				eycms.ajaxjson "文件名称错误，不能包含特殊字符",0:exit sub
			end if
			if eycms.db.dbcount("ey_content","url='"&t19&"' and id<>"&id&"")>0 then
				eycms.ajaxjson "文件名称已存在，请更换！",0:exit sub
			end if
		end if
		if up=1 then
			t3=eycms.deal_outfile(t3,array(id,1,adminid))
		end if
		if frist=1 and o1=0 then
			t6=eycms.get_frist_pic(t3)
			if t6="" then o1=0 else o1=1
		end If
		If eycms.strlen(t6)>0 Then imgArr=imgArr&","&t6
		if eycms.strlen(t17)=0 then t16=eycms.get_intro(t3) else t17=replace(t17,vbcrlf,"<br>")
		
		dim fstr:fstr=deal_model_field(modeid)
		
		dim old_lock:old_lock=eycms.db.dbloadone("islock","ey_content","id="&id&"")
		deal_tags t1_0,t1
		data=array(array("classid",classid,0,0),array("title",t0,255,1),array("tags",t1,255,1),array("keyword",t4,255,1),array("description",t5,255,1),array("pic",t6,255,1),array("hits",t8,10,0),array("islock",t9,3,0),array("isnice",t10,1,0),array("ontop",t11,1,0),array("iscomment",t12,1,0),array("createdate",fuckdate(t13),50,1),array("likeid",t14,0,1),array("style",style,0,1),array("ispic",o1,1,0),array("lastupdate",fuckdate(o2),50,1),array("author",t15,50,1),array("userid",t20,0,0),array("comefrom",t16,50,1),array("intro",t17,0,1),array("timing",timing,1,0),array("point",t18,10,0),array("url",t19,255,1))
		eycms.db.dbupdate "ey_content","id="&id&"",data
		fstr="array(array(""content"",t3,0,1),array(""video"",t2,255,1),array(""playtime"",t7,50,1),array(""vtype"",vtype,50,1)"&fstr&")"
		eycms.db.dbupdate "ey_model_video","cid="&id&"",eval(fstr)
		if t9=1 and old_lock<0 then eycms.deal_user_publish_point id,""
		imgArr = imgArr&","&eycms.getfilelist(t3)
		delall imgArr,id,1
		eycms.ajaxjson id&":保存成功",1
	end sub
	
	islogin
	dim act:act=lcase(eycms.fget("act",0))
	dim classid:classid=eycms.getint(eycms.fget("classid",0),0)
	dim bclassid:bclassid=eycms.getint(eycms.fget("bclassid",0),0)
	If bclassid=0 Then bclassid=classid
	dim sta:sta=eycms.getint(eycms.fget("sta",0),0)
	dim nat:nat=eycms.getint(eycms.fget("nat",0),0)
	dim order:order=eycms.getint(eycms.fget("order",0),0)
	dim where:where=eycms.getint(eycms.fget("where",0),0)
	dim keyword:keyword=eycms.enhtml(eycms.fget("keyword",1))
	dim data
	dim catedata,catename,modeid,parentid,imgArr
	catedata=eycms.getclassdb(classid)
	if not isarray(catedata) then
		eycms.echo "&#26639;&#30446;&#19981;&#23384;&#22312;&#25110;&#24050;&#34987;&#21024;&#38500;"
		eycms.db.dbclose
		eycms.die
	end if
	catename=catedata(1)
	modeid=catedata(10)
	parentid=catedata(6)

	dim rootid,parents
	parents=catedata(6)
	rootid=split(parents,"]")(0)
	rootid=replace(rootid,"[","")
	rootid=CInt(rootid)

	dim field_data:field_data=eycms.get_model_field(modeid)
	dim editor_int:editor_int=""
	dim editor_get:editor_get=""
	if isarray(field_data) then
		dim ei
		for ei=0 to ubound(field_data,2)
			if field_data(2,ei)=6 then
				editor_int=editor_int&"UE.getEditor('"&field_data(0,ei)&"',editorOption);"
				editor_get=editor_get&"UE.getEditor('"&field_data(0,ei)&"').sync();"
				editor_get=editor_get&"$(""#"&field_data(0,ei)&""").val(UE.getEditor('"&field_data(0,ei)&"').getContent());"
			end if
		next
	end if
	dim theme_content_add:theme_content_add=catedata(26)
	dim theme_content_edit:theme_content_edit=catedata(27)
	dim theme_content_publish:theme_content_publish=catedata(28)
	select case act
		case "add":checkcateaction(1):load theme_content_add
		case "adddb":checkcateaction(1):adddb
		case "edit","publish"
			checkcateaction(2)
			dim id:id=eycms.getint(eycms.fget("id",0),0)
			dim filed,likeid
			filed="title,keyword,description,pic,hits,islock,isnice,ontop,iscomment,createdate,likeid,style,tags,author,comefrom,point,url,userid,intro,timing"'0-19
			data=eycms.db.dbload(1,filed,"ey_content","classid="&classid&" and id="&id&"","")
			likeid=data(10,0)
			dim rsshow
			set rsshow=eycms.db.exedb("select top 1 * from ey_model_video where cid="&id&"")
			if rsshow.eof then
				eycms.echo "参数错误":eycms.die
			end if
			load eval ("theme_content_"&act)
		case "editdb":checkcateaction(1):editdb
	end select
	eycms.db.dbclose
%>
