<!-- #include file="include/admin_onlogin.asp" -->
<!-- #include file="include/jk_code.asp" -->
<!-- #include file="include/con_video_class.asp" -->
<%
del_user_true=true
del_upload_true=true
index_url="video"
call admin_master(1,0)
call admin_cid_sid()
call admin_header(0,0)
select case jk_mod
case "istop"
  ntit="推荐"&tit_fir
  sql_add=" where hidden=1 and star>=5"
case "isfree"
  ntit="免费"&tit_fir
  sql_add=" where isfree=1"
case "sh"
  ntit="待审核"&tit_fir
  sql_add=" where hidden=0"
case else
  jk_mod=""
  ntit=tit_fir&"列表"
  sql_add=" where hidden=1"
end select
%>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?'><%response.write tit_fir%>列表</a></td>
  <td width=10></td>
  <td><a href='?jk_mod=isfree'<%if jk_mod="isfree" then response.write " class=red"%>>免费<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?jk_mod=istop'<%if jk_mod="istop" then response.write " class=red"%>>推荐<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?jk_mod=sh'<%if jk_mod="sh" then response.write " class=red"%>>待审核<%response.write tit_fir%></a></td>
  <td width=10></td>
  <td><a href='?action=add&c_id=<%response.write cid%>&s_id=<%response.write sid%>'<%if action="add" then response.write " class=red"%>>添加<%response.write tit_fir%></a></td>
<%call joekoe_is_nsort_review()%>
  </tr>
  </table>
</td></tr>
<tr><td align=center colspan=2 height=30>
  <table border=0>
  <tr>
  <td><a href='?action=style'<%if action="style" then response.write " class=red"%>>影院模板管理</a></td>
  <td width=10></td>
  <td><a href='?action=buy'<%if action="buy" then response.write " class=red"%>>购卡用户管理</a></td>
  <td width=10></td>
  <td><a href='?action=setup'<%if action="setup" then response.write " class=red"%>><%response.write tit_fir%>参数配置</a></td>
  <td width=10></td>
  <td><a href='?action=cons'<%if action="cons" then response.write " class=red"%>><%response.write tit_fir%>服务器批量修改</a></td>
  <td width=10></td>
  <td><a href='?action=cache'<%if action="cache" then response.write " class=red"%>>重建缓存</a></td>
  </tr>
  </table>
</td></tr>
<tr><td colspan=2 align=center>
  <table border=0 cellspacing=0 cellpadding=2>
  <form action='?' method=get>
  <input type=hidden name=jk_mod value='<%response.write jk_mod%>'>
  <input type=hidden name=c_id value='<%response.write cid%>'>
  <tr>
  <td>搜索（<%response.write ntit%>） 关键字：</td>
  <td><input type=text name=keyword value='<%response.write trim(request.querystring("keyword"))%>' size=15 maxlength=20></td>
  <td><select name=sea_type size=1>
<option value='name'>按<%response.write tit_fir%>名</option>
<option value='username'>按发布人</option>
</select></td>
  <td><select name=sea_term sizs=1><option value='all'>满足所有条件</option><option value='only'>满足一个条件</option></seelct></td>
  <td><input type=submit value='搜索'></td>
  </tr>
  </form>
  </table>
</td></tr>
</table>
<%
if action="setup" or action="buy" or action="style" then
  call admin_table(1,0)
else
  call admin_table(1,1)
end if

select case action
case "cache"
  call video_skin.video_skin_del()
  response.write joekoe_cms.js_put("alert(""清除所有缓存成功！\n\n点击返回……"");location.href='?';",1)
case "clear"
  call video_skin.cache_del("scroll")
  call video_skin.cache_del("counter")
  call joekoe_go_clear()
case "delurl"
  call movie_del()
case "setup"
  call video_setup()
case "cons"
  call video_cons()
case "add"
  call video_add()
case "edit"
  call video_edit()
case "buy"
  call video_buys()
case "buyedit"
  call video_buyedit()
case "edit_style"
  call video_style_edit()
case "set"
  call video_style_setup()
case "del"
  call video_style_del()
case "copy"
  call video_style_copy()
case "style"
  call video_style_main()
case "handle"
  call video_skin.cache_del("scroll")
  call video_skin.cache_del("counter")
  call joekoe_go_handle()
case else
  call video_main()
end select

set video_skin=nothing
call admin_ender(1)

'----------------影片操作 开始------------
sub video_main()
  dim name,star,pageurl2
  pageurl2=pageurl
  call sql_cid_sid(sql_add)
  call format_search("name","name,username",2,1)
%>
<tr valign=top align=center>
<td>
  <table class=table2>
  <tr><td><%response.write img_admin("s_left_sort","")%> <a href='?jk_mod=<%response.write jk_mod%>'><%response.write ntit%></a></td></tr>
  <tr><td height=5></td></tr>
  <tr><td class=htd>
  <%call left_sort(pageurl2,"")%></td></tr>
  </table>
</td>
<td>
  <table cellspacing=1 cellpadding=3 class=table0>
<form name=sel_form action='?jk_mod=<%response.write jk_mod%>&action=handle&c_id=<%response.write cid%>&s_id=<%response.write sid%>' method=post>
<tr align=center>
<td class=td width='7%'>序号</td>
<td class=td width='66%'><%response.write tit_fir%>标题及整理时间<%if sql_tmp<>"" then response.write "（搜索结果："&keyword&"）"%></td>
<td class=td width='22%'>相关属性</td>
<td class=td width='5%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
</tr>
<%
  sql="select count(id) from "&data_name&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" id,name,tim,star,hidden from "&data_name&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    id=rs("id")
    name=rs("name")
    star=rs("star")
%>
<tr align=center>
<td class=tims><a href='<%response.write index_url%>_view.asp?id=<%response.write id%>' target=_blank><%response.write (viewpage-1)*nummer+i%></a></td>
<td>
  <table border=0 cellspacing=0 cellpadding=0 width='100%'>
  <tr>
  <td><a href='?jk_mod=<%response.write jk_mod%>&action=edit&id=<%response.write id%>'><%response.write joekoe_cms.code_html(name,1,(22+tnum))%></a></td>
  <td align=right><font class=tims><%response.write joekoe_cms.time_type(rs("tim"),4)%></font></td>
  </tr>
  </table>
</td>
<td align=left><%
    response.write pro_edit("?jk_mod="&jk_mod&"&action=edit&id="&id,"编辑该"&tit_fir) &"&nbsp;"& pro_hidden(rs("hidden"),1) &"&nbsp;"
    if int(star)<1 then
      response.write "<font class=gray>没有等级</font>"
    else
      response.write "&nbsp;<font class=red>"&star&"</font> 星级"
    end if
    if int(star)>=5 then response.write "&nbsp;"& pro_istop(1)
%></td>
<td><input type=checkbox name=sel_id value='<%response.write id%>'></td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=2>
现有<font class=red><%response.write rssum%></font>个<%response.write tit_fir%>，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
<td colspan=2 align=center>
执行
<select name=sel_type size=1>
<option value='审核'>审核</option>
<option value='待审核'>待审核</option>
<option value='删除'>删除</option>
</select>
<input type=submit value='操作' onclick="return sel_click(this.form);">
</td>
</tr>
</form>
  </table>
</td>
</tr>
<%
end sub

sub movie_del()
  dim vid,vsum
  vid=trim(request.querystring("vid"))
  if not isnumeric(vid) then vid=0
  sql="select count(id) from video_url where nameid="&id
  set rs=joekoe_cms.exec(sql,1)
    vsum=rs(0)
  rs.close
  if vsum=1 then
    call admin_msg("无法删除唯一的 "&tit_fir&" 地址数据！","?action=edit&id="&id,1)
  else
  sql="select top 1 * from video_url where id="&vid&" and nameid="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(tit_fir&"地址ID（"&vid&"）不存在！","?",1)
    exit sub
  end if
  call joekoe_cms.exec("delete from video_url where id="&vid,0)
  call admin_msg("已成功删除 "&tit_fir&" 地址数据！","?action=edit&id="&id,1)
  end if
end sub

sub video_edit()
  dim pic,no,url,urlname,vid,ispic,username,hidden,tim,remark,whe,role,name
  dim power,emoney,counter,star,lang,newno,videoserver,isfree,viewtype,vsize
  call admin_td("编辑"&tit_fir)
  sql="select count(id) from video_url where nameid="&id
  set rs=joekoe_cms.exec(sql,1)
  if not rs.eof then
    no=int(rs(0))
  else
    no=0
  end if
  rs.close
  sql="select top 1 * from "&data_name&" where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(tit_fir&"ID（"&id&"）不存在！","?",1)
    exit sub
  end if
  if chk() then
	newno=trim(request.form("newno"))
	if newno<>"" or isnull(newno) then
	  newno=int(newno)
	else
	  newno=int(no)
	end if
    name=code_admin("name",1,50)
    csid=trim(request.form("c_id"))
	videoserver=trim(request.form("videoserver"))
	if not int_true(videoserver) then videoserver=0
    if cs_nd(csid)=false then
      call admin_error("请选择 "&tit_fir&"类型 ！")
      exit sub
    end if
    if name="" then
      call admin_error(tit_fir&"标题 不能为空！")
      exit sub
    end if
    for i=1 to newno
      url=code_admin("url"&i&"",1,255)
      if url="" or isnull(url) then
        call admin_error(tit_fir&"地址"&i&" 不能为空！")
        exit sub
      end if
      if videoserver>0 and instr(url,"://")<>0 then
        call admin_error("本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器相对路径！")
        exit sub
      end if
      if videoserver=0 and instr(url,"://")<1 then
        call admin_error("非本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器绝对路径！")
        exit sub
      end if
      urlname=code_admin("urlname"&i&"",1,20)
      if urlname="" or isnull(urlname) then
        call admin_error(tit_fir&"名称"&i&" 不能为空！")
        exit sub
      end if
    next
    whe=code_admin("whe",1,20)
    remark=request.form("remark")
    role=code_admin("role",1,100)
    power=code_admin("power",1,50)
    power=replace(power," ","")
    power=replace(power,",",".")
    emoney=trim(request.form("emoney"))
    if not isnumeric(emoney) then emoney=0
    pic=code_admin("pic",1,100)
	username=code_admin("username",1,20)
    if symbol_name(username)=false then username=login_username
    tim=code_admin("tim",1,20)
    tim=joekoe_cms.time_type(tim,1)
    if tim="" then tim=joekoe_cms.now_time
	counter=trim(request.form("counter"))
    if not isnumeric(counter) then counter=0
	star=trim(request.form("star"))
    if not isnumeric(star) then star=1
	viewtype=trim(request.form("viewtype"))
    if not isnumeric(viewtype) then viewtype=1
    hidden=true
    if trim(request.form("hidden"))="yes" then hidden=false
    isfree=false
    if trim(request.form("isfree"))="yes" then isfree=true
    call chk_cid_sid()
    rs("c_id")=cid
	rs("s_id")=sid
	rs("genre")=code_admin("genre",1,10)
	rs("name")=name
	rs("username")=username
	rs("lang")=code_admin("lang",1,10)
	rs("whe")=whe
	rs("remark")=remark
	rs("role")=role
	rs("hidden")=hidden
	rs("emoney")=emoney
	rs("power")=power
	rs("star")=star
	rs("viewtype")=viewtype
	rs("types")=code_admin("types",1,10)
	rs("pic")=pic
	rs("tim")=tim
	rs("counter")=counter
	rs("isfree")=isfree
	rs("server_id")=videoserver
    rs.update
    vid=rs("id")
    rs.close
	sql="select * from video_url where nameid="&vid
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
	for i=1 to no
		url=code_admin("url"&i&"",1,255)
		urlname=code_admin("urlname"&i&"",1,20)
		vsize=0
		if trim(request.form("vsize"&i))="yes" then vsize=1
		rs("nameid")=vid
		rs("url")=url
		rs("urlname")=urlname
		rs("video_size")=vsize
		rs.update
		rs.movenext
	next
	if newno<>no then
	  for i=no+1 to newno
		rs.addnew
		url=code_admin("url"&i&"",1,255)
		urlname=code_admin("urlname"&i&"",1,20)
		vsize=0
		if trim(request.form("vsize"&i))="yes" then vsize=1
		rs("nameid")=vid
		rs("url")=url
		rs("urlname")=urlname
		rs("video_size")=vsize
		rs.update
		rs.movenext
	  next
	end if
	rs.close
    call upload_note(index_url,id)
    call video_skin.cache_del("scroll")
    call video_skin.cache_del("counter")
    call admin_msg("已成功编辑了一个"&tit_fir&"！","?jk_mod="&jk_mod&"&c_id="&cid&"&s_id="&sid,0)
    exit sub
  end if
  call form_first()
  cid=rs("c_id")
  sid=rs("s_id")
  star=int(rs("star"))
  lang=rs("lang")
  whe=rs("whe")
  videoserver=rs("server_id")
  remark=joekoe_cms.code_word(rs("remark"))
  pic=rs("pic")
  ispic=apart_filename(pic,1,"/")
  if ispic="" then ispic=joekoe_cms.rand_file(index_url)
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&c_id=<%response.write cid%>&s_id=<%response.write sid%>&action=edit&id=<%response.write id%>' method=post>
<input type=hidden name=chk value='yes'>
<input type=hidden name=upid value=''>
<tr>
<td><%response.write tit_fir%>标题：</td>
<td><input type=text name=name value='<%response.write rs("name")%>'size=60 maxlength=50><% response.write redx %></td>
</tr>
<tr>
<td><%response.write tit_fir%>分类：</td>
<td><%call chk_csid(nsort,cid,sid)%></td>
</tr>
<tr><td><%response.write tit_fir%>主演：</td><td><input type=text name=role value='<%response.write rs("role")%>' size=50 maxlength=100></td></tr>
<tr>
<td><%response.write tit_fir%>发布人：</td>
<td><input type=text name=username value='<%response.write rs("username")%>' size=20 maxlength=20>&nbsp;&nbsp;<%call chk_emoney(rs("emoney"))%>&nbsp;&nbsp;免费影片：<input type=checkbox name=isfree value='yes'<%if rs("isfree")=true then response.write " checked"%>></td>
</tr>
<%call chk_power("影片",rs("power"),0)%>
<tr>
<td>发布时间：</td>
<td><input type=text name=tim value='<%response.write rs("tim")%>' size=20 maxlength=20>&nbsp;&nbsp;观看&nbsp;<input type=text name=counter value='<%response.write rs("counter")%>' size=6 maxlength=10>&nbsp;人次&nbsp;&nbsp;&nbsp;&nbsp;隐藏/审核：<input type=checkbox name=hidden value='yes'<%if rs("hidden")=false then response.write " checked"%>></td>
</tr>
<tr>
<td><%response.write tit_fir%>信息：</td>
<td>
<%response.write tit_fir%>产地：<select size=1 name=whe><%response.write video_skin.sel_type(rs("whe"),"大陆|台湾|香港|日韩|欧美|其他")%></select>
&nbsp;&nbsp;<%response.write tit_fir%>语种：<select size=1 name=lang><%response.write video_skin.sel_type(rs("lang"),"汉语|粤语|英语|日语|韩语|法语|其他")%></select>
&nbsp;&nbsp;推荐等级：<select name=star size=1>
<option value=1<% if star=1 then response.write " selected" %>>一星级</option>
<option value=2<% if star=2 then response.write " selected" %>>二星级</option>
<option value=3<% if star=3 then response.write " selected" %>>三星级</option>
<option value=4<% if star=4 then response.write " selected" %>>四星级</option>
<option value=5<% if star=5 then response.write " selected" %>>五星级</option>
</select>&nbsp;<font class=red>五星即为推荐</font>
</td>
</tr>
<tr>
<td><%response.write tit_fir%>格式：</td>
<td>
<img src='images/video/ico_rp.gif' width=16 height=16> <input type=radio value='real' name=genre<%if rs("genre")="real" then response.write " checked"%>>
&nbsp;<img src='images/video/ico_mov.gif' width=16 height=16> <input type=radio value='qt' name=genre<%if rs("genre")="qt" then response.write " checked"%>>
&nbsp;<img src='images/video/ico_wmp.gif' width=16 height=16> <input type=radio value='wmp' name=genre<%if rs("genre")="wmp" then response.write " checked"%>>
&nbsp;<%response.write tit_fir%>类型：&nbsp;<select name=types size=1>
<option value='film'<% if rs("types")="film" then response.write " selected" %>>影片</option>
<option value='mtv'<% if rs("types")="mtv" then response.write " selected" %>>MTV</option>
<option value='music'<% if rs("types")="music" then response.write " selected" %>>歌曲</option>
</select>
</td>
</tr>
<tr>
<td>开放方式：</td>
<td><input type=radio value=1 name=viewtype<%if int(rs("viewtype"))=1 then response.write " checked"%>>在线观看 <input type=radio value=0 name=viewtype<%if int(rs("viewtype"))=0 then response.write " checked"%>>影片下载 <input type=radio value=2 name=viewtype<%if int(rs("viewtype"))=2 then response.write " checked"%>>即能观看也可下载</td></tr>
<%
  rs.close
  if no=0 then
    response.write "<tr><td></td><td>没有影片提供观看</td></tr>"
  else
    sql="select * from video_url where nameid="&id
    set rs=joekoe_cms.exec(sql,1)
    for i=1 to no
      response.write vbcrlf&"<tr><td>"&tit_fir&"地址 "&i&"：</td>"
      response.write vbcrlf&"<td><input type=text name=url"&i&" size=50 value='"&rs("url")&"' maxlength=255>&nbsp;&nbsp;本集名称：&nbsp;&nbsp;<input type=text name=urlname"&i&" size=10 value='"&rs("urlname")&"' maxlength=20>&nbsp;１６∶９<input type=checkbox name=vsize"&i&" value='yes'"
      if int(rs("video_size"))=1 then response.write " checked"
      response.write ">  "
      if no>1 then response.write vbcrlf&"<a href='?action=delurl&id="&id&"&vid="&rs("id")&"'><font class=red>删除</font></a></td></tr>"
      rs.movenext
    next
    rs.close
  end if
%>
<script language=javascript>
<!--
function seturl()
{
	var str="";
	var j="";
	var oldno=<%=int(no)%>;
	oldno=Math.floor(oldno);
	var temname1=add_frm.t1.value;
	var temname2=add_frm.t2.value;
	if (!window.add_frm.addno.value) window.add_frm.addno.value=1;
	var adds=window.add_frm.addno.value;
	adds=Math.floor(adds);
	adds+=oldno;
	oldno+=1;
	for(i=oldno;i<=adds;i++)
	{
	if (i<10)
	{ j='0'+i; }
	else
	{ j=i; }
	str+='&nbsp;'+j+'：&nbsp;<input type=text name="url'+i+'" size=50 value="'+temname1+j+temname2+'" maxlength=255>&nbsp;本集名称：&nbsp;<input type=text name="urlname'+i+'" size=10 maxlength=20 value="第'+j+'集">&nbsp;１６:９<input type=checkbox name="vsize'+i+'" value="yes"><BR>';
	}
	window.addid.innerHTML=str+'<input type=hidden name=newno value='+adds+'>';
}
-->
</script>
<tr class=tr1>
<td>服务器设置：</td>
<td>
<select size=1 name=videoserver>
<%response.write video_skin.video_selsv(videoserver)%>
</select>
前缀：<input type=text name=t1 value='' size=20>
集数：<input type=text name=addno value=2 size=2>
后缀：<input type=text name=t2 value='' size=5>
<input type=button name=Button onclick="seturl();" value='设置'> <% response.write redx %></td></tr>
<tr><td>新增<%response.write tit_fir%>地址</td><td id="addid"></td></tr>
<tr>
<td><%call frm_ubb_type("")%></td>
<td><%call frm_ubb("add_frm","remark","&nbsp;&nbsp;")%></td>
</tr>
<tr>
<td valign=top><%response.write tit_fir%>简介：</td>
<td><textarea name=remark rows=10 cols=65><%response.write remark%></textarea></td>
</tr>
<tr>
<td><%response.write tit_fir%>图片：</td>
<td><input type=text name=pic value='<%response.write pic%>' size=40 maxlength=100>&nbsp;&nbsp;&nbsp;<a href='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic' target=upload_frame>上传图片</a>&nbsp;&nbsp;<a href='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write left(index_url,1)%>&uptext=remark' target=upload_frame>上传至内容</a></td>
</tr>
<tr>
<td>上传图片：</td>
<td><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic'></iframe></td>
</tr>
<%
  call submit_edit()
end sub

sub video_add()
  call admin_td("添加"&tit_fir)
  dim pic,no,url,urlname,vid,ispic,username,hidden,tim,remark,whe,role,name,power,emoney,counter,videoserver,isfree
  dim viewtype,star,vsize
  if chk() then
    name=code_admin("name",1,50)
    csid=trim(request.form("c_id"))
	no=trim(request.form("no"))
	if not int_true(no) then no=0
	videoserver=trim(request.form("videoserver"))
	if not int_true(videoserver) then videoserver=0
    if cs_nd(csid)=false then
      call admin_error("请选择 "&tit_fir&"类型 ！")
      exit sub
    end if
    if name="" then
      call admin_error(tit_fir&"标题 不能为空！")
      exit sub
    end if
    for i=1 to no
      url=code_admin("url"&i&"",1,255)
      if url="" then
        call admin_error(tit_fir&"地址"&i&" 不能为空！")
        exit sub
      end if
      if videoserver>0 and instr(url,"://")<>0 then
        call admin_error("本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器相对路径！")
        exit sub
      end if
      if videoserver=0 and instr(url,"://")<1 then
        call admin_error("非本地服务器"&tit_fir&"地址"&i&" 错误！请输入服务器绝对路径！")
        exit sub
      end if
      urlname=code_admin("urlname"&i&"",1,20)
      if urlname="" then
        call admin_error(tit_fir&"名称"&i&" 不能为空！")
        exit sub
      end if
    next
    whe=code_admin("whe",1,20)
    remark=request.form("remark")
    role=code_admin("role",1,100)
    power=code_admin("power",1,50)
    power=replace(power," ","")
    power=replace(power,",",".")
    emoney=trim(request.form("emoney"))
    if not isnumeric(emoney) then emoney=0
    pic=code_admin("pic",1,100)
	username=code_admin("username",1,20)
    if symbol_name(username)=false then username=login_username
    tim=code_admin("tim",1,20)
    tim=joekoe_cms.time_type(tim,1)
    if tim="" then tim=joekoe_cms.now_time
	counter=trim(request.form("counter"))
    if not isnumeric(counter) then counter=0
	star=trim(request.form("star"))
    if not isnumeric(star) then star=1
	viewtype=trim(request.form("viewtype"))
    if not isnumeric(viewtype) then viewtype=1
    hidden=true
    if trim(request.form("hidden"))="yes" then hidden=false
    isfree=false
    if trim(request.form("isfree"))="yes" then isfree=true
    call chk_cid_sid()
	sql="select * from "&data_name
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
	rs.addnew
	rs("c_id")=cid
	rs("s_id")=sid
	rs("genre")=code_admin("genre",1,10)
	rs("name")=name
	rs("username")=username
	rs("lang")=code_admin("lang",1,10)
	rs("whe")=whe
	rs("remark")=remark
	rs("role")=role
	rs("hidden")=hidden
	rs("emoney")=emoney
	rs("power")=power
	rs("star")=star
	rs("viewtype")=viewtype
	rs("types")=code_admin("types",1,10)
	rs("pic")=pic
	rs("tim")=tim
	rs("counter")=counter
	rs("isfree")=isfree
	rs("server_id")=videoserver
    rs.update
	vid=rs("id")
	rs.close
	sql="select * from video_url where id is null"
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
	for i=1 to no
		rs.addnew
		url=code_admin("url"&i,1,255)
		urlname=code_admin("urlname"&i,1,20)
		vsize=0
		if trim(request.form("vsize"&i))="yes" then vsize=1
		rs("nameid")=vid
		rs("url")=url
		rs("urlname")=urlname
		rs("video_size")=vsize
		rs.update
	next
	rs.close
    call upload_note(index_url,first_id(data_name,"id"))
    call video_skin.cache_del("scroll")
    call video_skin.cache_del("counter")
    call admin_msg("已成功添加了一个"&tit_fir&"！","?jk_mod="&jk_mod&"&c_id="&cid&"&s_id="&sid,0)
    exit sub
  end if
  call form_first()
  ispic=joekoe_cms.rand_file(index_url)
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=add' method=post>
<input type=hidden name=chk value='yes'>
<input type=hidden name=upid value=''>
<tr>
<td><%response.write tit_fir%>标题：</td>
<td><input type=text name=name size=60 maxlength=50><% response.write redx %></td>
</tr>
<tr>
<td><%response.write tit_fir%>分类：</td>
<td><%call chk_csid(nsort,cid,sid)%></td>
<tr><td><%response.write tit_fir%>主演：</td><td><input type=text name=role value='未知' size=50 maxlength=100></td></tr>
</tr>
<tr>
<td><%response.write tit_fir%>发布人：</td>
<td><input type=text name=username value='<%response.write login_username%>' size=20 maxlength=20>&nbsp;&nbsp;<%call chk_emoney(1)%>&nbsp;&nbsp;免费影片：<input type=checkbox name=isfree value='yes'></td>
</tr>
<%call chk_power("影片","",1)%>
<tr>
<td>发布时间：</td>
<td><input type=text name=tim value='<%response.write joekoe_cms.now_time%>' size=20 maxlength=20>&nbsp;&nbsp;观看&nbsp;<input type=text name=counter value='0' size=6 maxlength=10>&nbsp;人次&nbsp;&nbsp;&nbsp;&nbsp;隐藏/审核：<input type=checkbox name=hidden value='yes'></td>
</tr>
<tr>
<td><%response.write tit_fir%>信息：</td>
<td><%response.write tit_fir%>产地：<select size=1 name=whe><%response.write video_skin.sel_type("","大陆|台湾|香港|日韩|欧美|其他")%></select>
&nbsp;&nbsp;<%response.write tit_fir%>语种：<select size=1 name=lang><%response.write video_skin.sel_type("","汉语|粤语|英语|日语|韩语|法语|其他")%></select>
&nbsp;&nbsp;推荐等级：
<select name=star size=1>
<option value=1>一星级</option>
<option value=2>二星级</option>
<option value=3>三星级</option>
<option value=4>四星级</option>
<option value=5>五星级</option>
</select>
&nbsp;<font class=red>五星即为推荐</font>
</td>
</tr>
<tr>
<td><%response.write tit_fir%>格式：</td>
<td>
<img src='images/video/ico_rp.gif' width=16 height=16> <input type=radio value='real' name=genre checked>
&nbsp;<img src='images/video/ico_mov.gif' width=16 height=16> <input type=radio value='qt' name=genre>
&nbsp;<img src='images/video/ico_wmp.gif' width=16 height=16> <input type=radio value='wmp' name=genre>
&nbsp;<%response.write tit_fir%>类型：&nbsp;<select name=types size=1>
<option value='film'>影片</option>
<option value='mtv'>MTV</option>
<option value='music'>歌曲</option>
</select>
</td>
</tr>
<tr>
<td>开放方式：</td>
<td><input type=radio value=1 name=viewtype checked>在线观看 <input type=radio value=0 name=viewtype>影片下载 <input type=radio value=2 name=viewtype>即能观看也可下载</td>
</tr>
<script language=javascript>
<!--
function seturl()
{
	var str="";
	var j="";
	var temname1=add_frm.t1.value
	var temname2=add_frm.t2.value
	if (!window.add_frm.no.value) window.add_frm.no.value=1;
	for(i=1;i<=window.add_frm.no.value;i++)
	{
	if (i<10)
	{ j='0'+i; }
	else
	{ j=i; }
	str+='&nbsp;'+j+'：&nbsp;<input type=text name="url'+i+'" size=50 value="'+temname1+j+temname2+'" maxlength=255>&nbsp;本集名称：&nbsp;<input type=text name="urlname'+i+'" size=10 maxlength=20 value="第'+j+'集">&nbsp;１６∶９<input type=checkbox name="vsize'+i+'" value="yes"><BR>';
	}
	window.addid.innerHTML=str;
}
-->
</script>
<tr class=tr1>
<td>服务器设置：</td><td>
<select size=1 name=videoserver>
<%response.write video_skin.video_selsv("")%>
</select>
前缀：<input type=text name=t1 value='' size=20>
集数：<input type=text name=no value=2 size=2>
后缀：<input type=text name=t2 value='' size=5>
<input type=button name=Button onclick="seturl();" value='设置'> <% response.write redx %></td></tr>
<tr><td><%response.write tit_fir%>地址</td><td id="addid"></td></tr>
<tr>
<td><%call frm_ubb_type("")%></td>
<td><%call frm_ubb("add_frm","remark","&nbsp;&nbsp;")%></td>
</tr>
<tr>
<td valign=top><%response.write tit_fir%>简介：</td>
<td><textarea name=remark rows=10 cols=65></textarea></td>
</tr>
<tr>
<td><%response.write tit_fir%>图片：</td>
<td><input type=text name=pic value='<%response.write pic%>' size=40 maxlength=100>&nbsp;&nbsp;&nbsp;<a href='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic' target=upload_frame>上传图片</a>&nbsp;&nbsp;<a href='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write left(index_url,1)%>&uptext=remark' target=upload_frame>上传至内容</a></td>
</tr>
<tr>
<td>上传图片：</td>
<td><iframe frameborder=0 name=upload_frame width='100%' height=30 scrolling=no src='upload.asp?uppath=<%response.write index_url%>&upname=<%response.write ispic%>&uptext=pic'></iframe></td>
</tr>
<%
  call submit_add()
end sub

'----------------购卡用户操作 开始------------
sub video_buys()
  dim f_name,f_ip,f_tim,f_endtim
%>
<tr align=center>
<td class=td width='10%'>序号</td>
<td class=td width='25%'>购卡用户</td>
<td class=td width='15%'>购卡用户IP</td>
<td class=td width='25%'>购买时间</td>
<td class=td width='25%'>到期时间</td>
</tr>
<%
  sql="select count(id) from video_free"
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from video_free order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    id=rs("id")
    f_name=rs("username")
    f_ip=rs("userip")
    if f_ip="" or isnull(f_ip) then f_ip="未绑定"
    f_tim=rs("tim")
    f_endtim=video_skin.last_tim(f_tim,int(rs("freetype")))
    f_tim=joekoe_cms.time_type(f_tim,1)
    f_endtim=joekoe_cms.time_type(f_endtim,1)
%>
<tr align=center>
<td class=tims><%response.write (viewpage-1)*nummer+i%></td>
<td><a href='?jk_mod=<%response.write jk_mod%>&action=buyedit&id=<%response.write id%>'><%response.write joekoe_cms.code_html(f_name,1,(22+tnum))%></a></td>
<td><%response.write f_ip%></td>
<td><%response.write f_tim%></td>
<td><%response.write f_endtim%></td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=5>
现有<font class=red><%response.write rssum%></font>个购卡用户，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
</tr>
<%
end sub

sub video_buyedit()
  dim f_name,f_ip,f_type,f_tim,buy_tim
  call admin_td("编辑 购卡用户信息")
  sql="select top 1 * from video_free where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(" 购卡 用户ID（"&id&"）不存在！","?",1)
    exit sub
  end if
  f_name=rs("username")
  f_ip=rs("userip")
  f_type=int(rs("freetype"))
  f_tim=rs("tim")
  rs.close
  if chk() then
	f_type=trim(request.form("usertype"))
	if f_type="" or isnull(f_type) then f_type=1
	f_type=int(f_type)
    f_ip=code_admin("userip",1,15)
    f_name=code_admin("username",1,50)
    if f_name="" then
      call admin_error("购卡 用户名 不能为空！")
      exit sub
    end if
    buy_tim=code_admin("buytim",1,20)
    buy_tim=joekoe_cms.time_type(buy_tim,1)
    if buy_tim="" then buy_tim=joekoe_cms.now_time
    if trim(request.form("istim"))="yes" then buy_tim=joekoe_cms.now_time
    call joekoe_cms.exec("update video_free set username='"&f_name&"',userip='"&f_ip&"',tim='"&buy_tim&"',freetype="&f_type&" where id="&id,0)
    call admin_msg("已成功修改 "&f_name&" 的购卡信息！","?action=buy",1)
  end if
  call form_first()
%>
<form name=add_frm action='?jk_mod=<%response.write jk_mod%>&action=<%response.write action%>&id=<%response.write id%>' method=post>
<input type=hidden name=chk value='yes'>
<tr>
<td>用户名：</td>
<td><input type=text name=username size=30 maxlength=50 value='<%response.write f_name%>'></td>
</tr>
<tr>
<td>用户IP：</td>
<td><input type=text name=userip size=30 maxlength=15 value='<%response.write f_ip%>'>&nbsp;&nbsp;<font class=red>请正确填写IP格式，如：127.0.0.1</font></td>
</tr>
<tr>
<td>购卡类型：</td>
<td><select name=usertype size=1>
<option value=1 <%if f_type=1 then response.write " selected"%>>月卡</option>
<option value=2 <%if f_type=2 then response.write " selected"%>>季卡</option>
<option value=3 <%if f_type=3 then response.write " selected"%>>年卡</option>
</select>
</td>
</tr>
<tr>
<td>购卡时间：</td>
<td><input type=text name=buytim size=30 maxlength=20 value='<%response.write joekoe_cms.time_type(f_tim,1)%>'>&nbsp;&nbsp;&nbsp;&nbsp;更新购买时间为现在时间&nbsp;&nbsp;<input type=checkbox name=istim value='yes' class=bg_td>
</td>
</tr>
<%
  call submit_edit()
end sub
'----------------服务器修改操作 开始------------
sub video_cons()
  dim temp1,temp2,vname1,vname2
  call admin_td(tit_fir&"服务器批量修改")
  if chk() then
    dim sel1,sel2
    sel1=trim(request.form("sel_1"))
    sel2=trim(request.form("sel_2"))
    sel1=int(sel1)
    sel2=int(sel2)
    if sel1=sel2 then
      call admin_msg("请选择不同的服务器！","?action=cons",1)
      exit sub
    end if
    call joekoe_cms.exec("update "&data_name&" set server_id="&sel2&" where server_id="&sel1,0)
    call admin_msg("已经更新了"&rssum&"个影片数据！","?action=cons",1)
  end if
  call form_first()
%>
<form action='?action=cons' method=post>
<input type=hidden name='chk' value='yes'>
<tr class=tr1><td colspan=2 class=red>此操作不可恢复！执行前请做好数据库备份工作！</td></tr>
<tr>
<td>原服务器：</td>
<td><select size=1 name=sel_1><%response.write video_skin.video_selsv("")%></select></td>
</tr>
<tr>
<td>新服务器：</td>
<td><select size=1 name=sel_2><%response.write video_skin.video_selsv("")%></select></td>
</tr>
<tr>
<td></td>
<td><input type=submit value='开始修改' onclick="return click_return('开始执行',0);"></td>
</tr>
</form>
<%
end sub
'----------------参数设置 开始------------
sub video_setup()
  dim file_name,tdim,tnum,tmp1,video_ip,mint,jint,yint,power,playserver,downserver,videoserver,video_num,video_username
  file_name="include/common_video.asp"
  if chk() then
    video_ip=code_config(request.form("video_ip"),0)
    video_username=code_config(request.form("video_username"),0)
    videoserver=code_config(request.form("video_server"),0)
    videoserver=replace(videoserver," ","")
    videoserver=replace(videoserver,",","$")
    videoserver=videoserver&"$"
    for i=0 to 1
      if instr(videoserver,"$$")<1 then exit for
      videoserver=replace(videoserver,"$$","$")
    next
    if right(videoserver,1)="$" then videoserver=left(videoserver,len(videoserver)-1)
    mint=code_num(request.form("video_dim_0"),100)
    jint=code_num(request.form("video_dim_1"),250)
    yint=code_num(request.form("video_dim_2"),1000)
    power=code_admin("power",1,50)
    power=replace(power," ","")
    power=replace(power,",",".")
    video_ip=replace(video_ip," ","")
    video_ip=replace(video_ip,",","|")
    video_ip=video_ip&"|"
    for i=0 to 1
      if instr(video_ip,"||")<1 then exit for
      video_ip=replace(video_ip,"||","|")
    next
    if right(video_ip,1)="|" then video_ip=left(video_ip,len(video_ip)-1)
    video_num=code_num(request.form("video_num_1"),0)&code_num(request.form("video_num_2"),0)&code_num(request.form("video_num_3"),0)&code_num(request.form("video_num_4"),0)
    tmp1=vbcrlf&"<"&"%" & _
         vbcrlf&"dim video_dim(7)" & _
         vbcrlf&"video_dim(0)="""&mint&"""" & _
         vbcrlf&"video_dim(1)="""&jint&"""" & _
         vbcrlf&"video_dim(2)="""&yint&"""" & _
         vbcrlf&"video_dim(3)="""&video_num&"""" & _
         vbcrlf&"video_dim(4)="""&power&"""" & _
         vbcrlf&"video_dim(5)="""&videoserver&"""" & _
         vbcrlf&"video_dim(6)="""&video_ip&"""" & _
         vbcrlf&"video_dim(7)="""&video_username&"""" & _
         vbcrlf&"%"&">"
    call create_file(file_name,file_trim_vbcrlf(tmp1))
    call admin_msg("已成功修改了"&tit_fir&"参数！","?action="&action,1)
    exit sub
  end if
  call form_first()
  if len(video_dim(3))<>4 then video_dim(3)="0000"
%>
<form action='?action=<%response.write action%>' method=post>
<input type=hidden name=chk value='yes'>
<tr align=center>
<td class=td width='12%'>设置名称</td>
<td class=td width='48%'>基本参数设置</td>
<td class=td width='40%'>相关说明</td>
</tr>
<tr>
<td>月卡花费：</td>
<td><input type=text name=video_dim_0 value='<%response.write video_dim(0)%>' size=10 maxlength=5>&nbsp;个虚拟币</td>
<td class=gray>购买月卡所需虚拟币</td>
</tr>
<tr>
<td>度卡花费：</td>
<td><input type=text name=video_dim_1 value='<%response.write video_dim(1)%>' size=10 maxlength=5>&nbsp;个虚拟币</td>
<td class=gray>购买季卡所需虚拟币</td>
</tr>
<tr>
<td>年卡花费：</td>
<td><input type=text name=video_dim_2 value='<%response.write video_dim(2)%>' size=10 maxlength=5>&nbsp;个虚拟币</td>
<td class=gray>购买年卡所需虚拟币</td>
</tr>
<% tmp1=int(mid(video_dim(3),1,1)) %>
<tr>
<td>下载防盗：</td>
<td><input type=radio name=video_num_1 value='1'<% if int(tmp1)=1 then response.write " checked" %>>&nbsp;开启&nbsp;<input type=radio name=video_num_1 value='0'<% if int(tmp1)=0 then response.write " checked" %>>&nbsp;关闭</td>
<td class=gray>影片下载防盗功能</td>
</tr>
<% tmp1=int(mid(video_dim(3),2,1)) %>
<tr>
<td>检验状态：</td>
<td><input type=radio name=video_num_2 value='1'<% if int(tmp1)=1 then response.write " checked" %>>&nbsp;开启&nbsp;<input type=radio name=video_num_2 value='0'<% if int(tmp1)=0 then response.write " checked" %>>&nbsp;关闭</td>
<td class=gray>可临时检验播放地址是否正确</td>
</tr>
<% tmp1=int(mid(video_dim(3),3,1)) %>
<tr>
<td>地址加密：</td>
<td><input type=radio name=video_num_3 value='1'<% if int(tmp1)=1 then response.write " checked" %>>&nbsp;开启&nbsp;<input type=radio name=video_num_3 value='0'<% if int(tmp1)=0 then response.write " checked" %>>&nbsp;关闭</td>
<td class=gray>RM格式影片地址加密功能</td>
</tr>
<% tmp1=int(mid(video_dim(3),4,1)) %>
<tr>
<td>窗口样式：</td>
<td><input type=radio name=video_num_4 value='0'<% if int(tmp1)=0 then response.write " checked" %>>&nbsp;独占模式&nbsp;<input type=radio name=video_num_4 value='1'<% if int(tmp1)=1 then response.write " checked" %>>&nbsp;半自由模式(仅 IE5+ 支持)&nbsp;<input type=radio name=video_num_4 value='2'<% if int(tmp1)=2 then response.write " checked" %>>&nbsp;自由模式</td>
<td class=gray>播放窗口样式</td>
</tr>
<tr>
<td>免费用户：</td>
<td><input type=text name=video_username value='<%response.write video_dim(7)%>' size=40></td>
<td class=gray>某用户可免费观看，请用“|”分隔</td>
</tr>
<tr>
<td colspan=2><table border=0 width='100%'><%call chk_power("免费",video_dim(4),0)%></table></td>
<td class=gray>某用户组成员都可免费观看</td>
</tr>
<tr><td colspan=3 class=td>&nbsp;服务器设置</td></tr>
<tr class=tr1><td colspan=3>例：“播放服务器<font class=red>|</font>下载服务器<font class=red>|</font>服务器名称”，注意用“|”分隔，否则出错！地址结尾请加上“/”！</td></tr>
<%
  tdim=split(video_dim(5),"$")
  tnum=ubound(tdim)
  for i=0 to tnum+1
    tmp1=""
    if i<tnum+1 then tmp1=tdim(i)
    response.write vbcrlf&"<tr>"
    response.write vbcrlf&"<td>服务器"&i+1&"：</td>"
    response.write vbcrlf&"<td colspan=2><input type=text name=video_server value='"&tmp1&"' size=80 maxlength=80></td>"
    response.write vbcrlf&"</tr>"
  next
  erase tdim
%>
<tr><td colspan=3 class=td>&nbsp;免费IP访问设置</td></tr>
<tr class=tr1><td colspan=3>例：“127.0.0.1”、“127.0.0”！</td></tr>
<tr><td colspan=3 align=center>
  <table border=0 width='98%'>
  <tr><td width='33%' height=1></td><td width='34%'></td><td width='33%'></td></tr>
<%
  tdim=split(video_dim(6),"|")
  tnum=ubound(tdim)
  for i=0 to tnum+1
    if (i/3)-(i\3)=0 then response.write vbcrlf&"<tr>"
    tmp1=""
    if i<tnum+1 then tmp1=tdim(i)
    response.write vbcrlf&"<td>IP"&i+1&"：<input type=text name=video_ip value='"&tmp1&"' size=18 maxlength=15></td>"
    if ((i-2)/3)-((i-2)\3)=0 then response.write vbcrlf&"</tr>"
  next
  erase tdim
%>
  </table>
</td></tr>
<tr>
<td></td>
<td height=30 colspan=2 align=center><input type=submit value='提交修改'>　　<input type=reset value='重新填写'>　　<input type=button name=go_back value='返回上一页' onclick="javascript:history.back(1);"></td>
</tr></form>
<%
end sub
'----------------模板操作 开始------------
sub video_style_main()
  dim vname,vstyle
  call admin_td0("模板列表",4)
%>
<tr align=center class=tr1>
<td width='10%'>序号</td>
<td width='35%'>模板名称</td>
<td width='20%'>图片地址</td>
<td width='35%'>相关属性</td>
</tr>
<%
  sql="select count(id) from video_style"
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from video_style order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    id=rs("id")
    vname=rs("name")
%>
<tr align=center>
<td class=tims><%response.write (viewpage-1)*nummer+i%></td>
<td><a href='?action=edit_style&id=<%response.write id%>'><%response.write joekoe_cms.code_html(vname,1,(22+tnum))%></a></td>
<td class=blue><%response.write rs("picurl")%></td>
<td>
<%if rs("isdef")=true then%><font class=gray>此为默认模板</font><%else%><a href='?action=set&id=<%response.write id%>'>设为默认模板</a><%end if%>&nbsp;&nbsp;
<%if rs("isdef")=true then%><font class=gray>删除此模板</font><%else%><a href='?action=del&id=<%response.write id%>'>删除此模板</a><%end if%>&nbsp;&nbsp;
<a href='?action=copy&id=<%response.write id%>'>拷贝此模板</a>
</td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=4>
现有<font class=red><%response.write rssum%></font>个模板，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
</tr>
<%
end sub

sub video_style_setup()
  dim vname
  sql="select top 1 * from video_style where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(" ID（"&id&"）不存在！","?action=style",1)
    exit sub
  end if
  vname=rs("name")
  rs.close
  call joekoe_cms.exec("update video_style set isdef=false",0)
  call joekoe_cms.exec("update video_style set isdef=true where id="&id,0)
  call video_skin.video_skin_del()
  call admin_msg("成功更新 ("&vname&") 模板为默认模板！","?action=style",1)
end sub

sub video_style_copy()
  dim oname,vname,vstyle,picurl
  sql="select top 1 * from video_style where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(" ID（"&id&"）不存在！","?action=style",1)
    exit sub
  end if
  oname=rs("name")
  picurl=rs("picurl")
  vstyle=rs("style")
  rs.close
  vname=oname&"(新)"
  sql="select * from video_style"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  rs.addnew
  rs("name")=vname
  rs("picurl")=picurl
  rs("style")=vstyle
  rs("isdef")=false
  rs.update
  rs.close
  call admin_msg("成功复制 ("&oname&") 模板为 ("&vname&") 模板！","?action=style",1)
end sub

sub video_style_del()
  dim vname,isdef
  sql="select top 1 * from video_style where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(" ID（"&id&"）不存在！","?action=style",1)
    exit sub
  end if
  vname=rs("name")
  isdef=rs("isdef")
  rs.close
  if isdef=true then
    call admin_msg(" 该模板为默认模板，无法删除！","?",1)
    exit sub
  end if
  call joekoe_cms.exec("delete from video_style where isdef=false and id="&id,0)
  'call video_skin.video_skin_del()
  call admin_msg("成功删除 ("&vname&") 模板！","?action=style",1)
end sub

sub video_style_edit()
  dim vname,picurl,vstyle,allstr,htmlstr,helpstr,isdef
  sql="select top 1 * from video_style where id="&id
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,3
  if rs.eof then
    rs.close
    call admin_msg(" ID（"&id&"）不存在！","?action=style",1)
    exit sub
  end if
  vname=rs("name")
  picurl=rs("picurl")
  vstyle=rs("style")
  isdef=rs("isdef")
  rs.close
  call admin_td("编辑（"&vname&")")
  If chk() then
    dim tempstr
    htmlstr=""
    helpstr=""
    vname=code_admin("name",1,20)
    picurl=code_admin("picurl",1,20)
    if vname="" or picurl="" then
      call admin_error(tit_fir&"名称、图片地址 不能为空！")
      exit sub
    end if
	for each tempstr in request.form("htmlstr")
		if LCase(tempstr)<>"del" Then
			htmlstr=htmlstr&Replace(tempstr,"|||","")&"|||"
		end if
	Next
	htmlstr=video_skin.code_str(Replace(htmlstr,"@@@",""))
	If trim(htmlstr)="" Then
		htmlstr="|||"
	End If
	tempstr=""
	for each tempstr in request.form("helpstr")
		if LCase(tempstr)<>"del" Then
			helpstr=helpstr&Replace(tempstr,"|||","")&"|||"
		end if
	Next
	helpstr=video_skin.code_str(Replace(helpstr,"@@@",""))
	If trim(helpstr)="" Then
		helpstr="|||"
	End If
	if ubound(split(helpstr,"|||"))<>ubound(split(htmlstr,"|||")) then
 	  call admin_error("提交错误，如果想删除某个，请全部输入“del”！")
      exit sub
	end if
	allstr=htmlstr & "@@@" & helpstr
	call joekoe_cms.exec("update video_style set name='"&vname&"',picurl='"&picurl&"',style='"&allstr&"' where id="&id,0)
	if isdef then call video_skin.video_skin_del()
	call admin_msg("成功更新 ("&vname&") 模板！","?action=edit_style&id="&id,1)
	exit sub
  end if
  allstr=split(vstyle,"@@@")
  htmlstr=split(allstr(0),"|||")
  helpstr=split(allstr(1),"|||")
  If htmlstr(ubound(htmlstr))="" then htmlstr(ubound(htmlstr))="del"
  If helpstr(ubound(helpstr))="" then helpstr(ubound(helpstr))="del"
  call form_first()
%>
<form name=style_frm action='?action=<%response.write action%>&id=<%response.write id%>' method=post>
<input type=hidden name=chk value='yes'>
<tr class=tr1>
<td colspan=2>
<li>模板编辑规则：如果想清除该字段，请在对应的文本框中输入"del"，那么模板数据的序号就会前移。
<li>如果不想改变模板数据的序号,仅把该项目的数据清空,则只需要把内容清空。
</td>
</tr>
<tr>
<td>模板名称：</td>
<td><input type=text name=name size=20 maxlength=20 value="<%response.write vname%>"><%response.write redx%></td>
</tr>
<tr>
<td>模板图片地址：</td>
<td><input type=text name=picurl size=20 maxlength=20 value="<%response.write picurl%>"><%response.write redx%></td>
</tr>
<tr align=center class=tr1><td>调用方式</td><td>输出内容</td></tr>
<%
	for i=0 to ubound(htmlstr)
%>
<tr align=left>
<td rowspan=2>HtmlNums(<%response.write i%>)</td>
<td class=tr1>调用说明：<input type=text name=helpstr id=h<%=i%> size=20 value="<%response.write helpstr(i)%>"></td>
</tr>
<tr align=left>
<td>
<textarea name=htmlstr id=s<%response.write i%> rows=12 cols=70><%response.write server.htmlencode(htmlstr(i))%></textarea>
</td>
</tr>
<%
	next
	call submit_edit()
end sub
%>